[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: quotearg.c mbsinit
From: |
Paul Eggert |
Subject: |
Re: quotearg.c mbsinit |
Date: |
Mon, 24 Sep 2001 10:20:16 -0700 (PDT) |
> Date: Sun, 23 Sep 2001 13:46:07 (GMT)
> From: "Golubev I. N." <address@hidden>
>
> Some buggy libc's have `mbrtowc', but not `mbsinit' (violate Amendment
> 1 of ISO C90?). It appears that this is because `mbstate_t' value is
> never used by `mbrtowc' (`mbstate_t' is `char', just to shut
> compiler), so the fix is to pretend that `mbsinit' always returns
> true.
>
> gettext-0.10.40 already implements such a fix, you need just to port
> code from `mbswidth.c', `mbswidth.m4', `configure.in'.
Thanks. I did that for tar 1.13.24, and here's a proposed port of
this fix to bison.
2001-09-24 Paul Eggert <address@hidden>
Port quotearg fixes from tar 1.13.24.
* lib/quotearg.c: BSD/OS 4.1 wchar.h requires FILE and struct
tm to be declared.
(HAVE_MBSINIT): Undef if !HAVE_MBRTOWC.
(mbsinit): Define to 1 if !defined mbsinit && !HAVE_MBSINIT.
* m4/Makefile.am (EXTRA_DIST): Add mbrtowc.m4.
* m4/mbrtowc.m4: New file.
* m4/prereq.m4 (jm_PREREQ_QUOTEARG): Check for mbsinit and stddef.h.
Use jm_FUNC_MBRTOWC instead of AC_CHECK_FUNCS(mbrtowc).
diff -Naurp bison/lib/quotearg.c bison-fix/lib/quotearg.c
--- bison/lib/quotearg.c Fri Aug 3 08:48:49 2001
+++ bison-fix/lib/quotearg.c Mon Sep 17 23:41:26 2001
@@ -63,6 +63,11 @@
#endif
#if HAVE_WCHAR_H
+
+/* BSD/OS 4.1 wchar.h requires FILE and struct tm to be declared. */
+# include <stdio.h>
+# include <time.h>
+
# include <wchar.h>
#endif
@@ -73,8 +78,12 @@
# undef MB_CUR_MAX
# define MB_CUR_MAX 1
# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0)
-# define mbsinit(ps) 1
# define iswprint(wc) ISPRINT ((unsigned char) (wc))
+# undef HAVE_MBSINIT
+#endif
+
+#if !defined mbsinit && !HAVE_MBSINIT
+# define mbsinit(ps) 1
#endif
#ifndef iswprint
diff -Naurp bison/m4/Makefile.am bison-fix/m4/Makefile.am
--- bison/m4/Makefile.am Fri Aug 3 08:22:03 2001
+++ bison-fix/m4/Makefile.am Mon Sep 24 13:43:09 2001
@@ -11,6 +11,7 @@ isc-posix.m4 \
lcmessage.m4 \
m4.m4 \
malloc.m4 \
+mbrtowc.m4 \
mbstate_t.m4 \
prereq.m4 \
progtest.m4 \
diff -Naurp bison/m4/mbrtowc.m4 bison-fix/m4/mbrtowc.m4
--- bison/m4/mbrtowc.m4 Thu Jan 1 00:00:00 1970
+++ bison-fix/m4/mbrtowc.m4 Thu Aug 23 17:25:21 2001
@@ -0,0 +1,18 @@
+#serial 4
+
+dnl From Paul Eggert
+
+AC_DEFUN([jm_FUNC_MBRTOWC],
+[
+ AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
+ jm_cv_func_mbrtowc,
+ [AC_TRY_LINK(
+ [#include <wchar.h>],
+ [mbstate_t state; return ! (sizeof state && mbrtowc);],
+ jm_cv_func_mbrtowc=yes,
+ jm_cv_func_mbrtowc=no)])
+ if test $jm_cv_func_mbrtowc = yes; then
+ AC_DEFINE(HAVE_MBRTOWC, 1,
+ [Define to 1 if mbrtowc and mbstate_t are properly declared.])
+ fi
+])
diff -Naurp bison/m4/prereq.m4 bison-fix/m4/prereq.m4
--- bison/m4/prereq.m4 Mon Oct 16 17:28:40 2000
+++ bison-fix/m4/prereq.m4 Mon Sep 24 13:44:15 2001
@@ -1,12 +1,13 @@
-#serial 1
+#serial 2
dnl These are the prerequisite macros for files in the lib/
dnl directories of Bison.
AC_DEFUN([jm_PREREQ_QUOTEARG],
[
- AC_CHECK_FUNCS(isascii iswprint mbrtowc)
- AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h)
+ AC_CHECK_FUNCS(isascii iswprint mbsinit)
+ jm_FUNC_MBRTOWC
+ AC_CHECK_HEADERS(limits.h stddef.h stdlib.h string.h wchar.h wctype.h)
AC_HEADER_STDC
AC_C_BACKSLASH_A
AC_MBSTATE_T