chiark / gitweb /
cgi/cgimain.c: Make the CGI program be (a little) locale-aware.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 23 Jul 2018 01:26:53 +0000 (02:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 23 Jul 2018 10:08:35 +0000 (11:08 +0100)
Otherwise it can't properly parse configuration files which contain
non-ASCII characters, e.g., for transforming pieces of track names.

cgi/cgimain.c
cgi/disorder-cgi.h

index 4ea98ecf25460fa38d41c862cd160d1c400758e8..236cca65892179f404d2b058abf4860d7f63f3d5 100644 (file)
@@ -28,6 +28,7 @@ int main(int argc, char **argv) {
     progname = argv[0];
   /* RFC 3875 s8.2 recommends rejecting PATH_INFO if we don't make use of
    * it. */
+  if(!setlocale(LC_CTYPE, "")) disorder_error(errno, "error calling setlocale");
   /* TODO we could make disorder/ACTION equivalent to disorder?action=ACTION */
   if(getenv("PATH_INFO")) {
     /* TODO it might be nice to link back to the right place... */
index 168ba9b43137064e594ecb0a2c4d9fca21c0e0a1..78156322f0059204dc7b25ada45cb6df6050dc18 100644 (file)
@@ -28,6 +28,7 @@
 #include <time.h>
 #include <errno.h>
 #include <ctype.h>
+#include <locale.h>
 #include <stddef.h>
 
 #include "log.h"