+2018-06-19 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ * configure.ac:
+ - Bump library revision to reflect code changes.
+
+ * NEWS:
+ === Version 0.2.12 ===
+
+2018-06-19 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ Use HTTPS in URL
+
+ * README:
+ - Update document URL to HTTPS
+
+2018-06-14 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ Cast (wchar_t *) to fix warnings in tests
+
+ "%ls" printf() format requires (wchar_t *) [aka int *] arg.
+ So, let's cast (AlphaChar *) [aka unsigned int *] to satisfy it.
+
+ * tests/test_walk.c:
+ * tests/test_iterator.c:
+ * tests/test_store-retrieve.c:
+ * tests/test_file.c:
+ * tests/test_nonalpha.c:
+ * tests/test_null_trie.c:
+ - Add <wchar.h> include, for wchar_t type
+ - Cast "%ls" args from (AlphaChar *) to (wchar_t *)
+
+2018-06-06 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ Avoid non-ANSI C snprintf()
+
+ * tools/trietool.c (+full_path, prepare_trie, close_trie):
+ - Instead of preparing full path name with snprintf(), which is
+ non-ANSI, and still risks path name trimming, do it with
+ size-calculated malloc().
+ - free() it as needed.
+
+2018-06-04 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ Fix sscanf() string format
+
+ * tools/trietool.c (prepare_trie):
+ - Define b, e as unsigned int, as required by "%x" format.
+ Fixing warning from '-Wformat=' gcc option.
+
+2018-06-04 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ Fix compiler warnings in tests
+
+ * tests/test_byte_alpha.c (main):
+ * tests/test_file.c (main):
+ * tests/test_iterator.c (main):
+ * tests/test_nonalpha.c (main):
+ * tests/test_null_trie.c (main):
+ * tests/test_store-retrieve.c (main):
+ * tests/test_term_state.c (main):
+ * tests/test_walk.c (main):
+ - Declare main function with 'main (void)'.
+ Fixing warning from '-Wstrict-prototypes' gcc option.
+ * tests/test_walk.c (main):
+ - Split long string, which required C90 compilers.
+ Fixing warning from '-Woverlength-strings' gcc option.
+
+2018-06-04 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ Duplicate TrieChar string in more portable manner
+
+ * datrie/tail.c (tail_set_suffix, +tc_strdup, +tc_strlen):
+ - Replace cast strdup() with crafted implementation,
+ allowing TrieChar to be of larger size than char.
+ Fixing warning from '-Wint-to-pointer-cast' gcc option.
+
+2018-06-04 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ Split long string
+
+ * tools/trietool.c (usage):
+ - Split help message which was too long and required C90 compiler.
+ Caught by '-Woverlength-strings' gcc option.
+
+2018-06-04 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ Remove unused byte, word, dword typedefs
+
+ These are likely to conflict with other uses.
+
+ * datrie/typedefs.h (-byte, -word, -dword):
+ - Remove the unused typedefs
+
+ Thanks Peter Moulder for the patch.
+
+2018-06-04 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ Rename TRUE/FALSE in Bool enum to avoid clash
+
+ Some other header file may have already define TRUE/FALSE.
+
+ * datrie/typedefs.h (Bool):
+ - Rename FALSE, TRUE to DA_FALSE, DA_TRUE respectively,
+ and define FALSE, TRUE macros only if they haven't been defined.
+
+ Thanks Peter Moulder for the patch.
+
+2018-06-04 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ Declare argument-less functions with "(void)"
+
+ "f()" declaration form is K&R style, specifying that no information
+ about the number or types of parameters is supplied. This caused
+ warnings on '-Wstrict-prototypes' gcc option.
+
+ * datrie/alpha-map.h, datrie/alpha-map.c (alpha_map_new):
+ * datrie/darray.h, datrie/darray.c (da_new, symbols_new):
+ * datrie/tail.h, datrie/tail.c (tail_new):
+ * tests/utils.h, tests/utils.c (en_alpha_map_new, en_trie_new):
+ - Use "(void)" form in declaration
+ - Also use "(void)" form in definition, for consistency
+
+ Thanks Peter Moulder for the initial patch.
+
+2018-05-24 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ Remove duplicate include
+
+ * tools/trietool.c:
+ - Remove duplicate include <config.h>
+
+2018-04-23 Theppitak Karoonboonyanan <theppitak@gmail.com>
+
+ Add missing include in test
+
+ * tests/test_byte_alpha.c:
+ - Add missing include for utils.h
+
2018-04-23 Theppitak Karoonboonyanan <theppitak@gmail.com>
* configure.ac:
libdatrie
+0.2.12 (2018-06-19)
+======
+- More C90 (ANSI C) compliance.
+ (Thanks Peter Moulder for the patch)
+- Prevent some compiling conflicts with other sources.
+ (Thanks Peter Moulder for the patch)
+- Fix miscellaneous compiler warnings.
+- Prevent trimming on extremely long dictionary path names.
+
0.2.11 (2018-04-23)
======
- Detect iconv() error more correctly in trietool.
dictionaries.
See the details of the implementation at [2]:
- http://linux.thai.net/~thep/datrie/datrie.html
+ https://linux.thai.net/~thep/datrie/datrie.html
Historically, this was first implemented as C++ classes in a library called
midatrie [2], but later simplified and rewritten from scratch in C.
(Sep 1989). pp. 1066-1077.
[2] Karoonboonyanan, T. "An Implementation of Double-Array Trie".
- http://linux.thai.net/~thep/datrie/datrie.html
+ https://linux.thai.net/~thep/datrie/datrie.html
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libdatrie 0.2.11.
+# Generated by GNU Autoconf 2.69 for libdatrie 0.2.12.
#
# Report bugs to <theppitak@gmail.com>.
#
# Identity of this package.
PACKAGE_NAME='libdatrie'
PACKAGE_TARNAME='libdatrie'
-PACKAGE_VERSION='0.2.11'
-PACKAGE_STRING='libdatrie 0.2.11'
+PACKAGE_VERSION='0.2.12'
+PACKAGE_STRING='libdatrie 0.2.12'
PACKAGE_BUGREPORT='theppitak@gmail.com'
PACKAGE_URL=''
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libdatrie 0.2.11 to adapt to many kinds of systems.
+\`configure' configures libdatrie 0.2.12 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libdatrie 0.2.11:";;
+ short | recursive ) echo "Configuration of libdatrie 0.2.12:";;
esac
cat <<\_ACEOF
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-libdatrie configure 0.2.11
+libdatrie configure 0.2.12
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libdatrie $as_me 0.2.11, which was
+It was created by libdatrie $as_me 0.2.12, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
# Define the identity of the package.
PACKAGE='libdatrie'
- VERSION='0.2.11'
+ VERSION='0.2.12'
cat >>confdefs.h <<_ACEOF
# Interfaces added: CURRENT++ REVISION=0 AGE++
# Interfaces changed/removed: CURRENT++ REVISION=0 AGE=0
LT_CURRENT=4
-LT_REVISION=4
+LT_REVISION=5
LT_AGE=3
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by libdatrie $as_me 0.2.11, which was
+This file was extended by libdatrie $as_me 0.2.12, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-libdatrie config.status 0.2.11
+libdatrie config.status 0.2.12
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
# Interfaces added: CURRENT++ REVISION=0 AGE++
# Interfaces changed/removed: CURRENT++ REVISION=0 AGE=0
LT_CURRENT=4
-LT_REVISION=4
+LT_REVISION=5
LT_AGE=3
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
* The created object must be freed with alpha_map_free().
*/
AlphaMap *
-alpha_map_new ()
+alpha_map_new (void)
{
AlphaMap *alpha_map;
*/
typedef struct _AlphaMap AlphaMap;
-AlphaMap * alpha_map_new ();
+AlphaMap * alpha_map_new (void);
AlphaMap * alpha_map_clone (const AlphaMap *a_map);
TrieChar symbols[TRIE_CHAR_MAX + 1];
};
-static Symbols * symbols_new ();
+static Symbols * symbols_new (void);
static void symbols_add (Symbols *syms, TrieChar c);
#define symbols_add_fast(s,c) ((s)->symbols[(s)->num_symbols++] = c)
*------------------------------------*/
static Symbols *
-symbols_new ()
+symbols_new (void)
{
Symbols *syms;
* Create a new empty doubla-array object.
*/
DArray *
-da_new ()
+da_new (void)
{
DArray *d;
typedef struct _DArray DArray;
-DArray * da_new ();
+DArray * da_new (void);
DArray * da_fread (FILE *file);
* Create a new empty tail object.
*/
Tail *
-tail_new ()
+tail_new (void)
{
Tail *t;
return LIKELY (index < t->num_tails) ? t->tails[index].suffix : NULL;
}
+static size_t
+tc_strlen (const TrieChar *str)
+{
+ size_t len = 0;
+ while (*str++) {
+ ++len;
+ }
+ return len;
+}
+
+static TrieChar *
+tc_strdup (const TrieChar *str)
+{
+ TrieChar *dup
+ = (TrieChar *) malloc (sizeof (TrieChar) * (tc_strlen (str) + 1));
+ TrieChar *p = dup;
+
+ while (*str) {
+ *p++ = *str++;
+ }
+ *p = (TrieChar) 0;
+
+ return dup;
+}
+
/**
* @brief Set suffix of existing entry
*
*/
TrieChar *tmp = NULL;
if (suffix) {
- tmp = (TrieChar *) strdup ((const char *)suffix);
+ tmp = tc_strdup (suffix);
if (UNLIKELY (!tmp))
return FALSE;
}
*/
typedef struct _Tail Tail;
-Tail * tail_new ();
+Tail * tail_new (void);
Tail * tail_fread (FILE *file);
#include <limits.h>
-typedef enum { FALSE = 0, TRUE = 1 } Bool;
+typedef enum { DA_FALSE = 0, DA_TRUE = 1 } Bool;
+#ifndef FALSE
+# define FALSE DA_FALSE
+#endif
+#ifndef TRUE
+# define TRUE DA_TRUE
+#endif
# if UCHAR_MAX == 0xff
# ifndef UINT8_TYPEDEF
# error "int32 type is undefined!"
# endif
-typedef uint8 byte;
-typedef uint16 word;
-typedef uint32 dword;
-
#endif /* __TYPEDEFS_H */
*/
#include <datrie/trie.h>
+#include "utils.h"
#include <stdio.h>
#include <stdlib.h>
#define TEST_DATA 255
int
-main ()
+main (void)
{
AlphaMap *alpha_map;
Trie *test_trie;
#include <datrie/trie.h>
#include "utils.h"
#include <stdio.h>
+#include <wchar.h>
#include <unistd.h>
#define TRIE_FILENAME "test.tri"
src_data = dict_src_get_data (key);
if (TRIE_DATA_ERROR == src_data) {
- printf ("Extra entry in file: key '%ls', data %d.\n", key, key_data);
+ printf ("Extra entry in file: key '%ls', data %d.\n",
+ (wchar_t *)key, key_data);
*is_failed = TRUE;
} else if (src_data != key_data) {
printf ("Data mismatch for: key '%ls', expected %d, got %d.\n",
- key, src_data, key_data);
+ (wchar_t *)key, src_data, key_data);
*is_failed = TRUE;
} else {
dict_src_set_data (key, TRIE_DATA_READ);
}
int
-main ()
+main (void)
{
Trie *test_trie;
DictRec *dict_p;
for (dict_p = dict_src; dict_p->key; dict_p++) {
if (!trie_store (test_trie, dict_p->key, dict_p->data)) {
printf ("Failed to add key '%ls', data %d.\n",
- dict_p->key, dict_p->data);
+ (wchar_t *)dict_p->key, dict_p->data);
goto err_trie_created;
}
}
for (dict_p = dict_src; dict_p->key; dict_p++) {
if (dict_p->data != TRIE_DATA_READ) {
printf ("Entry missed in file: key '%ls', data %d.\n",
- dict_p->key, dict_p->data);
+ (wchar_t *)dict_p->key, dict_p->data);
is_failed = TRUE;
}
}
#include "utils.h"
#include <stdio.h>
#include <stdlib.h>
+#include <wchar.h>
int
-main ()
+main (void)
{
Trie *test_trie;
DictRec *dict_p;
for (dict_p = dict_src; dict_p->key; dict_p++) {
if (!trie_store (test_trie, dict_p->key, dict_p->data)) {
printf ("Failed to add key '%ls', data %d.\n",
- dict_p->key, dict_p->data);
+ (wchar_t *)dict_p->key, dict_p->data);
goto err_trie_created;
}
}
key_data = trie_iterator_get_data (trie_it);
if (TRIE_DATA_ERROR == key_data) {
printf ("Failed to get data from trie iterator for key '%ls'\n",
- key);
+ (wchar_t *)key);
is_failed = TRUE;
}
/* mark entries found in trie */
src_data = dict_src_get_data (key);
if (TRIE_DATA_ERROR == src_data) {
printf ("Extra entry in trie: key '%ls', data %d.\n",
- key, key_data);
+ (wchar_t *)key, key_data);
is_failed = TRUE;
} else if (src_data != key_data) {
printf ("Data mismatch for: key '%ls', expected %d, got %d.\n",
- key, src_data, key_data);
+ (wchar_t *)key, src_data, key_data);
is_failed = TRUE;
} else {
dict_src_set_data (key, TRIE_DATA_READ);
for (dict_p = dict_src; dict_p->key; dict_p++) {
if (dict_p->data != TRIE_DATA_READ) {
printf ("Entry missed in trie: key '%ls', data %d.\n",
- dict_p->key, dict_p->data);
+ (wchar_t *)dict_p->key, dict_p->data);
is_failed = TRUE;
}
}
#include <datrie/trie.h>
#include "utils.h"
#include <stdio.h>
+#include <wchar.h>
const AlphaChar *nonalpha_src[] = {
(AlphaChar *)L"a6acus",
};
int
-main ()
+main (void)
{
Trie *test_trie;
DictRec *dict_p;
for (dict_p = dict_src; dict_p->key; dict_p++) {
if (!trie_store (test_trie, dict_p->key, dict_p->data)) {
printf ("Failed to add key '%ls', data %d.\n",
- dict_p->key, dict_p->data);
+ (wchar_t *)dict_p->key, dict_p->data);
goto err_trie_created;
}
}
for (nonalpha_key = nonalpha_src; *nonalpha_key; nonalpha_key++) {
if (trie_retrieve (test_trie, *nonalpha_key, &trie_data)) {
printf ("False duplication on key '%ls', with existing data %d.\n",
- *nonalpha_key, trie_data);
+ (wchar_t *)*nonalpha_key, trie_data);
is_fail = TRUE;
}
if (trie_store (test_trie, *nonalpha_key, TRIE_DATA_UNREAD)) {
printf ("Wrongly added key '%ls' containing non-alphanet char\n",
- *nonalpha_key);
+ (wchar_t *)*nonalpha_key);
is_fail = TRUE;
}
}
#include <datrie/trie.h>
#include "utils.h"
#include <stdio.h>
+#include <wchar.h>
#include <stdlib.h>
int
-main ()
+main (void)
{
Trie *test_trie;
TrieState *trie_root_state;
key = trie_iterator_get_key (trie_it);
if (key) {
printf ("Got key from empty trie, which is weird! (key='%ls')\n",
- key);
+ (wchar_t *)key);
is_failed = TRUE;
free (key);
}
#include <datrie/trie.h>
#include "utils.h"
#include <stdio.h>
+#include <wchar.h>
#include <stdlib.h>
#include <time.h>
int
-main ()
+main (void)
{
Trie *test_trie;
DictRec *dict_p;
for (dict_p = dict_src; dict_p->key; dict_p++) {
if (!trie_store (test_trie, dict_p->key, dict_p->data)) {
printf ("Failed to add key '%ls', data %d.\n",
- dict_p->key, dict_p->data);
+ (wchar_t *)dict_p->key, dict_p->data);
goto err_trie_created;
}
}
is_failed = FALSE;
for (dict_p = dict_src; dict_p->key; dict_p++) {
if (!trie_retrieve (test_trie, dict_p->key, &trie_data)) {
- printf ("Failed to retrieve key '%ls'.\n", dict_p->key);
+ printf ("Failed to retrieve key '%ls'.\n", (wchar_t *)dict_p->key);
is_failed = TRUE;
}
if (trie_data != dict_p->data) {
printf ("Wrong data for key '%ls'; expected %d, got %d.\n",
- dict_p->key, dict_p->data, trie_data);
+ (wchar_t *)dict_p->key, dict_p->data, trie_data);
is_failed = TRUE;
}
}
i = rand () % n_entries;
} while (TRIE_DATA_READ == dict_src[i].data);
- printf ("Deleting '%ls'\n", dict_src[i].key);
+ printf ("Deleting '%ls'\n", (wchar_t *)dict_src[i].key);
if (!trie_delete (test_trie, dict_src[i].key)) {
- printf ("Failed to delete '%ls'\n", dict_src[i].key);
+ printf ("Failed to delete '%ls'\n", (wchar_t *)dict_src[i].key);
is_failed = TRUE;
}
dict_src[i].data = TRIE_DATA_READ;
continue;
if (!trie_retrieve (test_trie, dict_p->key, &trie_data)) {
- printf ("Failed to retrieve key '%ls'.\n", dict_p->key);
+ printf ("Failed to retrieve key '%ls'.\n", (wchar_t *)dict_p->key);
is_failed = TRUE;
}
if (trie_data != dict_p->data) {
printf ("Wrong data for key '%ls'; expected %d, got %d.\n",
- dict_p->key, dict_p->data, trie_data);
+ (wchar_t *)dict_p->key, dict_p->data, trie_data);
is_failed = TRUE;
}
}
key_data = trie_iterator_get_data (trie_it);
if (TRIE_DATA_ERROR == key_data) {
printf ("Failed to get data from trie iterator for key '%ls'\n",
- key);
+ (wchar_t *)key);
is_failed = TRUE;
}
/* mark entries found in trie */
src_data = dict_src_get_data (key);
if (TRIE_DATA_ERROR == src_data) {
printf ("Extra entry in trie: key '%ls', data %d.\n",
- key, key_data);
+ (wchar_t *)key, key_data);
is_failed = TRUE;
} else if (src_data != key_data) {
printf ("Data mismatch for: key '%ls', expected %d, got %d.\n",
- key, src_data, key_data);
+ (wchar_t *)key, src_data, key_data);
is_failed = TRUE;
} else {
dict_src_set_data (key, TRIE_DATA_READ);
for (dict_p = dict_src; dict_p->key; dict_p++) {
if (dict_p->data != TRIE_DATA_READ) {
printf ("Entry missed in trie: key '%ls', data %d.\n",
- dict_p->key, dict_p->data);
+ (wchar_t *)dict_p->key, dict_p->data);
is_failed = TRUE;
}
}
*
*/
int
-main ()
+main (void)
{
Trie *test_trie;
TrieState *trie_state;
#include <datrie/trie.h>
#include "utils.h"
#include <stdio.h>
+#include <wchar.h>
/*
* Sample trie in http://linux.thai.net/~thep/datrie/datrie.html
#define ALPHABET_SIZE 256
int
-main ()
+main (void)
{
Trie *test_trie;
DictRec *dict_p;
for (dict_p = walk_dict; dict_p->key; dict_p++) {
if (!trie_store (test_trie, dict_p->key, dict_p->data)) {
printf ("Failed to add key '%ls', data %d.\n",
- dict_p->key, dict_p->data);
+ (wchar_t *)dict_p->key, dict_p->data);
goto err_trie_created;
}
}
printf (
"Now the trie structure is supposed to be:\n"
"\n"
+ );
+ printf (
" +---o-> (3) -o-> (4) -l-> [5]\n"
" |\n"
" | +---i-> (7) -z-> (8) -e-> [9]\n"
* Trie creation helpers *
*-------------------------*/
static AlphaMap *
-en_alpha_map_new ()
+en_alpha_map_new (void)
{
AlphaMap *en_map;
}
Trie *
-en_trie_new ()
+en_trie_new (void)
{
AlphaMap *en_map;
Trie *en_trie;
};
int
-dict_src_n_entries ()
+dict_src_n_entries (void)
{
return sizeof (dict_src) / sizeof (dict_src[0]) - 1;
}
/*-------------------------*
* Trie creation helpers *
*-------------------------*/
-Trie * en_trie_new ();
+Trie * en_trie_new (void);
/*---------------------------*
* Dict source for testing *
extern DictRec dict_src[];
-int dict_src_n_entries ();
+int dict_src_n_entries (void);
TrieData dict_src_get_data (const AlphaChar *key);
int dict_src_set_data (const AlphaChar *key, TrieData data);
#include <assert.h>
-#include <config.h>
#include <datrie/trie.h>
/* iconv encoding name for AlphaChar string */
iconv_close (env->from_alpha_conv);
}
+static char *
+full_path (const char *path, const char *name, const char *ext)
+{
+ int full_size = strlen (path) + strlen (name) + strlen (ext) + 2;
+ char *full_path_buff = (char *) malloc (full_size);
+ sprintf (full_path_buff, "%s/%s%s", path, name, ext);
+ return full_path_buff;
+}
+
static int
prepare_trie (ProgEnv *env)
{
char buff[256];
+ char *path_name;
- snprintf (buff, sizeof (buff),
- "%s/%s.tri", env->path, env->trie_name);
- env->trie = trie_new_from_file (buff);
+ path_name = full_path (env->path, env->trie_name, ".tri");
+ env->trie = trie_new_from_file (path_name);
+ free (path_name);
if (!env->trie) {
FILE *sbm;
AlphaMap *alpha_map;
- snprintf (buff, sizeof (buff),
- "%s/%s.abm", env->path, env->trie_name);
- sbm = fopen (buff, "r");
+ path_name = full_path (env->path, env->trie_name, ".abm");
+ sbm = fopen (path_name, "r");
if (!sbm) {
- fprintf (stderr, "Cannot open alphabet map file %s\n", buff);
+ fprintf (stderr, "Cannot open alphabet map file %s\n", path_name);
+ free (path_name);
return -1;
}
+ free (path_name);
alpha_map = alpha_map_new ();
while (fgets (buff, sizeof (buff), sbm)) {
- int b, e;
+ unsigned int b, e;
/* read the range
* format: [b,e]
close_trie (ProgEnv *env)
{
if (trie_is_dirty (env->trie)) {
- char path[256];
-
- snprintf (path, sizeof (path),
- "%s/%s.tri", env->path, env->trie_name);
+ char *path = full_path (env->path, env->trie_name, ".tri");
if (trie_save (env->trie, path) != 0) {
fprintf (stderr, "Cannot save trie to %s\n", path);
+ free (path);
return -1;
}
+ free (path);
}
trie_free (env->trie);
{
printf ("%s - double-array trie manipulator\n", prog_name);
printf ("Usage: %s [OPTION]... TRIE CMD ARG ...\n", prog_name);
+ printf ("Options:\n");
printf (
- "Options:\n"
" -p, --path DIR set trie directory to DIR [default=.]\n"
+ );
+ printf (
" -h, --help display this help and exit\n"
+ );
+ printf (
" -V, --version output version information and exit\n"
- "\n"
- "Commands:\n"
+ );
+ printf ("\n");
+ printf ("Commands:\n");
+ printf (
" add WORD DATA ...\n"
" Add WORD with DATA to trie\n"
+ );
+ printf (
" add-list [OPTION] LISTFILE\n"
" Add words and data listed in LISTFILE to trie\n"
" Options:\n"
" -e, --encoding ENC specify character encoding of LISTFILE\n"
+ );
+ printf (
" delete WORD ...\n"
" Delete WORD from trie\n"
+ );
+ printf (
" delete-list [OPTION] LISTFILE\n"
" Delete words listed in LISTFILE from trie\n"
" Options:\n"
" -e, --encoding ENC specify character encoding of LISTFILE\n"
+ );
+ printf (
" query WORD\n"
" Query WORD data from trie\n"
+ );
+ printf (
" list\n"
" List all words in trie\n"
);