bug-gnulib
[Top][All Lists]
Advanced

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

Re: enforcing the use of string.h related modules


From: Paul Eggert
Subject: Re: enforcing the use of string.h related modules
Date: Fri, 02 Feb 2007 14:16:48 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Eric Blake <address@hidden> writes:

> I reverted the mountlist change, thanks to Bruno's string_.h latest patch not 
> being so vocal about the use of strstr.  This brings both regex and mountlist 
> back to their state prior to the string link warnings,

No it doesn't; regex still has a mempcpy-related change.
To work around the problem I installed the following patch, so that
regex no longer uses mempcpy at all, when used outside glibc.

But this is backwards!  Gnulib is supposed to make it easier to write
code that uses mempcpy, not harder.  The recent "#define mempcpy
mempcpy_is_unportable ...."-like changes are causing too many
problems.

Let's come up with a better way to do that sort of checking.
Or, if we can't, let's remove those #defines entirely.

2007-02-02  Paul Eggert  <address@hidden>

        Avoid mempcpy in the regex code, as the string.h mempcpy stuff
        is causing more trouble than it's curing.
        * lib/regex_internal.h (__mempcpy): Remove.
        * lib/regcomp.c (regerror): Rewrite to avoid the need for mempcpy.
        * m4/regex.m4 (gl_PREREQ_REGEX): Don't check for mempcpy.

Index: lib/regex_internal.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/regex_internal.h,v
retrieving revision 1.30
diff -u -p -r1.30 regex_internal.h
--- lib/regex_internal.h        1 Feb 2007 13:41:12 -0000       1.30
+++ lib/regex_internal.h        2 Feb 2007 22:15:40 -0000
@@ -112,10 +112,6 @@
 # define __wctype wctype
 # define __iswctype iswctype
 # define __btowc btowc
-# ifndef __mempcpy
-#  undef mempcpy
-#  define __mempcpy mempcpy
-# endif
 # define __wcrtomb wcrtomb
 # define __regfree regfree
 # define attribute_hidden
Index: lib/regcomp.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/regcomp.c,v
retrieving revision 1.24
diff -u -p -r1.24 regcomp.c
--- lib/regcomp.c       29 Jan 2007 00:37:14 -0000      1.24
+++ lib/regcomp.c       2 Feb 2007 22:15:40 -0000
@@ -542,17 +542,13 @@ regerror (int errcode, const regex_t *_R

   if (BE (errbuf_size != 0, 1))
     {
+      size_t cpy_size = msg_size;
       if (BE (msg_size > errbuf_size, 0))
        {
-#if defined HAVE_MEMPCPY || defined _LIBC
-         *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
-#else
-         memcpy (errbuf, msg, errbuf_size - 1);
-         errbuf[errbuf_size - 1] = 0;
-#endif
+         cpy_size = errbuf_size - 1;
+         errbuf[cpy_size] = '\0';
        }
-      else
-       memcpy (errbuf, msg, msg_size);
+      memcpy (errbuf, msg, cpy_size);
     }

   return msg_size;
Index: m4/regex.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/regex.m4,v
retrieving revision 1.60
diff -u -p -r1.60 regex.m4
--- m4/regex.m4 16 Jan 2007 16:31:23 -0000      1.60
+++ m4/regex.m4 2 Feb 2007 22:15:40 -0000
@@ -1,4 +1,4 @@
-#serial 42
+#serial 43

 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
 # 2006, 2007 Free Software Foundation, Inc.
@@ -193,6 +193,6 @@ AC_DEFUN([gl_PREREQ_REGEX],
   AC_REQUIRE([AC_GNU_SOURCE])
   AC_REQUIRE([AC_C_RESTRICT])
   AC_REQUIRE([AM_LANGINFO_CODESET])
-  AC_CHECK_FUNCS_ONCE([iswctype mbrtowc mempcpy wcrtomb wcscoll])
+  AC_CHECK_FUNCS_ONCE([iswctype mbrtowc wcrtomb wcscoll])
   AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
 ])




reply via email to

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