From: Paul Eggert Date: Thu, 30 May 2013 01:48:09 +0000 (-0700) Subject: c-ctype, regex, verify: port to gcc -std=c90 -pedantic X-Git-Tag: v0.1~117 X-Git-Url: http://erislabs.net/gitweb/?p=gnulib.git;a=commitdiff_plain;h=96a263f7953ec80851c81f3a1f40127600b7ea7b 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 --git a/ChangeLog b/ChangeLog index 8097562ed..6cfb46b33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 --git a/lib/c-ctype.h b/lib/c-ctype.h index 36144b8a0..5347d344e 100644 --- a/lib/c-ctype.h +++ b/lib/c-ctype.h @@ -136,7 +136,8 @@ extern int c_tolower (int c) _GL_ATTRIBUTE_CONST; 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 --git a/lib/regcomp.c b/lib/regcomp.c index 534438169..4de2ed2d8 100644 --- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -586,7 +586,7 @@ weak_alias (__regerror, regerror) 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 --git a/lib/regex_internal.h b/lib/regex_internal.h index 0f917e66e..c92fb1a38 100644 --- 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)) diff --git a/lib/verify.h b/lib/verify.h index cb8e90b54..03492efcd 100644 --- 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