summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-02-17 09:37:17 +0800
committerPeng Wu <alexepico@gmail.com>2013-02-17 09:37:17 +0800
commit0763b3456c64f52c710636af63de5bdc6a836753 (patch)
treeb903ead40c7d01c2c1ba47573609f0c8f571df4c
parent47f65d95f3e003f415a47b586bd35cb3662c6f73 (diff)
downloadibus-libpinyin-0763b3456c64f52c710636af63de5bdc6a836753.tar.gz
ibus-libpinyin-0763b3456c64f52c710636af63de5bdc6a836753.tar.xz
ibus-libpinyin-0763b3456c64f52c710636af63de5bdc6a836753.zip
fixes code style
-rw-r--r--src/PYLibPinyin.cc40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/PYLibPinyin.cc b/src/PYLibPinyin.cc
index 62efd4b..d2cb5d1 100644
--- a/src/PYLibPinyin.cc
+++ b/src/PYLibPinyin.cc
@@ -243,10 +243,10 @@ LibPinyinBackEnd::modified (void)
}
gboolean
-LibPinyinBackEnd::importPinyinDictionary(const char * filename)
+LibPinyinBackEnd::importPinyinDictionary (const char * filename)
{
/* user phrase library should be already loaded here. */
- FILE * dictfile = fopen(filename, "r");
+ FILE * dictfile = fopen (filename, "r");
if (NULL == dictfile)
return FALSE;
@@ -257,16 +257,16 @@ LibPinyinBackEnd::importPinyinDictionary(const char * filename)
return FALSE;
char* linebuf = NULL; size_t size = 0; ssize_t read;
- while ((read = getline(&linebuf, &size, dictfile)) != -1) {
- if (0 == strlen(linebuf))
+ while ((read = getline (&linebuf, &size, dictfile)) != -1) {
+ if (0 == strlen (linebuf))
continue;
- if ( '\n' == linebuf[strlen(linebuf) - 1] ) {
- linebuf[strlen(linebuf) - 1] = '\0';
+ if ( '\n' == linebuf[strlen (linebuf) - 1] ) {
+ linebuf[strlen (linebuf) - 1] = '\0';
}
- gchar ** items = g_strsplit_set(linebuf, " \t", 3);
- guint len = g_strv_length(items);
+ gchar ** items = g_strsplit_set (linebuf, " \t", 3);
+ guint len = g_strv_length (items);
gchar * phrase = NULL, * pinyin = NULL;
gint count = -1;
@@ -274,28 +274,32 @@ LibPinyinBackEnd::importPinyinDictionary(const char * filename)
phrase = items[0];
pinyin = items[1];
if (3 == len)
- count = atoi(items[2]);
+ count = atoi (items[2]);
} else
continue;
- pinyin_iterator_add_phrase(iter, phrase, pinyin, count);
+ pinyin_iterator_add_phrase (iter, phrase, pinyin, count);
}
- pinyin_end_add_phrases(iter);
- fclose(dictfile);
+ pinyin_end_add_phrases (iter);
+ fclose (dictfile);
+
+ pinyin_save (m_pinyin_context);
+ return TRUE;
}
gboolean
LibPinyinBackEnd::clearPinyinUserData (const char * target)
{
- if (0 == strcmp("all", target))
- pinyin_mask_out(m_pinyin_context, 0x0, 0x0);
- else if (0 == strcmp("user", target))
- pinyin_mask_out(m_pinyin_context, PHRASE_INDEX_LIBRARY_MASK,
- PHRASE_INDEX_MAKE_TOKEN(15, null_token));
+ if (0 == strcmp ("all", target))
+ pinyin_mask_out (m_pinyin_context, 0x0, 0x0);
+ else if (0 == strcmp ("user", target))
+ pinyin_mask_out (m_pinyin_context, PHRASE_INDEX_LIBRARY_MASK,
+ PHRASE_INDEX_MAKE_TOKEN (15, null_token));
else
- g_warning("unknown clear target: %s.\n", target);
+ g_warning ("unknown clear target: %s.\n", target);
+ pinyin_save (m_pinyin_context);
return TRUE;
}