apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject cvs commit: apr/strings apr_snprintf.c
Date Tue, 05 Feb 2002 05:56:01 GMT
jerenkrantz    02/02/04 21:56:01

  Modified:    strings  apr_snprintf.c
  Log:
  Style changes - tabs to spaces primarily.
  No functional changes.
  (This file is a stylistic nightmare to read.  We're seeing an OS/X stack
  smash with SVN.  We need a reformat so we can understand it.)
  
  Revision  Changes    Path
  1.17      +680 -676  apr/strings/apr_snprintf.c
  
  Index: apr_snprintf.c
  ===================================================================
  RCS file: /home/cvs/apr/strings/apr_snprintf.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- apr_snprintf.c	16 May 2001 05:30:52 -0000	1.16
  +++ apr_snprintf.c	5 Feb 2002 05:56:01 -0000	1.17
  @@ -87,13 +87,13 @@
   } boolean_e;
   
   #ifndef FALSE
  -#define FALSE			0
  +#define FALSE 0
   #endif
   #ifndef TRUE
  -#define TRUE			1
  +#define TRUE 1
   #endif
  -#define NUL			'\0'
  -#define WIDE_INT		long
  +#define NUL '\0'
  +#define WIDE_INT long
   
   typedef WIDE_INT wide_int;
   typedef unsigned WIDE_INT u_wide_int;
  @@ -106,18 +106,18 @@
   #endif
   typedef int bool_int;
   
  -#define S_NULL			"(null)"
  -#define S_NULL_LEN		6
  +#define S_NULL "(null)"
  +#define S_NULL_LEN 6
   
  -#define FLOAT_DIGITS		6
  -#define EXPONENT_LENGTH		10
  +#define FLOAT_DIGITS 6
  +#define EXPONENT_LENGTH 10
   
   /*
    * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions
    *
    * XXX: this is a magic number; do not decrease it
    */
  -#define NUM_BUF_SIZE		512
  +#define NUM_BUF_SIZE 512
   
   /*
    * cvt.c - IEEE floating point formatting routines for FreeBSD
  @@ -131,7 +131,7 @@
    *      sign is set to 0 for positive, 1 for negative
    */
   
  -#define	NDIG	80
  +#define NDIG 80
   
   /* buf must have at least NDIG bytes */
   static char *apr_cvt(double arg, int ndigits, int *decpt, int *sign, 
  @@ -142,13 +142,13 @@
       register char *p, *p1;
       
       if (ndigits >= NDIG - 1)
  -	ndigits = NDIG - 2;
  +        ndigits = NDIG - 2;
       r2 = 0;
       *sign = 0;
       p = &buf[0];
       if (arg < 0) {
  -	*sign = 1;
  -	arg = -arg;
  +        *sign = 1;
  +        arg = -arg;
       }
       arg = modf(arg, &fi);
       p1 = &buf[NDIG];
  @@ -156,53 +156,53 @@
        * Do integer part
        */
       if (fi != 0) {
  -	p1 = &buf[NDIG];
  -	while (p1 > &buf[0] && fi != 0) {
  -	    fj = modf(fi / 10, &fi);
  -	    *--p1 = (int) ((fj + .03) * 10) + '0';
  -	    r2++;
  -	}
  -	while (p1 < &buf[NDIG])
  -	    *p++ = *p1++;
  +        p1 = &buf[NDIG];
  +        while (p1 > &buf[0] && fi != 0) {
  +            fj = modf(fi / 10, &fi);
  +            *--p1 = (int) ((fj + .03) * 10) + '0';
  +            r2++;
  +        }
  +        while (p1 < &buf[NDIG])
  +            *p++ = *p1++;
       }
       else if (arg > 0) {
  -	while ((fj = arg * 10) < 1) {
  -	    arg = fj;
  -	    r2--;
  -	}
  +        while ((fj = arg * 10) < 1) {
  +            arg = fj;
  +            r2--;
  +        }
       }
       p1 = &buf[ndigits];
       if (eflag == 0)
  -	p1 += r2;
  +        p1 += r2;
       *decpt = r2;
       if (p1 < &buf[0]) {
  -	buf[0] = '\0';
  -	return (buf);
  +        buf[0] = '\0';
  +        return (buf);
       }
       while (p <= p1 && p < &buf[NDIG]) {
  -	arg *= 10;
  -	arg = modf(arg, &fj);
  -	*p++ = (int) fj + '0';
  +        arg *= 10;
  +        arg = modf(arg, &fj);
  +        *p++ = (int) fj + '0';
       }
       if (p1 >= &buf[NDIG]) {
  -	buf[NDIG - 1] = '\0';
  -	return (buf);
  +        buf[NDIG - 1] = '\0';
  +        return (buf);
       }
       p = p1;
       *p1 += 5;
       while (*p1 > '9') {
  -	*p1 = '0';
  -	if (p1 > buf)
  -	    ++ * --p1;
  -	else {
  -	    *p1 = '1';
  -	    (*decpt)++;
  -	    if (eflag == 0) {
  -		if (p > buf)
  -		    *p = '0';
  -		p++;
  -	    }
  -	}
  +        *p1 = '0';
  +        if (p1 > buf)
  +            ++ * --p1;
  +        else {
  +            *p1 = '1';
  +            (*decpt)++;
  +            if (eflag == 0) {
  +                if (p > buf)
  +                    *p = '0';
  +                p++;
  +            }
  +        }
       }
       *p = '\0';
       return (buf);
  @@ -233,51 +233,51 @@
       p1 = apr_ecvt(number, ndigit, &decpt, &sign, buf1);
       p2 = buf;
       if (sign)
  -	*p2++ = '-';
  +        *p2++ = '-';
       for (i = ndigit - 1; i > 0 && p1[i] == '0'; i--)
  -	ndigit--;
  +        ndigit--;
       if ((decpt >= 0 && decpt - ndigit > 4)
  -	|| (decpt < 0 && decpt < -3)) {		/* use E-style */
  -	decpt--;
  -	*p2++ = *p1++;
  -	*p2++ = '.';
  -	for (i = 1; i < ndigit; i++)
  -	    *p2++ = *p1++;
  -	*p2++ = 'e';
  -	if (decpt < 0) {
  -	    decpt = -decpt;
  -	    *p2++ = '-';
  -	}
  -	else
  -	    *p2++ = '+';
  -	if (decpt / 100 > 0)
  -	    *p2++ = decpt / 100 + '0';
  -	if (decpt / 10 > 0)
  -	    *p2++ = (decpt % 100) / 10 + '0';
  -	*p2++ = decpt % 10 + '0';
  +        || (decpt < 0 && decpt < -3)) {                /* use E-style */
  +        decpt--;
  +        *p2++ = *p1++;
  +        *p2++ = '.';
  +        for (i = 1; i < ndigit; i++)
  +            *p2++ = *p1++;
  +        *p2++ = 'e';
  +        if (decpt < 0) {
  +            decpt = -decpt;
  +            *p2++ = '-';
  +        }
  +        else
  +            *p2++ = '+';
  +        if (decpt / 100 > 0)
  +            *p2++ = decpt / 100 + '0';
  +        if (decpt / 10 > 0)
  +            *p2++ = (decpt % 100) / 10 + '0';
  +        *p2++ = decpt % 10 + '0';
       }
       else {
  -	if (decpt <= 0) {
  -	    if (*p1 != '0')
  -		*p2++ = '.';
  -	    while (decpt < 0) {
  -		decpt++;
  -		*p2++ = '0';
  -	    }
  -	}
  -	for (i = 1; i <= ndigit; i++) {
  -	    *p2++ = *p1++;
  -	    if (i == decpt)
  -		*p2++ = '.';
  -	}
  -	if (ndigit < decpt) {
  -	    while (ndigit++ < decpt)
  -		*p2++ = '0';
  -	    *p2++ = '.';
  -	}
  +        if (decpt <= 0) {
  +            if (*p1 != '0')
  +                *p2++ = '.';
  +            while (decpt < 0) {
  +                decpt++;
  +                *p2++ = '0';
  +            }
  +        }
  +        for (i = 1; i <= ndigit; i++) {
  +            *p2++ = *p1++;
  +            if (i == decpt)
  +                *p2++ = '.';
  +        }
  +        if (ndigit < decpt) {
  +            while (ndigit++ < decpt)
  +                *p2++ = '0';
  +            *p2++ = '.';
  +        }
       }
       if (p2[-1] == '.' && !altform)
  -	p2--;
  +        p2--;
       *p2 = '\0';
       return (buf);
   }
  @@ -292,27 +292,27 @@
    *
    * NOTE: Evaluation of the c argument should not have any side-effects
    */
  -#define INS_CHAR(c, sp, bep, cc)				\
  -	    {							\
  -		if (sp >= bep) {				\
  -		    vbuff->curpos = sp;                         \
  -		    if (flush_func(vbuff))			\
  -			return -1;				\
  -		    sp = vbuff->curpos;				\
  -		    bep = vbuff->endpos;			\
  -		} 						\
  -		*sp++ = (c);					\
  -		cc++; 						\
  -	    }
  -
  -#define NUM( c )			( c - '0' )
  -
  -#define STR_TO_DEC( str, num )		\
  -    num = NUM( *str++ ) ;		\
  -    while ( apr_isdigit( *str ) )		\
  -    {					\
  -	num *= 10 ;			\
  -	num += NUM( *str++ ) ;		\
  +#define INS_CHAR(c, sp, bep, cc)                    \
  +{                                                   \
  +    if (sp >= bep) {                                \
  +        vbuff->curpos = sp;                         \
  +        if (flush_func(vbuff))                      \
  +            return -1;                              \
  +        sp = vbuff->curpos;                         \
  +        bep = vbuff->endpos;                        \
  +    }                                               \
  +    *sp++ = (c);                                    \
  +    cc++;                                           \
  +}
  +
  +#define NUM(c) (c - '0')
  +
  +#define STR_TO_DEC(str, num)                        \
  +    num = NUM(*str++);                              \
  +    while (apr_isdigit(*str))                       \
  +    {                                               \
  +        num *= 10 ;                                 \
  +        num += NUM(*str++);                         \
       }
   
   /*
  @@ -321,31 +321,35 @@
    * adding '0's to the left of the string that is going
    * to be printed.
    */
  -#define FIX_PRECISION( adjust, precision, s, s_len )	\
  -    if ( adjust )					\
  -	while ( s_len < precision )			\
  -	{						\
  -	    *--s = '0' ;				\
  -	    s_len++ ;					\
  -	}
  +#define FIX_PRECISION(adjust, precision, s, s_len)  \
  +    if (adjust)                                     \
  +        while (s_len < precision)                   \
  +        {                                           \
  +            *--s = '0';                             \
  +            s_len++;                                \
  +        }
   
   /*
    * Macro that does padding. The padding is done by printing
    * the character ch.
    */
  -#define PAD( width, len, ch )	do		\
  -	{					\
  -	    INS_CHAR( ch, sp, bep, cc ) ;	\
  -	    width-- ;				\
  -	}					\
  -	while ( width > len )
  +#define PAD(width, len, ch)                         \
  +do                                                  \
  +{                                                   \
  +    INS_CHAR(ch, sp, bep, cc);                      \
  +    width--;                                        \
  +}                                                   \
  +while (width > len)
   
   /*
    * Prefix the character ch to the string str
    * Increase length
    * Set the has_prefix flag
    */
  -#define PREFIX( str, length, ch )	 *--str = ch ; length++ ; has_prefix = YES
  +#define PREFIX(str, length, ch)                     \
  +    *--str = ch;                                    \
  +    length++;                                       \
  +    has_prefix=YES;
   
   
   /*
  @@ -365,45 +369,45 @@
    * latter is faster.
    */
   static char *conv_10(register wide_int num, register bool_int is_unsigned,
  -		     register bool_int *is_negative, char *buf_end,
  -		     register int *len)
  +                     register bool_int *is_negative, char *buf_end,
  +                     register int *len)
   {
       register char *p = buf_end;
       register u_wide_int magnitude;
   
       if (is_unsigned) {
  -	magnitude = (u_wide_int) num;
  -	*is_negative = FALSE;
  +        magnitude = (u_wide_int) num;
  +        *is_negative = FALSE;
       }
       else {
  -	*is_negative = (num < 0);
  +        *is_negative = (num < 0);
   
  -	/*
  -	 * On a 2's complement machine, negating the most negative integer 
  -	 * results in a number that cannot be represented as a signed integer.
  -	 * Here is what we do to obtain the number's magnitude:
  -	 *      a. add 1 to the number
  -	 *      b. negate it (becomes positive)
  -	 *      c. convert it to unsigned
  -	 *      d. add 1
  -	 */
  -	if (*is_negative) {
  -	    wide_int t = num + 1;
  -
  -	    magnitude = ((u_wide_int) -t) + 1;
  -	}
  -	else
  -	    magnitude = (u_wide_int) num;
  +        /*
  +         * On a 2's complement machine, negating the most negative integer 
  +         * results in a number that cannot be represented as a signed integer.
  +         * Here is what we do to obtain the number's magnitude:
  +         *      a. add 1 to the number
  +         *      b. negate it (becomes positive)
  +         *      c. convert it to unsigned
  +         *      d. add 1
  +         */
  +        if (*is_negative) {
  +            wide_int t = num + 1;
  +
  +            magnitude = ((u_wide_int) -t) + 1;
  +        }
  +        else
  +            magnitude = (u_wide_int) num;
       }
   
       /*
        * We use a do-while loop so that we write at least 1 digit 
        */
       do {
  -	register u_wide_int new_magnitude = magnitude / 10;
  +        register u_wide_int new_magnitude = magnitude / 10;
   
  -	*--p = (char) (magnitude - new_magnitude * 10 + '0');
  -	magnitude = new_magnitude;
  +        *--p = (char) (magnitude - new_magnitude * 10 + '0');
  +        magnitude = new_magnitude;
       }
       while (magnitude);
   
  @@ -412,8 +416,8 @@
   }
   
   static char *conv_10_quad(widest_int num, register bool_int is_unsigned,
  -		     register bool_int *is_negative, char *buf_end,
  -		     register int *len)
  +                     register bool_int *is_negative, char *buf_end,
  +                     register int *len)
   {
       register char *p = buf_end;
       u_widest_int magnitude;
  @@ -424,42 +428,42 @@
        * punt to the quicker version.
        */
       if ((num <= ULONG_MAX && is_unsigned) || (num <= LONG_MAX && !is_unsigned))
  -    	return(conv_10( (wide_int)num, is_unsigned, is_negative,
  -	       buf_end, len));
  +            return(conv_10( (wide_int)num, is_unsigned, is_negative,
  +               buf_end, len));
   
       if (is_unsigned) {
  -	magnitude = (u_widest_int) num;
  -	*is_negative = FALSE;
  +        magnitude = (u_widest_int) num;
  +        *is_negative = FALSE;
       }
       else {
  -	*is_negative = (num < 0);
  +        *is_negative = (num < 0);
   
  -	/*
  -	 * On a 2's complement machine, negating the most negative integer 
  -	 * results in a number that cannot be represented as a signed integer.
  -	 * Here is what we do to obtain the number's magnitude:
  -	 *      a. add 1 to the number
  -	 *      b. negate it (becomes positive)
  -	 *      c. convert it to unsigned
  -	 *      d. add 1
  -	 */
  -	if (*is_negative) {
  -	    widest_int t = num + 1;
  -
  -	    magnitude = ((u_widest_int) -t) + 1;
  -	}
  -	else
  -	    magnitude = (u_widest_int) num;
  +        /*
  +         * On a 2's complement machine, negating the most negative integer 
  +         * results in a number that cannot be represented as a signed integer.
  +         * Here is what we do to obtain the number's magnitude:
  +         *      a. add 1 to the number
  +         *      b. negate it (becomes positive)
  +         *      c. convert it to unsigned
  +         *      d. add 1
  +         */
  +        if (*is_negative) {
  +            widest_int t = num + 1;
  +
  +            magnitude = ((u_widest_int) -t) + 1;
  +        }
  +        else
  +            magnitude = (u_widest_int) num;
       }
   
       /*
        * We use a do-while loop so that we write at least 1 digit 
        */
       do {
  -	u_widest_int new_magnitude = magnitude / 10;
  +        u_widest_int new_magnitude = magnitude / 10;
   
  -	*--p = (char) (magnitude - new_magnitude * 10 + '0');
  -	magnitude = new_magnitude;
  +        *--p = (char) (magnitude - new_magnitude * 10 + '0');
  +        magnitude = new_magnitude;
       }
       while (magnitude);
   
  @@ -539,74 +543,74 @@
       char buf1[NDIG];
   
       if (format == 'f')
  -	p = apr_fcvt(num, precision, &decimal_point, is_negative, buf1);
  -    else			/* either e or E format */
  -	p = apr_ecvt(num, precision + 1, &decimal_point, is_negative, buf1);
  +        p = apr_fcvt(num, precision, &decimal_point, is_negative, buf1);
  +    else /* either e or E format */
  +        p = apr_ecvt(num, precision + 1, &decimal_point, is_negative, buf1);
   
       /*
        * Check for Infinity and NaN
        */
       if (apr_isalpha(*p)) {
  -	*len = strlen(strcpy(buf, p));
  -	*is_negative = FALSE;
  -	return (buf);
  +        *len = strlen(strcpy(buf, p));
  +        *is_negative = FALSE;
  +        return (buf);
       }
   
       if (format == 'f') {
  -	if (decimal_point <= 0) {
  -	    *s++ = '0';
  -	    if (precision > 0) {
  -		*s++ = '.';
  -		while (decimal_point++ < 0)
  -		    *s++ = '0';
  -	    }
  -	    else if (add_dp)
  -		*s++ = '.';
  -	}
  -	else {
  -	    while (decimal_point-- > 0)
  -		*s++ = *p++;
  -	    if (precision > 0 || add_dp)
  -		*s++ = '.';
  -	}
  +        if (decimal_point <= 0) {
  +            *s++ = '0';
  +            if (precision > 0) {
  +                *s++ = '.';
  +                while (decimal_point++ < 0)
  +                    *s++ = '0';
  +            }
  +            else if (add_dp)
  +                *s++ = '.';
  +        }
  +        else {
  +            while (decimal_point-- > 0)
  +                *s++ = *p++;
  +            if (precision > 0 || add_dp)
  +                *s++ = '.';
  +        }
       }
       else {
  -	*s++ = *p++;
  -	if (precision > 0 || add_dp)
  -	    *s++ = '.';
  +        *s++ = *p++;
  +        if (precision > 0 || add_dp)
  +            *s++ = '.';
       }
   
       /*
        * copy the rest of p, the NUL is NOT copied
        */
       while (*p)
  -	*s++ = *p++;
  +        *s++ = *p++;
   
       if (format != 'f') {
  -	char temp[EXPONENT_LENGTH];	/* for exponent conversion */
  -	int t_len;
  -	bool_int exponent_is_negative;
  -
  -	*s++ = format;		/* either e or E */
  -	decimal_point--;
  -	if (decimal_point != 0) {
  -	    p = conv_10((wide_int) decimal_point, FALSE, &exponent_is_negative,
  -			&temp[EXPONENT_LENGTH], &t_len);
  -	    *s++ = exponent_is_negative ? '-' : '+';
  -
  -	    /*
  -	     * Make sure the exponent has at least 2 digits
  -	     */
  -	    if (t_len == 1)
  -		*s++ = '0';
  -	    while (t_len--)
  -		*s++ = *p++;
  -	}
  -	else {
  -	    *s++ = '+';
  -	    *s++ = '0';
  -	    *s++ = '0';
  -	}
  +        char temp[EXPONENT_LENGTH];        /* for exponent conversion */
  +        int t_len;
  +        bool_int exponent_is_negative;
  +
  +        *s++ = format;                /* either e or E */
  +        decimal_point--;
  +        if (decimal_point != 0) {
  +            p = conv_10((wide_int) decimal_point, FALSE, &exponent_is_negative,
  +                        &temp[EXPONENT_LENGTH], &t_len);
  +            *s++ = exponent_is_negative ? '-' : '+';
  +
  +            /*
  +             * Make sure the exponent has at least 2 digits
  +             */
  +            if (t_len == 1)
  +                *s++ = '0';
  +            while (t_len--)
  +                *s++ = *p++;
  +        }
  +        else {
  +            *s++ = '+';
  +            *s++ = '0';
  +            *s++ = '0';
  +        }
       }
   
       *len = s - buf;
  @@ -628,7 +632,7 @@
    * the number isn't quad size.
    */
   static char *conv_p2(register u_wide_int num, register int nbits,
  -		     char format, char *buf_end, register int *len)
  +                     char format, char *buf_end, register int *len)
   {
       register int mask = (1 << nbits) - 1;
       register char *p = buf_end;
  @@ -637,8 +641,8 @@
       register const char *digits = (format == 'X') ? upper_digits : low_digits;
   
       do {
  -	*--p = digits[num & mask];
  -	num >>= nbits;
  +        *--p = digits[num & mask];
  +        num >>= nbits;
       }
       while (num);
   
  @@ -647,7 +651,7 @@
   }
   
   static char *conv_p2_quad(u_widest_int num, register int nbits,
  -		     char format, char *buf_end, register int *len)
  +                     char format, char *buf_end, register int *len)
   {
       register int mask = (1 << nbits) - 1;
       register char *p = buf_end;
  @@ -656,11 +660,11 @@
       register const char *digits = (format == 'X') ? upper_digits : low_digits;
   
       if (num <= ULONG_MAX)
  -    	return(conv_p2( (u_wide_int)num, nbits, format, buf_end, len));
  +        return(conv_p2((u_wide_int)num, nbits, format, buf_end, len));
   
       do {
  -	*--p = digits[num & mask];
  -	num >>= nbits;
  +        *--p = digits[num & mask];
  +        num >>= nbits;
       }
       while (num);
   
  @@ -687,7 +691,7 @@
       register int min_width = 0;
       int precision = 0;
       enum {
  -	LEFT, RIGHT
  +        LEFT, RIGHT
       } adjust;
       char pad_char;
       char prefix_char;
  @@ -699,10 +703,10 @@
       u_wide_int ui_num;
   
       char num_buf[NUM_BUF_SIZE];
  -    char char_buf[2];		/* for printing %% and %<unknown> */
  +    char char_buf[2];                /* for printing %% and %<unknown> */
   
       enum var_type_enum {
  -    	IS_QUAD, IS_LONG, IS_SHORT, IS_INT
  +            IS_QUAD, IS_LONG, IS_SHORT, IS_INT
       };
       enum var_type_enum var_type = IS_INT;
   
  @@ -720,470 +724,470 @@
       bep = vbuff->endpos;
   
       while (*fmt) {
  -	if (*fmt != '%') {
  -	    INS_CHAR(*fmt, sp, bep, cc);
  -	}
  -	else {
  -	    /*
  -	     * Default variable settings
  -	     */
  +        if (*fmt != '%') {
  +            INS_CHAR(*fmt, sp, bep, cc);
  +        }
  +        else {
  +            /*
  +             * Default variable settings
  +             */
               boolean_e print_something = YES;
  -	    adjust = RIGHT;
  -	    alternate_form = print_sign = print_blank = NO;
  -	    pad_char = ' ';
  -	    prefix_char = NUL;
  -
  -	    fmt++;
  -
  -	    /*
  -	     * Try to avoid checking for flags, width or precision
  -	     */
  -	    if (!apr_islower(*fmt)) {
  -		/*
  -		 * Recognize flags: -, #, BLANK, +
  -		 */
  -		for (;; fmt++) {
  -		    if (*fmt == '-')
  -			adjust = LEFT;
  -		    else if (*fmt == '+')
  -			print_sign = YES;
  -		    else if (*fmt == '#')
  -			alternate_form = YES;
  -		    else if (*fmt == ' ')
  -			print_blank = YES;
  -		    else if (*fmt == '0')
  -			pad_char = '0';
  -		    else
  -			break;
  -		}
  -
  -		/*
  -		 * Check if a width was specified
  -		 */
  -		if (apr_isdigit(*fmt)) {
  -		    STR_TO_DEC(fmt, min_width);
  -		    adjust_width = YES;
  -		}
  -		else if (*fmt == '*') {
  -		    min_width = va_arg(ap, int);
  -		    fmt++;
  -		    adjust_width = YES;
  -		    if (min_width < 0) {
  -			adjust = LEFT;
  -			min_width = -min_width;
  -		    }
  -		}
  -		else
  -		    adjust_width = NO;
  -
  -		/*
  -		 * Check if a precision was specified
  -		 *
  -		 * XXX: an unreasonable amount of precision may be specified
  -		 * resulting in overflow of num_buf. Currently we
  -		 * ignore this possibility.
  -		 */
  -		if (*fmt == '.') {
  -		    adjust_precision = YES;
  -		    fmt++;
  -		    if (apr_isdigit(*fmt)) {
  -			STR_TO_DEC(fmt, precision);
  -		    }
  -		    else if (*fmt == '*') {
  -			precision = va_arg(ap, int);
  -			fmt++;
  -			if (precision < 0)
  -			    precision = 0;
  -		    }
  -		    else
  -			precision = 0;
  -		}
  -		else
  -		    adjust_precision = NO;
  -	    }
  -	    else
  -		adjust_precision = adjust_width = NO;
  -
  -	    /*
  -	     * Modifier check
  -	     */
  +            adjust = RIGHT;
  +            alternate_form = print_sign = print_blank = NO;
  +            pad_char = ' ';
  +            prefix_char = NUL;
  +
  +            fmt++;
  +
  +            /*
  +             * Try to avoid checking for flags, width or precision
  +             */
  +            if (!apr_islower(*fmt)) {
  +                /*
  +                 * Recognize flags: -, #, BLANK, +
  +                 */
  +                for (;; fmt++) {
  +                    if (*fmt == '-')
  +                        adjust = LEFT;
  +                    else if (*fmt == '+')
  +                        print_sign = YES;
  +                    else if (*fmt == '#')
  +                        alternate_form = YES;
  +                    else if (*fmt == ' ')
  +                        print_blank = YES;
  +                    else if (*fmt == '0')
  +                        pad_char = '0';
  +                    else
  +                        break;
  +                }
  +
  +                /*
  +                 * Check if a width was specified
  +                 */
  +                if (apr_isdigit(*fmt)) {
  +                    STR_TO_DEC(fmt, min_width);
  +                    adjust_width = YES;
  +                }
  +                else if (*fmt == '*') {
  +                    min_width = va_arg(ap, int);
  +                    fmt++;
  +                    adjust_width = YES;
  +                    if (min_width < 0) {
  +                        adjust = LEFT;
  +                        min_width = -min_width;
  +                    }
  +                }
  +                else
  +                    adjust_width = NO;
  +
  +                /*
  +                 * Check if a precision was specified
  +                 *
  +                 * XXX: an unreasonable amount of precision may be specified
  +                 * resulting in overflow of num_buf. Currently we
  +                 * ignore this possibility.
  +                 */
  +                if (*fmt == '.') {
  +                    adjust_precision = YES;
  +                    fmt++;
  +                    if (apr_isdigit(*fmt)) {
  +                        STR_TO_DEC(fmt, precision);
  +                    }
  +                    else if (*fmt == '*') {
  +                        precision = va_arg(ap, int);
  +                        fmt++;
  +                        if (precision < 0)
  +                            precision = 0;
  +                    }
  +                    else
  +                        precision = 0;
  +                }
  +                else
  +                    adjust_precision = NO;
  +            }
  +            else
  +                adjust_precision = adjust_width = NO;
  +
  +            /*
  +             * Modifier check
  +             */
               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);
  +                var_type = IS_QUAD;
  +                fmt += (sizeof(APR_INT64_T_FMT) - 2);
               }
  -	    else if (*fmt == 'q') {
  -		var_type = IS_QUAD;
  -		fmt++;
  -	    }
  -	    else if (*fmt == 'l') {
  -		var_type = IS_LONG;
  -		fmt++;
  -	    }
  -	    else if (*fmt == 'h') {
  -		var_type = IS_SHORT;
  -		fmt++;
  -	    }
  -	    else {
  -		var_type = IS_INT;
  -	    }
  -
  -	    /*
  -	     * Argument extraction and printing.
  -	     * First we determine the argument type.
  -	     * Then, we convert the argument to a string.
  -	     * On exit from the switch, s points to the string that
  -	     * must be printed, s_len has the length of the string
  -	     * The precision requirements, if any, are reflected in s_len.
  -	     *
  -	     * NOTE: pad_char may be set to '0' because of the 0 flag.
  -	     *   It is reset to ' ' by non-numeric formats
  -	     */
  -	    switch (*fmt) {
  -	    case 'u':
  -	    	if (var_type == IS_QUAD) {
  -		    i_quad = va_arg(ap, u_widest_int);
  -		    s = conv_10_quad(i_quad, 1, &is_negative,
  -			    &num_buf[NUM_BUF_SIZE], &s_len);
  -		}
  -		else {
  -		    if (var_type == IS_LONG)
  -			i_num = (wide_int) va_arg(ap, u_wide_int);
  -		    else if (var_type == IS_SHORT)
  -			i_num = (wide_int) (unsigned short) va_arg(ap, unsigned int);
  -		    else
  -			i_num = (wide_int) va_arg(ap, unsigned int);
  -		    s = conv_10(i_num, 1, &is_negative,
  -			    &num_buf[NUM_BUF_SIZE], &s_len);
  -		}
  -		FIX_PRECISION(adjust_precision, precision, s, s_len);
  -		break;
  -
  -	    case 'd':
  -	    case 'i':
  -	    	if (var_type == IS_QUAD) {
  -		    i_quad = va_arg(ap, widest_int);
  -		    s = conv_10_quad(i_quad, 0, &is_negative,
  -			    &num_buf[NUM_BUF_SIZE], &s_len);
  -		}
  -		else {
  -		    if (var_type == IS_LONG)
  -			i_num = (wide_int) va_arg(ap, wide_int);
  -		    else if (var_type == IS_SHORT)
  -			i_num = (wide_int) (short) va_arg(ap, int);
  -		    else
  -			i_num = (wide_int) va_arg(ap, int);
  -		    s = conv_10(i_num, 0, &is_negative,
  -			    &num_buf[NUM_BUF_SIZE], &s_len);
  -		}
  -		FIX_PRECISION(adjust_precision, precision, s, s_len);
  -
  -		if (is_negative)
  -		    prefix_char = '-';
  -		else if (print_sign)
  -		    prefix_char = '+';
  -		else if (print_blank)
  -		    prefix_char = ' ';
  -		break;
  -
  -
  -	    case 'o':
  -		if (var_type == IS_QUAD) {
  -		    ui_quad = va_arg(ap, u_widest_int);
  -		    s = conv_p2_quad(ui_quad, 3, *fmt,
  -			    &num_buf[NUM_BUF_SIZE], &s_len);
  -		}
  -		else {
  -		    if (var_type == IS_LONG)
  -			ui_num = (u_wide_int) va_arg(ap, u_wide_int);
  -		    else if (var_type == IS_SHORT)
  -			ui_num = (u_wide_int) (unsigned short) va_arg(ap, unsigned int);
  -		    else
  -			ui_num = (u_wide_int) va_arg(ap, unsigned int);
  -		    s = conv_p2(ui_num, 3, *fmt,
  -			    &num_buf[NUM_BUF_SIZE], &s_len);
  -		}
  -		FIX_PRECISION(adjust_precision, precision, s, s_len);
  -		if (alternate_form && *s != '0') {
  -		    *--s = '0';
  -		    s_len++;
  -		}
  -		break;
  -
  -
  -	    case 'x':
  -	    case 'X':
  -		if (var_type == IS_QUAD) {
  -		    ui_quad = va_arg(ap, u_widest_int);
  -		    s = conv_p2_quad(ui_quad, 4, *fmt,
  -			    &num_buf[NUM_BUF_SIZE], &s_len);
  -		}
  -		else {
  -		    if (var_type == IS_LONG)
  -			ui_num = (u_wide_int) va_arg(ap, u_wide_int);
  -		    else if (var_type == IS_SHORT)
  -			ui_num = (u_wide_int) (unsigned short) va_arg(ap, unsigned int);
  -		    else
  -			ui_num = (u_wide_int) va_arg(ap, unsigned int);
  -		    s = conv_p2(ui_num, 4, *fmt,
  -			    &num_buf[NUM_BUF_SIZE], &s_len);
  -		}
  -		FIX_PRECISION(adjust_precision, precision, s, s_len);
  -		if (alternate_form && i_num != 0) {
  -		    *--s = *fmt;	/* 'x' or 'X' */
  -		    *--s = '0';
  -		    s_len += 2;
  -		}
  -		break;
  -
  -
  -	    case 's':
  -		s = va_arg(ap, char *);
  -		if (s != NULL) {
  -		    s_len = strlen(s);
  -		    if (adjust_precision && precision < s_len)
  -			s_len = precision;
  -		}
  -		else {
  -		    s = S_NULL;
  -		    s_len = S_NULL_LEN;
  -		}
  -		pad_char = ' ';
  -		break;
  -
  -
  -	    case 'f':
  -	    case 'e':
  -	    case 'E':
  -		fp_num = va_arg(ap, double);
  -		/*
  -		 * We use &num_buf[ 1 ], so that we have room for the sign
  -		 */
  +            else if (*fmt == 'q') {
  +                var_type = IS_QUAD;
  +                fmt++;
  +            }
  +            else if (*fmt == 'l') {
  +                var_type = IS_LONG;
  +                fmt++;
  +            }
  +            else if (*fmt == 'h') {
  +                var_type = IS_SHORT;
  +                fmt++;
  +            }
  +            else {
  +                var_type = IS_INT;
  +            }
  +
  +            /*
  +             * Argument extraction and printing.
  +             * First we determine the argument type.
  +             * Then, we convert the argument to a string.
  +             * On exit from the switch, s points to the string that
  +             * must be printed, s_len has the length of the string
  +             * The precision requirements, if any, are reflected in s_len.
  +             *
  +             * NOTE: pad_char may be set to '0' because of the 0 flag.
  +             *   It is reset to ' ' by non-numeric formats
  +             */
  +            switch (*fmt) {
  +            case 'u':
  +                    if (var_type == IS_QUAD) {
  +                    i_quad = va_arg(ap, u_widest_int);
  +                    s = conv_10_quad(i_quad, 1, &is_negative,
  +                            &num_buf[NUM_BUF_SIZE], &s_len);
  +                }
  +                else {
  +                    if (var_type == IS_LONG)
  +                        i_num = (wide_int) va_arg(ap, u_wide_int);
  +                    else if (var_type == IS_SHORT)
  +                        i_num = (wide_int) (unsigned short) va_arg(ap, unsigned int);
  +                    else
  +                        i_num = (wide_int) va_arg(ap, unsigned int);
  +                    s = conv_10(i_num, 1, &is_negative,
  +                            &num_buf[NUM_BUF_SIZE], &s_len);
  +                }
  +                FIX_PRECISION(adjust_precision, precision, s, s_len);
  +                break;
  +
  +            case 'd':
  +            case 'i':
  +                    if (var_type == IS_QUAD) {
  +                    i_quad = va_arg(ap, widest_int);
  +                    s = conv_10_quad(i_quad, 0, &is_negative,
  +                            &num_buf[NUM_BUF_SIZE], &s_len);
  +                }
  +                else {
  +                    if (var_type == IS_LONG)
  +                        i_num = (wide_int) va_arg(ap, wide_int);
  +                    else if (var_type == IS_SHORT)
  +                        i_num = (wide_int) (short) va_arg(ap, int);
  +                    else
  +                        i_num = (wide_int) va_arg(ap, int);
  +                    s = conv_10(i_num, 0, &is_negative,
  +                            &num_buf[NUM_BUF_SIZE], &s_len);
  +                }
  +                FIX_PRECISION(adjust_precision, precision, s, s_len);
  +
  +                if (is_negative)
  +                    prefix_char = '-';
  +                else if (print_sign)
  +                    prefix_char = '+';
  +                else if (print_blank)
  +                    prefix_char = ' ';
  +                break;
  +
  +
  +            case 'o':
  +                if (var_type == IS_QUAD) {
  +                    ui_quad = va_arg(ap, u_widest_int);
  +                    s = conv_p2_quad(ui_quad, 3, *fmt,
  +                            &num_buf[NUM_BUF_SIZE], &s_len);
  +                }
  +                else {
  +                    if (var_type == IS_LONG)
  +                        ui_num = (u_wide_int) va_arg(ap, u_wide_int);
  +                    else if (var_type == IS_SHORT)
  +                        ui_num = (u_wide_int) (unsigned short) va_arg(ap, unsigned int);
  +                    else
  +                        ui_num = (u_wide_int) va_arg(ap, unsigned int);
  +                    s = conv_p2(ui_num, 3, *fmt,
  +                            &num_buf[NUM_BUF_SIZE], &s_len);
  +                }
  +                FIX_PRECISION(adjust_precision, precision, s, s_len);
  +                if (alternate_form && *s != '0') {
  +                    *--s = '0';
  +                    s_len++;
  +                }
  +                break;
  +
  +
  +            case 'x':
  +            case 'X':
  +                if (var_type == IS_QUAD) {
  +                    ui_quad = va_arg(ap, u_widest_int);
  +                    s = conv_p2_quad(ui_quad, 4, *fmt,
  +                            &num_buf[NUM_BUF_SIZE], &s_len);
  +                }
  +                else {
  +                    if (var_type == IS_LONG)
  +                        ui_num = (u_wide_int) va_arg(ap, u_wide_int);
  +                    else if (var_type == IS_SHORT)
  +                        ui_num = (u_wide_int) (unsigned short) va_arg(ap, unsigned int);
  +                    else
  +                        ui_num = (u_wide_int) va_arg(ap, unsigned int);
  +                    s = conv_p2(ui_num, 4, *fmt,
  +                            &num_buf[NUM_BUF_SIZE], &s_len);
  +                }
  +                FIX_PRECISION(adjust_precision, precision, s, s_len);
  +                if (alternate_form && i_num != 0) {
  +                    *--s = *fmt;        /* 'x' or 'X' */
  +                    *--s = '0';
  +                    s_len += 2;
  +                }
  +                break;
  +
  +
  +            case 's':
  +                s = va_arg(ap, char *);
  +                if (s != NULL) {
  +                    s_len = strlen(s);
  +                    if (adjust_precision && precision < s_len)
  +                        s_len = precision;
  +                }
  +                else {
  +                    s = S_NULL;
  +                    s_len = S_NULL_LEN;
  +                }
  +                pad_char = ' ';
  +                break;
  +
  +
  +            case 'f':
  +            case 'e':
  +            case 'E':
  +                fp_num = va_arg(ap, double);
  +                /*
  +                 * We use &num_buf[ 1 ], so that we have room for the sign
  +                 */
           s = NULL;
   #ifdef HAVE_ISNAN
  -		if (isnan(fp_num)) {
  -		    s = "nan";
  -		    s_len = 3;
  -		}
  +                if (isnan(fp_num)) {
  +                    s = "nan";
  +                    s_len = 3;
  +                }
   #endif
   #ifdef HAVE_ISINF
  -		if (!s && isinf(fp_num)) {
  -		    s = "inf";
  -		    s_len = 3;
  -		}
  +                if (!s && isinf(fp_num)) {
  +                    s = "inf";
  +                    s_len = 3;
  +                }
   #endif
  -	    if (!s) {
  -		    s = conv_fp(*fmt, fp_num, alternate_form,
  -			    (adjust_precision == NO) ? FLOAT_DIGITS : precision,
  -				&is_negative, &num_buf[1], &s_len);
  -		    if (is_negative)
  -			prefix_char = '-';
  -		    else if (print_sign)
  -			prefix_char = '+';
  -		    else if (print_blank)
  -			prefix_char = ' ';
  -		}
  -		break;
  -
  -
  -	    case 'g':
  -	    case 'G':
  -		if (adjust_precision == NO)
  -		    precision = FLOAT_DIGITS;
  -		else if (precision == 0)
  -		    precision = 1;
  -		/*
  -		 * * We use &num_buf[ 1 ], so that we have room for the sign
  -		 */
  -		s = apr_gcvt(va_arg(ap, double), precision, &num_buf[1],
  -		            alternate_form);
  -		if (*s == '-')
  -		    prefix_char = *s++;
  -		else if (print_sign)
  -		    prefix_char = '+';
  -		else if (print_blank)
  -		    prefix_char = ' ';
  -
  -		s_len = strlen(s);
  -
  -		if (alternate_form && (q = strchr(s, '.')) == NULL) {
  -		    s[s_len++] = '.';
  -		    s[s_len] = '\0'; /* delimit for following strchr() */
  -		}
  -		if (*fmt == 'G' && (q = strchr(s, 'e')) != NULL)
  -		    *q = 'E';
  -		break;
  -
  -
  -	    case 'c':
  -		char_buf[0] = (char) (va_arg(ap, int));
  -		s = &char_buf[0];
  -		s_len = 1;
  -		pad_char = ' ';
  -		break;
  -
  -
  -	    case '%':
  -		char_buf[0] = '%';
  -		s = &char_buf[0];
  -		s_len = 1;
  -		pad_char = ' ';
  -		break;
  -
  -
  -	    case 'n':
  -	    	if (var_type == IS_QUAD)
  -		    *(va_arg(ap, widest_int *)) = cc;
  -		else if (var_type == IS_LONG)
  -		    *(va_arg(ap, long *)) = cc;
  -		else if (var_type == IS_SHORT)
  -		    *(va_arg(ap, short *)) = cc;
  -		else
  -		    *(va_arg(ap, int *)) = cc;
  +            if (!s) {
  +                    s = conv_fp(*fmt, fp_num, alternate_form,
  +                            (adjust_precision == NO) ? FLOAT_DIGITS : precision,
  +                                &is_negative, &num_buf[1], &s_len);
  +                    if (is_negative)
  +                        prefix_char = '-';
  +                    else if (print_sign)
  +                        prefix_char = '+';
  +                    else if (print_blank)
  +                        prefix_char = ' ';
  +                }
  +                break;
  +
  +
  +            case 'g':
  +            case 'G':
  +                if (adjust_precision == NO)
  +                    precision = FLOAT_DIGITS;
  +                else if (precision == 0)
  +                    precision = 1;
  +                /*
  +                 * * We use &num_buf[ 1 ], so that we have room for the sign
  +                 */
  +                s = apr_gcvt(va_arg(ap, double), precision, &num_buf[1],
  +                            alternate_form);
  +                if (*s == '-')
  +                    prefix_char = *s++;
  +                else if (print_sign)
  +                    prefix_char = '+';
  +                else if (print_blank)
  +                    prefix_char = ' ';
  +
  +                s_len = strlen(s);
  +
  +                if (alternate_form && (q = strchr(s, '.')) == NULL) {
  +                    s[s_len++] = '.';
  +                    s[s_len] = '\0'; /* delimit for following strchr() */
  +                }
  +                if (*fmt == 'G' && (q = strchr(s, 'e')) != NULL)
  +                    *q = 'E';
  +                break;
  +
  +
  +            case 'c':
  +                char_buf[0] = (char) (va_arg(ap, int));
  +                s = &char_buf[0];
  +                s_len = 1;
  +                pad_char = ' ';
  +                break;
  +
  +
  +            case '%':
  +                char_buf[0] = '%';
  +                s = &char_buf[0];
  +                s_len = 1;
  +                pad_char = ' ';
  +                break;
  +
  +
  +            case 'n':
  +                    if (var_type == IS_QUAD)
  +                    *(va_arg(ap, widest_int *)) = cc;
  +                else if (var_type == IS_LONG)
  +                    *(va_arg(ap, long *)) = cc;
  +                else if (var_type == IS_SHORT)
  +                    *(va_arg(ap, short *)) = cc;
  +                else
  +                    *(va_arg(ap, int *)) = cc;
                   print_something = NO;
  -		break;
  +                break;
   
  -		/*
  -		 * This is where we extend the printf format, with a second
  -		 * type specifier
  -		 */
  -	    case 'p':
  -		switch(*++fmt) {
  -		    /*
  -		     * If the pointer size is equal to or smaller than the size
  -		     * of the largest unsigned int, we convert the pointer to a
  -		     * hex number, otherwise we print "%p" to indicate that we
  -		     * don't handle "%p".
  -		     */
  -		case 'p':
  +                /*
  +                 * This is where we extend the printf format, with a second
  +                 * type specifier
  +                 */
  +            case 'p':
  +                switch(*++fmt) {
  +                    /*
  +                     * If the pointer size is equal to or smaller than the size
  +                     * of the largest unsigned int, we convert the pointer to a
  +                     * hex number, otherwise we print "%p" to indicate that we
  +                     * don't handle "%p".
  +                     */
  +                case 'p':
   #ifdef APR_VOID_P_IS_QUAD
  -		    if (sizeof(void *) <= sizeof(u_widest_int)) {
  -		    	ui_quad = (u_widest_int) va_arg(ap, void *);
  -			s = conv_p2_quad(ui_quad, 4, 'x',
  -				&num_buf[NUM_BUF_SIZE], &s_len);
  -		    }
  +                    if (sizeof(void *) <= sizeof(u_widest_int)) {
  +                        ui_quad = (u_widest_int) va_arg(ap, void *);
  +                        s = conv_p2_quad(ui_quad, 4, 'x',
  +                                &num_buf[NUM_BUF_SIZE], &s_len);
  +                    }
   #else
  -		    if (sizeof(void *) <= sizeof(u_wide_int)) {
  -		    	ui_num = (u_wide_int) va_arg(ap, void *);
  -			s = conv_p2(ui_num, 4, 'x',
  -				&num_buf[NUM_BUF_SIZE], &s_len);
  -		    }
  +                    if (sizeof(void *) <= sizeof(u_wide_int)) {
  +                        ui_num = (u_wide_int) va_arg(ap, void *);
  +                        s = conv_p2(ui_num, 4, 'x',
  +                                &num_buf[NUM_BUF_SIZE], &s_len);
  +                    }
   #endif
  -		    else {
  -			s = "%p";
  -			s_len = 2;
  -			prefix_char = NUL;
  -		    }
  -		    pad_char = ' ';
  -		    break;
  -
  -		    /* print an apr_sockaddr_t as a.b.c.d:port */
  -		case 'I':
  -		    {
  -			apr_sockaddr_t *sa;
  -
  -			sa = va_arg(ap, apr_sockaddr_t *);
  -			if (sa != NULL) {
  -			    s = conv_apr_sockaddr(sa, &num_buf[NUM_BUF_SIZE], &s_len);
  -			    if (adjust_precision && precision < s_len)
  -				s_len = precision;
  -			}
  -			else {
  -			    s = S_NULL;
  -			    s_len = S_NULL_LEN;
  -			}
  -			pad_char = ' ';
  -		    }
  -		    break;
  -
  -		    /* print a struct in_addr as a.b.c.d */
  -		case 'A':
  -		    {
  -			struct in_addr *ia;
  -
  -			ia = va_arg(ap, struct in_addr *);
  -			if (ia != NULL) {
  -			    s = conv_in_addr(ia, &num_buf[NUM_BUF_SIZE], &s_len);
  -			    if (adjust_precision && precision < s_len)
  -				s_len = precision;
  -			}
  -			else {
  -			    s = S_NULL;
  -			    s_len = S_NULL_LEN;
  -			}
  -			pad_char = ' ';
  -		    }
  -		    break;
  -
  -		case NUL:
  -		    /* if %p ends the string, oh well ignore it */
  -		    continue;
  -
  -		default:
  -		    s = "bogus %p";
  -		    s_len = 8;
  -		    prefix_char = NUL;
  -		    break;
  -		}
  -		break;
  -
  -	    case NUL:
  -		/*
  -		 * The last character of the format string was %.
  -		 * We ignore it.
  -		 */
  -		continue;
  -
  -
  -		/*
  -		 * The default case is for unrecognized %'s.
  -		 * We print %<char> to help the user identify what
  -		 * option is not understood.
  -		 * This is also useful in case the user wants to pass
  -		 * the output of format_converter to another function
  -		 * that understands some other %<char> (like syslog).
  -		 * Note that we can't point s inside fmt because the
  -		 * unknown <char> could be preceded by width etc.
  -		 */
  -	    default:
  -		char_buf[0] = '%';
  -		char_buf[1] = *fmt;
  -		s = char_buf;
  -		s_len = 2;
  -		pad_char = ' ';
  -		break;
  -	    }
  -
  -	    if (prefix_char != NUL && s != S_NULL && s != char_buf) {
  -		*--s = prefix_char;
  -		s_len++;
  -	    }
  -
  -	    if (adjust_width && adjust == RIGHT && min_width > s_len) {
  -		if (pad_char == '0' && prefix_char != NUL) {
  -		    INS_CHAR(*s, sp, bep, cc);
  -		    s++;
  -		    s_len--;
  -		    min_width--;
  -		}
  -		PAD(min_width, s_len, pad_char);
  -	    }
  -
  -	    /*
  -	     * Print the string s. 
  -	     */
  +                    else {
  +                        s = "%p";
  +                        s_len = 2;
  +                        prefix_char = NUL;
  +                    }
  +                    pad_char = ' ';
  +                    break;
  +
  +                    /* print an apr_sockaddr_t as a.b.c.d:port */
  +                case 'I':
  +                    {
  +                        apr_sockaddr_t *sa;
  +
  +                        sa = va_arg(ap, apr_sockaddr_t *);
  +                        if (sa != NULL) {
  +                            s = conv_apr_sockaddr(sa, &num_buf[NUM_BUF_SIZE], &s_len);
  +                            if (adjust_precision && precision < s_len)
  +                                s_len = precision;
  +                        }
  +                        else {
  +                            s = S_NULL;
  +                            s_len = S_NULL_LEN;
  +                        }
  +                        pad_char = ' ';
  +                    }
  +                    break;
  +
  +                    /* print a struct in_addr as a.b.c.d */
  +                case 'A':
  +                    {
  +                        struct in_addr *ia;
  +
  +                        ia = va_arg(ap, struct in_addr *);
  +                        if (ia != NULL) {
  +                            s = conv_in_addr(ia, &num_buf[NUM_BUF_SIZE], &s_len);
  +                            if (adjust_precision && precision < s_len)
  +                                s_len = precision;
  +                        }
  +                        else {
  +                            s = S_NULL;
  +                            s_len = S_NULL_LEN;
  +                        }
  +                        pad_char = ' ';
  +                    }
  +                    break;
  +
  +                case NUL:
  +                    /* if %p ends the string, oh well ignore it */
  +                    continue;
  +
  +                default:
  +                    s = "bogus %p";
  +                    s_len = 8;
  +                    prefix_char = NUL;
  +                    break;
  +                }
  +                break;
  +
  +            case NUL:
  +                /*
  +                 * The last character of the format string was %.
  +                 * We ignore it.
  +                 */
  +                continue;
  +
  +
  +                /*
  +                 * The default case is for unrecognized %'s.
  +                 * We print %<char> to help the user identify what
  +                 * option is not understood.
  +                 * This is also useful in case the user wants to pass
  +                 * the output of format_converter to another function
  +                 * that understands some other %<char> (like syslog).
  +                 * Note that we can't point s inside fmt because the
  +                 * unknown <char> could be preceded by width etc.
  +                 */
  +            default:
  +                char_buf[0] = '%';
  +                char_buf[1] = *fmt;
  +                s = char_buf;
  +                s_len = 2;
  +                pad_char = ' ';
  +                break;
  +            }
  +
  +            if (prefix_char != NUL && s != S_NULL && s != char_buf) {
  +                *--s = prefix_char;
  +                s_len++;
  +            }
  +
  +            if (adjust_width && adjust == RIGHT && min_width > s_len) {
  +                if (pad_char == '0' && prefix_char != NUL) {
  +                    INS_CHAR(*s, sp, bep, cc);
  +                    s++;
  +                    s_len--;
  +                    min_width--;
  +                }
  +                PAD(min_width, s_len, pad_char);
  +            }
  +
  +            /*
  +             * Print the string s. 
  +             */
               if (print_something == YES) {
                   for (i = s_len; i != 0; i--) {
  -  		    INS_CHAR(*s, sp, bep, cc);
  -		    s++;
  +                      INS_CHAR(*s, sp, bep, cc);
  +                    s++;
                   }
               }
   
  -	    if (adjust_width && adjust == LEFT && min_width > s_len)
  -		PAD(min_width, s_len, pad_char);
  -	}
  -	fmt++;
  +            if (adjust_width && adjust == LEFT && min_width > s_len)
  +                PAD(min_width, s_len, pad_char);
  +        }
  +        fmt++;
       }
       vbuff->curpos = sp;
       return cc;
  @@ -1207,7 +1211,7 @@
       apr_vformatter_buff_t vbuff;
   
       if (len == 0)
  -	return 0;
  +        return 0;
   
       /* save one byte for nul terminator */
       vbuff.curpos = buf;
  @@ -1221,13 +1225,13 @@
   
   
   APR_DECLARE(int) apr_vsnprintf(char *buf, apr_size_t len, const char *format,
  -			     va_list ap)
  +                             va_list ap)
   {
       int cc;
       apr_vformatter_buff_t vbuff;
   
       if (len == 0)
  -	return 0;
  +        return 0;
   
       /* save one byte for nul terminator */
       vbuff.curpos = buf;
  
  
  

Mime
View raw message