[Frugalware-darcs] pacman-g2: libpacman: fix i18n pkgdesc when LANG and LC_ALL is not set

VMiklos vmiklos at frugalware.org
Sat Jun 9 21:04:27 CEST 2007


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=pacman-g2;a=darcs_commitdiff;h=20070609190310-e2957-58ddb42303e228ea868018f75abf9bd0050df1c5.gz;

[libpacman: fix i18n pkgdesc when LANG and LC_ALL is not set
VMiklos <vmiklos at frugalware.org>**20070609190310] {
hunk ./lib/libpacman/be_files.c 216
-	char *lang_tmp;
-	pmlist_t *tmplist;
+	pmlist_t *i;
hunk ./lib/libpacman/be_files.c 251
-
-				if (setlocale(LC_ALL, "") == NULL) { /* To fix segfault when locale invalid */
-					setenv("LC_ALL", "C", 1);
-				}
-				if((lang_tmp = (char *)malloc(strlen(setlocale(LC_ALL, "")))) == NULL) {
-					RET_ERR(PM_ERR_MEMORY, -1);
-				}
-				snprintf(lang_tmp, strlen(setlocale(LC_ALL, "")), "%s", setlocale(LC_ALL, ""));
-
-				if(info->desc_localized && !info->desc_localized->next) {
-				    snprintf(info->desc, 512, "%s", (char*)info->desc_localized->data);
-				} else {
-				    for (tmplist = info->desc_localized; tmplist; tmplist = tmplist->next) {
-					if (tmplist->data && strncmp(tmplist->data, lang_tmp, strlen(lang_tmp))) {
-					    snprintf(info->desc, 512, "%s", (char*)info->desc_localized->data);
-					} else {
-					    ptr = strdup(tmplist->data);
-					    snprintf(info->desc, 512, "%s", ptr+strlen(lang_tmp)+1);
-					    FREE(ptr);
-					    break;
+				STRNCPY(info->desc, (char*)info->desc_localized->data, sizeof(info->desc));
+				for (i = info->desc_localized; i; i = i->next) {
+					if (!strncmp(i->data, handle->language, strlen(handle->language))) {
+						STRNCPY(info->desc, (char*)i->data+strlen(handle->language)+1, sizeof(info->desc));
hunk ./lib/libpacman/be_files.c 256
-				    }
hunk ./lib/libpacman/be_files.c 258
-				FREE(lang_tmp);
hunk ./lib/libpacman/handle.c 35
+#include <locale.h>
hunk ./lib/libpacman/handle.c 87
+	handle->language = setlocale(LC_ALL, NULL);
+	printf("[DEBUG] ->language: '%s'\n", handle->language);
+
hunk ./lib/libpacman/handle.h 61
+	char *language;
hunk ./lib/libpacman/package.c 219
-				char *lang_tmp;
hunk ./lib/libpacman/package.c 220
-				if((lang_tmp = (char *)malloc(strlen(setlocale(LC_ALL, "")))) == NULL) {
-					RET_ERR(PM_ERR_MEMORY, -1);
-				}
-				STRNCPY(lang_tmp, setlocale(LC_ALL, ""), strlen(setlocale(LC_ALL, "")));
-				if(info->desc_localized && !info->desc_localized->next) {
+				if(_pacman_list_count(info->desc_localized) == 1) {
hunk ./lib/libpacman/package.c 222
-				} else if (ptr && !strncmp(ptr, lang_tmp, strlen(lang_tmp))) {
-					STRNCPY(info->desc, ptr+strlen(lang_tmp)+1, sizeof(info->desc));
+				} else if (!strncmp(ptr, handle->language, strlen(handle->language))) {
+					STRNCPY(info->desc, ptr+strlen(handle->language)+1, sizeof(info->desc));
hunk ./lib/libpacman/package.c 225
-				FREE(lang_tmp);
}


More information about the Frugalware-darcs mailing list