httpd: LC_TIME locale _must_ be POSIX to httpd! We speak over the net!
authorDenis Vlasenko <vda.linux@googlemail.com>
Tue, 21 Nov 2006 00:09:37 +0000 (00:09 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Tue, 21 Nov 2006 00:09:37 +0000 (00:09 -0000)
applets/busybox.c
coreutils/cal.c
coreutils/ls.c
coreutils/wc.c
networking/httpd.c
shell/ash.c
shell/lash.c

index 9f2eddebd8cbe3e752748d39ed64bdce2ea7bdc7..4d59b45181b63acb0bc5c4c75af5beb6d9998ecf 100644 (file)
@@ -64,8 +64,8 @@ int main(int argc, char **argv)
        for (s = applet_name; *s ;)
                if (*(s++) == '/') applet_name = s;
 
-       /* Set locale for everybody except `init' */
-       if(ENABLE_LOCALE_SUPPORT && getpid() != 1)
+       /* Set locale for everybody except 'init' */
+       if (ENABLE_LOCALE_SUPPORT && getpid() != 1)
                setlocale(LC_ALL, "");
 
        run_applet_by_name(applet_name, argc, argv);
index 6f5f0a434c46cdfbbdb46309ff75a57a5a86a5ce..681a88d90d63e455141ef5305b9ca802f11f4e6f 100644 (file)
@@ -87,9 +87,10 @@ int cal_main(int argc, char **argv)
        char day_headings[28];  /* 28 for julian, 21 for nonjulian */
        char buf[40];
 
-#ifdef CONFIG_LOCALE_SUPPORT
-       setlocale(LC_TIME, "");
-#endif
+// Done in busybox.c, ok to remove?
+//#ifdef CONFIG_LOCALE_SUPPORT
+//     setlocale(LC_TIME, "");
+//#endif
 
        flags = getopt32(argc, argv, "jy");
 
index 8a83d75437501787c103223ab54116d716c37a4c..909f4d54e8332827ad799eeef3e40048ab0e5f17 100644 (file)
@@ -359,7 +359,7 @@ static int sortcmp(const void *a, const void *b)
        }
 
        if (dif == 0) {
-               /* sort by name- may be a tie_breaker for time or size cmp */
+               /* sort by name - may be a tie_breaker for time or size cmp */
                if (ENABLE_LOCALE_SUPPORT) dif = strcoll(d1->name, d2->name);
                else dif = strcmp(d1->name, d2->name);
        }
index 4b76e549950816fe59ee4869253d31324d800078..973929ebeb765caec76eedfb272bd616b1ee3e91 100644 (file)
@@ -44,8 +44,6 @@
 #include "busybox.h"
 
 #ifdef CONFIG_LOCALE_SUPPORT
-#include <locale.h>
-#include <ctype.h>
 #define isspace_given_isprint(c) isspace(c)
 #else
 #undef isspace
index afcd089b0ca864821ca2036a06c1c133748195e7..47d41a1e2adf596e28d7f4a744ed5e7d4d911d1d 100644 (file)
@@ -846,9 +846,11 @@ static int sendHeaders(HttpResponseNum responseNum)
        time_t timer = time(0);
        char timeStr[80];
        int len;
+       enum {
+               numNames = sizeof(httpResponseNames) / sizeof(httpResponseNames[0])
+       };
 
-       for (i = 0;
-               i < (sizeof(httpResponseNames)/sizeof(httpResponseNames[0])); i++) {
+       for (i = 0; i < numNames; i++) {
                if (httpResponseNames[i].type == responseNum) {
                        responseString = httpResponseNames[i].name;
                        infoString = httpResponseNames[i].info;
@@ -1177,7 +1179,7 @@ static int sendCgi(const char *url,
 # error "PIPESIZE >= MAX_MEMORY_BUFF"
 #endif
 
-                       // There is something to read
+                       /* There is something to read */
                        count = safe_read(inFd, rbuf, PIPESIZE);
                        if (count == 0)
                                break;  /* closed */
@@ -1197,7 +1199,7 @@ static int sendCgi(const char *url,
                                        break;
 
                                if (DEBUG)
-                                       fprintf(stderr, "cgi read %d bytes\n", count);
+                                       fprintf(stderr, "cgi read %d bytes: '%.*s'\n", count, count, rbuf);
                        }
                }
        }
@@ -1838,6 +1840,11 @@ int httpd_main(int argc, char *argv[])
        USE_FEATURE_HTTPD_SETUID(struct bb_uidgid_t ugid;)
        USE_FEATURE_HTTPD_AUTH_MD5(const char *pass;)
 
+#if ENABLE_LOCALE_SUPPORT
+       /* Undo busybox.c: we want to speak English in http (dates etc) */
+       setlocale(LC_TIME, "C");
+#endif
+
        config = xzalloc(sizeof(*config));
 #if ENABLE_FEATURE_HTTPD_BASIC_AUTH
        config->realm = "Web Server Authentication";
index 3c76397071d40fac6cf5f1b8c13c9e9f0b10ae41..4fef0f2d3f568e9bb99f84dee9bfecf526fbdcbe 100644 (file)
@@ -1495,7 +1495,6 @@ static void getoptsreset(const char *);
 #endif
 
 #ifdef CONFIG_LOCALE_SUPPORT
-#include <locale.h>
 static void change_lc_all(const char *value);
 static void change_lc_ctype(const char *value);
 #endif
index 4067bc6bc853f2bb6622a4658477286bc3101df3..472cbddb961b5904838caf85949a6aaabbd2e04c 100644 (file)
 #include <getopt.h>
 #include "cmdedit.h"
 
-#ifdef CONFIG_LOCALE_SUPPORT
-#include <locale.h>
-#endif
-
 #include <glob.h>
 #define expand_t       glob_t
 
@@ -377,6 +373,7 @@ static int builtin_export(struct child_prog *child)
 #endif
 
 #ifdef CONFIG_LOCALE_SUPPORT
+       // TODO: why getenv? "" would be just as good...
        if(strncmp(v, "LC_ALL=", 7)==0)
                setlocale(LC_ALL, getenv("LC_ALL"));
        if(strncmp(v, "LC_CTYPE=", 9)==0)