ddate: St. Tib's Day in other languages
PATCH 1/1 ddate: St. Tib's Day in other languages
In other languages than english, the translation of "St. Tib's Day" may not be 13 bytes long. Example of what happens in german:
$ ddate 29 2 2008 St. Tib’s D, 3174 YOLD
Signed-off-by Nick Erdmann <[email protected]>
misc-utils/ddate.c +4 -1
@@ -223,6 +223,7 @@int tib_start=-1 , tib_end=0 ;int i, fmtlen=strlen (fmt);char *bufptr=buf; +char *foo;/* fprintf(stderr, "format(%p, \"%s\", dt)\n", buf, fmt);*/
@@ -249,7 +250,9 @@for (i=0 ; i<fmtlen; i++) {if ((i==tib_start) && (dt.day==-1 )) {/* handle St. Tib's Day */ -strcpy (bufptr,_ ("St. Tib's Day" )); bufptr +=13 ; + foo =_ ("St. Tib's Day" ); +while ((*bufptr++=*foo++)); + --bufptr; i=tib_end; }else {if (fmt[i]=='%' ) {
Karel Zak
maintainerQuoted 17 lines · Nick Erdmann
In other languages than english, the translation of "St. Tib's Day" may not be 13 bytes long. Example of what happens in german:
$ ddate 29 2 2008 St. Tib’s D, 3174 YOLDSigned-off-by Nick Erdmann <[email protected]>misc-utils/ddate.c +1
-0@@ -223,6 +223,7 @@int tib_start=-1 , tib_end=0 ;int i, fmtlen=strlen (fmt);char *bufptr=buf; +char *foo;/* fprintf(stderr, "format(%p, \"%s\", dt)\n", buf, fmt);*/
misc-utils/ddate.c line 256
Quoted 8 lines
misc-utils/ddate.c +3
-1@@ -249,7 +250,9 @@for (i=0 ; i<fmtlen; i++) {if ((i==tib_start) && (dt.day==-1 )) {/* handle St. Tib's Day */ -strcpy (bufptr,_ ("St. Tib's Day" )); bufptr +=13 ; + foo =_ ("St. Tib's Day" ); +while ((*bufptr++=*foo++)); + --bufptr; i=tib_end;
strcpy(bufptr, _("St. Tib's Day"));
bufptr += strlen(bufptr);seems more readable.
Anyway, the horrible code does not check the size of the bufptr, etc.
I'm still surprised that we have this crazy thing in util-linux package and it's enabled by default. I'll probably add --enable-ddate.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com