[cvslog] Module eggdrop1.6: Change committed

cvslog cvs at tsss.iavalley.cc.ia.us
Sat Mar 10 00:37:01 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.6
Commit time: 2001-03-10 06:36:31 UTC
Commited by: guppy

Modified files:
     doc/UPDATES1.6 src/botmsg.c src/dccutil.c src/misc.c
     src/modules.c src/patch.h src/proto.h src/mod/module.h
     src/mod/channels.mod/tclchan.c

Log message:

Wingman's utf8 fix ... please test this alot people :P~

---------------------- diff included ----------------------
Index: eggdrop1.6/doc/UPDATES1.6
diff -u eggdrop1.6/doc/UPDATES1.6:1.70 eggdrop1.6/doc/UPDATES1.6:1.71
--- eggdrop1.6/doc/UPDATES1.6:1.70	Tue Feb 27 15:33:18 2001
+++ eggdrop1.6/doc/UPDATES1.6	Sat Mar 10 00:36:20 2001
@@ -4,6 +4,8 @@
 
 1.6.4
 Found by  Fixed by  What...
+KingBob   Tothwolf/ Fixed rest of the problems with utf8 characters. 
+          Wingman
 
 1.6.3 (27 February 2001)
 Found by  Fixed by  What...
Index: eggdrop1.6/src/botmsg.c
diff -u eggdrop1.6/src/botmsg.c:1.18 eggdrop1.6/src/botmsg.c:1.19
--- eggdrop1.6/src/botmsg.c:1.18	Tue Jan 16 11:13:20 2001
+++ eggdrop1.6/src/botmsg.c	Sat Mar 10 00:36:20 2001
@@ -5,7 +5,7 @@
  * 
  * by Darrin Smith (beldin at light.iinet.net.au)
  * 
- * $Id: botmsg.c,v 1.18 2001/01/16 17:13:20 guppy Exp $
+ * $Id: botmsg.c,v 1.19 2001/03/10 06:36:20 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -44,21 +44,28 @@
  */
 void tandout_but EGG_VARARGS_DEF(int, arg1)
 {
-  int i, x, l;
+  int i, x, len;
   char *format;
   char s[601];
   va_list va;
 
   x = EGG_VARARGS_START(int, arg1, va);
   format = va_arg(va, char *);
-
-  if ((l = egg_vsnprintf(s, 511, format, va)) < 0)
-    s[l = 511] = 0;
+  egg_vsnprintf(s, 511, format, va);      
   va_end(va);
+  len = strlen(s);
+  if (len > 511)
+    len = 511;
+  s[len + 1] = 0;  
+
+#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1
+  len = str_utf8tounicode(s);
+#endif    
+
   for (i = 0; i < dcc_total; i++)
     if ((dcc[i].type == &DCC_BOT) && (i != x) &&
-	(b_numver(i) < NEAT_BOTNET))
-      tputs(dcc[i].sock, s, l);
+        (b_numver(i) < NEAT_BOTNET))
+      tputs(dcc[i].sock, s, len);
 }
 #endif
 
@@ -287,7 +294,7 @@
 
 void botnet_send_priv EGG_VARARGS_DEF(int, arg1)
 {
-  int idx, l;
+  int idx, l, len;
   char *from, *to, *tobot, *format;
   char tbuf[1024];
   va_list va;
@@ -297,10 +304,18 @@
   to = va_arg(va, char *);
   tobot = va_arg(va, char *);
   format = va_arg(va, char *);
-
-  if (egg_vsnprintf(tbuf, 450, format, va) < 0)
-    tbuf[450] = 0;
+  egg_vsnprintf(tbuf, 450, format, va);    
   va_end(va);
+  
+  len = strlen(tbuf);
+  if (len > 450)
+    len = 450;
+  tbuf[len + 1] = 0;    
+
+#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1
+  len = str_utf8tounicode(tbuf);
+#endif    
+
   if (tobot) {
 #ifndef NO_OLD_BOTNET
     if (b_numver(idx) < NEAT_BOTNET)
Index: eggdrop1.6/src/dccutil.c
diff -u eggdrop1.6/src/dccutil.c:1.27 eggdrop1.6/src/dccutil.c:1.28
--- eggdrop1.6/src/dccutil.c:1.27	Sat Jan 27 00:26:40 2001
+++ eggdrop1.6/src/dccutil.c	Sat Mar 10 00:36:20 2001
@@ -6,7 +6,7 @@
  *   memory management for dcc structures
  *   timeout checking for dcc connections
  * 
- * $Id: dccutil.c,v 1.27 2001/01/27 06:26:40 tothwolf Exp $
+ * $Id: dccutil.c,v 1.28 2001/03/10 06:36:20 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -39,6 +39,7 @@
 extern char		 botnetnick[], spaces[], version[];
 extern time_t		 now;
 extern sock_list	*socklist;
+extern Tcl_Interp	*interp;
 
 char	motdfile[121] = "text/motd";	/* File where the motd is stored */
 int	connect_timeout = 15;		/* How long to wait before a telnet
@@ -81,7 +82,6 @@
   return tot;
 }
 
-static char SBUF[1024];
 
 /* Replace \n with \r\n */
 char *add_cr(char *buf)
@@ -102,27 +102,41 @@
 
 void dprintf EGG_VARARGS_DEF(int, arg1)
 {
+  static char buf[1024];
   char *format;
   int idx, len;
   va_list va;
 
   idx = EGG_VARARGS_START(int, arg1, va);
   format = va_arg(va, char *);
-  if ((len = egg_vsnprintf(SBUF, 1023, format, va)) < 0)
-    SBUF[len = 1023] = 0;
+  egg_vsnprintf(buf, 1023, format, va);
   va_end(va);
+  /* We can not use the return value vsnprintf() to determine where
+   * to null terminate. The C99 standard specifies that vsnprintf()
+   * shall return the number of bytes that would be written if the
+   * buffer had been large enough, rather then -1.
+   */
+  len = strlen(buf);
+  if (len > 1023)
+    len = 1023;
+  buf[len + 1] = 0;
+
+#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1
+  len = str_utf8tounicode(buf);
+#endif
+
   if (idx < 0) {
-    tputs(-idx, SBUF, len);
+    tputs(-idx, buf, len);
   } else if (idx > 0x7FF0) {
     switch (idx) {
     case DP_LOG:
-      putlog(LOG_MISC, "*", "%s", SBUF);
+      putlog(LOG_MISC, "*", "%s", buf);
       break;
     case DP_STDOUT:
-      tputs(STDOUT, SBUF, len);
+      tputs(STDOUT, buf, len);
       break;
     case DP_STDERR:
-      tputs(STDERR, SBUF, len);
+      tputs(STDERR, buf, len);
       break;
     case DP_SERVER:
     case DP_HELP:
@@ -130,49 +144,58 @@
     case DP_MODE_NEXT:
     case DP_SERVER_NEXT:
     case DP_HELP_NEXT:
-      qserver(idx, SBUF, len);
+      qserver(idx, buf, len);
       break;
     }
     return;
   } else {
     if (len > 500) {		/* Truncate to fit */
-      SBUF[500] = 0;
-      strcat(SBUF, "\n");
+      buf[500] = 0;
+      strcat(buf, "\n");
       len = 501;
     }
     if (dcc[idx].type && ((long) (dcc[idx].type->output) == 1)) {
-      char *p = add_cr(SBUF);
+      char *p = add_cr(buf);
 
       tputs(dcc[idx].sock, p, strlen(p));
     } else if (dcc[idx].type && dcc[idx].type->output) {
-      dcc[idx].type->output(idx, SBUF, dcc[idx].u.other);
+      dcc[idx].type->output(idx, buf, dcc[idx].u.other);
     } else
-      tputs(dcc[idx].sock, SBUF, len);
+      tputs(dcc[idx].sock, buf, len);
   }
 }
 
 void chatout EGG_VARARGS_DEF(char *, arg1)
 {
-  int i;
+  int i, len;
   char *format;
   char s[601];
   va_list va;
 
   format = EGG_VARARGS_START(char *, arg1, va);
-  if (egg_vsnprintf(s, 511, format, va) < 0)
-    s[511] = 0;
+  egg_vsnprintf(s, 511, format, va);
+  va_end(va);
+  len = strlen(s);
+  if (len > 511)
+    len = 511;
+  s[len + 1] = 0;    
+
+#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1
+  len = str_utf8tounicode(s);
+#endif
+
   for (i = 0; i < dcc_total; i++)
     if (dcc[i].type == &DCC_CHAT)
       if (dcc[i].u.chat->channel >= 0)
-	dprintf(i, "%s", s);
-  va_end(va);
+        dprintf(i, "%s", s);
+  
 }
 
 /* Print to all on this channel but one.
  */
 void chanout_but EGG_VARARGS_DEF(int, arg1)
 {
-  int i, x, chan;
+  int i, x, chan, len;
   char *format;
   char s[601];
   va_list va;
@@ -180,13 +203,22 @@
   x = EGG_VARARGS_START(int, arg1, va);
   chan = va_arg(va, int);
   format = va_arg(va, char *);
-  if (egg_vsnprintf(s, 511, format, va) < 0)
-    s[511] = 0;
+  egg_vsnprintf(s, 511, format, va);
+  va_end(va);
+  len = strlen(s);
+  if (len > 511)
+    len = 511;
+  s[len + 1] = 0; 
+    
+#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1
+  len = str_utf8tounicode(s);
+#endif  
+
   for (i = 0; i < dcc_total; i++)
     if ((dcc[i].type == &DCC_CHAT) && (i != x))
       if (dcc[i].u.chat->channel == chan)
-	dprintf(i, "%s", s);
-  va_end(va);
+        dprintf(i, "%s", s);
+  
 }
 
 void dcc_chatter(int idx)
Index: eggdrop1.6/src/misc.c
diff -u eggdrop1.6/src/misc.c:1.35 eggdrop1.6/src/misc.c:1.36
--- eggdrop1.6/src/misc.c:1.35	Fri Jan 26 15:18:22 2001
+++ eggdrop1.6/src/misc.c	Sat Mar 10 00:36:20 2001
@@ -7,7 +7,7 @@
  *   help system
  *   motd display and %var substitution
  * 
- * $Id: misc.c,v 1.35 2001/01/26 21:18:22 guppy Exp $
+ * $Id: misc.c,v 1.36 2001/03/10 06:36:20 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -370,12 +370,51 @@
   }
 }
 
+#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1
+/* Converts an UTF-8 string to unicode safe string,
+ * returns the length of the unicode string
+ */
+int str_utf8tounicode(char *str)
+{
+  Tcl_DString       ds_conversion;
+  Tcl_SavedResult   sr_oldresult;
+
+  /* Don't call this before calling init_tcl() */
+  if (interp) {
+    Tcl_DStringInit(&ds_conversion);
+
+    /* save our old result */
+    Tcl_SaveResult(interp, &sr_oldresult);
+
+    /* clear any previous interp->result */
+    Tcl_ResetResult(interp);
+
+    /* convert UTF-8 to unicode */
+    Tcl_UtfToExternalDString(NULL, str, -1, &ds_conversion);
+    Tcl_DStringResult(interp, &ds_conversion);
+    strncpyz(str, interp->result, strlen(str) + 1);
+
+    /* restore our old result */
+    Tcl_RestoreResult(interp, &sr_oldresult);
+
+    /* free our DString buffers */
+    Tcl_DStringFree(&ds_conversion);
+  }
+
+  return strlen(str);
+}
+#endif
+
 /* Dump a potentially super-long string of text.
  */
 void dumplots(int idx, const char *prefix, char *data)
 {
   char		*p = data, *q, *n, c;
   const int	 max_data_len = 500 - strlen(prefix);
+  
+#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1
+  str_utf8tounicode(p);
+#endif
 
   if (!*data) {
     dprintf(idx, "%s\n", prefix);
Index: eggdrop1.6/src/mod/channels.mod/tclchan.c
diff -u eggdrop1.6/src/mod/channels.mod/tclchan.c:1.42 eggdrop1.6/src/mod/channels.mod/tclchan.c:1.43
--- eggdrop1.6/src/mod/channels.mod/tclchan.c:1.42	Tue Jan 16 11:13:21 2001
+++ eggdrop1.6/src/mod/channels.mod/tclchan.c	Sat Mar 10 00:36:20 2001
@@ -1,7 +1,7 @@
 /* 
  * tclchan.c -- part of channels.mod
  * 
- * $Id: tclchan.c,v 1.42 2001/01/16 17:13:21 guppy Exp $
+ * $Id: tclchan.c,v 1.43 2001/03/10 06:36:20 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -1562,6 +1562,12 @@
 
   if (!newname || !newname[0] || !strchr(CHANMETA, newname[0]))
     return TCL_ERROR;
+
+#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1
+  str_utf8tounicode(newname);
+  str_utf8tounicode(options);
+#endif
+
   convert_element(glob_chanmode, buf2);
   simple_sprintf(buf, "chanmode %s ", buf2);
   strncat(buf, glob_chanset, 2047 - strlen(buf));
Index: eggdrop1.6/src/mod/module.h
diff -u eggdrop1.6/src/mod/module.h:1.40 eggdrop1.6/src/mod/module.h:1.41
--- eggdrop1.6/src/mod/module.h:1.40	Mon Feb 26 21:18:24 2001
+++ eggdrop1.6/src/mod/module.h	Sat Mar 10 00:36:20 2001
@@ -1,7 +1,7 @@
 /* 
  * module.h
  * 
- * $Id: module.h,v 1.40 2001/02/27 03:18:24 guppy Exp $
+ * $Id: module.h,v 1.41 2001/03/10 06:36:20 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -431,6 +431,7 @@
 #define str_unescape ((void (*)(char *, register const char))global[264])
 #define egg_strcatn ((int (*)(char *dst, const char *src, size_t max))global[265])
 #define clear_chanlist_member ((void (*)(const char *nick))global[266])
+#define str_utf8tounicode ((int (*)(char *))global[267])
 
 /* This is for blowfish module, couldnt be bothered making a whole new .h
  * file for it ;)
Index: eggdrop1.6/src/modules.c
diff -u eggdrop1.6/src/modules.c:1.45 eggdrop1.6/src/modules.c:1.46
--- eggdrop1.6/src/modules.c:1.45	Mon Feb 26 21:18:23 2001
+++ eggdrop1.6/src/modules.c	Sat Mar 10 00:36:20 2001
@@ -4,7 +4,7 @@
  * 
  * by Darrin Smith (beldin at light.iinet.net.au)
  * 
- * $Id: modules.c,v 1.45 2001/02/27 03:18:23 guppy Exp $
+ * $Id: modules.c,v 1.46 2001/03/10 06:36:20 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -527,7 +527,8 @@
   /* 264 - 267 */
   (Function) str_unescape,
   (Function) egg_strcatn,
-  (Function) clear_chanlist_member
+  (Function) clear_chanlist_member,
+  (Function) str_utf8tounicode
 };
 
 void init_modules(void)
Index: eggdrop1.6/src/patch.h
diff -u eggdrop1.6/src/patch.h:1.437 eggdrop1.6/src/patch.h:1.438
--- eggdrop1.6/src/patch.h:1.437	Tue Feb 27 15:33:19 2001
+++ eggdrop1.6/src/patch.h	Sat Mar 10 00:36:20 2001
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  * 
- * $Id: patch.h,v 1.437 2001/02/27 21:33:19 guppy Exp $
+ * $Id: patch.h,v 1.438 2001/03/10 06:36:20 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("983310174");		/* current unixtime */
+patch("984207081");		/* current unixtime */
 /*
  *
  *
  */
-patch("none");
+patch("utf8-fix");
 /*
  *
  *
Index: eggdrop1.6/src/proto.h
diff -u eggdrop1.6/src/proto.h:1.37 eggdrop1.6/src/proto.h:1.38
--- eggdrop1.6/src/proto.h:1.37	Sun Dec 17 15:48:42 2000
+++ eggdrop1.6/src/proto.h	Sat Mar 10 00:36:20 2001
@@ -7,7 +7,7 @@
  * because they use structures in those
  * (saves including those .h files EVERY time) - Beldin
  * 
- * $Id: proto.h,v 1.37 2000/12/17 21:48:42 guppy Exp $
+ * $Id: proto.h,v 1.38 2001/03/10 06:36:20 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -232,6 +232,7 @@
 char *str_escape(const char *str, const char div, const char mask);
 char *strchr_unescape(char *str, const char div, register const char esc_char);
 void str_unescape(char *str, register const char esc_char);
+int str_utf8tounicode(char *str);
 
 /* net.c */
 IP my_atoul(char *);
----------------------- End of diff -----------------------



More information about the Changes mailing list