[cvslog] Module eggdrop1.6: Change committed

cvslog cvs at tsss.iavalley.cc.ia.us
Mon Jan 22 17:42:01 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.6
Commit time: 2001-01-22 23:41:21 UTC

Modified files:
     doc/UPDATES1.6 src/patch.h src/tcl.c src/tclegg.h

Log message:

applied Tothwolf's i18n support patch -- lets test this one, cause it would be good for 1.6.4

---------------------- diff included ----------------------
Index: eggdrop1.6/doc/UPDATES1.6
diff -u eggdrop1.6/doc/UPDATES1.6:1.49 eggdrop1.6/doc/UPDATES1.6:1.50
--- eggdrop1.6/doc/UPDATES1.6:1.49	Mon Jan 22 17:34:40 2001
+++ eggdrop1.6/doc/UPDATES1.6	Mon Jan 22 17:41:11 2001
@@ -4,6 +4,7 @@
 
 1.6.3
 Found by  Fixed by  What...
+various   Tothwolf  added i18n support to fix our problems with tcl
           ppslim    some minor doc fixes
 GregMo    Sup       `.note' wasn't correctly requiring a message parameter.
           Jason     fixed it so that +d or +k users cannot remove hosts and
Index: eggdrop1.6/src/patch.h
diff -u eggdrop1.6/src/patch.h:1.416 eggdrop1.6/src/patch.h:1.417
--- eggdrop1.6/src/patch.h:1.416	Mon Jan 22 17:34:41 2001
+++ eggdrop1.6/src/patch.h	Mon Jan 22 17:41:11 2001
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  * 
- * $Id: patch.h,v 1.416 2001/01/22 23:34:41 guppy Exp $
+ * $Id: patch.h,v 1.417 2001/01/22 23:41:11 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("980206468");		/* current unixtime */
+patch("980206584");		/* current unixtime */
 /*
  *
  *
  */
-patch("docfixes");
+patch("i18n-support");
 /*
  *
  *
Index: eggdrop1.6/src/tcl.c
diff -u eggdrop1.6/src/tcl.c:1.26 eggdrop1.6/src/tcl.c:1.27
--- eggdrop1.6/src/tcl.c:1.26	Sun Dec 17 15:48:42 2000
+++ eggdrop1.6/src/tcl.c	Mon Jan 22 17:41:11 2001
@@ -4,7 +4,7 @@
  *   Tcl initialization
  *   getting and setting Tcl/eggdrop variables
  * 
- * $Id: tcl.c,v 1.26 2000/12/17 21:48:42 guppy Exp $
+ * $Id: tcl.c,v 1.27 2001/01/22 23:41:11 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -26,6 +26,7 @@
  */
 
 #include "main.h"
+#include <locale.h>
 
 /* Used for read/write to internal strings */
 typedef struct {
@@ -493,12 +494,90 @@
  */
 void init_tcl(int argc, char **argv)
 {
-#ifndef HAVE_PRE7_5_TCL
+#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1
+  const char *encoding;
   int i;
+  char *langEnv;
+#endif
+#ifndef HAVE_PRE7_5_TCL
+  int j;
   char pver[1024] = "";
 #endif
 
-#ifndef HAVE_PRE7_5_TCL
+/* Code based on Tcl's TclpSetInitialEncodings() */
+#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1
+  /* Determine the current encoding from the LC_* or LANG environment
+   * variables.
+   */
+  langEnv = getenv("LC_ALL");
+  if (langEnv == NULL || langEnv[0] == '\0') {
+    langEnv = getenv("LC_CTYPE");
+  }
+  if (langEnv == NULL || langEnv[0] == '\0') {
+    langEnv = getenv("LANG");
+  }
+  if (langEnv == NULL || langEnv[0] == '\0') {
+    langEnv = NULL;
+  }
+
+  encoding = NULL;
+  if (langEnv != NULL) {
+    for (i = 0; localeTable[i].lang != NULL; i++)
+      if (strcmp(localeTable[i].lang, langEnv) == 0) {
+	encoding = localeTable[i].encoding;
+	break;
+      }
+
+    /* There was no mapping in the locale table.  If there is an
+     * encoding subfield, we can try to guess from that.
+     */
+    if (encoding == NULL) {
+      char *p;
+
+      for (p = langEnv; *p != '\0'; p++) {
+        if (*p == '.') {
+          p++;
+          break;
+        }
+      }
+      if (*p != '\0') {
+        Tcl_DString ds;
+        Tcl_DStringInit(&ds);
+        Tcl_DStringAppend(&ds, p, -1);
+
+        encoding = Tcl_DStringValue(&ds);
+        Tcl_UtfToLower(Tcl_DStringValue(&ds));
+        if (Tcl_SetSystemEncoding(NULL, encoding) == TCL_OK) {
+          Tcl_DStringFree(&ds);
+          goto resetPath;
+        }
+        Tcl_DStringFree(&ds);
+        encoding = NULL;
+      }
+    }
+  }
+
+  if (encoding == NULL) {
+    encoding = "iso8859-1";
+  }
+
+  Tcl_SetSystemEncoding(NULL, encoding);
+
+  resetPath:
+
+  /* Initialize the C library's locale subsystem. */
+  setlocale(LC_CTYPE, "");
+
+  /* In case the initial locale is not "C", ensure that the numeric
+   * processing is done in "C" locale regardless. */
+  setlocale(LC_NUMERIC, "C");
+
+  /* Keep the iso8859-1 encoding preloaded.  The IO package uses it for
+   * gets on a binary channel. */
+  Tcl_GetEncoding(NULL, "iso8859-1");
+#endif
+
+#ifndef HAVE_PRE7_5_TCL 
   /* This is used for 'info nameofexecutable'.
    * The filename in argv[0] must exist in a directory listed in
    * the environment variable PATH for it to register anything.
@@ -506,24 +585,30 @@
   Tcl_FindExecutable(argv[0]);
 #endif
 
-  /* Initialize the interpreter */
+  /* Create Tcl interpreter */
   interp = Tcl_CreateInterp();
-  Tcl_Init(interp);
 
 #ifdef DEBUG_MEM
-  /* Initialize Tcl's memory debugging if we have it */
+  /* Initialize Tcl's memory debugging if we want it */
   Tcl_InitMemory(interp);
 #endif
 
-#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1
-  /* Set default encoding to default system encoding, i.e. binary.
-     Unicode support present since Tcl library version 8.1. */
-  Tcl_SetSystemEncoding(interp, NULL);
-#endif
+  /* Initialize Tcl interpreter */
+  Tcl_Init(interp);
 
   /* Set Tcl variable tcl_interactive to 0 */
   Tcl_SetVar(interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY);
 
+#ifndef HAVE_PRE7_5_TCL
+  /* Add eggdrop to Tcl's package list */
+  for (j = 0; j <= strlen(egg_version); j++) {
+    if ((egg_version[j] == ' ') || (egg_version[j] == '+'))
+      break;
+    pver[strlen(pver)] = egg_version[j];
+  }
+  Tcl_PkgProvide(interp, "eggdrop", pver);
+#endif
+
   /* Initialize binds and traces */
   init_bind();
   init_traces();
@@ -534,16 +619,6 @@
   add_tcl_commands(tcldcc_cmds);
   add_tcl_commands(tclmisc_cmds);
   add_tcl_commands(tcldns_cmds);
-
-#ifndef HAVE_PRE7_5_TCL
-  /* Add eggdrop to Tcl's package list */
-  for (i = 0; i <= strlen(egg_version); i++) {
-    if ((egg_version[i] == ' ') || (egg_version[i] == '+'))
-      break;
-    pver[strlen(pver)] = egg_version[i];
-  }
-  Tcl_PkgProvide(interp, "eggdrop", pver);
-#endif
 }
 
 void do_tcl(char *whatzit, char *script)
Index: eggdrop1.6/src/tclegg.h
diff -u eggdrop1.6/src/tclegg.h:1.9 eggdrop1.6/src/tclegg.h:1.10
--- eggdrop1.6/src/tclegg.h:1.9	Wed Jul 12 16:50:35 2000
+++ eggdrop1.6/src/tclegg.h	Mon Jan 22 17:41:11 2001
@@ -2,7 +2,7 @@
  * tclegg.h
  *   stuff used by tcl.c and tclhash.c
  * 
- * $Id: tclegg.h,v 1.9 2000/07/12 21:50:35 fabian Exp $
+ * $Id: tclegg.h,v 1.10 2001/01/22 23:41:11 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -123,5 +123,52 @@
 void rem_tcl_coups(tcl_coups *);
 void add_tcl_ints(tcl_ints *);
 void rem_tcl_ints(tcl_ints *);
+
+/* From Tcl's tclUnixInit.c */
+/* The following table is used to map from Unix locale strings to
+ * encoding files. */
+
+typedef struct LocaleTable {
+    const char *lang;
+    const char *encoding;
+} LocaleTable;
+
+static const LocaleTable localeTable[] = {
+    {"ja_JP.SJIS",	"shiftjis"},
+    {"ja_JP.EUC",	"euc-jp"},
+    {"ja_JP.JIS",	"iso2022-jp"},
+    {"ja_JP.mscode",	"shiftjis"},
+    {"ja_JP.ujis",	"euc-jp"},
+    {"ja_JP",		"euc-jp"},
+    {"Ja_JP",		"shiftjis"},
+    {"Jp_JP",		"shiftjis"},
+    {"japan",		"euc-jp"},
+#ifdef hpux
+    {"japanese",	"shiftjis"},	
+    {"ja",		"shiftjis"},	
+#else
+    {"japanese",	"euc-jp"},
+    {"ja",		"euc-jp"},
+#endif
+    {"japanese.sjis",	"shiftjis"},
+    {"japanese.euc",	"euc-jp"},
+    {"japanese-sjis",	"shiftjis"},
+    {"japanese-ujis",	"euc-jp"},
+
+    {"ko",              "euc-kr"},
+    {"ko_KR",           "euc-kr"},
+    {"ko_KR.EUC",       "euc-kr"},
+    {"ko_KR.euc",       "euc-kr"},
+    {"ko_KR.eucKR",     "euc-kr"},
+    {"korean",          "euc-kr"},
+
+    {"ru",		"iso8859-5"},		
+    {"ru_RU",		"iso8859-5"},		
+    {"ru_SU",		"iso8859-5"},		
+
+    {"zh",		"cp936"},
+
+    {NULL, NULL}
+};
 
 #endif				/* _EGG_TCLEGG_H */
----------------------- End of diff -----------------------



More information about the Changes mailing list