helly Thu Feb 7 12:47:44 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/main snprintf.c snprintf.h spprintf.c spprintf.h
Log:
- MFH WS
http://cvs.php.net/viewvc.cgi/php-src/main/snprintf.c?r1=1.37.2.4.2.14.2.2&r2=1.37.2.4.2.14.2.3&diff_format=u
Index: php-src/main/snprintf.c
diff -u php-src/main/snprintf.c:1.37.2.4.2.14.2.2
php-src/main/snprintf.c:1.37.2.4.2.14.2.3
--- php-src/main/snprintf.c:1.37.2.4.2.14.2.2 Mon Dec 31 07:17:17 2007
+++ php-src/main/snprintf.c Thu Feb 7 12:47:44 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: snprintf.c,v 1.37.2.4.2.14.2.2 2007/12/31 07:17:17 sebastian Exp $ */
+/* $Id: snprintf.c,v 1.37.2.4.2.14.2.3 2008/02/07 12:47:44 helly Exp $ */
#include "php.h"
@@ -156,7 +156,7 @@
}
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) */
@@ -241,7 +241,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
@@ -327,7 +327,7 @@
*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
@@ -344,7 +344,7 @@
}
/*
- * 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;
@@ -763,7 +763,7 @@
fmt++;
}
/* these are promoted to int, so no
break */
- default:
+ default:
modifier = LM_STD;
break;
}
@@ -961,7 +961,7 @@
pad_char = ' ';
break;
-
+
case 'f':
case 'F':
case 'e':
@@ -1084,17 +1084,17 @@
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';
@@ -1152,7 +1152,7 @@
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);
http://cvs.php.net/viewvc.cgi/php-src/main/snprintf.h?r1=1.32.2.3.2.5.2.1&r2=1.32.2.3.2.5.2.2&diff_format=u
Index: php-src/main/snprintf.h
diff -u php-src/main/snprintf.h:1.32.2.3.2.5.2.1
php-src/main/snprintf.h:1.32.2.3.2.5.2.2
--- php-src/main/snprintf.h:1.32.2.3.2.5.2.1 Mon Dec 31 07:17:17 2007
+++ php-src/main/snprintf.h Thu Feb 7 12:47:44 2008
@@ -17,11 +17,11 @@
+----------------------------------------------------------------------+
*/
-/* $Id: snprintf.h,v 1.32.2.3.2.5.2.1 2007/12/31 07:17:17 sebastian Exp $ */
+/* $Id: snprintf.h,v 1.32.2.3.2.5.2.2 2008/02/07 12:47:44 helly Exp $ */
/*
-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 @@
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 @@
| | 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);
*/
http://cvs.php.net/viewvc.cgi/php-src/main/spprintf.c?r1=1.25.2.2.2.10.2.2&r2=1.25.2.2.2.10.2.3&diff_format=u
Index: php-src/main/spprintf.c
diff -u php-src/main/spprintf.c:1.25.2.2.2.10.2.2
php-src/main/spprintf.c:1.25.2.2.2.10.2.3
--- php-src/main/spprintf.c:1.25.2.2.2.10.2.2 Mon Dec 31 07:17:17 2007
+++ php-src/main/spprintf.c Thu Feb 7 12:47:44 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spprintf.c,v 1.25.2.2.2.10.2.2 2007/12/31 07:17:17 sebastian Exp $ */
+/* $Id: spprintf.c,v 1.25.2.2.2.10.2.3 2008/02/07 12:47:44 helly Exp $ */
/* This is the spprintf implementation.
* It has emerged from apache snprintf. See original header:
@@ -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
@@ -133,7 +133,7 @@
#define INS_STRING(xbuf, s, slen) do { \
smart_str_appendl(xbuf, s, slen); \
} while (0)
-
+
#define INS_CHAR(xbuf, ch) \
INS_CHAR_NR(xbuf, ch)
@@ -359,7 +359,7 @@
fmt++;
}
/* these are promoted to int, so no
break */
- default:
+ default:
modifier = LM_STD;
break;
}
@@ -677,17 +677,17 @@
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';
@@ -745,7 +745,7 @@
PAD(xbuf, min_width - s_len, pad_char);
}
/*
- * Print the string s.
+ * Print the string s.
*/
INS_STRING(xbuf, s, s_len);
@@ -767,14 +767,14 @@
smart_str xbuf = {0};
xbuf_format_converter(&xbuf, format, ap);
-
+
if (max_len && xbuf.len > max_len) {
xbuf.len = max_len;
}
smart_str_0(&xbuf);
-
+
*pbuf = xbuf.c;
-
+
return xbuf.len;
}
/* }}} */
http://cvs.php.net/viewvc.cgi/php-src/main/spprintf.h?r1=1.11.2.1.2.1.2.1&r2=1.11.2.1.2.1.2.2&diff_format=u
Index: php-src/main/spprintf.h
diff -u php-src/main/spprintf.h:1.11.2.1.2.1.2.1
php-src/main/spprintf.h:1.11.2.1.2.1.2.2
--- php-src/main/spprintf.h:1.11.2.1.2.1.2.1 Mon Dec 31 07:17:17 2007
+++ php-src/main/spprintf.h Thu Feb 7 12:47:44 2008
@@ -16,9 +16,9 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spprintf.h,v 1.11.2.1.2.1.2.1 2007/12/31 07:17:17 sebastian Exp $ */
+/* $Id: spprintf.h,v 1.11.2.1.2.1.2.2 2008/02/07 12:47:44 helly Exp $ */
-/*
+/*
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.
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php