# HG changeset patch # User Paul Eggert # Date 1369878489 25200 # Node ID 6166f60e5a9cb055ff3aef5d028863f6a368472b # Parent 2c5155680da76d0084b39298feb3b86ea814250f 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. diff -r 2c5155680da7 -r 6166f60e5a9c ChangeLog --- a/ChangeLog Wed May 29 10:24:17 2013 -0700 +++ b/ChangeLog Wed May 29 18:48:09 2013 -0700 @@ -1,5 +1,16 @@ 2013-05-29 Paul Eggert + 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 diff -r 2c5155680da7 -r 6166f60e5a9c lib/c-ctype.h --- a/lib/c-ctype.h Wed May 29 10:24:17 2013 -0700 +++ b/lib/c-ctype.h Wed May 29 18:48:09 2013 -0700 @@ -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. */ diff -r 2c5155680da7 -r 6166f60e5a9c lib/regcomp.c --- a/lib/regcomp.c Wed May 29 10:24:17 2013 -0700 +++ b/lib/regcomp.c Wed May 29 18:48:09 2013 -0700 @@ -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 diff -r 2c5155680da7 -r 6166f60e5a9c lib/regex_internal.h --- a/lib/regex_internal.h Wed May 29 10:24:17 2013 -0700 +++ b/lib/regex_internal.h Wed May 29 18:48:09 2013 -0700 @@ -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)) diff -r 2c5155680da7 -r 6166f60e5a9c lib/verify.h --- a/lib/verify.h Wed May 29 10:24:17 2013 -0700 +++ b/lib/verify.h Wed May 29 18:48:09 2013 -0700 @@ -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