cvs: /php4/ext/standard basic_functions.c php3_string.h string.c
| From: | Jouni Ahto | Date: | Fri, 08 Oct 1999 02:11:28 +0000 |
| Subject: | cvs: /php4/ext/standard basic_functions.c php3_string.h string.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-5359@lists.php.net to get a copy of this message | ||
jah Thu Oct 7 22:11:28 1999 EDT
Modified files:
/php4/ext/standard basic_functions.c php3_string.h string.c
Log:
(PHP setlocale) Locale settings are now correctly restored to the values
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.
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.98 php4/ext/standard/basic_functions.c:1.99
--- php4/ext/standard/basic_functions.c:1.98 Wed Oct 6 08:54:45 1999
+++ php4/ext/standard/basic_functions.c Thu Oct 7 22:10:55 1999
@@ -36,6 +36,9 @@
#else
#include <strings.h>
#endif
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
#include "safe_mode.h"
#if WIN32|WINNT
#include "win32/unistd.h"
@@ -424,6 +427,7 @@
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;
@@ -441,6 +445,12 @@
#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;
}
Index: php4/ext/standard/php3_string.h
diff -u php4/ext/standard/php3_string.h:1.15 php4/ext/standard/php3_string.h:1.16
--- php4/ext/standard/php3_string.h:1.15 Mon Sep 20 12:56:02 1999
+++ php4/ext/standard/php3_string.h Thu Oct 7 22:10:57 1999
@@ -29,7 +29,7 @@
*/
-/* $Id: php3_string.h,v 1.15 1999/09/20 16:56:02 andi Exp $ */
+/* $Id: php3_string.h,v 1.16 1999/10/08 02:10:57 jah Exp $ */
/* Synced with php3 revision 1.43 1999-06-16 [ssb] */
@@ -38,6 +38,7 @@
#ifndef THREAD_SAFE
extern char *strtok_string;
+extern char *locale_string;
#endif
PHP_FUNCTION(strspn);
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.47 php4/ext/standard/string.c:1.48
--- php4/ext/standard/string.c:1.47 Thu Sep 30 16:03:32 1999
+++ php4/ext/standard/string.c Thu Oct 7 22:10:57 1999
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.47 1999/09/30 20:03:32 andrei Exp $ */
+/* $Id: string.c,v 1.48 1999/10/08 02:10:57 jah Exp $ */
/* Synced with php3 revision 1.193 1999-06-16 [ssb] */
@@ -1795,6 +1795,10 @@
}
/* }}} */
+#ifndef THREAD_SAFE
+char *locale_string;
+#endif
+
/* {{{ proto string setlocale(string category, string locale)
Set locale information */
PHP_FUNCTION(setlocale)
@@ -1833,6 +1837,12 @@
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;
}