fixes utils helper
authorPeng Wu <alexepico@gmail.com>
Fri, 19 Oct 2012 05:44:33 +0000 (13:44 +0800)
committerPeng Wu <alexepico@gmail.com>
Fri, 19 Oct 2012 05:55:12 +0000 (13:55 +0800)
utils/segment/spseg.cpp
utils/utils_helper.h

index 073a3d8..b7d6176 100644 (file)
@@ -196,7 +196,7 @@ int main(int argc, char * argv[]){
         for ( glong i = 0; i < strings->len; ++i ) {
             SegmentStep * step = &g_array_index(strings, SegmentStep, i);
             char * string = g_ucs4_to_utf8( step->m_phrase, step->m_phrase_len, NULL, NULL, NULL);
-            printf("%s\n", string);
+            printf("%d %s\n", step->m_handle, string);
             g_free(string);
         }
 
index 520c14f..6a90cce 100644 (file)
 
 #define TAGLIB_PARSE_SEGMENTED_LINE(phrase_index, var, line)            \
     phrase_token_t var = null_token;                                    \
-    {                                                                   \
+    do {                                                                \
+        if (0 == strlen(line))                                          \
+            break;                                                      \
+                                                                        \
         gchar ** strs = g_strsplit_set(line, " \t", 2);                 \
-        assert(2 == g_strv_length(strs));                               \
+        if (2 != g_strv_length(strs))                                   \
+            assert(false);                                              \
                                                                         \
         phrase_token_t token = atoi(strs[0]);                           \
         const char * phrase = strs[1];                                  \
@@ -63,7 +67,7 @@
         var = token;                                                    \
                                                                         \
         g_strfreev(strs);                                               \
-    }
+    } while(false);
 
 
 static bool load_phrase_index(FacadePhraseIndex * phrase_index) {