[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xfree-i18n
Subject:    [I18n] [patch] 8-bit clean .twmrc
From:       Tomohiro KUBOTA <kubota () surfchem0 ! riken ! go ! jp>
Date:       2000-10-03 16:46:36
[Download RAW message or body]

Hi,

I found that the configuration-file reader of TWM is not 8-bit clean.
It uses 'char' type (not 'unsigned char') to read configuration files 
and checks the validity of the read value using 'c <= 0' (lex.l 80).

The following is a patch to fix the problem.

---------------------------------------------------
diff -ruN twm.orig/Imakefile twm.8bit/Imakefile
--- twm.orig/Imakefile	Mon Sep  4 23:25:21 2000
+++ twm.8bit/Imakefile	Wed Oct  4 01:21:32 2000
@@ -53,7 +53,7 @@
 	echo ' * twm bindings file system.twmrc by the twm Imakefile.' >>$@
 	echo ' */' >>$@
 	echo '' >>$@
-	echo 'char *defTwmrc[] = {' >>$@
+	echo 'unsigned char *defTwmrc[] = {' >>$@
 	sed -f deftwmrc.sed <system.twmrc >>$@
 	echo '    (char *) 0 };' >>$@
 
diff -ruN twm.orig/parse.c twm.8bit/parse.c
--- twm.orig/parse.c	Mon Sep  4 23:25:21 2000
+++ twm.8bit/parse.c	Wed Oct  4 01:21:38 2000
@@ -77,10 +77,10 @@
 static FILE *twmrc;
 static int ptr = 0;
 static int len = 0;
-static char buff[BUF_LEN+1];
-static char overflowbuff[20];		/* really only need one */
+static unsigned char buff[BUF_LEN+1];
+static unsigned char overflowbuff[20];		/* really only need one */
 static int overflowlen;
-static char **stringListSource, *currentString;
+static unsigned char **stringListSource, *currentString;
 
 static int doparse ( int (*ifunc)(void), char *srctypename, char *srcname );
 static int twmFileInput ( void );
@@ -94,7 +94,7 @@
 
 int (*twmInputFunc)(void);
 
-extern char *defTwmrc[];		/* default bindings */
+extern unsigned char *defTwmrc[];		/* default bindings */
 
 
 /***********************************************************************
@@ -235,7 +235,7 @@
 }
 
 int ParseStringList (sl)
-    char **sl;
+    unsigned char **sl;
 {
     stringListSource = sl;
     currentString = *sl;
@@ -304,7 +304,7 @@
     int c;
 {
     if (overflowlen < sizeof overflowbuff) {
-	overflowbuff[overflowlen++] = (char) c;
+	overflowbuff[overflowlen++] = (unsigned char) c;
     } else {
 	twmrc_error_prefix ();
 	fprintf (stderr, "unable to unput character (%d)\n",
diff -ruN twm.orig/parse.h twm.8bit/parse.h
--- twm.orig/parse.h	Mon Sep  4 23:25:21 2000
+++ twm.8bit/parse.h	Wed Oct  4 01:19:49 2000
@@ -72,7 +72,7 @@
 void put_pixel_on_root ( Pixel pixel );
 extern void do_string_savecolor ( int colormode, char *s );
 extern void do_var_savecolor ( int key );
-extern int ParseStringList ( char **sl );
+extern int ParseStringList ( unsigned char **sl );
 extern int ParseTwmrc ( char *filename );
 extern int parse_keyword ( char *s, int *nump );
 extern void TwmOutput ( int c );
---------------------------------------------------


I also found that the problem is fixed with the following very 
simple patch.


---------------------------------------------------
diff -ruN twm.patch2/lex.l twm.patch3/lex.l
--- twm.patch2/lex.l	Fri Sep 29 09:14:33 2000
+++ twm.patch3/lex.l	Sat Sep 30 11:05:31 2000
@@ -77,7 +77,7 @@
 	if (size == 0)
 		return (0);
 
-	if ((c = (*twmInputFunc)()) <= 0)
+	if ((c = (*twmInputFunc)()) == 0)
 		return (0);
 
 	buf[0] = c;
---------------------------------------------------


I would like to send one of them to patch@xfree86.org
(I prefer the former patch).  However, I am not familiar 
with lex and yacc.  I might write a bad patch....

Please check these patches.  Though I prefer the former
patch, if someone recommends the latter one I may change
my mind.

 ---

I sent the previous i18n patch of TWM to patch@xfree86.org.
I got the patch sequence number of 4165 (for the original
patch) and 4168 (for a minor bug fix).  However, I could 
not find any information about the address patch@xfree86.org
in the XFree86 web pages.  Are there any informations on 
the development of XFree86?  (I am just interested in how 
my patches are processed...)

---
Tomohiro KUBOTA <kubota@debian.org>

_______________________________________________
I18n mailing list
I18n@XFree86.Org
http://XFree86.Org/mailman/listinfo/i18n

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic