diff --git a/ChangeLog b/ChangeLog index 0a341cc..e602c8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2016-06-26 Theppitak Karoonboonyanan + + Use 'wc' prefix instead of suffix for wide-char word break APIs. + + To be consistent with other modules, wide-char APIs should be + prefixed, not suffixed with 'wc'. + + * include/thai/thwbrk.h: + * src/libthai.c: + * src/libthai.def: + * src/libthai.map: + * src/thwbrk/thwbrk.c: + * tests/test_thwbrk.c: + - Rename th_brk_find_breaks_wc() -> th_brk_wc_find_breaks(). + - Rename th_brk_insert_breaks_wc() -> th_brk_wc_insert_breaks(). + 2016-06-25 Theppitak Karoonboonyanan Rename the new APIs to be more meaningful. diff --git a/include/thai/thwbrk.h b/include/thai/thwbrk.h index 21528c9..26ff0cb 100644 --- a/include/thai/thwbrk.h +++ b/include/thai/thwbrk.h @@ -35,17 +35,17 @@ BEGIN_CDECL * @brief Thai wide-char word segmentation */ -extern int th_brk_find_breaks_wc(ThBrk *brk, const thwchar_t *s, +extern int th_brk_wc_find_breaks(ThBrk *brk, const thwchar_t *s, int pos[], size_t pos_sz); -extern int th_brk_insert_breaks_wc(ThBrk *brk, const thwchar_t *in, +extern int th_brk_wc_insert_breaks(ThBrk *brk, const thwchar_t *in, thwchar_t *out, size_t out_sz, const thwchar_t *delim); -TH_DEPRECATED_FOR(th_brk_find_breaks_wc) +TH_DEPRECATED_FOR(th_brk_wc_find_breaks) extern int th_wbrk(const thwchar_t *s, int pos[], size_t pos_sz); -TH_DEPRECATED_FOR(th_brk_insert_breaks_wc) +TH_DEPRECATED_FOR(th_brk_wc_insert_breaks) extern int th_wbrk_line(const thwchar_t *in, thwchar_t *out, size_t out_sz, const thwchar_t *delim); diff --git a/src/libthai.c b/src/libthai.c index 2e31103..8065c1f 100644 --- a/src/libthai.c +++ b/src/libthai.c @@ -57,7 +57,7 @@ * * th_brk_new(), th_brk_delete(), * th_brk_find_breaks(), th_brk_insert_breaks(), - * th_brk_find_breaks_wc(), th_brk_insert_breaks_wc(), + * th_brk_wc_find_breaks(), th_brk_wc_insert_breaks(), * th_brk(), th_brk_line(), th_wbrk(), th_wbrk_line() * * @subsection ThColl Functions for Thai string collation diff --git a/src/libthai.def b/src/libthai.def index b7cf54f..676140a 100644 --- a/src/libthai.def +++ b/src/libthai.def @@ -8,11 +8,11 @@ _th_ctype_tbl th_brk th_brk_delete th_brk_find_breaks -th_brk_find_breaks_wc th_brk_insert_breaks -th_brk_insert_breaks_wc th_brk_line th_brk_new +th_brk_wc_find_breaks +th_brk_wc_insert_breaks th_chlevel th_init_cell th_isaccept diff --git a/src/libthai.map b/src/libthai.map index 9f9392b..7838401 100644 --- a/src/libthai.map +++ b/src/libthai.map @@ -85,10 +85,10 @@ LIBTHAI_0.1.25 { global: th_brk_delete; th_brk_find_breaks; - th_brk_find_breaks_wc; th_brk_insert_breaks; - th_brk_insert_breaks_wc; th_brk_new; + th_brk_wc_find_breaks; + th_brk_wc_insert_breaks; local: *; } LIBTHAI_0.1.19; diff --git a/src/thwbrk/thwbrk.c b/src/thwbrk/thwbrk.c index 37e8222..9aa9b14 100644 --- a/src/thwbrk/thwbrk.c +++ b/src/thwbrk/thwbrk.c @@ -50,7 +50,7 @@ * (Available since version 0.1.25, libthai.so.0.3.0) */ int -th_brk_find_breaks_wc (ThBrk *brk, const thwchar_t *s, int pos[], size_t pos_sz) +th_brk_wc_find_breaks (ThBrk *brk, const thwchar_t *s, int pos[], size_t pos_sz) { thchar_t* tis_str; size_t alloc_size; @@ -88,7 +88,7 @@ th_brk_find_breaks_wc (ThBrk *brk, const thwchar_t *s, int pos[], size_t pos_sz) * (Available since version 0.1.25, libthai.so.0.3.0) */ int -th_brk_insert_breaks_wc (ThBrk *brk, const thwchar_t *in, +th_brk_wc_insert_breaks (ThBrk *brk, const thwchar_t *in, thwchar_t *out, size_t out_sz, const thwchar_t* delim) { @@ -104,7 +104,7 @@ th_brk_insert_breaks_wc (ThBrk *brk, const thwchar_t *in, if (!brk_pos) return 0; - n_brk_pos = th_brk_find_breaks_wc (brk, in, brk_pos, n_brk_pos); + n_brk_pos = th_brk_wc_find_breaks (brk, in, brk_pos, n_brk_pos); delim_len = wcslen (delim); for (i = j = 0, p_out = out; out_sz > 1 && i < n_brk_pos; i++) { @@ -143,12 +143,12 @@ th_brk_insert_breaks_wc (ThBrk *brk, const thwchar_t *in, * Uses the shared word breaker. * * (This function is deprecated since version 0.1.25, in favor of - * th_brk_find_breaks_wc(), which is more thread-safe.) + * th_brk_wc_find_breaks(), which is more thread-safe.) */ int th_wbrk (const thwchar_t *s, int pos[], size_t pos_sz) { - return th_brk_find_breaks_wc ((ThBrk *) NULL, s, pos, pos_sz); + return th_brk_wc_find_breaks ((ThBrk *) NULL, s, pos, pos_sz); } /** @@ -166,13 +166,13 @@ th_wbrk (const thwchar_t *s, int pos[], size_t pos_sz) * Uses the shared word breaker. * * (This function is deprecated since version 0.1.25, in favor of - * th_brk_insert_breaks_wc(), which is more thread-safe.) + * th_brk_wc_insert_breaks(), which is more thread-safe.) */ int th_wbrk_line (const thwchar_t *in, thwchar_t *out, size_t out_sz, const thwchar_t* delim ) { - return th_brk_insert_breaks_wc ((ThBrk *) NULL, in, out, out_sz, delim); + return th_brk_wc_insert_breaks ((ThBrk *) NULL, in, out, out_sz, delim); } /* diff --git a/tests/test_thwbrk.c b/tests/test_thwbrk.c index c7cd757..a1bbd58 100644 --- a/tests/test_thwbrk.c +++ b/tests/test_thwbrk.c @@ -35,8 +35,8 @@ int main (int argc, char* argv[]) printf ("Converting to Unicode...\n"); th_tis2uni_line (str, ustr, MAXLINELENGTH); - printf ("Calling th_brk_find_breaks_wc()...\n"); - numCut = th_brk_find_breaks_wc (brk, ustr, pos, MAXLINELENGTH); + printf ("Calling th_brk_wc_find_breaks()...\n"); + numCut = th_brk_wc_find_breaks (brk, ustr, pos, MAXLINELENGTH); printf ("Total %d cut points.", numCut); if (numCut > 0) { @@ -48,7 +48,7 @@ int main (int argc, char* argv[]) printf ("\n"); if (numCut != 7) { printf ("Error! Should have 7 cut points.\n" - "Test th_brk_find_breaks_wc() failed...\n"); + "Test th_brk_wc_find_breaks() failed...\n"); exit (-1); } @@ -59,16 +59,16 @@ int main (int argc, char* argv[]) (long)strlen (""), unicodeCutCodeLength); } - printf ("Calling th_brk_insert_breaks_wc() ....\n"); - outputLength = th_brk_insert_breaks_wc (brk, ustr, + printf ("Calling th_brk_wc_insert_breaks() ....\n"); + outputLength = th_brk_wc_insert_breaks (brk, ustr, (thwchar_t*) uout, MAXLINELENGTH, unicodeCutCode); - printf ("Return value from th_brk_insert_breaks_wc is %d\n", outputLength); + printf ("Return value from th_brk_wc_insert_breaks is %d\n", outputLength); printf ("Output string length is %ld\n", (long)wcslen(uout)); if (outputLength != 75) { printf ("Error! Output string length != 75. " - "Test th_brk_insert_breaks_wc() failed...\n"); + "Test th_brk_wc_insert_breaks() failed...\n"); exit (-1); } @@ -77,13 +77,13 @@ int main (int argc, char* argv[]) th_uni2tis_line(uout, out2, MAXLINELENGTH); if (strcmp ((const char *)out1, (const char *)out2) == 0) { - printf ("Correct! .. test th_brk_insert_breaks_wc() passed...\n"); + printf ("Correct! .. test th_brk_wc_insert_breaks() passed...\n"); } else { printf ("Error! Comparison of results from th_brk_insert_breaks() " - "and th_brk_insert_breaks_wc() failed.\n"); + "and th_brk_wc_insert_breaks() failed.\n"); printf ("th_brk_insert_breaks :\"%s\"\n", out1); - printf ("th_brk_insert_breaks_wc:\"%s\"\n", out2); - printf ("Test th_brk_insert_breaks_wc() failed...\n"); + printf ("th_brk_wc_insert_breaks:\"%s\"\n", out2); + printf ("Test th_brk_wc_insert_breaks() failed...\n"); exit (-1); }