Skip to content

Commit

Permalink
Use 'wc' prefix instead of suffix for wide-char word break APIs.
Browse files Browse the repository at this point in the history
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().

Cc: pull request #1
  • Loading branch information
thep committed Jun 26, 2016
1 parent 2051952 commit 3ec84a2
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 27 deletions.
16 changes: 16 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
2016-06-26 Theppitak Karoonboonyanan <[email protected]>

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 <[email protected]>

Rename the new APIs to be more meaningful.
Expand Down
8 changes: 4 additions & 4 deletions include/thai/thwbrk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/libthai.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/libthai.def
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/libthai.map
Original file line number Diff line number Diff line change
Expand Up @@ -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;

14 changes: 7 additions & 7 deletions src/thwbrk/thwbrk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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++) {
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/*
Expand Down
22 changes: 11 additions & 11 deletions tests/test_thwbrk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}

Expand All @@ -59,16 +59,16 @@ int main (int argc, char* argv[])
(long)strlen ("<WBR>"), 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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit 3ec84a2

Please sign in to comment.