Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: langinfo module thinks October is January

I tried to use $langinfo to get the month names instead of typing them
out but it was printing January for October to December.

${(v)langinfo[(I)MON*]} correctly lists the months but try
$langinfo[MON_10] and you get January. The problem is caused by it
using strncmp to find the keys in the table and comparing the first
five characters of MON_1 with MON_10 matches. So $langinfo[MON_5wibble]
will also return May. With this patch, it just uses strcmp instead.

The termcap module seems to suffer from a similar problem (for both
echotc and the termcap association). Are all termcap codes two
characters? If so, I think we can just add a couple of
   if (strlen(s) != 2 )) return 1/NULL
I can't see how else termcap.c goes wrong (no strncmp) so I'm assuming
that it is tgetent that only looks at the first two characters.


Index: Src/Modules/langinfo.c
RCS file: /cvsroot/zsh/zsh/Src/Modules/langinfo.c,v
retrieving revision 1.1
diff -u -r1.1 langinfo.c
--- Src/Modules/langinfo.c	19 Feb 2002 02:14:09 -0000	1.1
+++ Src/Modules/langinfo.c	30 May 2003 09:45:56 -0000
@@ -388,7 +388,7 @@
     nlcode = &nl_vals[0];
     for (element = (char **)nl_names; *element; element++, nlcode++) {
-	if ((!strncmp(*element, name, strlen(*element))))
+	if ((!strcmp(*element, name)))
 	    return nlcode;

Messages sorted by: Reverse Date, Date, Thread, Author