SOURCES: poldek-desc_in_utf8.patch (NEW) - show UTF-8 descriptions

witekfl witekfl at pld-linux.org
Thu May 31 18:08:51 CEST 2007


Author: witekfl                      Date: Thu May 31 16:08:51 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- show UTF-8 descriptions

---- Files affected:
SOURCES:
   poldek-desc_in_utf8.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/poldek-desc_in_utf8.patch
diff -u /dev/null SOURCES/poldek-desc_in_utf8.patch:1.1
--- /dev/null	Thu May 31 18:08:51 2007
+++ SOURCES/poldek-desc_in_utf8.patch	Thu May 31 18:08:46 2007
@@ -0,0 +1,70 @@
+--- poldek-0.20.1-cvs20070108.22/pkgdir/pndir/description.c.stare	2007-05-29 22:39:55.000000000 +0200
++++ poldek-0.20.1-cvs20070108.22/pkgdir/pndir/description.c	2007-05-30 15:11:58.000000000 +0200
+@@ -166,6 +166,7 @@
+         for (i = n_array_size(langs) - 1; i >= 0; i--) {
+             struct tndb *db;
+             const char *lang;
++            char lang_utf8[24];
+             char dkey[512];
+             int  dklen;
+ 
+@@ -176,6 +177,19 @@
+             if ((db = pndir_db_dscr_h_get(db_dscr_h, lang)) == NULL)
+                 continue;
+ 
++            snprintf(lang_utf8, sizeof(lang_utf8), "%s.UTF-8", lang);
++
++            dklen = n_snprintf(dkey, sizeof(dkey), "%s%s", key, lang_utf8);
++            vlen = tndb_get(db, dkey, dklen, val, sizeof(val));
++            DBGF("ld %s: %s (%d)\n", pkg_snprintf_s(pkg), lang_utf8, vlen);
++            if (vlen > 0) {
++                tn_buf_it it;
++                n_buf_clean(nbuf);
++                n_buf_init(nbuf, val, vlen);
++                n_buf_it_init(&it, nbuf);
++                pkguinf_restore_i18n(pkgu, &it, lang_utf8);
++            }
++    
+             dklen = n_snprintf(dkey, sizeof(dkey), "%s%s", key, lang);
+             vlen = tndb_get(db, dkey, dklen, val, sizeof(val));
+             DBGF("ld %s: %s (%d)\n", pkg_snprintf_s(pkg), lang, vlen);
+--- poldek-0.20.1-cvs20070108.22/pkgu.c.stare	2007-05-29 21:40:39.000000000 +0200
++++ poldek-0.20.1-cvs20070108.22/pkgu.c	2007-05-30 16:37:16.000000000 +0200
+@@ -15,6 +15,8 @@
+ */
+ 
+ #include <ctype.h>
++#include <iconv.h>
++#include <langinfo.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+@@ -576,7 +576,27 @@
+         return 0;
+     description = n_buf_it_getz(it, &dlen);
+ 
+-    inf = pkguinf_i18n_new(pkgu->_na, summary, description);
++    if (strstr(lang, "UTF-8")) {
++        iconv_t cd;
++        size_t u_slen = slen, u_dlen = dlen;
++        char *new_s, *new_d;
++        char *summary_utf8 = n_malloc(u_slen + 1);
++        char *description_utf8 = n_malloc(u_dlen + 1);
++
++        new_s = summary_utf8;
++        new_d = description_utf8;
++        cd = iconv_open(nl_langinfo(CODESET), "UTF-8");
++        iconv(cd, &summary, &slen, &new_s, &u_slen);
++        iconv(cd, &description, &dlen, &new_d, &u_dlen);
++        iconv_close(cd);
++        *new_s = '\0';
++        *new_d = '\0';
++        inf = pkguinf_i18n_new(pkgu->_na, summary_utf8, description_utf8);
++        n_free(summary_utf8);
++        n_free(description_utf8);
++    } else {
++        inf = pkguinf_i18n_new(pkgu->_na, summary, description);
++    }
+     n_hash_insert(pkgu->_ht, lang, inf);
+     
+     pkgu->summary = inf->summary;
================================================================


More information about the pld-cvs-commit mailing list