From 06f7622100701688a981cb30c50bfff789522516 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 1 Jan 2011 15:11:53 -0800 Subject: [PATCH] Remove u#-grapheme-len modules as too redundant with u#-grapheme-next. Remove module 'u8-grapheme-len' as too redundant with 'u8-grapheme-next'. * modules/unigbrk/u8-grapheme-len: Delete file. * modules/unigbrk/u8-grapheme-len-tests: Delete file. * lib/unigbrk.in.h: Remove prototype for deleted function. * lib/unigbrk/u8-grapheme-len.c: Delete file. * tests/unigbrk/test-u8-grapheme-len.c: Delete file. Remove module 'u16-grapheme-len' as too redundant with 'u16-grapheme-next'. * modules/unigbrk/u16-grapheme-len: Delete file. * modules/unigbrk/u16-grapheme-len-tests: Delete file. * lib/unigbrk.in.h: Remove prototype for deleted function. * lib/unigbrk/u16-grapheme-len.c: Delete file. * tests/unigbrk/test-u16-grapheme-len.c: Delete file. Remove module 'u32-grapheme-len' as too redundant with 'u32-grapheme-next'. * modules/unigbrk/u32-grapheme-len: Delete file. * modules/unigbrk/u32-grapheme-len-tests: Delete file. * lib/unigbrk.in.h: Remove prototype for deleted function. * lib/unigbrk/u32-grapheme-len.c: Delete file. * tests/unigbrk/test-u32-grapheme-len.c: Delete file. Suggested by Bruno Haible. --- ChangeLog | 28 ++++++++++ lib/unigbrk.in.h | 10 ---- lib/unigbrk/u16-grapheme-len.c | 47 ----------------- lib/unigbrk/u32-grapheme-len.c | 47 ----------------- lib/unigbrk/u8-grapheme-len.c | 47 ----------------- modules/unigbrk/u16-grapheme-len | 28 ---------- modules/unigbrk/u16-grapheme-len-tests | 12 ----- modules/unigbrk/u32-grapheme-len | 28 ---------- modules/unigbrk/u32-grapheme-len-tests | 12 ----- modules/unigbrk/u8-grapheme-len | 28 ---------- modules/unigbrk/u8-grapheme-len-tests | 12 ----- tests/unigbrk/test-u16-grapheme-len.c | 95 --------------------------------- tests/unigbrk/test-u32-grapheme-len.c | 96 ---------------------------------- tests/unigbrk/test-u8-grapheme-len.c | 52 ------------------ 14 files changed, 28 insertions(+), 514 deletions(-) delete mode 100644 lib/unigbrk/u16-grapheme-len.c delete mode 100644 lib/unigbrk/u32-grapheme-len.c delete mode 100644 lib/unigbrk/u8-grapheme-len.c delete mode 100644 modules/unigbrk/u16-grapheme-len delete mode 100644 modules/unigbrk/u16-grapheme-len-tests delete mode 100644 modules/unigbrk/u32-grapheme-len delete mode 100644 modules/unigbrk/u32-grapheme-len-tests delete mode 100644 modules/unigbrk/u8-grapheme-len delete mode 100644 modules/unigbrk/u8-grapheme-len-tests delete mode 100644 tests/unigbrk/test-u16-grapheme-len.c delete mode 100644 tests/unigbrk/test-u32-grapheme-len.c delete mode 100644 tests/unigbrk/test-u8-grapheme-len.c diff --git a/ChangeLog b/ChangeLog index c5a1cae33..87c7bcd2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,33 @@ 2011-01-01 Ben Pfaff + Remove module 'u8-grapheme-len' as too redundant with + 'u8-grapheme-next'. + * modules/unigbrk/u8-grapheme-len: Delete file. + * modules/unigbrk/u8-grapheme-len-tests: Delete file. + * lib/unigbrk.in.h: Remove prototype for deleted function. + * lib/unigbrk/u8-grapheme-len.c: Delete file. + * tests/unigbrk/test-u8-grapheme-len.c: Delete file. + + Remove module 'u16-grapheme-len' as too redundant with + 'u16-grapheme-next'. + * modules/unigbrk/u16-grapheme-len: Delete file. + * modules/unigbrk/u16-grapheme-len-tests: Delete file. + * lib/unigbrk.in.h: Remove prototype for deleted function. + * lib/unigbrk/u16-grapheme-len.c: Delete file. + * tests/unigbrk/test-u16-grapheme-len.c: Delete file. + + Remove module 'u32-grapheme-len' as too redundant with + 'u32-grapheme-next'. + * modules/unigbrk/u32-grapheme-len: Delete file. + * modules/unigbrk/u32-grapheme-len-tests: Delete file. + * lib/unigbrk.in.h: Remove prototype for deleted function. + * lib/unigbrk/u32-grapheme-len.c: Delete file. + * tests/unigbrk/test-u32-grapheme-len.c: Delete file. + + Suggested by Bruno Haible. + +2011-01-01 Ben Pfaff + * unigbrk.in.h: Fix typo: "ben" => "been". Reported by Bruno Haible. diff --git a/lib/unigbrk.in.h b/lib/unigbrk.in.h index acce151c4..c95b75be0 100644 --- a/lib/unigbrk.in.h +++ b/lib/unigbrk.in.h @@ -78,16 +78,6 @@ extern int extern bool uc_is_grapheme_cluster_break (ucs4_t a, ucs4_t b); -/* Returns the length (in units) of the first grapheme cluster in the N units - in S. If the return value is N, then extending the string could extend the - length of the grapheme cluster too. Returns 0 only if N is zero. */ -extern size_t - u8_grapheme_len (const uint8_t *s, size_t n); -extern size_t - u16_grapheme_len (const uint16_t *s, size_t n); -extern size_t - u32_grapheme_len (const uint32_t *s, size_t n); - /* Returns the start of the next grapheme cluster following S, or NULL if the end of the string has been reached. */ extern const uint8_t * diff --git a/lib/unigbrk/u16-grapheme-len.c b/lib/unigbrk/u16-grapheme-len.c deleted file mode 100644 index 645936fc4..000000000 --- a/lib/unigbrk/u16-grapheme-len.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Grapheme cluster length function. - Copyright (C) 2010-2011 Free Software Foundation, Inc. - Written by Ben Pfaff , 2010. - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include "unigbrk.h" - -#include "unistr.h" - -size_t -u16_grapheme_len (const uint16_t *s, size_t n) -{ - ucs4_t prev; - size_t ofs; - int mblen; - - if (n == 0) - return 0; - - for (ofs = u16_mbtouc (&prev, s, n); ofs < n; ofs += mblen) - { - ucs4_t next; - - mblen = u16_mbtouc (&next, s + ofs, n - ofs); - if (uc_is_grapheme_cluster_break (prev, next)) - break; - - prev = next; - } - - return ofs; -} diff --git a/lib/unigbrk/u32-grapheme-len.c b/lib/unigbrk/u32-grapheme-len.c deleted file mode 100644 index 5468852ad..000000000 --- a/lib/unigbrk/u32-grapheme-len.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Grapheme cluster length function. - Copyright (C) 2010-2011 Free Software Foundation, Inc. - Written by Ben Pfaff , 2010. - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include "unigbrk.h" - -#include "unistr.h" - -size_t -u32_grapheme_len (const uint32_t *s, size_t n) -{ - ucs4_t prev; - size_t ofs; - - if (n == 0) - return 0; - - u32_mbtouc (&prev, s, n); - for (ofs = 1; ofs < n; ofs++) - { - ucs4_t next; - - u32_mbtouc (&next, s + ofs, n - ofs); - if (uc_is_grapheme_cluster_break (prev, next)) - break; - - prev = next; - } - - return ofs; -} diff --git a/lib/unigbrk/u8-grapheme-len.c b/lib/unigbrk/u8-grapheme-len.c deleted file mode 100644 index a4e05726f..000000000 --- a/lib/unigbrk/u8-grapheme-len.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Grapheme cluster length function. - Copyright (C) 2010-2011 Free Software Foundation, Inc. - Written by Ben Pfaff , 2010. - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include "unigbrk.h" - -#include "unistr.h" - -size_t -u8_grapheme_len (const uint8_t *s, size_t n) -{ - ucs4_t prev; - size_t ofs; - int mblen; - - if (n == 0) - return 0; - - for (ofs = u8_mbtouc (&prev, s, n); ofs < n; ofs += mblen) - { - ucs4_t next; - - mblen = u8_mbtouc (&next, s + ofs, n - ofs); - if (uc_is_grapheme_cluster_break (prev, next)) - break; - - prev = next; - } - - return ofs; -} diff --git a/modules/unigbrk/u16-grapheme-len b/modules/unigbrk/u16-grapheme-len deleted file mode 100644 index 06d064603..000000000 --- a/modules/unigbrk/u16-grapheme-len +++ /dev/null @@ -1,28 +0,0 @@ -Description: -Length of first grapheme cluster in UTF-16 string. - -Files: -lib/unigbrk/u16-grapheme-len.c -tests/macros.h - -Depends-on: -unigbrk/uc-is-grapheme-break -unistr/u16-mbtouc - -configure.ac: -gl_MODULE_INDICATOR([unigbrk/u16-grapheme-len]) -gl_LIBUNISTRING_MODULE([0.9.4], [unigbrk/u16-grapheme-len]) - -Makefile.am: -if LIBUNISTRING_COMPILE_UNIGBRK_U16_GRAPHEME_LEN -lib_SOURCES += unigbrk/u16-grapheme-len.c -endif - -Include: -"unigbrk.h" - -License: -LGPL - -Maintainer: -Ben Pfaff, Bruno Haible diff --git a/modules/unigbrk/u16-grapheme-len-tests b/modules/unigbrk/u16-grapheme-len-tests deleted file mode 100644 index 66f7aac7d..000000000 --- a/modules/unigbrk/u16-grapheme-len-tests +++ /dev/null @@ -1,12 +0,0 @@ -Files: -tests/unigbrk/test-u16-grapheme-len.c - -Depends-on: - -configure.ac: - -Makefile.am: -TESTS += test-u16-grapheme-len -check_PROGRAMS += test-u16-grapheme-len -test_u16_grapheme_len_SOURCES = unigbrk/test-u16-grapheme-len.c -test_u16_grapheme_len_LDADD = $(LDADD) $(LIBUNISTRING) diff --git a/modules/unigbrk/u32-grapheme-len b/modules/unigbrk/u32-grapheme-len deleted file mode 100644 index 4129fb1b2..000000000 --- a/modules/unigbrk/u32-grapheme-len +++ /dev/null @@ -1,28 +0,0 @@ -Description: -Length of first grapheme cluster in UTF-32 string. - -Files: -lib/unigbrk/u32-grapheme-len.c -tests/macros.h - -Depends-on: -unigbrk/uc-is-grapheme-break -unistr/u32-mbtouc - -configure.ac: -gl_MODULE_INDICATOR([unigbrk/u32-grapheme-len]) -gl_LIBUNISTRING_MODULE([0.9.4], [unigbrk/u32-grapheme-len]) - -Makefile.am: -if LIBUNISTRING_COMPILE_UNIGBRK_U32_GRAPHEME_LEN -lib_SOURCES += unigbrk/u32-grapheme-len.c -endif - -Include: -"unigbrk.h" - -License: -LGPL - -Maintainer: -Ben Pfaff, Bruno Haible diff --git a/modules/unigbrk/u32-grapheme-len-tests b/modules/unigbrk/u32-grapheme-len-tests deleted file mode 100644 index 1618abda8..000000000 --- a/modules/unigbrk/u32-grapheme-len-tests +++ /dev/null @@ -1,12 +0,0 @@ -Files: -tests/unigbrk/test-u32-grapheme-len.c - -Depends-on: - -configure.ac: - -Makefile.am: -TESTS += test-u32-grapheme-len -check_PROGRAMS += test-u32-grapheme-len -test_u32_grapheme_len_SOURCES = unigbrk/test-u32-grapheme-len.c -test_u32_grapheme_len_LDADD = $(LDADD) $(LIBUNISTRING) diff --git a/modules/unigbrk/u8-grapheme-len b/modules/unigbrk/u8-grapheme-len deleted file mode 100644 index 04e6c40ef..000000000 --- a/modules/unigbrk/u8-grapheme-len +++ /dev/null @@ -1,28 +0,0 @@ -Description: -Length of first grapheme cluster in UTF-8 string. - -Files: -lib/unigbrk/u8-grapheme-len.c -tests/macros.h - -Depends-on: -unigbrk/uc-is-grapheme-break -unistr/u8-mbtouc - -configure.ac: -gl_MODULE_INDICATOR([unigbrk/u8-grapheme-len]) -gl_LIBUNISTRING_MODULE([0.9.4], [unigbrk/u8-grapheme-len]) - -Makefile.am: -if LIBUNISTRING_COMPILE_UNIGBRK_U8_GRAPHEME_LEN -lib_SOURCES += unigbrk/u8-grapheme-len.c -endif - -Include: -"unigbrk.h" - -License: -LGPL - -Maintainer: -Ben Pfaff, Bruno Haible diff --git a/modules/unigbrk/u8-grapheme-len-tests b/modules/unigbrk/u8-grapheme-len-tests deleted file mode 100644 index 4067abfe3..000000000 --- a/modules/unigbrk/u8-grapheme-len-tests +++ /dev/null @@ -1,12 +0,0 @@ -Files: -tests/unigbrk/test-u8-grapheme-len.c - -Depends-on: - -configure.ac: - -Makefile.am: -TESTS += test-u8-grapheme-len -check_PROGRAMS += test-u8-grapheme-len -test_u8_grapheme_len_SOURCES = unigbrk/test-u8-grapheme-len.c -test_u8_grapheme_len_LDADD = $(LDADD) $(LIBUNISTRING) diff --git a/tests/unigbrk/test-u16-grapheme-len.c b/tests/unigbrk/test-u16-grapheme-len.c deleted file mode 100644 index 637b04bc8..000000000 --- a/tests/unigbrk/test-u16-grapheme-len.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Grapheme cluster length test. - Copyright (C) 2010-2011 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . */ - -/* Written by Ben Pfaff , 2010. */ - -#include - -/* Specification. */ -#include - -#include -#include -#include - -static void -test_u16_grapheme_len (size_t len, ...) -{ - uint16_t s[16]; - size_t retval; - va_list args; - size_t n; - - va_start (args, len); - n = 0; - for (;;) - { - int unit = va_arg (args, int); - if (unit == -1) - break; - else if (n >= sizeof s / sizeof *s) - abort (); - - s[n++] = unit; - } - va_end (args); - - retval = u16_grapheme_len (s, n); - if (retval != len) - { - size_t i; - - fprintf (stderr, "u16_grapheme_len counted %zu units, expected %zu:", - retval, len); - for (i = 0; i < n; i++) - fprintf (stderr, " %04x", s[i]); - putc ('\n', stderr); - abort (); - } -} - - -int -main (void) -{ - /* Empty string. */ - test_u16_grapheme_len (0, -1); - - /* Standalone 1-unit graphemes. */ - test_u16_grapheme_len (1, 'a', -1); - test_u16_grapheme_len (1, 'a', 'b', -1); - test_u16_grapheme_len (1, 'a', 'b', 'c', -1); - - /* Multi-unit, single code point graphemes. */ -#define HIRAGANA_A 0x3042 /* あ: Hiragana letter 'a'. */ - test_u16_grapheme_len (1, HIRAGANA_A, -1); - test_u16_grapheme_len (1, HIRAGANA_A, 'x', -1); - test_u16_grapheme_len (1, HIRAGANA_A, HIRAGANA_A, -1); - - /* Combining accents. */ -#define GRAVE 0x0300 /* Combining grave accent. */ -#define ACUTE 0x0301 /* Combining acute accent. */ - test_u16_grapheme_len (2, 'e', ACUTE, -1); - test_u16_grapheme_len (3, 'e', ACUTE, GRAVE, -1); - test_u16_grapheme_len (2, 'e', ACUTE, 'x', -1); - test_u16_grapheme_len (2, 'e', ACUTE, 'e', ACUTE, -1); - - /* Surrogate pairs. */ - test_u16_grapheme_len (2, 0xd83d, 0xde10, -1); /* 😐: neutral face. */ - test_u16_grapheme_len (3, 0xd83d, 0xde10, GRAVE, -1); - - return 0; -} diff --git a/tests/unigbrk/test-u32-grapheme-len.c b/tests/unigbrk/test-u32-grapheme-len.c deleted file mode 100644 index 0b36f9cb1..000000000 --- a/tests/unigbrk/test-u32-grapheme-len.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Grapheme cluster length test. - Copyright (C) 2010-2011 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . */ - -/* Written by Ben Pfaff , 2010. */ - -#include - -/* Specification. */ -#include - -#include -#include -#include - -static void -test_u32_grapheme_len (size_t len, ...) -{ - uint32_t s[32]; - size_t retval; - va_list args; - size_t n; - - va_start (args, len); - n = 0; - for (;;) - { - int unit = va_arg (args, int); - if (unit == -1) - break; - else if (n >= sizeof s / sizeof *s) - abort (); - - s[n++] = unit; - } - va_end (args); - - retval = u32_grapheme_len (s, n); - if (retval != len) - { - size_t i; - - fprintf (stderr, "u32_grapheme_len counted %zu units, expected %zu:", - retval, len); - for (i = 0; i < n; i++) - fprintf (stderr, " %04x", (unsigned int) s[i]); - putc ('\n', stderr); - abort (); - } -} - - -int -main (void) -{ - /* Empty string. */ - test_u32_grapheme_len (0, -1); - - /* Standalone 1-unit graphemes. */ - test_u32_grapheme_len (1, 'a', -1); - test_u32_grapheme_len (1, 'a', 'b', -1); - test_u32_grapheme_len (1, 'a', 'b', 'c', -1); - - /* Multi-unit, single code point graphemes. */ -#define HIRAGANA_A 0x3042 /* あ: Hiragana letter 'a'. */ - test_u32_grapheme_len (1, HIRAGANA_A, -1); - test_u32_grapheme_len (1, HIRAGANA_A, 'x', -1); - test_u32_grapheme_len (1, HIRAGANA_A, HIRAGANA_A, -1); - - /* Combining accents. */ -#define GRAVE 0x0300 /* Combining grave accent. */ -#define ACUTE 0x0301 /* Combining acute accent. */ - test_u32_grapheme_len (2, 'e', ACUTE, -1); - test_u32_grapheme_len (3, 'e', ACUTE, GRAVE, -1); - test_u32_grapheme_len (2, 'e', ACUTE, 'x', -1); - test_u32_grapheme_len (2, 'e', ACUTE, 'e', ACUTE, -1); - - /* Outside BMP. */ -#define NEUTRAL_FACE 0x1f610 /* 😐: neutral face. */ - test_u32_grapheme_len (1, NEUTRAL_FACE, -1); - test_u32_grapheme_len (2, NEUTRAL_FACE, GRAVE, -1); - - return 0; -} diff --git a/tests/unigbrk/test-u8-grapheme-len.c b/tests/unigbrk/test-u8-grapheme-len.c deleted file mode 100644 index 19b7a543a..000000000 --- a/tests/unigbrk/test-u8-grapheme-len.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Grapheme cluster length test. - Copyright (C) 2010, 2011 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . */ - -/* Written by Ben Pfaff , 2010. */ - -#include - -/* Specification. */ -#include - -#include "macros.h" - -int -main (void) -{ - /* Empty string. */ - ASSERT (u8_grapheme_len ("", 0) == 0); - - /* Standalone 1-unit graphemes. */ - ASSERT (u8_grapheme_len ("a", 1) == 1); - ASSERT (u8_grapheme_len ("ab", 2) == 1); - ASSERT (u8_grapheme_len ("abc", 3) == 1); - - /* Multi-unit, single code point graphemes. */ -#define HIRAGANA_A "\343\201\202" /* あ: Hiragana letter 'a'. */ - ASSERT (u8_grapheme_len (HIRAGANA_A, 3) == 3); - ASSERT (u8_grapheme_len (HIRAGANA_A"x", 4) == 3); - ASSERT (u8_grapheme_len (HIRAGANA_A HIRAGANA_A, 6) == 3); - - /* Combining accents. */ -#define GRAVE "\314\200" /* Combining grave accent. */ -#define ACUTE "\314\201" /* Combining acute accent. */ - ASSERT (u8_grapheme_len ("e"ACUTE, 3) == 3); - ASSERT (u8_grapheme_len ("e"ACUTE GRAVE, 5) == 5); - ASSERT (u8_grapheme_len ("e"ACUTE"x", 4) == 3); - ASSERT (u8_grapheme_len ("e"ACUTE "e"ACUTE, 6) == 3); - - return 0; -} -- 2.11.0