Sophie

Sophie

distrib > Mageia > 9 > armv7hl > media > core-release-src > by-pkgid > 4ff4ce161041daa8cd20a830f4c8a435 > files > 2

pyzy-0.1.0-15.mga9.src.rpm

From 344872231b95ce7c2808288101cc563dcd011940 Mon Sep 17 00:00:00 2001
From: Hillwood Yang <hillwoodroc@gmail.com>
Date: Thu, 26 Feb 2015 11:04:29 +0800
Subject: [PATCH 1/2] Update SimpTradConverter.cc

Use opencc 1.0.2
---
 src/SimpTradConverter.cc | 42 +++++++++++++-----------------------------
 1 file changed, 13 insertions(+), 29 deletions(-)

diff --git a/src/SimpTradConverter.cc b/src/SimpTradConverter.cc
index 6fe9123..7be0749 100644
--- a/src/SimpTradConverter.cc
+++ b/src/SimpTradConverter.cc
@@ -40,7 +41,6 @@ namespace PyZy {
 #ifdef HAVE_OPENCC
 
 class opencc {
-    static const int BUFFER_SIZE = 64;
 public:
     opencc (void)
     {
@@ -55,29 +55,13 @@ class opencc {
 
     void convert (const char *in, String &out)
     {
-        long n_char;
-        unichar *in_ucs4 = g_utf8_to_ucs4_fast (in, -1, &n_char);
-
-        ucs4_t *pinbuf = (ucs4_t *)in_ucs4;
-        size_t inbuf_left = n_char;
-        while (inbuf_left != 0) {
-            ucs4_t *poutbuf = (ucs4_t *)m_buffer;
-            size_t outbuf_left = BUFFER_SIZE;
-            size_t retval = opencc_convert(m_od, &pinbuf, &inbuf_left, &poutbuf, &outbuf_left);
-            if (retval == (size_t) -1) {
-                /* append left chars in pinbuf */
-                g_warning ("opencc_convert return failed");
-                out << (unichar *) pinbuf;
-                break;
-            }
-            *poutbuf = L'\0';
-            out << m_buffer;
-        }
-        g_free (in_ucs4);
+        char * converted = opencc_convert_utf8 (m_od, in, -1);
+        g_assert (converted != NULL);
+        out = converted;
+        opencc_convert_utf8_free (converted);
     }
 private:
     opencc_t m_od;
-    unichar m_buffer[BUFFER_SIZE + 1];
 };
 
 void