Mercurial > hg > octave-lyh > gnulib-hg
changeset 8073:eaa00773406b
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
(and make the code a tad smaller to boot).
* m4/regex.m4 (gl_PREREQ_REGEX): Don't check for mempcpy.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 02 Feb 2007 22:15:43 +0000 |
parents | c31253d5c505 |
children | 2700fc6b6734 |
files | ChangeLog lib/regcomp.c lib/regex_internal.h m4/regex.m4 |
diffstat | 4 files changed, 15 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-02-02 Paul Eggert <eggert@cs.ucla.edu> + + 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 + (and make the code a tad smaller to boot). + * m4/regex.m4 (gl_PREREQ_REGEX): Don't check for mempcpy. + 2007-02-02 Jim Meyering <jim@meyering.net> * modules/arpa_inet: Put AC_PROG_MKDIR_P in the configure.ac:
--- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -542,17 +542,13 @@ 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;
--- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -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
--- a/m4/regex.m4 +++ b/m4/regex.m4 @@ -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_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>]) ])