Mercurial > hg > octave-nkf > gnulib-hg
changeset 17423:6105f1dfb98e
c-ctype, regex, verify: port to gcc -std=c90 -pedantic
Avoid constructions that are rejected by gcc -std=c90 -pedantic.
This fixes a porting bug I recently reintroduced in regex, and
some other instances that I discovered while testing the fix.
* lib/c-ctype.h [__STRICT_ANSI__]: Avoid ({ ... }).
* lib/regcomp.c (utf8_sb_map) [__STRICT_ANSI__]: Avoid [0 ... N] = E.
* lib/regex_internal.h [!_LIBC && GNULIB_LOCK]: Do not use a macro
with an empty argument if this is a pedantic pre-C99 GCC.
* lib/verify.h: Do not use _Static_assert if this is a pedantic
pre-C11 GCC.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 29 May 2013 18:48:09 -0700 |
parents | 08883714ab3e |
children | c2521dab0c42 |
files | ChangeLog lib/c-ctype.h lib/regcomp.c lib/regex_internal.h lib/verify.h |
diffstat | 5 files changed, 33 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2013-05-29 Paul Eggert <eggert@cs.ucla.edu> + c-ctype, regex, verify: port to gcc -std=c90 -pedantic + Avoid constructions that are rejected by gcc -std=c90 -pedantic. + This fixes a porting bug I recently reintroduced in regex, and + some other instances that I discovered while testing the fix. + * lib/c-ctype.h [__STRICT_ANSI__]: Avoid ({ ... }). + * lib/regcomp.c (utf8_sb_map) [__STRICT_ANSI__]: Avoid [0 ... N] = E. + * lib/regex_internal.h [!_LIBC && GNULIB_LOCK]: Do not use a macro + with an empty argument if this is a pedantic pre-C99 GCC. + * lib/verify.h: Do not use _Static_assert if this is a pedantic + pre-C11 GCC. + regex: adapt to locking regime instead of depending on pthread Instead of depending on pthread, adapt to whatever thread modules are in use. Problem reported by Ludovic Courtès in
--- a/lib/c-ctype.h +++ b/lib/c-ctype.h @@ -136,7 +136,8 @@ extern int c_toupper (int c) _GL_ATTRIBUTE_CONST; -#if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS +#if (defined __GNUC__ && !defined __STRICT_ANSI__ && defined __OPTIMIZE__ \ + && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS) /* ASCII optimizations. */
--- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -586,7 +586,7 @@ static const bitset_t utf8_sb_map = { /* Set the first 128 bits. */ -# ifdef __GNUC__ +# if defined __GNUC__ && !defined __STRICT_ANSI__ [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX # else # if 4 * BITSET_WORD_BITS < ASCII_CHARS
--- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -42,7 +42,22 @@ # define lock_unlock(lock) __libc_lock_unlock (lock) #elif defined GNULIB_LOCK # include "glthread/lock.h" -# define lock_define(name) gl_lock_define (, name) + /* Use gl_lock_define if empty macro arguments are known to work. + Otherwise, fall back on less-portable substitutes. */ +# if ((defined __GNUC__ && !defined __STRICT_ANSI__) \ + || (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__)) +# define lock_define(name) gl_lock_define (, name) +# elif USE_POSIX_THREADS +# define lock_define(name) pthread_mutex_t name; +# elif USE_PTH_THREADS +# define lock_define(name) pth_mutex_t name; +# elif USE_SOLARIS_THREADS +# define lock_define(name) mutex_t name; +# elif USE_WINDOWS_THREADS +# define lock_define(name) gl_lock_t name; +# else +# define lock_define(name) +# endif # define lock_init(lock) glthread_lock_init (&(lock)) # define lock_fini(lock) glthread_lock_destroy (&(lock)) # define lock_lock(lock) glthread_lock_lock (&(lock))
--- a/lib/verify.h +++ b/lib/verify.h @@ -31,7 +31,9 @@ Use this only with GCC. If we were willing to slow 'configure' down we could also use it with other compilers, but since this affects only the quality of diagnostics, why bother? */ -# if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)) && !defined __cplusplus +# if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \ + && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \ + && !defined __cplusplus) # define _GL_HAVE__STATIC_ASSERT 1 # endif /* The condition (99 < __GNUC__) is temporary, until we know about the