summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.in4
-rw-r--r--ext/standard/formatted_print.c14
-rw-r--r--main/php.h4
-rw-r--r--main/php_sprintf.c4
-rw-r--r--main/snprintf.c4
-rw-r--r--main/snprintf.h6
6 files changed, 10 insertions, 26 deletions
diff --git a/configure.in b/configure.in
index 463c4a3..9e47f27 100644
--- a/configure.in
+++ b/configure.in
@@ -619,8 +619,8 @@ fi
AC_REPLACE_FUNCS(strlcat strlcpy getopt)
AC_FUNC_UTIME_NULL
AC_FUNC_ALLOCA
-PHP_AC_BROKEN_SPRINTF
-PHP_AC_BROKEN_SNPRINTF
+dnl PHP_AC_BROKEN_SPRINTF
+dnl PHP_AC_BROKEN_SNPRINTF
PHP_DECLARED_TIMEZONE
PHP_TIME_R_TYPE
PHP_READDIR_R_TYPE
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
index e35946f..75cf020 100644
--- a/ext/standard/formatted_print.c
+++ b/ext/standard/formatted_print.c
@@ -303,13 +303,14 @@ php_sprintf_appenddouble(char **buffer, int *pos,
char *cvt;
register int i = 0, j = 0;
int sign, decpt, cvt_len;
+ char decimal_point = '.';
#ifdef HAVE_LOCALE_H
struct lconv lc;
- char decimal_point;
+ char locale_decimal_point;
localeconv_r(&lc);
- decimal_point = (lc.decimal_point)[0];
+ locale_decimal_point = (lc.decimal_point)[0];
#else
- char decimal_point = '.';
+ char locale_decimal_point = '.';
#endif
PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n",
@@ -343,12 +344,12 @@ php_sprintf_appenddouble(char **buffer, int *pos,
numbuf[i++] = '+';
}
- if (fmt == 'f') {
+ if (fmt == 'f' || fmt == 'F') {
if (decpt <= 0) {
numbuf[i++] = '0';
if (precision > 0) {
int k = precision;
- numbuf[i++] = decimal_point;
+ numbuf[i++] = fmt == 'F' ? decimal_point : locale_decimal_point;
while ((decpt++ < 0) && k--) {
numbuf[i++] = '0';
}
@@ -358,7 +359,7 @@ php_sprintf_appenddouble(char **buffer, int *pos,
numbuf[i++] = j < cvt_len ? cvt[j++] : '0';
}
if (precision > 0) {
- numbuf[i++] = decimal_point;
+ numbuf[i++] = fmt == 'F' ? decimal_point : locale_decimal_point;
while (precision-- > 0) {
numbuf[i++] = j < cvt_len ? cvt[j++] : '0';
}
@@ -697,6 +698,7 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
case 'e':
case 'f':
+ case 'F':
/* XXX not done */
convert_to_double(tmp);
php_sprintf_appenddouble(&result, &outpos, &size,
diff --git a/main/php.h b/main/php.h
index 6e5612b..1ea49e6 100644
--- a/main/php.h
+++ b/main/php.h
@@ -37,10 +37,8 @@
#include "zend_API.h"
-#if PHP_BROKEN_SPRINTF
#undef sprintf
#define sprintf php_sprintf
-#endif
/* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
#undef PHP_DEBUG
@@ -228,9 +226,7 @@ char *strerror(int);
#define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC
#define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT
-#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) || PHP_BROKEN_SPRINTF || PHP_BROKEN_SNPRINTF || PHP_BROKEN_VSNPRINTF
#include "snprintf.h"
-#endif
#include "spprintf.h"
#define EXEC_INPUT_BUF 4096
diff --git a/main/php_sprintf.c b/main/php_sprintf.c
index f7daab2..b0589c2 100644
--- a/main/php_sprintf.c
+++ b/main/php_sprintf.c
@@ -26,8 +26,6 @@
#include "php_config.h"
#endif
-#if PHP_BROKEN_SPRINTF
-
int
php_sprintf (char*s, const char* format, ...)
{
@@ -43,8 +41,6 @@ php_sprintf (char*s, const char* format, ...)
return strlen (s);
}
-#endif /* PHP_BROKEN_SPRINTF */
-
/*
* Local variables:
* tab-width: 4
diff --git a/main/snprintf.c b/main/snprintf.c
index fa0e7f1..e0804b0 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -466,8 +466,6 @@ ap_php_gcvt(double number, int ndigit, char *buf, boolean_e altform)
return (buf);
}
-#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) || PHP_BROKEN_SNPRINTF || PHP_BROKEN_VSNPRINTF
-
/*
* NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions
*
@@ -1157,8 +1155,6 @@ int ap_php_vsnprintf(char *buf, size_t len, const char *format, va_list ap)
return (cc);
}
-#endif /* HAVE_SNPRINTF */
-
/*
* Local variables:
* tab-width: 4
diff --git a/main/snprintf.h b/main/snprintf.h
index 76b7b6a..a6d9879 100644
--- a/main/snprintf.h
+++ b/main/snprintf.h
@@ -64,20 +64,14 @@ Example:
#ifndef SNPRINTF_H
#define SNPRINTF_H
-#if !defined(HAVE_SNPRINTF) || PHP_BROKEN_SNPRINTF
int ap_php_snprintf(char *, size_t, const char *, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
#define snprintf ap_php_snprintf
-#endif
-#if !defined(HAVE_VSNPRINTF) || PHP_BROKEN_VSNPRINTF
int ap_php_vsnprintf(char *, size_t, const char *, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0);
#define vsnprintf ap_php_vsnprintf
-#endif
-#if PHP_BROKEN_SPRINTF
int php_sprintf (char* s, const char* format, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3);
#define sprintf php_sprintf
-#endif
typedef enum {
NO = 0, YES = 1