bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new module 'iswblank'


From: Bruno Haible
Subject: new module 'iswblank'
Date: Sun, 6 Feb 2011 22:06:15 +0100
User-agent: KMail/1.9.9

The module 'wctype-h' causes an object file (iswblank.o) to be built on
some platforms. It's better to separate code modules from header file
modules.

Here's the proposed change.


2011-02-06  Bruno Haible  <address@hidden>

        New module 'iswblank'.
        * lib/wctype.in.h (iswblank): Don't declare of GNULIB_ISWBLANK is 0.
        * modules/iswblank: New file.
        * modules/wctype-h (Files): Remove lib/iswblank.c.
        (Makefile.am): Substitute GNULIB_ISWBLANK.
        * m4/iswblank.m4: New file, partially extracted from m4/wctype_h.m4.
        * m4/wctype_h.m4 (gl_WCTYPE_MODULE_INDICATOR): New macro.
        (gl_WCTYPE_H_DEFAULTS): New macro.
        (gl_WCTYPE_H): Require it. Remove iswblank related code.
        * modules/iswblank-tests: New file.
        * tests/test-iswblank.c: New file, extraced from tests/test-wctype-h.c.
        * tests/test-wctype-h.c (main): Remove iswblank tests.
        * tests/test-wctype-h-c++.cc: Guard the signature test of iswblank.
        * doc/posix-functions/iswblank.texi: Mention module 'iswblank' instead
        of 'wctype-h'.
        * NEWS: Mention the change.
        * modules/mbchar (Depends-on): Add iswblank.

=============================== m4/iswblank.m4 ===============================
# iswblank.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_ISWBLANK],
[
  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
  AC_REQUIRE([gl_WCTYPE_H])
  AC_CHECK_FUNCS_ONCE([iswblank])
  AC_CHECK_DECLS_ONCE([iswblank])
  if test $ac_cv_func_iswblank = no; then
    HAVE_ISWBLANK=0
    if test $ac_cv_have_decl_iswblank = yes; then
      REPLACE_ISWBLANK=1
    fi
  fi
  if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
    dnl Redefine all of iswcntrl, ..., towupper in <wctype.h>.
    :
  else
    if test $HAVE_ISWBLANK = 0 || test $REPLACE_ISWBLANK = 1; then
      dnl Redefine only iswblank.
      AC_LIBOBJ([iswblank])
    fi
  fi

])
============================== modules/iswblank ==============================
Description:
iswblank() function: test wide character for being blank.

Files:
lib/iswblank.c
m4/iswblank.m4

Depends-on:
wctype-h

configure.ac:
gl_FUNC_ISWBLANK
gl_WCTYPE_MODULE_INDICATOR([iswblank])

Makefile.am:

Include:
<wctype.h>

License:
LGPLv2+

Maintainer:
Bruno Haible
=========================== modules/iswblank-tests ===========================
Files:
tests/test-iswblank.c
tests/macros.h

Depends-on:
wctype-h-c++-tests

configure.ac:

Makefile.am:
TESTS += test-iswblank
check_PROGRAMS += test-iswblank
============================ tests/test-iswblank.c ============================
/* Test of iswblank() function.
   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
   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>

#include <wctype.h>

#include "macros.h"

/* Check that WEOF is defined.  */
wint_t e = WEOF;

int
main (void)
{
  /* Check that the function exist as a function or as a macro.  */
  (void) iswblank (0);
  /* Check that the isw* functions map WEOF to 0.  */
  ASSERT (!iswblank (e));

  return 0;
}
===============================================================================
--- NEWS.orig   Sun Feb  6 21:55:19 2011
+++ NEWS        Sun Feb  6 20:41:59 2011
@@ -12,6 +12,10 @@
 
 Date        Modules         Changes
 
+2011-02-06  wctype          This module no longer provides the iswblank()
+                            function. If you need this function, you now need
+                            to request the 'iswblank' module.
+
 2011-02-06  wctype          This module is renamed to wctype-h.
 
 2011-01-18  multiarch       This no longer #defines AA_APPLE_UNIVERSAL_BUILD;
--- doc/posix-functions/iswblank.texi.orig      Sun Feb  6 21:55:19 2011
+++ doc/posix-functions/iswblank.texi   Sun Feb  6 20:43:11 2011
@@ -4,7 +4,7 @@
 
 POSIX specification:@* 
@url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswblank.html}
 
-Gnulib module: wctype-h
+Gnulib module: iswblank
 
 Portability problems fixed by Gnulib:
 @itemize
--- lib/wctype.in.h.orig        Sun Feb  6 21:55:19 2011
+++ lib/wctype.in.h     Sun Feb  6 19:36:05 2011
@@ -277,7 +277,7 @@
   return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
 }
 
-#elif ! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@
+#elif @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@)
 /* Only the iswblank function is missing.  */
 
 # if @REPLACE_ISWBLANK@
@@ -329,7 +329,6 @@
 #if @REPLACE_ISWCNTRL@
 _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
 _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
-_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
 _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
 _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
 _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
@@ -342,11 +341,6 @@
 #else
 _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
 _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
-# if @REPLACE_ISWBLANK@
-_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
-# else
-_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
-# endif
 _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
 _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
 _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
@@ -359,7 +353,6 @@
 #endif
 _GL_CXXALIASWARN (iswalnum);
 _GL_CXXALIASWARN (iswalpha);
-_GL_CXXALIASWARN (iswblank);
 _GL_CXXALIASWARN (iswcntrl);
 _GL_CXXALIASWARN (iswdigit);
 _GL_CXXALIASWARN (iswgraph);
@@ -370,6 +363,15 @@
 _GL_CXXALIASWARN (iswupper);
 _GL_CXXALIASWARN (iswxdigit);
 
+#if @GNULIB_ISWBLANK@
+# if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@
+_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
+# else
+_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
+# endif
+_GL_CXXALIASWARN (iswblank);
+#endif
+
 #if @REPLACE_ISWCNTRL@ || defined __MINGW32__
 _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
 _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
--- m4/wctype_h.m4.orig Sun Feb  6 21:55:19 2011
+++ m4/wctype_h.m4      Sun Feb  6 20:50:40 2011
@@ -1,4 +1,4 @@
-# wctype_h.m4 serial 12
+# wctype_h.m4 serial 13
 
 dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
 
@@ -11,6 +11,7 @@
 
 AC_DEFUN([gl_WCTYPE_H],
 [
+  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
   AC_REQUIRE([AC_PROG_CC])
   AC_REQUIRE([AC_CANONICAL_HOST])
   AC_CHECK_FUNCS_ONCE([iswcntrl])
@@ -20,21 +21,6 @@
     HAVE_ISWCNTRL=0
   fi
   AC_SUBST([HAVE_ISWCNTRL])
-  AC_CHECK_FUNCS_ONCE([iswblank])
-  AC_CHECK_DECLS_ONCE([iswblank])
-  if test $ac_cv_func_iswblank = yes; then
-    HAVE_ISWBLANK=1
-    REPLACE_ISWBLANK=0
-  else
-    HAVE_ISWBLANK=0
-    if test $ac_cv_have_decl_iswblank = yes; then
-      REPLACE_ISWBLANK=1
-    else
-      REPLACE_ISWBLANK=0
-    fi
-  fi
-  AC_SUBST([HAVE_ISWBLANK])
-  AC_SUBST([REPLACE_ISWBLANK])
 
   AC_REQUIRE([AC_C_INLINE])
 
@@ -91,10 +77,22 @@
   if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
     dnl Redefine all of iswcntrl, ..., towupper in <wctype.h>.
     :
-  else
-    if test $HAVE_ISWBLANK = 0 || test $REPLACE_ISWBLANK = 1; then
-      dnl Redefine only iswblank.
-      AC_LIBOBJ([iswblank])
-    fi
   fi
 ])
+
+AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+  dnl Define it also as a C macro, for the benefit of the unit tests.
+  gl_MODULE_INDICATOR_FOR_TESTS([$1])
+])
+
+AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
+[
+  GNULIB_ISWBLANK=0;    AC_SUBST([GNULIB_ISWBLANK])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_ISWBLANK=1;      AC_SUBST([HAVE_ISWBLANK])
+  REPLACE_ISWBLANK=0;   AC_SUBST([REPLACE_ISWBLANK])
+])
--- modules/mbchar.orig Sun Feb  6 21:55:19 2011
+++ modules/mbchar      Sun Feb  6 20:42:37 2011
@@ -11,6 +11,7 @@
 stdbool
 wchar
 wctype-h
+iswblank
 wcwidth
 memcmp
 
--- modules/wctype-h.orig       Sun Feb  6 21:55:19 2011
+++ modules/wctype-h    Sun Feb  6 20:18:27 2011
@@ -3,7 +3,6 @@
 
 Files:
 lib/wctype.in.h
-lib/iswblank.c
 m4/wctype_h.m4
 m4/wint_t.m4
 
@@ -28,6 +27,7 @@
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
              -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
+             -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \
              -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \
              -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
              -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
--- tests/test-wctype-h-c++.cc.orig     Sun Feb  6 21:55:19 2011
+++ tests/test-wctype-h-c++.cc  Sun Feb  6 20:29:59 2011
@@ -26,7 +26,9 @@
 
 SIGNATURE_CHECK (GNULIB_NAMESPACE::iswalnum, int, (wint_t));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::iswalpha, int, (wint_t));
+#if GNULIB_TEST_ISWBLANK
 SIGNATURE_CHECK (GNULIB_NAMESPACE::iswblank, int, (wint_t));
+#endif
 SIGNATURE_CHECK (GNULIB_NAMESPACE::iswcntrl, int, (wint_t));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::iswdigit, int, (wint_t));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::iswgraph, int, (wint_t));
--- tests/test-wctype-h.c.orig  Sun Feb  6 21:55:19 2011
+++ tests/test-wctype-h.c       Sun Feb  6 20:32:58 2011
@@ -33,7 +33,6 @@
   /* Check that the isw* functions exist as functions or as macros.  */
   (void) iswalnum (0);
   (void) iswalpha (0);
-  (void) iswblank (0);
   (void) iswcntrl (0);
   (void) iswdigit (0);
   (void) iswgraph (0);
@@ -47,7 +46,6 @@
   /* Check that the isw* functions map WEOF to 0.  */
   ASSERT (!iswalnum (e));
   ASSERT (!iswalpha (e));
-  ASSERT (!iswblank (e));
   ASSERT (!iswcntrl (e));
   ASSERT (!iswdigit (e));
   ASSERT (!iswgraph (e));


-- 
In memoriam Chris Gueffroy <http://en.wikipedia.org/wiki/Chris_Gueffroy>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]