strftime: remove dependencies on multibyte modules
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 18 Jan 2011 17:40:16 +0000 (09:40 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 18 Jan 2011 18:26:59 +0000 (10:26 -0800)
strftime depended on mbrlen, mbsinit, and wchar, but these modules
are needed only if ! MULTIBYTE_IS_FORMAT_SAFE, and that is true
only if __osf__ is defined, and I suspect OSF doesn't need these
other modules.  If my guess is wrong, we'll need to come up with a
variant of strftime that doesn't need the multibyte modules.

I discovered this problem when attempting modify Emacs to use the
strftime module.  With the previous gnulib, this caused Emacs to
need 31 new files, ranging from lib/config.charset to
m4/wint_t.m4.  This was overkill and I expect would be offputting
to the Emacs maintainers.  After this change, only 6 new files are
needed, namely strftime.[ch], srtftime.m4, stdbool.in.h,
stdbool.m4, and tm_gmtoff.m4.

* lib/strftime.c (MULTIBYTE_IS_FORMAT_SAFE): Define to 1 always.
Suggested by Bruno Haible in
<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00238.html>.
* m4/strftime.m4 (gl_FUNC_STRFTIME): Do not require AC_TYPE_MBSTATE_T,
and do not check for wchar.h.
* modules/strftime (Files): Remove m4/mbstate_t.m4.
(Depends-on): Remove mbrlen, mbsinit, wchar.

ChangeLog
lib/strftime.c
m4/strftime.m4
modules/strftime

index 9668daf..783de42 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2011-01-18  Paul Eggert  <eggert@cs.ucla.edu>
+
+       strftime: remove dependencies on multibyte modules
+
+       strftime depended on mbrlen, mbsinit, and wchar, but these modules
+       are needed only if ! MULTIBYTE_IS_FORMAT_SAFE, and that is true
+       only if __osf__ is defined, and I suspect OSF doesn't need these
+       other modules.  If my guess is wrong, we'll need to come up with a
+       variant of strftime that doesn't need the multibyte modules.
+
+       I discovered this problem when attempting modify Emacs to use the
+       strftime module.  With the previous gnulib, this caused Emacs to
+       need 31 new files, ranging from lib/config.charset to
+       m4/wint_t.m4.  This was overkill and I expect would be offputting
+       to the Emacs maintainers.  After this change, only 6 new files are
+       needed, namely strftime.[ch], srtftime.m4, stdbool.in.h,
+       stdbool.m4, and tm_gmtoff.m4.
+
+       * lib/strftime.c (MULTIBYTE_IS_FORMAT_SAFE): Define to 1 always.
+       Suggested by Bruno Haible in
+       <http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00238.html>.
+       * m4/strftime.m4 (gl_FUNC_STRFTIME): Do not require AC_TYPE_MBSTATE_T,
+       and do not check for wchar.h.
+       * modules/strftime (Files): Remove m4/mbstate_t.m4.
+       (Depends-on): Remove mbrlen, mbsinit, wchar.
+
 2011-01-18  Bruno Haible  <bruno@clisp.org>
 
        Tests for module 'get-rusage-as'.
index de890b7..0a02b50 100644 (file)
@@ -48,8 +48,11 @@ extern char *tzname[];
    GB18030, EUC-TW, BIG5, BIG5-HKSCS, CP950, EUC-JP, EUC-KR, CP949,
    SHIFT_JIS, CP932, JOHAB) are safe for formats, because the byte '%'
    cannot occur in a multibyte character except in the first byte.
-   But this does not hold for the DEC-HANYU encoding used on OSF/1.  */
-#if !defined __osf__
+
+   The DEC-HANYU encoding used on OSF/1 is not safe for formats, but
+   this encoding has never been seen in real-life use, so we ignore
+   it.  */
+#if !(defined __osf__ && 0)
 # define MULTIBYTE_IS_FORMAT_SAFE 1
 #endif
 #define DO_MULTIBYTE (! MULTIBYTE_IS_FORMAT_SAFE)
index d2a6f7e..d9de341 100644 (file)
@@ -21,11 +21,9 @@ AC_DEFUN([gl_FUNC_STRFTIME],
  # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE.
  AC_REQUIRE([AC_STRUCT_TIMEZONE])
 
- AC_REQUIRE([AC_TYPE_MBSTATE_T])
  AC_REQUIRE([gl_TM_GMTOFF])
 
  AC_CHECK_FUNCS_ONCE([tzset])
- AC_CHECK_HEADERS_ONCE([wchar.h])
 
  AC_DEFINE([my_strftime], [nstrftime],
    [Define to the name of the strftime replacement function.])
index dc53916..0af5e13 100644 (file)
@@ -4,17 +4,13 @@ nstrftime() function: convert date and time to string, with GNU extensions.
 Files:
 lib/strftime.h
 lib/strftime.c
-m4/mbstate_t.m4
 m4/tm_gmtoff.m4
 m4/strftime.m4
 
 Depends-on:
 extensions
-mbrlen
-mbsinit
 stdbool
 time_r
-wchar
 
 configure.ac:
 gl_FUNC_GNU_STRFTIME