]> granicus.if.org Git - php/commitdiff
- WS
authorMarcus Boerger <helly@php.net>
Thu, 7 Feb 2008 12:45:42 +0000 (12:45 +0000)
committerMarcus Boerger <helly@php.net>
Thu, 7 Feb 2008 12:45:42 +0000 (12:45 +0000)
main/snprintf.c
main/snprintf.h
main/spprintf.c
main/spprintf.h

index 40b3e1bb5df6517efbb351fc1d3367c9a3c8955b..91e0b67cd49ca546d912a229924f16fbe98a1b73 100644 (file)
@@ -153,7 +153,7 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
        }
 
        for (i = 0; i < ndigit && digits[i] != '\0'; i++);
-       
+
        if ((decpt >= 0 && decpt - i > 4) || (decpt < 0 && decpt < -3)) { /* use E-style */
                /* exponential format (e.g. 1.2345e+13) */
                if (--decpt < 0) {
@@ -237,7 +237,7 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
+ *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
@@ -323,7 +323,7 @@ char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
                *is_negative = (num < 0);
 
                /*
-                * On a 2's complement machine, negating the most negative integer 
+                * 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
@@ -340,7 +340,7 @@ char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
        }
 
        /*
-        * We use a do-while loop so that we write at least 1 digit 
+        * We use a do-while loop so that we write at least 1 digit
         */
        do {
                register u_wide_int new_magnitude = magnitude / 10;
@@ -761,7 +761,7 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
                                                fmt++;
                                        }
                                        /* these are promoted to int, so no break */
-                               default:                                
+                               default:
                                        modifier = LM_STD;
                                        break;
                        }
@@ -990,7 +990,7 @@ fmt_unicode:
                                        }
                                        s = res;
                                        s_to_free = s;
-                                               
+
                                        pad_char = ' ';
                                        break;
                                }
@@ -1128,17 +1128,17 @@ fmt_string:
                                        goto skip_output;
 
                                        /*
-                                        * Always extract the argument as a "char *" pointer. We 
-                                        * should be using "void *" but there are still machines 
+                                        * Always extract the argument as a "char *" pointer. We
+                                        * should be using "void *" but there are still machines
                                         * that don't understand it.
                                         * If the pointer size is equal to the size of an unsigned
-                                        * integer we convert the pointer to a hex number, otherwise 
+                                        * integer we convert the pointer to a hex number, otherwise
                                         * we print "%p" to indicate that we don't handle "%p".
                                         */
                                case 'p':
                                        if (sizeof(char *) <= sizeof(u_wide_int)) {
                                                ui_num = (u_wide_int)((size_t) va_arg(ap, char *));
-                                               s = ap_php_conv_p2(ui_num, 4, 'x', 
+                                               s = ap_php_conv_p2(ui_num, 4, 'x',
                                                                &num_buf[NUM_BUF_SIZE], &s_len);
                                                if (ui_num != 0) {
                                                        *--s = 'x';
@@ -1196,7 +1196,7 @@ fmt_error:
                                PAD(min_width, s_len, pad_char);
                        }
                        /*
-                        * Print the string s. 
+                        * Print the string s.
                         */
                        for (i = s_len; i != 0; i--) {
                                INS_CHAR(*s, sp, bep, cc);
index b3ea02ee82faba84959e0d113f6522e49d4cc1fd..3ba50259ffadd02c972dee029de51c3c6c5d8fc5 100644 (file)
@@ -21,7 +21,7 @@
 
 /*
 
-Comparing: sprintf, snprintf, slprintf, spprintf 
+Comparing: sprintf, snprintf, slprintf, spprintf
 
 sprintf  offers the ability to make a lot of failures since it does not know
          the size of the buffer it uses. Therefore usage of sprintf often
@@ -34,19 +34,19 @@ snprintf knows the buffers size and will not write behind it. But you will
          before beeing able to call the function. In other words you must
          be sure that you really know the maximum size of the buffer required.
          A bad thing is having a big maximum while in most cases you would
-         only need a small buffer. If the size of the resulting string is 
+         only need a small buffer. If the size of the resulting string is
          longer or equal to the buffer size than the buffer is not terminated.
-         The function also returns the number of chars not including the 
+         The function also returns the number of chars not including the
          terminating \0 that were needed to fully comply to the print request.
 
-slprintf same as snprintf with the difference that it actually returns the 
+slprintf same as snprintf with the difference that it actually returns the
          length printed not including the terminating \0.
 
 spprintf is the dynamical version of snprintf. It allocates the buffer in size
          as needed and allows a maximum setting as snprintf (turn this feature
          off by setting max_len to 0). spprintf is a little bit slower than
-         snprintf and offers possible memory leakes if you miss freeing the 
-         buffer allocated by the function. Therfore this function should be 
+         snprintf and offers possible memory leakes if you miss freeing the
+         buffer allocated by the function. Therfore this function should be
          used where either no maximum is known or the maximum is much bigger
          than normal size required. spprintf allways terminates the buffer.
 
@@ -61,8 +61,8 @@ Example:
                                |                                | if (!buffer)
                                |                                |   return OUT_OF_MEMORY
  // sprintf allways terminates | // manual termination of       | // spprintf allays terminates buffer
- // buffer                     | // buffer *IS* required        |   
-                               | buffer[MAX-1] = 0;             | 
+ // buffer                     | // buffer *IS* required        |
+                               | buffer[MAX-1] = 0;             |
  action_with_buffer(buffer);   | action_with_buffer(buffer);    | action_with_buffer(buffer);
                                |                                | efree(buffer);
 */
index 2ee9faa7cc9e6dba267140eadbd3a770dad2faa9..219a767322d5d167f09d1082cbde0d123ae065e7 100644 (file)
@@ -30,7 +30,7 @@
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
+ *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
@@ -154,7 +154,7 @@ do {                                                                                                \
                smart_str_appendl(xbuf, s, s_len);                      \
        }                                                                                               \
 } while (0)
-       
+
 #define INS_CHAR(unicode, xbuf, ch)                                    \
        INS_CHAR_NR(unicode, xbuf, ch)
 
@@ -394,7 +394,7 @@ static void xbuf_format_converter(int unicode, smart_str *xbuf, const char *fmt,
                                                fmt++;
                                        }
                                        /* these are promoted to int, so no break */
-                               default:                                
+                               default:
                                        modifier = LM_STD;
                                        break;
                        }
@@ -629,7 +629,7 @@ fmt_unicode:
                                                s = res;
                                                free_s = 1;
                                        }
-                                               
+
                                        pad_char = ' ';
                                        break;
                                }
@@ -767,17 +767,17 @@ fmt_string:
                                        goto skip_output;
 
                                        /*
-                                        * Always extract the argument as a "char *" pointer. We 
-                                        * should be using "void *" but there are still machines 
+                                        * Always extract the argument as a "char *" pointer. We
+                                        * should be using "void *" but there are still machines
                                         * that don't understand it.
                                         * If the pointer size is equal to the size of an unsigned
-                                        * integer we convert the pointer to a hex number, otherwise 
+                                        * integer we convert the pointer to a hex number, otherwise
                                         * we print "%p" to indicate that we don't handle "%p".
                                         */
                                case 'p':
                                        if (sizeof(char *) <= sizeof(u_wide_int)) {
                                                ui_num = (u_wide_int)((size_t) va_arg(ap, char *));
-                                               s = ap_php_conv_p2(ui_num, 4, 'x', 
+                                               s = ap_php_conv_p2(ui_num, 4, 'x',
                                                                &num_buf[NUM_BUF_SIZE], &s_len);
                                                if (ui_num != 0) {
                                                        *--s = 'x';
@@ -835,7 +835,7 @@ fmt_error:
                                PAD(unicode, xbuf, min_width - s_len, pad_char);
                        }
                        /*
-                        * Print the string s. 
+                        * Print the string s.
                         */
                        INS_STRING(unicode, s_unicode, xbuf, s, s_len);
                        if (free_s) efree(s);
@@ -859,14 +859,14 @@ PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap
        smart_str xbuf = {0};
 
        xbuf_format_converter(0, &xbuf, format, ap);
-       
+
        if (max_len && xbuf.len > max_len) {
                xbuf.len = max_len;
        }
        smart_str_0(&xbuf);
-               
+
        *pbuf = xbuf.c;
-       
+
        return xbuf.len;
 }
 /* }}} */
@@ -888,14 +888,14 @@ PHPAPI int vuspprintf(UChar **pbuf, size_t max_len, const char *format, va_list
        smart_str xbuf = {0};
 
        xbuf_format_converter(1, &xbuf, format, ap);
-       
+
        if (max_len && xbuf.len > max_len) {
                xbuf.len = max_len;
        }
        smart_str_0(&xbuf);
-               
+
        *pbuf = (UChar*)xbuf.c;
-       
+
        return xbuf.len / sizeof(UChar);
 }
 /* }}} */
index 55424e5345a3006bdd0b42b3ef48d2806deb469f..8641fba545ad310cba3c5b39cb8878448b58e221 100644 (file)
@@ -18,7 +18,7 @@
 
 /* $Id$ */
 
-/* 
+/*
 
 The pbuf parameter of all spprintf version receives a pointer to the allocated
 buffer. This buffer must be freed manually after usage using efree() function.
@@ -27,7 +27,7 @@ the function can be used to calculate the required size of the buffer but for
 that purpose snprintf is faster. When both pbuf and the return value are 0
 than you are out of memory.
 
-All functions return the number of character printed (e.g. length), not the 
+All functions return the number of character printed (e.g. length), not the
 number of bytes.
 
 There is also snprintf: See difference explained in snprintf.h