]> Savannah Git Hosting - gnulib.git/commitdiff
uchar: New module.
authorBruno Haible <bruno@clisp.org>
Tue, 31 Dec 2019 18:35:48 +0000 (19:35 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 31 Dec 2019 18:35:48 +0000 (19:35 +0100)
* lib/uchar.in.h: New file.
* m4/uchar.m4: New file.
* modules/uchar: New file.
* doc/posix-headers/uchar.texi: Mention the new module.

ChangeLog
doc/posix-headers/uchar.texi
lib/uchar.in.h [new file with mode: 0644]
m4/uchar.m4 [new file with mode: 0644]
modules/uchar [new file with mode: 0644]

index 6f6e6190ceb3000c21ad940a78458eebef535609..7d4c550cb2bd3ef94a3df6c733c5c86250ff7f73 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-12-31  Bruno Haible  <bruno@clisp.org>
+
+       uchar: New module.
+       * lib/uchar.in.h: New file.
+       * m4/uchar.m4: New file.
+       * modules/uchar: New file.
+       * doc/posix-headers/uchar.texi: Mention the new module.
+
 2019-12-30  Jim Meyering  <meyering@fb.com>
 
        localeinfo: ->simple would be wrong for LC_ALL=C
index 7662a793059cea0cad40aea95bbc268410e68c99..3907732205c58e592d880ffc8879f43098ec666f 100644 (file)
@@ -5,15 +5,15 @@ Defines the types @code{char16_t}, @code{char32_t} and declares the
 functions @code{mbrtoc16}, @code{c16rtomb}, @code{mbrtoc32},
 @code{c32rtomb}.
 
-Gnulib module: ---
+Gnulib module: uchar
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This header file is missing on many non-glibc platforms:
+glibc 2.15, Mac OS X 10.5, FreeBSD 6.4, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.3, Cygwin, mingw, MSVC 9.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This header file is missing on many non-glibc platforms:
-glibc 2.15, Mac OS X 10.5, FreeBSD 6.4, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.3, Cygwin, mingw, MSVC 9.
 @end itemize
diff --git a/lib/uchar.in.h b/lib/uchar.in.h
new file mode 100644 (file)
index 0000000..2870bae
--- /dev/null
@@ -0,0 +1,54 @@
+/* <uchar.h> substitute - 16-bit and 32-bit wide character types.
+   Copyright (C) 2019 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
+   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 <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2019.  */
+
+/*
+ * ISO C 11 <uchar.h> for platforms that lack it.
+ */
+
+#ifndef _@GUARD_PREFIX@_UCHAR_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if @HAVE_UCHAR_H@
+# @INCLUDE_NEXT@ @NEXT_UCHAR_H@
+#endif
+
+/* Get uint_least16_t, uint_least32_t.  */
+#include <stdint.h>
+
+/* Get mbstate_t, size_t.  */
+#include <wchar.h>
+
+#if !@HAVE_UCHAR_H@
+
+/* A 16-bit variant of wchar_t.
+   Note: This type does *NOT* denote UTF-16 units.  (Only on platforms
+   on which __STDC_UTF_16__ is defined.)  */
+typedef uint_least16_t char16_t;
+
+/* A 32-bit variant of wchar_t.
+   Note: This type does *NOT* denote UTF-32 code points.  (Only on platforms
+   on which __STDC_UTF_32__ is defined.)  */
+typedef uint_least32_t char32_t;
+
+#endif
+
+#endif /* _@GUARD_PREFIX@_UCHAR_H */
diff --git a/m4/uchar.m4 b/m4/uchar.m4
new file mode 100644 (file)
index 0000000..ca6a21f
--- /dev/null
@@ -0,0 +1,19 @@
+# uchar.m4 serial 1
+dnl Copyright (C) 2019 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.
+
+dnl From Bruno Haible.
+dnl Prepare the overridden <uchar.h>.
+
+AC_DEFUN_ONCE([gl_UCHAR_H],
+[
+  gl_CHECK_NEXT_HEADERS([uchar.h])
+  if test $ac_cv_header_uchar_h = yes; then
+    HAVE_UCHAR_H=1
+  else
+    HAVE_UCHAR_H=0
+  fi
+  AC_SUBST([HAVE_UCHAR_H])
+])
diff --git a/modules/uchar b/modules/uchar
new file mode 100644 (file)
index 0000000..48ed448
--- /dev/null
@@ -0,0 +1,40 @@
+Description:
+A GNU-like <uchar.h>.
+
+Files:
+lib/uchar.in.h
+m4/uchar.m4
+
+Depends-on:
+include_next
+stdint
+wchar
+
+configure.ac:
+gl_UCHAR_H
+
+Makefile.am:
+BUILT_SOURCES += uchar.h
+
+uchar.h: uchar.in.h $(top_builddir)/config.status
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''GUARD_PREFIX''@|${gl_include_guard_prefix}|g' \
+             -e 's/@''HAVE_UCHAR_H''@/$(HAVE_UCHAR_H)/g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_UCHAR_H''@|$(NEXT_UCHAR_H)|g' \
+             < $(srcdir)/uchar.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += uchar.h uchar.h-t
+
+Include:
+<uchar.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all