* PATCH: langinfo module thinks October is January
@ 2003-05-30 10:16 Oliver Kiddle
0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2003-05-30 10:16 UTC (permalink / raw)
To: Zsh workers
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.
Oliver
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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-05-30 10:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-30 10:16 PATCH: langinfo module thinks October is January Oliver Kiddle
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).