From 3d419eecb050d8bd7b608e2e3513c162309e2778 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 30 Jul 2013 12:43:38 +0800 Subject: [PATCH] Fixes load table.conf in German locale --- libpinyin-0.10.x-head.patch | 95 +++++++++++++++++++++++++++++++++++++ libpinyin.spec | 7 ++- 2 files changed, 100 insertions(+), 2 deletions(-) diff --git a/libpinyin-0.10.x-head.patch b/libpinyin-0.10.x-head.patch index e69de29..1abd02e 100644 --- a/libpinyin-0.10.x-head.patch +++ b/libpinyin-0.10.x-head.patch @@ -0,0 +1,95 @@ +From 8abc8cfd97cfe63c8e26e0838d4c825283b30630 Mon Sep 17 00:00:00 2001 +From: Peng Wu +Date: Fri, 26 Jul 2013 12:35:46 +0800 +Subject: [PATCH] Force to use C locale to load table.conf + +--- + src/storage/table_info.cpp | 14 ++++++++++++++ + tests/storage/test_table_info.cpp | 3 +++ + 2 files changed, 17 insertions(+) + +diff --git a/src/storage/table_info.cpp b/src/storage/table_info.cpp +index 795d93d..63af8e0 100644 +--- a/src/storage/table_info.cpp ++++ b/src/storage/table_info.cpp +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + + using namespace pinyin; + +@@ -121,6 +122,8 @@ static PHRASE_FILE_TYPE to_file_type(const char * str) { + bool SystemTableInfo::load(const char * filename) { + reset(); + ++ char * locale = setlocale(LC_NUMERIC, "C"); ++ + FILE * input = fopen(filename, "r"); + if (NULL == input) { + fprintf(stderr, "open %s failed.\n", filename); +@@ -183,6 +186,9 @@ bool SystemTableInfo::load(const char * filename) { + + /* postfix reserved tables. */ + postfix_tables(); ++ ++ setlocale(LC_NUMERIC, locale); ++ + return true; + } + +@@ -208,6 +214,8 @@ void UserTableInfo::reset() { + bool UserTableInfo::load(const char * filename) { + reset(); + ++ char * locale = setlocale(LC_NUMERIC, "C"); ++ + FILE * input = fopen(filename, "r"); + if (NULL == input) { + fprintf(stderr, "open %s failed.", filename); +@@ -237,10 +245,14 @@ bool UserTableInfo::load(const char * filename) { + + fclose(input); + ++ setlocale(LC_NUMERIC, locale); ++ + return true; + } + + bool UserTableInfo::save(const char * filename) { ++ char * locale = setlocale(LC_NUMERIC, "C"); ++ + FILE * output = fopen(filename, "w"); + if (NULL == output) { + fprintf(stderr, "write %s failed.\n", filename); +@@ -252,6 +264,8 @@ bool UserTableInfo::save(const char * filename) { + + fclose(output); + ++ setlocale(LC_NUMERIC, locale); ++ + return true; + } + +diff --git a/tests/storage/test_table_info.cpp b/tests/storage/test_table_info.cpp +index 68b4735..5781c97 100644 +--- a/tests/storage/test_table_info.cpp ++++ b/tests/storage/test_table_info.cpp +@@ -20,10 +20,13 @@ + */ + + #include ++#include + #include "pinyin_internal.h" + + + int main(int argc, char * argv[]) { ++ setlocale(LC_ALL, ""); ++ + SystemTableInfo system_table_info; + + bool retval = system_table_info.load("../../data/table.conf"); +-- +1.8.3.1 + diff --git a/libpinyin.spec b/libpinyin.spec index dba997f..e518af9 100644 --- a/libpinyin.spec +++ b/libpinyin.spec @@ -1,8 +1,8 @@ -%global snapshot 0 +%global snapshot 1 Name: libpinyin Version: 0.9.93 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Library to deal with pinyin License: GPLv2+ @@ -92,6 +92,9 @@ find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';' %{_mandir}/man1/*.1.* %changelog +* Tue Jul 30 2013 Peng Wu - 0.9.93-2 +- Fixes load table.conf in German locale + * Thu Jun 27 2013 Peng Wu - 0.9.93-1 - Update to 0.9.93