diff options
author | Choe Hwanjin <choe.hwanjin@gmail.com> | 2007-07-08 22:21:05 +0900 |
---|---|---|
committer | Choe Hwanjin <choe.hwanjin@gmail.com> | 2007-07-08 22:21:05 +0900 |
commit | 5734557afad4ec545852a0f861a5783756210ead (patch) | |
tree | 20d3286459c1a0fdbcc37daa8f79ddfb21931dda /test/hanja.c | |
parent | a07c2ed843a06748f6375bc87b4b116200fdc8be (diff) | |
download | libhangul-5734557afad4ec545852a0f861a5783756210ead.tar.gz |
hanja 테스트 코드 변경
git-svn-id: http://kldp.net/svn/hangul/libhangul/trunk@127 8f00fcd2-89fc-0310-932e-b01be5b65e01
Diffstat (limited to 'test/hanja.c')
-rw-r--r-- | test/hanja.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/test/hanja.c b/test/hanja.c index 1db3aff..129056c 100644 --- a/test/hanja.c +++ b/test/hanja.c @@ -5,18 +5,30 @@ int main(int argc, char *argv[]) { - HanjaTable *table = hanja_table_load(NULL); + char* hanja_table_file = NULL; + char buf[256] = { '\0', }; - HanjaList *list = hanja_table_match_prefix(table, argv[1]); + if (argc > 1) + hanja_table_file = argv[1]; - int i, n; - n = hanja_list_get_size(list); - for (i = 0; i < n; i++) { - const char* value = hanja_list_get_nth_value(list, i); - printf("%s\n", value); - } + HanjaTable *table = hanja_table_load(hanja_table_file); + + while (fgets(buf, sizeof(buf), stdin) != NULL) { + char* p = strchr(buf, '\n'); + if (p != NULL) + *p = '\0'; + + HanjaList *list = hanja_table_match_prefix(table, buf); - hanja_list_delete(list); + int i, n; + n = hanja_list_get_size(list); + for (i = 0; i < n; i++) { + const char* value = hanja_list_get_nth_value(list, i); + printf("%s\n", value); + } + + hanja_list_delete(list); + } hanja_table_delete(table); |