set in environment at request shutdown.
@- setlocale doesn't anymore screw up things if you forgot to change it back
to the original settings. (Jouni)
# Trying to conform to the rules set up by Andrei. Let's hope this works.
#else
#include <strings.h>
#endif
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
#include "safe_mode.h"
#if WIN32|WINNT
#include "win32/unistd.h"
PHP_RINIT_FUNCTION(basic)
{
strtok_string = NULL;
+ locale_string = NULL;
#ifdef HAVE_PUTENV
if (zend_hash_init(&putenv_ht, 1, NULL, (int (*)(void *)) _php3_putenv_destructor, 0) == FAILURE) {
return FAILURE;
#ifdef HAVE_PUTENV
zend_hash_destroy(&putenv_ht);
#endif
+ /* Check if locale was changed and change it back
+ to the value in startup environment */
+ if (locale_string != NULL) {
+ setlocale(LC_ALL, "");
+ }
+ STR_FREE(locale_string);
return SUCCESS;
}
#ifndef THREAD_SAFE
extern char *strtok_string;
+extern char *locale_string;
#endif
PHP_FUNCTION(strspn);
}
/* }}} */
+#ifndef THREAD_SAFE
+char *locale_string;
+#endif
+
/* {{{ proto string setlocale(string category, string locale)
Set locale information */
PHP_FUNCTION(setlocale)
loc = locale->value.str.val;
retval = setlocale (cat, loc);
if (retval) {
+ /* Remember if locale was changed */
+ if (loc) {
+ STR_FREE(locale_string);
+ strtok_string = estrdup(retval);
+ }
+
RETVAL_STRING(retval,1);
return;
}