Blame SOURCES/0022-localization-properly-handle-locales-with-encoding-s.patch

28bab8
From 09da182cd50ee9df08a20180d5fd1d136dc794d3 Mon Sep 17 00:00:00 2001
28bab8
From: Jakub Filak <jfilak@redhat.com>
28bab8
Date: Sat, 8 Feb 2014 09:15:35 +0100
28bab8
Subject: [LIBREPORT PATCH 22/24] localization: properly handle locales with
28bab8
 encoding suffix
28bab8
28bab8
XML nodes contain xml:lang attributes whose values are plain language
28bab8
codes (en_GB, zh_CN, ...).
28bab8
28bab8
libreport tries to find exact match with cur locale which may be
28bab8
suffixed with char set identifier (.UTF-8). Therefore libreport never
28bab8
finds exact match.
28bab8
28bab8
This patch removes the encoding suffix from cur locale string.
28bab8
28bab8
Closes to rhbz#1063320
28bab8
28bab8
Signed-off-by: Jakub Filak <jfilak@redhat.com>
28bab8
---
28bab8
 src/include/xml_parser.h      | 2 +-
28bab8
 src/lib/event_xml_parser.c    | 6 ++++--
28bab8
 src/lib/workflow_xml_parser.c | 4 +++-
28bab8
 3 files changed, 8 insertions(+), 4 deletions(-)
28bab8
28bab8
diff --git a/src/include/xml_parser.h b/src/include/xml_parser.h
28bab8
index 59517b3..36fd2ae 100644
28bab8
--- a/src/include/xml_parser.h
28bab8
+++ b/src/include/xml_parser.h
28bab8
@@ -22,7 +22,7 @@
28bab8
 struct my_parse_data
28bab8
 {
28bab8
     workflow_t *workflow;
28bab8
-    const char *cur_locale;
28bab8
+    char *cur_locale;
28bab8
     char *attribute_lang;
28bab8
     bool in_event_list;
28bab8
     bool exact_name;
28bab8
diff --git a/src/lib/event_xml_parser.c b/src/lib/event_xml_parser.c
28bab8
index 2a6f477..1f98158 100644
28bab8
--- a/src/lib/event_xml_parser.c
28bab8
+++ b/src/lib/event_xml_parser.c
28bab8
@@ -60,7 +60,7 @@ struct my_parse_data
28bab8
 {
28bab8
     parsed_event_config_t event_config;
28bab8
     parsed_event_option_t cur_option;
28bab8
-    const char *cur_locale;
28bab8
+    char *cur_locale;
28bab8
     char *attribute_lang;
28bab8
     bool in_adv_option;
28bab8
 };
28bab8
@@ -511,7 +511,8 @@ void load_event_description_from_file(event_config_t *event_config, const char*
28bab8
 {
28bab8
     log_notice("loading event: '%s'", filename);
28bab8
     struct my_parse_data parse_data = { {event_config, false, false, false}, {NULL, false, false}, NULL, NULL };
28bab8
-    parse_data.cur_locale = setlocale(LC_ALL, NULL);
28bab8
+    parse_data.cur_locale = xstrdup(setlocale(LC_ALL, NULL));
28bab8
+    strchrnul(parse_data.cur_locale, '.')[0] = '\0';
28bab8
 
28bab8
     GMarkupParser parser;
28bab8
     memset(&parser, 0, sizeof(parser)); /* just in case */
28bab8
@@ -541,4 +542,5 @@ void load_event_description_from_file(event_config_t *event_config, const char*
28bab8
 
28bab8
     consume_cur_option(&parse_data); /* just in case */
28bab8
     free(parse_data.attribute_lang); /* just in case */
28bab8
+    free(parse_data.cur_locale);
28bab8
 }
28bab8
diff --git a/src/lib/workflow_xml_parser.c b/src/lib/workflow_xml_parser.c
28bab8
index 681b171..0efc733 100644
28bab8
--- a/src/lib/workflow_xml_parser.c
28bab8
+++ b/src/lib/workflow_xml_parser.c
28bab8
@@ -165,7 +165,8 @@ void load_workflow_description_from_file(workflow_t *workflow, const char* filen
28bab8
 {
28bab8
     log_notice("loading workflow: '%s'", filename);
28bab8
     struct my_parse_data parse_data = { workflow, NULL, NULL, 0, 0, 0};
28bab8
-    parse_data.cur_locale = setlocale(LC_ALL, NULL);
28bab8
+    parse_data.cur_locale = xstrdup(setlocale(LC_ALL, NULL));
28bab8
+    strchrnul(parse_data.cur_locale, '.')[0] = '\0';
28bab8
 
28bab8
     GMarkupParser parser;
28bab8
     memset(&parser, 0, sizeof(parser)); /* just in case */
28bab8
@@ -194,4 +195,5 @@ void load_workflow_description_from_file(workflow_t *workflow, const char* filen
28bab8
     g_markup_parse_context_free(context);
28bab8
 
28bab8
     free(parse_data.attribute_lang); /* just in case */
28bab8
+    free(parse_data.cur_locale);
28bab8
 }
28bab8
-- 
28bab8
1.8.3.1
28bab8