fixes compile
authorPeng Wu <alexepico@gmail.com>
Mon, 8 Apr 2013 03:52:24 +0000 (11:52 +0800)
committerPeng Wu <alexepico@gmail.com>
Mon, 8 Apr 2013 03:55:01 +0000 (11:55 +0800)
src/include/novel_types.h
src/storage/Makefile.am
src/storage/phrase_index.cpp
src/storage/phrase_index.h
src/storage/table_info.cpp
src/storage/table_info.h

index 6dcacb7..0ef845f 100644 (file)
@@ -147,17 +147,6 @@ typedef enum {
     GB_DICTIONARY = 1,
     GBK_DICTIONARY = 2,
     MERGED_DICTIONARY = 3,
-    ART_DICTIONARY,
-    CULTURE_DICTIONARY,
-    ECONOMY_DICTIONARY,
-    GEOLOGY_DICTIONARY,
-    HISTORY_DICTIONARY,
-    LIFE_DICTIONARY,
-    NATURE_DICTIONARY,
-    SCITECH_DICTIONARY,
-    SOCIETY_DICTIONARY,
-    SPORT_DICTIONARY,
-    RESERVED1,
     USER_DICTIONARY = 15
 } PHRASE_INDEX_LIBRARIES;
 
index 8e78568..d805f18 100644 (file)
@@ -39,7 +39,8 @@ noinst_HEADERS                = chewing_enum.h \
                          pinyin_phrase2.h \
                          chewing_large_table.h \
                          facade_chewing_table.h \
-                         facade_phrase_table2.h
+                         facade_phrase_table2.h \
+                         table_info.h
 
 
 noinst_LTLIBRARIES      = libstorage.la
@@ -53,5 +54,6 @@ libstorage_la_SOURCES    = phrase_index.cpp \
                           ngram.cpp \
                           tag_utility.cpp \
                           pinyin_parser2.cpp \
-                          chewing_large_table.cpp
+                          chewing_large_table.cpp \
+                          table_info.cpp
 
index c462fef..5f468b3 100644 (file)
@@ -699,30 +699,6 @@ bool FacadePhraseIndex::mask_out(guint8 phrase_index,
 }
 
 namespace pinyin{
-const pinyin_table_info_t pinyin_phrase_files[PHRASE_INDEX_LIBRARY_COUNT] =
-    {
-        {RESERVED, NULL, NULL, NULL, NOT_USED},
-        {GB_DICTIONARY, "gb_char.table", "gb_char.bin", "gb_char.dbin", SYSTEM_FILE},
-        {GBK_DICTIONARY, "gbk_char.table", "gbk_char.bin", "gbk_char.dbin", SYSTEM_FILE},
-
-        {MERGED_DICTIONARY, "merged.table", "merged.bin", "merged.dbin", SYSTEM_FILE},
-
-        {ART_DICTIONARY, "art.table", "art.bin", "art.dbin", DICTIONARY},
-        {CULTURE_DICTIONARY, "culture.table", "culture.bin", "culture.dbin", DICTIONARY},
-        {ECONOMY_DICTIONARY, "economy.table", "economy.bin", "economy.dbin", DICTIONARY},
-        {GEOLOGY_DICTIONARY, "geology.table", "geology.bin", "geology.dbin", DICTIONARY},
-        {HISTORY_DICTIONARY, "history.table", "history.bin", "history.dbin", DICTIONARY},
-
-        {LIFE_DICTIONARY, "life.table", "life.bin", "life.dbin", DICTIONARY},
-        {NATURE_DICTIONARY, "nature.table", "nature.bin", "nature.dbin", DICTIONARY},
-        {SCITECH_DICTIONARY, "scitech.table", "scitech.bin", "scitech.dbin", DICTIONARY},
-        {SOCIETY_DICTIONARY, "society.table", "society.bin", "society.dbin", DICTIONARY},
-        {SPORT_DICTIONARY, "sport.table", "sport.bin", "sport.dbin", DICTIONARY},
-
-        {RESERVED1, NULL, NULL, NULL, NOT_USED},
-
-        {USER_DICTIONARY, NULL, NULL, "user.bin", USER_FILE}
-    };
 
 
 static bool _peek_header(PhraseIndexLogger * logger,
index 0ecfbec..e1dad0b 100644 (file)
@@ -831,23 +831,6 @@ public:
     }
 };
 
-typedef enum {
-    NOT_USED,                /* not used. */
-    SYSTEM_FILE,             /* system phrase file. */
-    DICTIONARY,              /* professional dictionary. */
-    USER_FILE,               /* user only phrase file. */
-} PHRASE_FILE_TYPE;
-
-typedef struct {
-    const guint8 m_dict_index; /* for assert purpose. */
-    const char * m_table_filename;
-    const char * m_system_filename;
-    const char * m_user_filename;
-    PHRASE_FILE_TYPE m_file_type;
-} pinyin_table_info_t;
-
-extern const pinyin_table_info_t pinyin_phrase_files[PHRASE_INDEX_LIBRARY_COUNT];
-
 PhraseIndexLogger * mask_out_phrase_index_logger
 (PhraseIndexLogger * oldlogger, phrase_token_t mask, phrase_token_t value);
 
index 12cd970..fd2d2f4 100644 (file)
@@ -22,6 +22,7 @@
 #include "table_info.h"
 #include <stdio.h>
 #include <assert.h>
+#include <string.h>
 
 using namespace pinyin;
 
@@ -67,12 +68,13 @@ void SystemTableInfo::reset() {
     for (i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
         pinyin_table_info_t * tableinfo = &m_table_info[i];
 
-        g_free(tableinfo->m_table_filename);
+        g_free((gchar *)tableinfo->m_table_filename);
         tableinfo->m_table_filename = NULL;
-        g_free(tableinfo->m_system_filename);
+        g_free((gchar *)tableinfo->m_system_filename);
         tableinfo->m_system_filename = NULL;
-        g_free(tableinfo->m_user_filename);
+        g_free((gchar *)tableinfo->m_user_filename);
         tableinfo->m_user_filename = NULL;
+
         tableinfo->m_file_type = NOT_USED;
     }
 }
@@ -80,7 +82,7 @@ void SystemTableInfo::reset() {
 void SystemTableInfo::postfix_tables() {
     size_t i;
     for (i = 0; i < G_N_ELEMENTS(reserved_tables); ++i) {
-        pinyin_table_info_t * postfix = &reserved_tables[i];
+        const pinyin_table_info_t * postfix = &reserved_tables[i];
 
         guint8 index = postfix->m_dict_index;
         pinyin_table_info_t * tableinfo = &m_table_info[index];
@@ -150,8 +152,8 @@ bool SystemTableInfo::load(const char * filename) {
 
     int index = 0;
     char tablefile[256], sysfile[256], userfile[256], filetype[256];
-    while (!feof(infile)){
-        num = fscanf("%d %s %s %s %s",
+    while (!feof(input)) {
+        num = fscanf(input, "%d %s %s %s %s",
                      &index, tablefile, sysfile, userfile, filetype);
 
         if (5 != num)
@@ -164,11 +166,11 @@ bool SystemTableInfo::load(const char * filename) {
         pinyin_table_info_t * tableinfo = &m_table_info[index];
         assert(index == tableinfo->m_dict_index);
 
-        table_info->m_table_filename = to_string(tablefile);
-        table_info->m_system_filename = to_string(sysfile);
-        table_info->m_user_filename = to_string(userfile);
+        tableinfo->m_table_filename = to_string(tablefile);
+        tableinfo->m_system_filename = to_string(sysfile);
+        tableinfo->m_user_filename = to_string(userfile);
 
-        table_info->m_file_type = to_file_type(filetype);
+        tableinfo->m_file_type = to_file_type(filetype);
     }
 
     fclose(input);
@@ -197,7 +199,7 @@ void UserTableInfo::reset() {
     m_model_data_version = 0;
 }
 
-bool UserTableInfo::load(cosnt char * filename) {
+bool UserTableInfo::load(const char * filename) {
     reset();
 
     FILE * input = fopen(filename, "r");
@@ -231,7 +233,7 @@ bool UserTableInfo::load(cosnt char * filename) {
 bool UserTableInfo::save(const char * filename) {
     FILE * output = fopen(filename, "w");
     if (NULL == output) {
-        fprintf(stderr, "write %s failed.\n", output);
+        fprintf(stderr, "write %s failed.\n", filename);
         return false;
     }
 
index 8feee95..8d7fa05 100644 (file)
 #ifndef TABLE_INFO_H
 #define TABLE_INFO_H
 
+#include "novel_types.h"
+
+
 namespace pinyin{
 
+typedef enum {
+    NOT_USED,                /* not used. */
+    SYSTEM_FILE,             /* system phrase file. */
+    DICTIONARY,              /* professional dictionary. */
+    USER_FILE,               /* user only phrase file. */
+} PHRASE_FILE_TYPE;
+
+typedef struct {
+    guint8 m_dict_index; /* for assert purpose. */
+    const gchar * m_table_filename;
+    const gchar * m_system_filename;
+    const gchar * m_user_filename;
+    PHRASE_FILE_TYPE m_file_type;
+} pinyin_table_info_t;
+
+
 class UserTableInfo;
 
 class SystemTableInfo{