summaryrefslogtreecommitdiff
path: root/miniperlmain.c
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters.nicoh.com>1996-01-03 23:03:37 +0000
committerAndy Dougherty <doughera.lafayette.edu>1996-01-03 23:03:37 +0000
commit28e44ed9749d8684067f67623a63b70fce87c3b8 (patch)
treeb65b568e8ffe0a2d88ec6219fa68f23f273ef7e0 /miniperlmain.c
parent222dd4a00bed84c0b275ad03ff7126aff93a9e22 (diff)
downloadperl-28e44ed9749d8684067f67623a63b70fce87c3b8.tar.gz
perl 5.002beta1h patch: miniperlmain.c
Better locale handling, courtesy of jhi. Include a proper cast of NULL for non-prototyping compilers.
Diffstat (limited to 'miniperlmain.c')
-rw-r--r--miniperlmain.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/miniperlmain.c b/miniperlmain.c
index 2c1e0b62c8..95e9c49973 100644
--- a/miniperlmain.c
+++ b/miniperlmain.c
@@ -20,6 +20,36 @@ static void xs_init _((void));
static PerlInterpreter *my_perl;
int
+i18nl14n()
+{
+ char * lang = getenv("LANG");
+#if defined(HAS_SETLOCALE) && defined(LC_CTYPE)
+ {
+ char * lc_ctype = getenv("LC_CTYPE");
+ int i;
+
+ if (setlocale(LC_CTYPE, "") == NULL && (lc_ctype || lang)) {
+ fprintf(stderr,
+ "warning: setlocale(LC_CTYPE, \"\") failed, LC_CTYPE = \"%s\", LANG = \"%s\",\n",
+ lc_ctype ? lc_ctype : "(null)",
+ lang ? lang : "(null)"
+ );
+ fprintf(stderr,
+ "warning: falling back to the \"C\" locale.\n");
+ setlocale(LC_CTYPE, "C");
+ }
+
+ for (i = 0; i < 256; i++) {
+ if (isUPPER(i)) fold[i] = toLOWER(i);
+ else if (isLOWER(i)) fold[i] = toUPPER(i);
+ else fold[i] = i;
+ }
+
+ }
+#endif
+}
+
+int
#ifndef CAN_PROTOTYPE
main(argc, argv, env)
int argc;
@@ -40,13 +70,9 @@ main(int argc, char **argv, char **env)
getredirection(&argc,&argv);
#endif
-#if defined(HAS_SETLOCALE) && defined(LC_CTYPE)
- if (setlocale(LC_CTYPE, "") == NULL) {
- fprintf(stderr,
- "setlocale(LC_CTYPE, \"\") failed (LC_CTYPE = \"%s\").\n",
- getenv("LC_CTYPE"));
- exit(1);
- }
+/* here a union of the cpp #if:s inside i18nl14n() */
+#if (defined(HAS_SETLOCALE) && defined(LC_CTYPE))
+ i18nl14n();
#endif
if (!do_undump) {
@@ -56,7 +82,7 @@ main(int argc, char **argv, char **env)
perl_construct( my_perl );
}
- exitstatus = perl_parse( my_perl, xs_init, argc, argv, NULL );
+ exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL );
if (exitstatus)
exit( exitstatus );