[Pkg-wmaker-commits] [wmtime] 03/101: wmtime: Fixed Debian bug #661843. Applied a patch by Milan Cermak.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:59:20 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmtime.

commit 406d1a769ce47c32c6bc3669767f0985969495fd
Author: Doug Torrance <profzoom at hotmail.com>
Date:   Tue Oct 30 13:56:52 2012 -0700

    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
---
 wmtime/wmtime.c | 67 +++++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 46 insertions(+), 21 deletions(-)

diff --git a/wmtime/wmtime.c b/wmtime/wmtime.c
index 6f1a007..85cfbba 100644
--- a/wmtime/wmtime.c
+++ b/wmtime/wmtime.c
@@ -65,6 +65,10 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <math.h>
+#include <locale.h>
+#include <langinfo.h>
+#include <iconv.h>
+#include <ctype.h>
 
 #include <sys/wait.h>
 #include <sys/param.h>
@@ -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);
 }
 
 /*******************************************************************************\

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmtime.git



More information about the Pkg-wmaker-commits mailing list