You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by wr...@apache.org on 2001/05/03 18:51:17 UTC

cvs commit: apr/strings apr_snprintf.c

wrowe       01/05/03 09:51:15

  Modified:    strings  apr_snprintf.c
  Log:
    Patch to allow %qd within apr_snprintf, but handle the platform specific
    APR_INT64_T_FMT string regardless (e.g. older lld or win32 I64d).
  
  Revision  Changes    Path
  1.15      +7 -1      apr/strings/apr_snprintf.c
  
  Index: apr_snprintf.c
  ===================================================================
  RCS file: /home/cvs/apr/strings/apr_snprintf.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- apr_snprintf.c	2001/04/27 18:36:06	1.14
  +++ apr_snprintf.c	2001/05/03 16:51:05	1.15
  @@ -807,7 +807,13 @@
   	    /*
   	     * Modifier check
   	     */
  -	    if (*fmt == 'q') {
  +            if (strncmp(fmt, APR_INT64_T_FMT, 
  +                             sizeof(APR_INT64_T_FMT) - 2) == 0) {
  +                /* Need to account for trailing 'd' and null in sizeof() */
  +		var_type = IS_QUAD;
  +		fmt += (sizeof(APR_INT64_T_FMT) - 2);
  +            }
  +	    else if (*fmt == 'q') {
   		var_type = IS_QUAD;
   		fmt++;
   	    }
  
  
  

Re: cvs commit: apr/strings apr_snprintf.c

Posted by "Roy T. Fielding" <fi...@ebuilt.com>.
>   diff -u -r1.14 -r1.15
>   --- apr_snprintf.c	2001/04/27 18:36:06	1.14
>   +++ apr_snprintf.c	2001/05/03 16:51:05	1.15
>   @@ -807,7 +807,13 @@
>    	    /*
>    	     * Modifier check
>    	     */
>   -	    if (*fmt == 'q') {
>   +            if (strncmp(fmt, APR_INT64_T_FMT, 
>   +                             sizeof(APR_INT64_T_FMT) - 2) == 0) {
>   +                /* Need to account for trailing 'd' and null in sizeof() */
>   +		var_type = IS_QUAD;
>   +		fmt += (sizeof(APR_INT64_T_FMT) - 2);
>   +            }
>   +	    else if (*fmt == 'q') {
>    		var_type = IS_QUAD;
>    		fmt++;
>    	    }

This doesn't look right.  APR_INT64_T_FMT may be someting other than qd
or lld on some platforms.  Specifically, it will be ld on platforms where
a normal long happens to be 64 bits.  So this if statement will be picked
up at possibly unusual times.  I'm not sure if anything bad would result,
but it is weird.

Why not just add all of the known format names to apr_snprintf?

....Roy