summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchenxiajian <chenxiajian1985@gmail.com>2011-08-11 15:34:59 +0000
committerchenxiajian <chenxiajian1985@gmail.com>2011-08-11 15:34:59 +0000
commited989817528a088940a38c817797569fb0fb9625 (patch)
treece0c80980cbccb51dd8bbca95073fd5431b173dd
parent64c70b0e4a5fd3429bbd153a2adcc964cd61438a (diff)
downloadenchant-ed989817528a088940a38c817797569fb0fb9625.tar.gz
enchant hyphenation test in enchant-ispell.c
git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/branches/gsoc2011hyphenation@30163 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
-rw-r--r--tests/enchant-ispell.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/enchant-ispell.c b/tests/enchant-ispell.c
index 639d74b..9b1a83b 100644
--- a/tests/enchant-ispell.c
+++ b/tests/enchant-ispell.c
@@ -57,7 +57,8 @@ typedef enum
MODE_NONE,
MODE_VERSION,
MODE_A,
- MODE_L
+ MODE_L,
+ MODE_H
} IspellMode_t;
static void
@@ -75,6 +76,7 @@ print_help (FILE * to, const char * prog)
fprintf (to, "\t-d dict uses dictionary <dict>.\n");
fprintf (to, "\t-l lists misspellings.\n");
fprintf (to, "\t-m is ignored.\n");
+ fprintf (to, "\t-h list hyphenation result.\n");
fprintf (to, "\t-L displays line numbers.\n");
fprintf (to, "\t-v displays program version.\n");
}
@@ -186,6 +188,21 @@ do_mode_l (FILE * out, EnchantDict * dict, GString * word, size_t lineCount)
}
}
+static void
+do_mode_h (FILE * out, EnchantDict * dict, GString * word, size_t lineCount)
+{
+ char* result=enchant_dict_hyphenate(dict,word->str,word->len);
+ if (result != NULL) {
+ print_utf (out, result);
+ fwrite ("\n", 1, 1, out);
+ }
+ else
+ {
+ print_utf (out, "not find!");
+ fwrite ("\n", 1, 1, out);
+ }
+}
+
static int
is_word_char (gunichar uc, size_t n)
@@ -431,6 +448,8 @@ parse_file (FILE * in, FILE * out, IspellMode_t mode, int countLines, gchar *dic
do_mode_a (out, dict, word, pos, lineCount);
else if (mode == MODE_L)
do_mode_l (out, dict, word, lineCount);
+ else if (mode == MODE_H)
+ do_mode_h (out, dict, word, lineCount);
g_string_free(word, TRUE);
}
@@ -477,6 +496,8 @@ int main (int argc, char ** argv)
mode = MODE_A;
else if (arg[1] == 'l' && MODE_NONE == mode)
mode = MODE_L;
+ else if (arg[1] == 'h' && MODE_NONE == mode)
+ mode = MODE_H;
else if (arg[1] == 'v' && MODE_NONE == mode)
mode = MODE_VERSION;
else if (arg[1] == 'L' && MODE_NONE == mode)