Use cheaders
authorPeng Huang <shawn.p.huang@gmail.com>
Wed, 14 Apr 2010 03:19:09 +0000 (11:19 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Wed, 14 Apr 2010 03:26:08 +0000 (11:26 +0800)
src/Database.cc
src/Engine.cc
src/Phrase.h
src/PinyinEngine.cc
src/PinyinParser.cc
src/SimpTradConverter.cc

index ba18e1b..cd35874 100644 (file)
@@ -1,10 +1,10 @@
 /* vim:set et sts=4: */
-#include <string.h>
+#include <cstring>
+#include <cstdio>
+#include <cstdlib>
+#include <cstdarg>
 #include <glib.h>
 #include <sqlite3.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
 #include "Database.h"
 #include "Util.h"
 
index f7e8851..5c16028 100644 (file)
@@ -1,7 +1,7 @@
 /* vim:set et sts=4: */
 
+#include <cstring>
 #include <ibus.h>
-#include <string.h>
 #include "Engine.h"
 #include "PinyinEngine.h"
 
index 02f091f..1f1f067 100644 (file)
@@ -2,7 +2,6 @@
 #ifndef __PY_PHRASE_H_
 #define __PY_PHRASE_H_
 
-#include <string.h>
 #include "Types.h"
 
 namespace PY {
index 27b2f8d..dd6d562 100644 (file)
@@ -1,8 +1,7 @@
 /* vim:set et sts=4: */
 
-#include <ibus.h>
-#include <string.h>
 #include <libintl.h>
+#include <ibus.h>
 #include "RawEditor.h"
 #include "ExtEditor.h"
 #include "FullPinyinEditor.h"
index a28cb32..8d269c0 100644 (file)
@@ -1,6 +1,6 @@
 /* vim:set et sts=4: */
-#include <string.h>
-#include <stdlib.h>
+#include <cstring>
+#include <cstdlib>
 #include <glib.h>
 #include "PinyinParser.h"
 
@@ -31,7 +31,7 @@ py_cmp (const void *p1, const void *p2)
     const gchar *str = (const gchar *) p1;
     const Pinyin *py = (const Pinyin *) p2;
 
-    return strcmp (str, py->text);
+    return std::strcmp (str, py->text);
 }
 
 static const Pinyin *
@@ -50,9 +50,9 @@ is_pinyin (const gchar *p,
         return NULL;
 
     if (G_LIKELY (len > 0)) {
-        strncpy (buf, p, len);
+        std::strncpy (buf, p, len);
         buf[len] = 0;
-        result = (const Pinyin *) bsearch (buf, pinyin_table, G_N_ELEMENTS (pinyin_table),
+        result = (const Pinyin *) std::bsearch (buf, pinyin_table, G_N_ELEMENTS (pinyin_table),
                                             sizeof (Pinyin), py_cmp);
         if (check_flags (result, option))
             return result;
@@ -61,11 +61,11 @@ is_pinyin (const gchar *p,
 
     /* len < 0 */
     len = MIN (6, end - p);
-    strncpy (buf, p, len);
+    std::strncpy (buf, p, len);
 
     for (; len > 0; len --) {
         buf[len] = 0;
-        result = (const Pinyin *) bsearch (buf, pinyin_table, G_N_ELEMENTS (pinyin_table),
+        result = (const Pinyin *) std::bsearch (buf, pinyin_table, G_N_ELEMENTS (pinyin_table),
                                             sizeof (Pinyin), py_cmp);
         if (G_UNLIKELY (check_flags (result, option))) {
             return result;
@@ -95,7 +95,7 @@ need_resplit(const Pinyin *p1,
 {
     const Pinyin * pys[] = {p1, p2};
 
-    return (const Pinyin **) bsearch (pys, special_table, G_N_ELEMENTS (special_table),
+    return (const Pinyin **) std::bsearch (pys, special_table, G_N_ELEMENTS (special_table),
                                         sizeof (special_table[0]), sp_cmp);
 }
 
index c470afd..0bbb1e8 100644 (file)
@@ -1,5 +1,5 @@
-#include <stdlib.h>
-#include <wchar.h>
+#include <cstdlib>
+#include <cwchar>
 #include <glib.h>
 #include <glib-object.h>
 #include "SimpTradConverter.h"
@@ -12,7 +12,7 @@ static int _cmp (const void *p1, const void *p2)
     const wchar_t *s1 = (const wchar_t *) p1;
     const wchar_t **s2 = (const wchar_t **) p2;
 
-    return wcscmp (s1, s2[0]);
+    return std::wcscmp (s1, s2[0]);
 }
 
 void
@@ -37,9 +37,9 @@ SimpTradConverter::simpToTrad (const gchar *in, String &out)
         }
         for (; i > 0; i--) {
             buf[i] = 0;
-            result = (const gunichar **) bsearch (buf, simp_to_trad,
-                                            G_N_ELEMENTS (simp_to_trad), sizeof (simp_to_trad[0]),
-                                            _cmp);
+            result = (const gunichar **) std::bsearch (buf, simp_to_trad,
+                                                G_N_ELEMENTS (simp_to_trad), sizeof (simp_to_trad[0]),
+                                                _cmp);
             if (G_UNLIKELY (result != NULL))
                 break;
         }