Mailing List Archive

I18N and L14N
The following patch to be applied atop 2b1f/g provedly fixes the
setlocale() problem 1) with Ultrix 4.5 (4.4 likely too), I seriously
suspect the setlocale() problem with Linux, and rewrites slightly the
fold[] init loop fix added by Johan Holmberg 2)

1) if both LC_CTYPE and LANG are null it is ok for setlocale()
to "fail" by returning null (and silently use the "C" locale)
2) just using setlocale(LC_CTYPE, "") is not enough: compile-time
folding needs changing the fold[] array too (for run-time things
the setlocale() works fine)

I still have got only one report back (from John Stoffel/Ultrix,
William Setzer/Linux and Johan are still to report...) but I release
this in hopes that Larry is preparing a certain big present for us all
for Christmas :-) and I hope to get this i18n/l14n support piece to be
sneaked in in time...

++jhi;


*** miniperlmain.c-dist Thu Dec 21 19:31:14 1995
--- miniperlmain.c Fri Dec 22 12:25:00 1995
***************
*** 20,25 ****
--- 20,47 ----
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,
+ "setlocale(LC_CTYPE, \"\") failed, LC_CTYPE = \"%s\", LANG = \"%s\".\n",
+ lc_ctype, lang);
+ exit(1);
+ }
+
+ for (i = 0; i < 256; i++)
+ fold[i] = i ^ toUPPER(i) ^ toLOWER(i);
+ }
+ #endif
+ }
+
+ int
#ifndef CAN_PROTOTYPE
main(argc, argv, env)
int argc;
***************
*** 40,52 ****
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);
! }
#endif

if (!do_undump) {
--- 62,70 ----
getredirection(&argc,&argv);
#endif

! /* here a union of the cpp #if:s inside i18nl14n() */
! #if (defined(HAS_SETLOCALE) && defined(LC_CTYPE))
! i18nl14n();
#endif

if (!do_undump) {