Blame SOURCES/libpinyin-0.10.x-head.patch

69cbd1
From 8abc8cfd97cfe63c8e26e0838d4c825283b30630 Mon Sep 17 00:00:00 2001
69cbd1
From: Peng Wu <alexepico@gmail.com>
69cbd1
Date: Fri, 26 Jul 2013 12:35:46 +0800
69cbd1
Subject: [PATCH] Force to use C locale to load table.conf
69cbd1
69cbd1
---
69cbd1
 src/storage/table_info.cpp        | 14 ++++++++++++++
69cbd1
 tests/storage/test_table_info.cpp |  3 +++
69cbd1
 2 files changed, 17 insertions(+)
69cbd1
69cbd1
diff --git a/src/storage/table_info.cpp b/src/storage/table_info.cpp
69cbd1
index 795d93d..63af8e0 100644
69cbd1
--- a/src/storage/table_info.cpp
69cbd1
+++ b/src/storage/table_info.cpp
69cbd1
@@ -23,6 +23,7 @@
69cbd1
 #include <stdio.h>
69cbd1
 #include <assert.h>
69cbd1
 #include <string.h>
69cbd1
+#include <locale.h>
69cbd1
 
69cbd1
 using namespace pinyin;
69cbd1
 
69cbd1
@@ -121,6 +122,8 @@ static PHRASE_FILE_TYPE to_file_type(const char * str) {
69cbd1
 bool SystemTableInfo::load(const char * filename) {
69cbd1
     reset();
69cbd1
 
69cbd1
+    char * locale = setlocale(LC_NUMERIC, "C");
69cbd1
+
69cbd1
     FILE * input = fopen(filename, "r");
69cbd1
     if (NULL == input) {
69cbd1
         fprintf(stderr, "open %s failed.\n", filename);
69cbd1
@@ -183,6 +186,9 @@ bool SystemTableInfo::load(const char * filename) {
69cbd1
 
69cbd1
     /* postfix reserved tables. */
69cbd1
     postfix_tables();
69cbd1
+
69cbd1
+    setlocale(LC_NUMERIC, locale);
69cbd1
+
69cbd1
     return true;
69cbd1
 }
69cbd1
 
69cbd1
@@ -208,6 +214,8 @@ void UserTableInfo::reset() {
69cbd1
 bool UserTableInfo::load(const char * filename) {
69cbd1
     reset();
69cbd1
 
69cbd1
+    char * locale = setlocale(LC_NUMERIC, "C");
69cbd1
+
69cbd1
     FILE * input = fopen(filename, "r");
69cbd1
     if (NULL == input) {
69cbd1
         fprintf(stderr, "open %s failed.", filename);
69cbd1
@@ -237,10 +245,14 @@ bool UserTableInfo::load(const char * filename) {
69cbd1
 
69cbd1
     fclose(input);
69cbd1
 
69cbd1
+    setlocale(LC_NUMERIC, locale);
69cbd1
+
69cbd1
     return true;
69cbd1
 }
69cbd1
 
69cbd1
 bool UserTableInfo::save(const char * filename) {
69cbd1
+    char * locale = setlocale(LC_NUMERIC, "C");
69cbd1
+
69cbd1
     FILE * output = fopen(filename, "w");
69cbd1
     if (NULL == output) {
69cbd1
         fprintf(stderr, "write %s failed.\n", filename);
69cbd1
@@ -252,6 +264,8 @@ bool UserTableInfo::save(const char * filename) {
69cbd1
 
69cbd1
     fclose(output);
69cbd1
 
69cbd1
+    setlocale(LC_NUMERIC, locale);
69cbd1
+
69cbd1
     return true;
69cbd1
 }
69cbd1
 
69cbd1
diff --git a/tests/storage/test_table_info.cpp b/tests/storage/test_table_info.cpp
69cbd1
index 68b4735..5781c97 100644
69cbd1
--- a/tests/storage/test_table_info.cpp
69cbd1
+++ b/tests/storage/test_table_info.cpp
69cbd1
@@ -20,10 +20,13 @@
69cbd1
  */
69cbd1
 
69cbd1
 #include <stdio.h>
69cbd1
+#include <locale.h>
69cbd1
 #include "pinyin_internal.h"
69cbd1
 
69cbd1
 
69cbd1
 int main(int argc, char * argv[]) {
69cbd1
+    setlocale(LC_ALL, "");
69cbd1
+
69cbd1
     SystemTableInfo system_table_info;
69cbd1
 
69cbd1
     bool retval = system_table_info.load("../../data/table.conf");
69cbd1
-- 
69cbd1
1.8.3.1
69cbd1