From: Doug Torrance Date: Tue, 30 Oct 2012 20:56:52 +0000 (-0700) Subject: wmtime: Fixed Debian bug #661843. Applied a patch by Milan Cermak. X-Git-Tag: wmix-3.2~53 X-Git-Url: https://repo.or.cz/w/dockapps.git/commitdiff_plain/13243aa4898f845820c267e22953827593b8487a wmtime: Fixed Debian bug #661843. Applied a patch by Milan Cermak. Package: wmtime Version: 1.0b3-2 Severity: normal Tags: upstream patch l10n Hi, the package wmtime claims that it supports localization. Looking into the code, it seems more like date customization. When claiming "localization", it should work as such - respecting LANG, LC_ALL, etc. environment variables and use locales for the day and month abbreviations. Please see my patch which adds such support. Regards, Milan Cermak -- System Information: Debian Release: 6.0.4 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 2.6.37.6 (SMP w/4 CPU cores; PREEMPT) Locale: LANG=cs_CZ.UTF-8, LC_CTYPE=cs_CZ.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages wmtime depends on: ii libc6 2.11.3-2 Embedded GNU C Library: Shared lib ii libx11-6 2:1.3.3-4 X11 client-side library ii libxext6 2:1.1.2-1 X11 miscellaneous extension librar ii libxpm4 1:3.5.8-1 X11 pixmap library wmtime recommends no packages. wmtime suggests no packages. -- no debconf information --- diff --git a/wmtime/wmtime/wmtime.c b/wmtime/wmtime/wmtime.c index 6f1a007..85cfbba 100644 --- a/wmtime/wmtime/wmtime.c +++ b/wmtime/wmtime/wmtime.c @@ -65,6 +65,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -148,7 +152,10 @@ int main(int argc, char *argv[]) { } } } - get_lang(); + + if (setlocale(LC_ALL, "") != NULL) + get_lang(); + wmtime_routine(argc, argv); return 0; } @@ -156,26 +163,44 @@ int main(int argc, char *argv[]) { /************/ /* get_lang */ /************/ -void get_lang(){ - FILE *fp; - int i; - const int line_size = 5; - char line[line_size]; - - fp=fopen("language","r"); - if (fp) { - /* Grab the days of the week */ - for (i=0;i<7;i++){ - fgets(line, line_size, fp); - strncpy(day_of_week[i], line, 2); - }; - /* Grab the names of the months */ - for (i=0;i<12;i++){ - fgets(line, line_size, fp); - strncpy(mon_of_year[i], line, 3); - }; - fclose(fp); - }; +void get_lang(void) +{ + char langbuf[10], outbuf[10]; + char *inp, *outp; + iconv_t icd; + int i, ret; + size_t insize, outsize; + + icd = iconv_open("ASCII//TRANSLIT", nl_langinfo(CODESET)); + if (icd < 0) + return; + + for (i = 0; i < 7; i++) { + strncpy(langbuf, nl_langinfo(ABDAY_1 + i), 10); + insize = outsize = 10; + inp = langbuf; + outp = outbuf; + do { + ret = iconv(icd, &inp, &insize, &outp, &outsize); + } while (outsize > 0 && ret > 0); + for (outp = outbuf, outsize = 0; *outp != 0 && outsize < 2; + outp++, outsize++) + day_of_week[i][outsize] = toupper(*outp); + } + for (i = 0; i < 12; i++) { + strncpy(langbuf, nl_langinfo(ABMON_1 + i), 10); + insize = outsize = 10; + inp = langbuf; + outp = outbuf; + do { + ret = iconv(icd, &inp, &insize, &outp, &outsize); + } while (outsize > 0 && ret > 0); + for (outp = outbuf, outsize = 0; *outp != 0 && outsize < 3; + outp++, outsize++) + mon_of_year[i][outsize] = toupper(*outp); + } + + iconv_close(icd); } /*******************************************************************************\