Mercurial > hg > octave-lojdl > gnulib-hg
changeset 14461:f3ad11231a87
unictype/bidi*: Rename functions.
* lib/unictype.in.h (uc_bidi_class_name, uc_bidi_class_byname,
uc_bidi_class, uc_is_bidi_class): New declarations.
* lib/unictype/bidi_byname.c (uc_bidi_class_byname): Renamed from
uc_bidi_category_byname.
(uc_bidi_category_byname): New function.
* lib/unictype/bidi_name.c (u_bidi_class_name): Renamed from
u_bidi_category_name.
(uc_bidi_class_name): Renamed from uc_bidi_category_name.
(uc_bidi_category_name): New function.
* lib/unictype/bidi_of.c (uc_bidi_class): Renamed from
uc_bidi_category.
(uc_bidi_category): New function.
* lib/unictype/bidi_test.c (uc_is_bidi_class): Renamed from
uc_is_bidi_category. Invoke uc_bidi_class.
(uc_is_bidi_category): New function.
* tests/unictype/test-bidi_byname.c (main): Test uc_bidi_class_byname
instead of uc_bidi_category_byname.
* tests/unictype/test-bidi_name.c (main): Test uc_bidi_class_name
instead of uc_bidi_category_name.
* tests/unictype/test-bidi_of.c (main): Test uc_bidi_class instead of
uc_bidi_category.
* tests/unictype/test-bidi_test.c (main): Test uc_is_bidi_class
instead of uc_is_bidi_category.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 23 Mar 2011 00:32:49 +0100 |
parents | 3d75f11c4199 |
children | 61818c1e26b8 |
files | ChangeLog lib/unictype.in.h lib/unictype/bidi_byname.c lib/unictype/bidi_name.c lib/unictype/bidi_of.c lib/unictype/bidi_test.c tests/unictype/test-bidi_byname.c tests/unictype/test-bidi_name.c tests/unictype/test-bidi_of.c tests/unictype/test-bidi_test.c |
diffstat | 10 files changed, 152 insertions(+), 89 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2011-03-22 Bruno Haible <bruno@clisp.org> + + unictype/bidi*: Rename functions. + * lib/unictype.in.h (uc_bidi_class_name, uc_bidi_class_byname, + uc_bidi_class, uc_is_bidi_class): New declarations. + * lib/unictype/bidi_byname.c (uc_bidi_class_byname): Renamed from + uc_bidi_category_byname. + (uc_bidi_category_byname): New function. + * lib/unictype/bidi_name.c (u_bidi_class_name): Renamed from + u_bidi_category_name. + (uc_bidi_class_name): Renamed from uc_bidi_category_name. + (uc_bidi_category_name): New function. + * lib/unictype/bidi_of.c (uc_bidi_class): Renamed from + uc_bidi_category. + (uc_bidi_category): New function. + * lib/unictype/bidi_test.c (uc_is_bidi_class): Renamed from + uc_is_bidi_category. Invoke uc_bidi_class. + (uc_is_bidi_category): New function. + * tests/unictype/test-bidi_byname.c (main): Test uc_bidi_class_byname + instead of uc_bidi_category_byname. + * tests/unictype/test-bidi_name.c (main): Test uc_bidi_class_name + instead of uc_bidi_category_name. + * tests/unictype/test-bidi_of.c (main): Test uc_bidi_class instead of + uc_bidi_category. + * tests/unictype/test-bidi_test.c (main): Test uc_is_bidi_class + instead of uc_is_bidi_category. + 2011-03-21 Bruno Haible <bruno@clisp.org> New module 'unictype/joininggroup-all'.
--- a/lib/unictype.in.h +++ b/lib/unictype.in.h @@ -257,7 +257,8 @@ /* ========================================================================= */ -/* Field 4 of Unicode Character Database: Bidirectional category. */ +/* Field 4 of Unicode Character Database: Bidi class. + Before Unicode 4.0, this field was called "Bidirectional category". */ enum { @@ -282,20 +283,31 @@ UC_BIDI_ON /* Other Neutral */ }; -/* Return the name of a bidirectional category. */ +/* Return the name of a bidi class. */ +extern const char * + uc_bidi_class_name (int bidi_class); +/* Same; obsolete function name. */ extern const char * uc_bidi_category_name (int category); -/* Return the bidirectional category given by name, e.g. "LRE". */ +/* Return the bidi class given by name, e.g. "LRE". */ +extern int + uc_bidi_class_byname (const char *bidi_class_name); +/* Same; obsolete function name. */ extern int uc_bidi_category_byname (const char *category_name); -/* Return the bidirectional category of a Unicode character. */ +/* Return the bidi class of a Unicode character. */ +extern int + uc_bidi_class (ucs4_t uc); +/* Same; obsolete function name. */ extern int uc_bidi_category (ucs4_t uc); -/* Test whether a Unicode character belongs to a given bidirectional - category. */ +/* Test whether a Unicode character belongs to a given bidi class. */ +extern bool + uc_is_bidi_class (ucs4_t uc, int bidi_class); +/* Same; obsolete function name. */ extern bool uc_is_bidi_category (ucs4_t uc, int category);
--- a/lib/unictype/bidi_byname.c +++ b/lib/unictype/bidi_byname.c @@ -1,5 +1,5 @@ /* Bidi categories of Unicode characters. - Copyright (C) 2002, 2006, 2009-2011 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2011 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This program is free software: you can redistribute it and/or modify it @@ -21,74 +21,74 @@ #include "unictype.h" int -uc_bidi_category_byname (const char *category_name) +uc_bidi_class_byname (const char *bidi_class_name) { - switch (category_name[0]) + switch (bidi_class_name[0]) { case 'A': - switch (category_name[1]) + switch (bidi_class_name[1]) { case 'L': - if (category_name[2] == '\0') + if (bidi_class_name[2] == '\0') return UC_BIDI_AL; break; case 'N': - if (category_name[2] == '\0') + if (bidi_class_name[2] == '\0') return UC_BIDI_AN; break; } break; case 'B': - switch (category_name[1]) + switch (bidi_class_name[1]) { case '\0': return UC_BIDI_B; case 'N': - if (category_name[2] == '\0') + if (bidi_class_name[2] == '\0') return UC_BIDI_BN; break; } break; case 'C': - switch (category_name[1]) + switch (bidi_class_name[1]) { case 'S': - if (category_name[2] == '\0') + if (bidi_class_name[2] == '\0') return UC_BIDI_CS; break; } break; case 'E': - switch (category_name[1]) + switch (bidi_class_name[1]) { case 'N': - if (category_name[2] == '\0') + if (bidi_class_name[2] == '\0') return UC_BIDI_EN; break; case 'S': - if (category_name[2] == '\0') + if (bidi_class_name[2] == '\0') return UC_BIDI_ES; break; case 'T': - if (category_name[2] == '\0') + if (bidi_class_name[2] == '\0') return UC_BIDI_ET; break; } break; case 'L': - switch (category_name[1]) + switch (bidi_class_name[1]) { case '\0': return UC_BIDI_L; case 'R': - switch (category_name[2]) + switch (bidi_class_name[2]) { case 'E': - if (category_name[3] == '\0') + if (bidi_class_name[3] == '\0') return UC_BIDI_LRE; break; case 'O': - if (category_name[3] == '\0') + if (bidi_class_name[3] == '\0') return UC_BIDI_LRO; break; } @@ -96,13 +96,13 @@ } break; case 'N': - switch (category_name[1]) + switch (bidi_class_name[1]) { case 'S': - switch (category_name[2]) + switch (bidi_class_name[2]) { case 'M': - if (category_name[3] == '\0') + if (bidi_class_name[3] == '\0') return UC_BIDI_NSM; break; } @@ -110,22 +110,22 @@ } break; case 'O': - switch (category_name[1]) + switch (bidi_class_name[1]) { case 'N': - if (category_name[2] == '\0') + if (bidi_class_name[2] == '\0') return UC_BIDI_ON; break; } break; case 'P': - switch (category_name[1]) + switch (bidi_class_name[1]) { case 'D': - switch (category_name[2]) + switch (bidi_class_name[2]) { case 'F': - if (category_name[3] == '\0') + if (bidi_class_name[3] == '\0') return UC_BIDI_PDF; break; } @@ -133,19 +133,19 @@ } break; case 'R': - switch (category_name[1]) + switch (bidi_class_name[1]) { case '\0': return UC_BIDI_R; case 'L': - switch (category_name[2]) + switch (bidi_class_name[2]) { case 'E': - if (category_name[3] == '\0') + if (bidi_class_name[3] == '\0') return UC_BIDI_RLE; break; case 'O': - if (category_name[3] == '\0') + if (bidi_class_name[3] == '\0') return UC_BIDI_RLO; break; } @@ -153,19 +153,25 @@ } break; case 'S': - if (category_name[1] == '\0') + if (bidi_class_name[1] == '\0') return UC_BIDI_S; break; case 'W': - switch (category_name[1]) + switch (bidi_class_name[1]) { case 'S': - if (category_name[2] == '\0') + if (bidi_class_name[2] == '\0') return UC_BIDI_WS; break; } break; } - /* Invalid category name. */ + /* Invalid bidi class name. */ return -1; } + +int +uc_bidi_category_byname (const char *category_name) +{ + return uc_bidi_class_byname (category_name); +}
--- a/lib/unictype/bidi_name.c +++ b/lib/unictype/bidi_name.c @@ -1,5 +1,5 @@ /* Bidi categories of Unicode characters. - Copyright (C) 2002, 2006, 2009-2011 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2011 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This program is free software: you can redistribute it and/or modify it @@ -20,16 +20,22 @@ /* Specification. */ #include "unictype.h" -static const char u_bidi_category_name[19][4] = +static const char u_bidi_class_name[19][4] = { "L", "LRE", "LRO", "R", "AL", "RLE", "RLO", "PDF", "EN", "ES", "ET", "AN", "CS", "NSM", "BN", "B", "S", "WS", "ON" }; const char * +uc_bidi_class_name (int bidi_class) +{ + if (bidi_class >= 0 && bidi_class < sizeof (u_bidi_class_name) / sizeof (u_bidi_class_name[0])) + return u_bidi_class_name[bidi_class]; + return NULL; +} + +const char * uc_bidi_category_name (int category) { - if (category >= 0 && category < sizeof (u_bidi_category_name) / sizeof (u_bidi_category_name[0])) - return u_bidi_category_name[category]; - return NULL; + return uc_bidi_class_name (category); }
--- a/lib/unictype/bidi_of.c +++ b/lib/unictype/bidi_of.c @@ -1,5 +1,5 @@ /* Bidi categories of Unicode characters. - Copyright (C) 2002, 2006, 2009-2011 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2011 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This program is free software: you can redistribute it and/or modify it @@ -24,7 +24,7 @@ #include "bidi_of.h" int -uc_bidi_category (ucs4_t uc) +uc_bidi_class (ucs4_t uc) { unsigned int index1 = uc >> bidi_category_header_0; if (index1 < bidi_category_header_1) @@ -50,3 +50,9 @@ } return UC_BIDI_L; } + +int +uc_bidi_category (ucs4_t uc) +{ + return uc_bidi_class (uc); +}
--- a/lib/unictype/bidi_test.c +++ b/lib/unictype/bidi_test.c @@ -1,5 +1,5 @@ /* Bidi categories of Unicode characters. - Copyright (C) 2002, 2006, 2009-2011 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2011 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2002. This program is free software: you can redistribute it and/or modify it @@ -21,7 +21,13 @@ #include "unictype.h" bool +uc_is_bidi_class (ucs4_t uc, int bidi_class) +{ + return (uc_bidi_class (uc) == bidi_class); +} + +bool uc_is_bidi_category (ucs4_t uc, int category) { - return (uc_bidi_category (uc) == category); + return uc_is_bidi_class (uc, category); }
--- a/tests/unictype/test-bidi_byname.c +++ b/tests/unictype/test-bidi_byname.c @@ -1,5 +1,5 @@ /* Test the Unicode character type functions. - Copyright (C) 2007-2010 Free Software Foundation, Inc. + Copyright (C) 2007-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,27 +25,27 @@ int main () { - ASSERT (uc_bidi_category_byname ("L") == UC_BIDI_L); - ASSERT (uc_bidi_category_byname ("LRE") == UC_BIDI_LRE); - ASSERT (uc_bidi_category_byname ("LRO") == UC_BIDI_LRO); - ASSERT (uc_bidi_category_byname ("R") == UC_BIDI_R); - ASSERT (uc_bidi_category_byname ("AL") == UC_BIDI_AL); - ASSERT (uc_bidi_category_byname ("RLE") == UC_BIDI_RLE); - ASSERT (uc_bidi_category_byname ("RLO") == UC_BIDI_RLO); - ASSERT (uc_bidi_category_byname ("PDF") == UC_BIDI_PDF); - ASSERT (uc_bidi_category_byname ("EN") == UC_BIDI_EN); - ASSERT (uc_bidi_category_byname ("ES") == UC_BIDI_ES); - ASSERT (uc_bidi_category_byname ("ET") == UC_BIDI_ET); - ASSERT (uc_bidi_category_byname ("AN") == UC_BIDI_AN); - ASSERT (uc_bidi_category_byname ("CS") == UC_BIDI_CS); - ASSERT (uc_bidi_category_byname ("NSM") == UC_BIDI_NSM); - ASSERT (uc_bidi_category_byname ("BN") == UC_BIDI_BN); - ASSERT (uc_bidi_category_byname ("B") == UC_BIDI_B); - ASSERT (uc_bidi_category_byname ("S") == UC_BIDI_S); - ASSERT (uc_bidi_category_byname ("WS") == UC_BIDI_WS); - ASSERT (uc_bidi_category_byname ("ON") == UC_BIDI_ON); - ASSERT (uc_bidi_category_byname ("X") < 0); - ASSERT (uc_bidi_category_byname ("") < 0); + ASSERT (uc_bidi_class_byname ("L") == UC_BIDI_L); + ASSERT (uc_bidi_class_byname ("LRE") == UC_BIDI_LRE); + ASSERT (uc_bidi_class_byname ("LRO") == UC_BIDI_LRO); + ASSERT (uc_bidi_class_byname ("R") == UC_BIDI_R); + ASSERT (uc_bidi_class_byname ("AL") == UC_BIDI_AL); + ASSERT (uc_bidi_class_byname ("RLE") == UC_BIDI_RLE); + ASSERT (uc_bidi_class_byname ("RLO") == UC_BIDI_RLO); + ASSERT (uc_bidi_class_byname ("PDF") == UC_BIDI_PDF); + ASSERT (uc_bidi_class_byname ("EN") == UC_BIDI_EN); + ASSERT (uc_bidi_class_byname ("ES") == UC_BIDI_ES); + ASSERT (uc_bidi_class_byname ("ET") == UC_BIDI_ET); + ASSERT (uc_bidi_class_byname ("AN") == UC_BIDI_AN); + ASSERT (uc_bidi_class_byname ("CS") == UC_BIDI_CS); + ASSERT (uc_bidi_class_byname ("NSM") == UC_BIDI_NSM); + ASSERT (uc_bidi_class_byname ("BN") == UC_BIDI_BN); + ASSERT (uc_bidi_class_byname ("B") == UC_BIDI_B); + ASSERT (uc_bidi_class_byname ("S") == UC_BIDI_S); + ASSERT (uc_bidi_class_byname ("WS") == UC_BIDI_WS); + ASSERT (uc_bidi_class_byname ("ON") == UC_BIDI_ON); + ASSERT (uc_bidi_class_byname ("X") < 0); + ASSERT (uc_bidi_class_byname ("") < 0); return 0; }
--- a/tests/unictype/test-bidi_name.c +++ b/tests/unictype/test-bidi_name.c @@ -1,5 +1,5 @@ /* Test the Unicode character type functions. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2009, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,8 +25,8 @@ int main () { - ASSERT (strcmp (uc_bidi_category_name (UC_BIDI_NSM), "NSM") == 0); - ASSERT (uc_bidi_category_name (-1) == NULL); + ASSERT (strcmp (uc_bidi_class_name (UC_BIDI_NSM), "NSM") == 0); + ASSERT (uc_bidi_class_name (-1) == NULL); return 0; }
--- a/tests/unictype/test-bidi_of.c +++ b/tests/unictype/test-bidi_of.c @@ -1,5 +1,5 @@ /* Test the Unicode character type functions. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2009, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,9 +25,9 @@ int main () { - ASSERT (uc_bidi_category ('x') == UC_BIDI_L); - ASSERT (uc_bidi_category (0x05D7) == UC_BIDI_R); - ASSERT (uc_bidi_category ('7') == UC_BIDI_EN); + ASSERT (uc_bidi_class ('x') == UC_BIDI_L); + ASSERT (uc_bidi_class (0x05D7) == UC_BIDI_R); + ASSERT (uc_bidi_class ('7') == UC_BIDI_EN); return 0; }
--- a/tests/unictype/test-bidi_test.c +++ b/tests/unictype/test-bidi_test.c @@ -1,5 +1,5 @@ /* Test the Unicode character type functions. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2009, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,23 +25,23 @@ int main () { - ASSERT (uc_is_bidi_category ('x', UC_BIDI_L)); - ASSERT (!uc_is_bidi_category ('x', UC_BIDI_R)); - ASSERT (!uc_is_bidi_category ('x', UC_BIDI_EN)); + ASSERT (uc_is_bidi_class ('x', UC_BIDI_L)); + ASSERT (!uc_is_bidi_class ('x', UC_BIDI_R)); + ASSERT (!uc_is_bidi_class ('x', UC_BIDI_EN)); - ASSERT (uc_is_bidi_category (0x05D7, UC_BIDI_R)); - ASSERT (!uc_is_bidi_category (0x05D7, UC_BIDI_L)); - ASSERT (!uc_is_bidi_category (0x05D7, UC_BIDI_EN)); + ASSERT (uc_is_bidi_class (0x05D7, UC_BIDI_R)); + ASSERT (!uc_is_bidi_class (0x05D7, UC_BIDI_L)); + ASSERT (!uc_is_bidi_class (0x05D7, UC_BIDI_EN)); - ASSERT (uc_is_bidi_category ('7', UC_BIDI_EN)); - ASSERT (!uc_is_bidi_category ('7', UC_BIDI_L)); - ASSERT (!uc_is_bidi_category ('7', UC_BIDI_R)); + ASSERT (uc_is_bidi_class ('7', UC_BIDI_EN)); + ASSERT (!uc_is_bidi_class ('7', UC_BIDI_L)); + ASSERT (!uc_is_bidi_class ('7', UC_BIDI_R)); { unsigned int c; for (c = 0; c < 0x110000; c++) - ASSERT (uc_is_bidi_category (c, uc_bidi_category (c))); + ASSERT (uc_is_bidi_class (c, uc_bidi_class (c))); } return 0;