New module 'wctrans'.
authorBruno Haible <bruno@clisp.org>
Sun, 6 Feb 2011 23:16:49 +0000 (00:16 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 9 Feb 2011 19:54:32 +0000 (20:54 +0100)
* modules/wctrans: New file.
* lib/wctype.in.h (wctrans): New declaration.
* lib/wctrans.c: New file.
* lib/wctrans-impl.h: New file.
* m4/wctrans.m4: New file.
* m4/wctype_h.m4 (gl_WCTYPE_H): Test whether wctrans is declared.
(gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_WCTRANS.
* modules/wctype-h (Makefile.am): Substitute GNULIB_WCTRANS.
* tests/test-wctype-h-c++.cc: Test the declaration of wctrans.
* doc/posix-functions/wctrans.texi: Mention the new module.

ChangeLog
doc/posix-functions/wctrans.texi
lib/wctrans-impl.h [new file with mode: 0644]
lib/wctrans.c [new file with mode: 0644]
lib/wctype.in.h
m4/wctrans.m4 [new file with mode: 0644]
m4/wctype_h.m4
modules/wctrans [new file with mode: 0644]
modules/wctype-h
tests/test-wctype-h-c++.cc

index a37ab00..3d4e23f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2011-02-06  Bruno Haible  <bruno@clisp.org>
 
+       New module 'wctrans'.
+       * modules/wctrans: New file.
+       * lib/wctype.in.h (wctrans): New declaration.
+       * lib/wctrans.c: New file.
+       * lib/wctrans-impl.h: New file.
+       * m4/wctrans.m4: New file.
+       * m4/wctype_h.m4 (gl_WCTYPE_H): Test whether wctrans is declared.
+       (gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_WCTRANS.
+       * modules/wctype-h (Makefile.am): Substitute GNULIB_WCTRANS.
+       * tests/test-wctype-h-c++.cc: Test the declaration of wctrans.
+       * doc/posix-functions/wctrans.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
        New module 'iswctype'.
        * modules/iswctype: New file.
        * lib/wctype.in.h (iswctype): New declaration.
index 4d054ad..a2143e7 100644 (file)
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wctrans.html}
 
-Gnulib module: ---
+Gnulib module: wctrans
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+HP-UX 11.00, IRIX 6.5, Solaris 2.5.1, mingw, Interix 3.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-HP-UX 11.00, IRIX 6.5, Solaris 2.5.1, mingw, Interix 3.5.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
diff --git a/lib/wctrans-impl.h b/lib/wctrans-impl.h
new file mode 100644 (file)
index 0000000..d099f8b
--- /dev/null
@@ -0,0 +1,37 @@
+/* Get descriptor for a wide character case conversion.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+wctrans_t
+wctrans (const char *name)
+{
+  if (name[0] == 't'
+      && name[1] == 'o')
+    switch (name[2])
+      {
+      case 'l':
+        if (strcmp (name + 3, "ower") == 0)
+          return (wctrans_t) towlower;
+        break;
+      case 'u':
+        if (strcmp (name + 3, "pper") == 0)
+          return (wctrans_t) towupper;
+        break;
+      default:
+        break;
+      }
+  return NULL;
+}
diff --git a/lib/wctrans.c b/lib/wctrans.c
new file mode 100644 (file)
index 0000000..1ce6d6f
--- /dev/null
@@ -0,0 +1,25 @@
+/* Get descriptor for a wide character case conversion.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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
+   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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <wctype.h>
+
+#include <string.h>
+
+#include "wctrans-impl.h"
index a295a09..99d8635 100644 (file)
@@ -433,6 +433,21 @@ typedef void * wctrans_t;
 # endif
 #endif
 
+/* Get a descriptor for a wide character case conversion.  */
+#if @GNULIB_WCTRANS@
+# if !@HAVE_WCTRANS_T@
+_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name));
+# endif
+_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
+_GL_CXXALIASWARN (wctrans);
+#elif defined GNULIB_POSIXCHECK
+# undef wctrans
+# if HAVE_RAW_DECL_WCTRANS
+_GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
+                 "use gnulib module wctrans for portability");
+# endif
+#endif
+
 
 #endif /* _GL_WCTYPE_H */
 #endif /* _GL_WCTYPE_H */
diff --git a/m4/wctrans.m4 b/m4/wctrans.m4
new file mode 100644 (file)
index 0000000..f09b3fc
--- /dev/null
@@ -0,0 +1,14 @@
+# wctrans.m4 serial 1
+dnl Copyright (C) 2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_WCTRANS],
+[
+  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
+  AC_REQUIRE([gl_WCTYPE_H])
+  if test $HAVE_WCTRANS_T = 0; then
+    AC_LIBOBJ([wctrans])
+  fi
+])
index 584083d..a82dec6 100644 (file)
@@ -146,7 +146,7 @@ AC_DEFUN([gl_WCTYPE_H],
 #endif
 #include <wctype.h>
     ]],
-    [wctype iswctype
+    [wctype iswctype wctrans
     ])
 ])
 
@@ -164,6 +164,7 @@ AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
   GNULIB_ISWBLANK=0;    AC_SUBST([GNULIB_ISWBLANK])
   GNULIB_WCTYPE=0;      AC_SUBST([GNULIB_WCTYPE])
   GNULIB_ISWCTYPE=0;    AC_SUBST([GNULIB_ISWCTYPE])
+  GNULIB_WCTRANS=0;     AC_SUBST([GNULIB_WCTRANS])
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_ISWBLANK=1;      AC_SUBST([HAVE_ISWBLANK])
   HAVE_WCTYPE_T=1;      AC_SUBST([HAVE_WCTYPE_T])
diff --git a/modules/wctrans b/modules/wctrans
new file mode 100644 (file)
index 0000000..c1eaeaa
--- /dev/null
@@ -0,0 +1,25 @@
+Description:
+wctrans() function: get descriptor for a wide character case conversion.
+
+Files:
+lib/wctrans.c
+lib/wctrans-impl.h
+m4/wctrans.m4
+
+Depends-on:
+wctype-h
+
+configure.ac:
+gl_FUNC_WCTRANS
+gl_WCTYPE_MODULE_INDICATOR([wctrans])
+
+Makefile.am:
+
+Include:
+<wctype.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
index 8ff881c..1879ed8 100644 (file)
@@ -30,6 +30,7 @@ wctype.h: wctype.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
              -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \
              -e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \
              -e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \
+             -e 's/@''GNULIB_WCTRANS''@/$(GNULIB_WCTRANS)/g' \
              -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \
              -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
              -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \
index 17337cc..1b02a9e 100644 (file)
@@ -50,6 +50,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::iswctype, int, (wint_t, wctype_t));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::towlower, wint_t, (wint_t));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::towupper, wint_t, (wint_t));
 
+#if GNULIB_TEST_WCTRANS
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wctrans, wctrans_t, (const char *));
+#endif
+
 
 int
 main ()