changeset 14081:2e7260ffde00

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.
author Ben Pfaff <blp@cs.stanford.edu>
date Sat, 01 Jan 2011 15:11:53 -0800
parents 87819eefffc5
children 42f8fcc42425
files ChangeLog lib/unigbrk.in.h lib/unigbrk/u16-grapheme-len.c lib/unigbrk/u32-grapheme-len.c lib/unigbrk/u8-grapheme-len.c modules/unigbrk/u16-grapheme-len modules/unigbrk/u16-grapheme-len-tests modules/unigbrk/u32-grapheme-len modules/unigbrk/u32-grapheme-len-tests modules/unigbrk/u8-grapheme-len modules/unigbrk/u8-grapheme-len-tests tests/unigbrk/test-u16-grapheme-len.c tests/unigbrk/test-u32-grapheme-len.c tests/unigbrk/test-u8-grapheme-len.c
diffstat 14 files changed, 28 insertions(+), 514 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2011-01-01  Ben Pfaff  <blp@cs.stanford.edu>
+
+	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  <blp@cs.stanford.edu>
 
 	* unigbrk.in.h: Fix typo: "ben" => "been".
--- a/lib/unigbrk.in.h
+++ b/lib/unigbrk.in.h
@@ -78,16 +78,6 @@
 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 *
deleted file mode 100644
--- 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 <blp@cs.stanford.edu>, 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 <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-/* 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;
-}
deleted file mode 100644
--- 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 <blp@cs.stanford.edu>, 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 <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-/* 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;
-}
deleted file mode 100644
--- 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 <blp@cs.stanford.edu>, 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 <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-/* 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;
-}
deleted file mode 100644
--- 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
deleted file mode 100644
--- 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)
deleted file mode 100644
--- 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
deleted file mode 100644
--- 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)
deleted file mode 100644
--- 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
deleted file mode 100644
--- 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)
deleted file mode 100644
--- 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 <http://www.gnu.org/licenses/>.  */
-
-/* Written by Ben Pfaff <blp@cs.stanford.edu>, 2010. */
-
-#include <config.h>
-
-/* Specification. */
-#include <unigbrk.h>
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-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;
-}
deleted file mode 100644
--- 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 <http://www.gnu.org/licenses/>.  */
-
-/* Written by Ben Pfaff <blp@cs.stanford.edu>, 2010. */
-
-#include <config.h>
-
-/* Specification. */
-#include <unigbrk.h>
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-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;
-}
deleted file mode 100644
--- 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 <http://www.gnu.org/licenses/>.  */
-
-/* Written by Ben Pfaff <blp@cs.stanford.edu>, 2010. */
-
-#include <config.h>
-
-/* Specification. */
-#include <unigbrk.h>
-
-#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;
-}