zend_opcode.c zend_operators.c zend_ptr_stack.c zend_stack.c \
zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \
zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \
- zend_ini.c zend_qsort.c zend_multibyte.c)
+ zend_ini.c zend_qsort.c zend_multibyte.c zend_strtod.c)
if test -r "$abs_srcdir/Zend/zend_objects.c"; then
PHP_ADD_SOURCES(Zend, zend_objects.c zend_object_handlers.c zend_objects_API.c zend_mm.c)
char *cvt;
register int i = 0, j = 0;
int sign, decpt, cvt_len;
- char decimal_point = EG(float_separator)[0];
+#ifdef HAVE_LOCALE_H
+ struct lconv lc;
+ char decimal_point;
+ localeconv_r(&lc);
+ decimal_point = (lc.decimal_point)[0];
+#else
+ char decimal_point = '.';
+#endif
PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n",
*buffer, pos, size, number, width, padding, alignment, fmt));
PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len, int fold_case);
#ifdef HAVE_LOCALECONV
-struct lconv *localeconv_r(struct lconv *out);
+PHPAPI struct lconv *localeconv_r(struct lconv *out);
#endif
PHPAPI char *php_strtoupper(char *s, size_t len);
#endif
#include "zend_execute.h"
#include "zend_operators.h"
+#include "zend_strtod.h"
#include "php_globals.h"
#include "basic_functions.h"
#include "scanf.h"
if (!(flags & SCAN_SUPPRESS)) {
double dvalue;
*end = '\0';
- dvalue = strtod(buf, NULL);
+ dvalue = zend_strtod(buf, NULL);
if (numVars) {
current = args[objIndex++];
convert_to_double( *current );
#ifdef HAVE_LOCALECONV
/* {{{ localeconv_r
* glibc's localeconv is not reentrant, so lets make it so ... sorta */
-struct lconv *localeconv_r(struct lconv *out)
+PHPAPI struct lconv *localeconv_r(struct lconv *out)
{
struct lconv *res;
efree(args);
RETVAL_STRING(retval, 1);
- if (cat == LC_NUMERIC || cat == LC_ALL) {
- struct lconv lc;
- localeconv_r(&lc);
-
- EG(float_separator)[0] = (lc.decimal_point)[0];
-
- if ((lc.decimal_point)[0] != '.') {
- /* set locale back to C */
- setlocale(LC_NUMERIC, "C");
- }
- }
-
return;
}
--TEST--
-Locale settings affecting float parsing
+Bug #12647 (Locale settings affecting float parsing)
--SKIPIF--
<?php # try to activate a german locale
if (setlocale(LC_NUMERIC, "de_DE", "de", "german", "ge") === FALSE) {
setlocale(LC_NUMERIC, "de_DE", "de", "german", "ge");
echo (float)"3.14", "\n";
-
?>
--EXPECT--
3,14
--- /dev/null
+--TEST--
+Bug #30638 (localeconv returns wrong LC_NUMERIC settings)
+--SKIPIF--
+<?php # try to activate a german locale
+if (setlocale(LC_NUMERIC, "de_DE", "de", "german", "ge") === FALSE) {
+ print "skip";
+}
+?>
+--FILE--
+<?php
+# activate the german locale
+setlocale(LC_NUMERIC, "de_DE", "de", "german", "ge");
+
+$lc = localeconv();
+printf("decimal_point: %s\n", $lc['decimal_point']);
+printf("thousands_sep: %s\n", $lc['thousands_sep']);
+?>
+--EXPECT--
+decimal_point: ,
+thousands_sep: .