sethostname tests: Avoid test failure on Cygwin
On Cygwin 2.9, I see this test failure: FAIL: test-sethostname2 === error setting valid hostname. FAIL test-sethostname2.exe (exit status: 1) This patch fixes it. Now the test reports Skipping test: insufficient permissions. 2021-01-20 Bruno Haible sethostname tests: Avoid test failure on Cygwin. * tests/test-sethostname2.c (main): Treat errno EACCESS like EPERM. diff --git a/tests/test-sethostname2.c b/tests/test-sethostname2.c index 8e5c12d..2af95f6 100644 --- a/tests/test-sethostname2.c +++ b/tests/test-sethostname2.c @@ -76,7 +76,9 @@ main (int argc, char *argv[] _GL_UNUSED) "Skipping test: sethostname is not really implemented.\n"); return 77; } - else if (rcs == -1 && errno == EPERM) + else if (rcs == -1 + && (errno == EPERM + || errno == EACCES)) /* Cygwin */ { fprintf (stderr, "Skipping test: insufficient permissions.\n"); return 77;
ptsname_r on Cygwin
Hi Ken, On Cygwin 2.9 (64-bit) I see a test failure in test-ptsname_r.c, here: { char buffer[256]; int result; result = ptsname_r (-1, buffer, sizeof buffer); ASSERT (result != 0); // < HERE ASSERT (result == EBADF || result == ENOTTY); } While https://www.kernel.org/doc/man-pages/online/pages/man3/ptsname_r.3.html says that ptsname_r, upon failure, should return an error code, on Cygwin, it returns 0 and stores the empty string in 'buffer'. This causes 2 test failures of Gnulib tests: FAIL: test-ptsname == ../../gltests/test-ptsname.c:76: assertion 'result == NULL' failed FAIL test-ptsname.exe (exit status: 134) FAIL: test-ptsname_r ../../gltests/test-ptsname_r.c:126: assertion 'result != 0' failed FAIL test-ptsname_r.exe (exit status: 134) Bruno
Re: [PATCH 1/5] posix: Sync regex code with gnulib
On 1/19/21 7:43 AM, Bruno Haible wrote: Adhemerval Zanella wrote: -# if (__GNUC__ >= 7) || (__clang_major__ >= 10) +# if (__GNUC__ >= 7) || (defined __clang_major__ &&__clang_major__ >= 10) I would write it as: +# if (__GNUC__ >= 7) || (defined __clang__ && __clang_major__ >= 10) This line should be used only if _LIBC is defined, so we can simplify it to just "#if __GNUC__ >= 7" and thus not worry about Clang. I see that Gnulib wasn't consistent about this, so I installed the attached patch to Gnulib to fix the issue here and elsewhere. The idea is that the Gnulib regex_internal.h can be copied back to glibc, and that the other uses in Gnulib should be similar. On 1/19/21 6:43 AM, Adhemerval Zanella wrote: Paul, this seemed to a common pattern scatter on multiple file in gnulib. Wouldn't be better to consolidate it on cdefs.h? We could append something like the following to cdefs.h, and switch to __attribute_fallthrough__ for modules shared between the two systems. Is that something you'd like to pursue? (We should also sync Gnulib cdefs.h back to glibc of course.) #if defined __STDC_VERSION__ && 201710L < __STDC_VERSION__ # define __attribute_fallthrough__ [[__fallthrough__]] #elif __GNUC_PREREQ (7, 0) || __glibc_has_attribute (__fallthrough__) # define __attribute_fallthrough__ __attribute__ ((__fallthrough__)) #else # define __attribute_fallthrough__ ((void) 0) #endif From 5c52f00c69f39fe86ec087654893087a83290ee7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 19 Jan 2021 18:35:30 -0800 Subject: [PATCH] fnmatch, regex, fts: FALLTHROUGH consistency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Be more consistent about how FALLTHROUGH is defined. For Gnulib, use attribute.h. For glibc, use __GNUC__ >= 7. Problem for glibc reported by Vaseeharan Vinayagamoorthy in: https://sourceware.org/pipermail/libc-alpha/2021-January/121778.html * lib/fnmatch.c (FALLTHROUGH) [_LIBC]: * lib/regex_internal.h (FALLTHROUGH) [_LIBC]: Don’t worry about Clang, as it’s not needed and provokes GCC. * lib/fts.c (FALLTHROUGH) [!_LIBC]: * lib/regex_internal.h (FALLTHROUGH) [!_LIBC]: Rely on attribute.h for FALLTHROUGH * modules/regex: Depend on attribute module. --- ChangeLog| 15 +++ lib/fnmatch.c| 2 +- lib/fts.c| 4 ++-- lib/regex_internal.h | 6 -- modules/regex| 1 + 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 269577caa..290fa1b4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2021-01-19 Paul Eggert + + fnmatch, regex, fts: FALLTHROUGH consistency + Be more consistent about how FALLTHROUGH is defined. + For Gnulib, use attribute.h. For glibc, use __GNUC__ >= 7. + Problem for glibc reported by Vaseeharan Vinayagamoorthy in: + https://sourceware.org/pipermail/libc-alpha/2021-January/121778.html + * lib/fnmatch.c (FALLTHROUGH) [_LIBC]: + * lib/regex_internal.h (FALLTHROUGH) [_LIBC]: + Don’t worry about Clang, as it’s not needed and provokes GCC. + * lib/fts.c (FALLTHROUGH) [!_LIBC]: + * lib/regex_internal.h (FALLTHROUGH) [!_LIBC]: + Rely on attribute.h for FALLTHROUGH + * modules/regex: Depend on attribute module. + 2021-01-19 KO Myung-Hun spawn-pipe: Fix SIGSEGV on OS/2 kLIBC. diff --git a/lib/fnmatch.c b/lib/fnmatch.c index 5896812c9..b8a71f164 100644 --- a/lib/fnmatch.c +++ b/lib/fnmatch.c @@ -64,7 +64,7 @@ extern int fnmatch (const char *pattern, const char *string, int flags); #endif #ifdef _LIBC -# if (__GNUC__ >= 7) || (__clang_major__ >= 10) +# if __GNUC__ >= 7 # define FALLTHROUGH __attribute__ ((__fallthrough__)) # else # define FALLTHROUGH ((void) 0) diff --git a/lib/fts.c b/lib/fts.c index 8a9b5ed96..e6603f40e 100644 --- a/lib/fts.c +++ b/lib/fts.c @@ -200,8 +200,8 @@ enum Fts_stat while (false) #endif -#ifndef FALLTHROUGH -# if (__GNUC__ >= 7) || (__clang_major__ >= 10) +#ifdef _LIBC +# if __GNUC__ >= 7 # define FALLTHROUGH __attribute__ ((__fallthrough__)) # else # define FALLTHROUGH ((void) 0) diff --git a/lib/regex_internal.h b/lib/regex_internal.h index b4f91d9ec..3fa2bf1aa 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -830,12 +830,14 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx) } #endif /* RE_ENABLE_I18N */ -#ifndef FALLTHROUGH -# if (__GNUC__ >= 7) || (__clang_major__ >= 10) +#ifdef _LIBC +# if __GNUC__ >= 7 # define FALLTHROUGH __attribute__ ((__fallthrough__)) # else # define FALLTHROUGH ((void) 0) # endif +#else +# include "attribute.h" #endif #endif /* _REGEX_INTERNAL_H */ diff --git a/modules/regex b/modules/regex index 20cbe375a..a32c46e18 100644 --- a/modules/regex +++ b/modules/regex @@ -16,6 +16,7 @@ Depends-on: c99 extensions ssize_t +attribute [test $ac_use_included_regex = yes] btowc [test $ac_use_included_regex = yes] builtin-expect [test $ac_use_included_regex = yes] dynarray[test
Re: Portability issues with scractch_buffer
On 1/19/21 10:22 AM, Akim Demaille wrote: Clang 3.3 and 3.4 cannot compile the new scratch-buffer module. On Bison's CI (Clang 3.4: https://api.travis-ci.org/v3/job/755133481/log.txt), there is: ... CC lib/lib_libbison_a-canonicalize.o In file included from ../lib/canonicalize.c:31: In file included from ../lib/scratch_buffer.h:28: ../lib/malloc/scratch_buffer.h:69:11: error: unknown type name 'max_align_t' Evidently the stddef module is not arranging for the replacement stddef.h to define max_align_t properly. Could you investigate why that might be? What does lib/stddef.h look like? What is the output of 'clang -E lib/lib_libbison_a-canonicalize.c' (with the proper compile-time options)? ../lib/canonicalize.c:237:15: warning: declaration does not declare anything [-Wmissing-declarations] FALLTHROUGH; ^~~ ../lib/attribute.h:142:21: note: expanded from macro 'FALLTHROUGH' #define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH ^ ./lib/config.h:2016:36: note: expanded from macro '_GL_ATTRIBUTE_FALLTHROUGH' # define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__)) My guess is that the preprocessor expands __has_attribute (__fallthrough__) to 1 but the attribute does not actually work. Is that the case? Looking at the Clang 3.4 source code, I don't see how that could be, as clang-3.4/include/clang/Basic/Attr.td lists the clang::fallthrough attribute for CXX11 but not for C. Possibly I'm misunderstanding that file, but just to check, does your preprocessor version match your compiler version? or are you compiling with clang++? It might not worth worrying about this warning glitch for such an old compiler, as you can just ignore the bogus warnings.
Portability issues with scractch_buffer
Hi all, Clang 3.3 and 3.4 cannot compile the new scratch-buffer module. On Bison's CI (Clang 3.4: https://api.travis-ci.org/v3/job/755133481/log.txt), there is: > make[2]: Entering directory `/home/travis/build/bison-3.7.4.285-a7d1a/_build' > CC lib/lib_libbison_a-bitsetv.o > CC lib/lib_libbison_a-c-ctype.o > CC lib/lib_libbison_a-c-strcasecmp.o > CC lib/lib_libbison_a-c-strncasecmp.o > CC lib/lib_libbison_a-canonicalize.o > In file included from ../lib/canonicalize.c:31: > In file included from ../lib/scratch_buffer.h:28: > ../lib/malloc/scratch_buffer.h:69:11: error: unknown type name 'max_align_t' > union { max_align_t __align; char __c[1024]; } __space; > ^ > ../lib/canonicalize.c:237:15: warning: declaration does not declare anything > [-Wmissing-declarations] > FALLTHROUGH; > ^~~ > ../lib/attribute.h:142:21: note: expanded from macro 'FALLTHROUGH' > #define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH > ^ > ./lib/config.h:2016:36: note: expanded from macro '_GL_ATTRIBUTE_FALLTHROUGH' > # define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__)) >^ > 1 warning and 1 error generated. > make[2]: *** [lib/lib_libbison_a-canonicalize.o] Error 1 > make[2]: *** Waiting for unfinished jobs > CC lib/lib_libbison_a-careadlinkat.o > make[2]: Leaving directory `/home/travis/build/bison-3.7.4.285-a7d1a/_build' > make[1]: *** [all-recursive] Error 1 > make[1]: Leaving directory `/home/travis/build/bis Cheers!
Re: [PATCH 1/7] spawn: Use special invocation for on OS/2 kLIBC
Hi KO, Thanks, I applied patches 1, 2, 3, 5, 6, 7, slightly modified. Some of the things that you put into the git commit message actually better belong in the code, as a comment. Bruno
Re: [PATCH 5/7] zerosize-ptr: Fix compilation on OS/2 kLIBC
Applied with modifications: > -#if HAVE_SYS_MMAN_H && HAVE_MPROTECT > +#if HAVE_SYS_MMAN_H && HAVE_MPROTECT && (!defined __KLIBC__ || HAVE_MMAP) There's a comment two lines above, that explains why HAVE_MMAP is not the right test here. And since you write "OS/2 kLIBC has and mprotect() but not mmap()", defined __KLIBC__ implies !HAVE_MMAP. Bruno
Re: [PATCH 4/7] stdlib: putenv() needs a cast on OS/2 kLIBC
Hi KO, > On OS/2 kLIBC, the first parameter of putenv () is `const char *string' > not `char *string'. Can't you fix that in OS/2 kLIBC? Then a workaround in Gnulib would not be needed. Bruno
Re: [PATCH 1/5] posix: Sync regex code with gnulib
On 19/01/2021 14:16, Florian Weimer wrote: > * Adhemerval Zanella: > >> On 19/01/2021 13:52, Florian Weimer wrote: >>> * Adhemerval Zanella via Libc-alpha: >>> Paul, this seemed to a common pattern scatter on multiple file in gnulib. Wouldn't be better to consolidate it on cdefs.h? >>> >>> gnulib shouldn't be using cdefs.h on glibc systems, so I think a >>> separate header would be needed. >> >> What is the problem of using cdefs.h for internal implementation? > > Isn't regex_internal.h sync'ed with gnulib? Yes, and gnulib also has an internal cdefs (which we should sync btw).
Re: [PATCH 1/5] posix: Sync regex code with gnulib
* Adhemerval Zanella: > On 19/01/2021 13:52, Florian Weimer wrote: >> * Adhemerval Zanella via Libc-alpha: >> >>> Paul, this seemed to a common pattern scatter on multiple file in gnulib. >>> Wouldn't be better to consolidate it on cdefs.h? >> >> gnulib shouldn't be using cdefs.h on glibc systems, so I think a >> separate header would be needed. > > What is the problem of using cdefs.h for internal implementation? Isn't regex_internal.h sync'ed with gnulib? Thanks, Florian -- Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn, Commercial register: Amtsgericht Muenchen, HRB 153243, Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
Re: [PATCH 1/5] posix: Sync regex code with gnulib
On 19/01/2021 13:52, Florian Weimer wrote: > * Adhemerval Zanella via Libc-alpha: > >> Paul, this seemed to a common pattern scatter on multiple file in gnulib. >> Wouldn't be better to consolidate it on cdefs.h? > > gnulib shouldn't be using cdefs.h on glibc systems, so I think a > separate header would be needed. What is the problem of using cdefs.h for internal implementation?
Re: [PATCH 1/5] posix: Sync regex code with gnulib
* Adhemerval Zanella via Libc-alpha: > Paul, this seemed to a common pattern scatter on multiple file in gnulib. > Wouldn't be better to consolidate it on cdefs.h? gnulib shouldn't be using cdefs.h on glibc systems, so I think a separate header would be needed. Thanks, Florian -- Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn, Commercial register: Amtsgericht Muenchen, HRB 153243, Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
Re: [PATCH 1/5] posix: Sync regex code with gnulib
Adhemerval Zanella wrote: > -# if (__GNUC__ >= 7) || (__clang_major__ >= 10) > +# if (__GNUC__ >= 7) || (defined __clang_major__ &&__clang_major__ >= 10) I would write it as: +# if (__GNUC__ >= 7) || (defined __clang__ && __clang_major__ >= 10) because 'defined __clang__' is the widely known way to test for a clang (or derivate) compiler. Bruno
Re: [PATCH 1/5] posix: Sync regex code with gnulib
After this commit [1], I am seeing -Werror=undef when bootstapping glibc on aarch64-none-linux-gnu : In file included from regex.c:70:0: regex_internal.h:852:26: error: "__clang_major__" is not defined [-Werror=undef] # if (__GNUC__ >= 7) || (__clang_major__ >= 10) ^~~ The build/host/target setup is: Build: aarch64-none-linux-gnu (Ubuntu 14.04) Host: aarch64-none-linux-gnu Target: aarch64-none-linux-gnu [1] commit c2a150d089fa096cb5f9e342da80fb30dc0d1953 Author: Adhemerval Zanella AuthorDate: Tue Dec 29 17:32:25 2020 -0300 Commit: Adhemerval Zanella CommitDate: Mon Jan 4 08:38:52 2021 -0300 posix: Sync regex code with gnulib It sync with gnulib commit 43ee1a6bf. The main change is 9682f18e9. (which does not have a meaniful description). Checked on x86_64-linux-gnu. On 30/12/2020, 20:15, "Libc-alpha on behalf of Adhemerval Zanella via Libc-alpha" wrote: It sync with gnulib commit 43ee1a6bf. The main change is 9682f18e9. (which does not have a meaniful description). Checked on x86_64-linux-gnu. --- posix/regcomp.c| 2 +- posix/regex.h | 17 - posix/regex_internal.c | 19 ++- posix/regex_internal.h | 16 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/posix/regcomp.c b/posix/regcomp.c index 93bb0a0538..692928b0db 100644 --- a/posix/regcomp.c +++ b/posix/regcomp.c @@ -558,7 +558,7 @@ weak_alias (__regerror, regerror) static const bitset_t utf8_sb_map = { /* Set the first 128 bits. */ -# if defined __GNUC__ && !defined __STRICT_ANSI__ +# if (defined __GNUC__ || __clang_major__ >= 4) && !defined __STRICT_ANSI__ [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX # else # if 4 * BITSET_WORD_BITS < ASCII_CHARS diff --git a/posix/regex.h b/posix/regex.h index 5fe41c8685..7418e6c76f 100644 --- a/posix/regex.h +++ b/posix/regex.h @@ -612,7 +612,9 @@ extern int re_exec (const char *); 'configure' might #define 'restrict' to those words, so pick a different name. */ #ifndef _Restrict_ -# if defined __restrict || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) +# if defined __restrict \ + || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ + || __clang_major__ >= 3 # define _Restrict_ __restrict # elif 199901L <= __STDC_VERSION__ || defined restrict # define _Restrict_ restrict @@ -620,13 +622,18 @@ extern int re_exec (const char *); # define _Restrict_ # endif #endif -/* For [restrict], use glibc's __restrict_arr if available. - Otherwise, GCC 3.1 (not in C++ mode) and C99 support [restrict]. */ +/* For the ISO C99 syntax + array_name[restrict] + use glibc's __restrict_arr if available. + Otherwise, GCC 3.1 and clang support this syntax (but not in C++ mode). + Other ISO C99 compilers support it as well. */ #ifndef _Restrict_arr_ # ifdef __restrict_arr # define _Restrict_arr_ __restrict_arr -# elif ((199901L <= __STDC_VERSION__ || 3 < __GNUC__ + (1 <= __GNUC_MINOR__)) \ -&& !defined __GNUG__) +# elif ((199901L <= __STDC_VERSION__ \ + || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \ + || __clang_major__ >= 3) \ +&& !defined __cplusplus) # define _Restrict_arr_ _Restrict_ # else # define _Restrict_arr_ diff --git a/posix/regex_internal.c b/posix/regex_internal.c index e1b6b4d5af..ed0a13461b 100644 --- a/posix/regex_internal.c +++ b/posix/regex_internal.c @@ -300,18 +300,20 @@ build_wcs_upper_buffer (re_string_t *pstr) while (byte_idx < end_idx) { wchar_t wc; + unsigned char ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; - if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]) - && mbsinit (>cur_state)) + if (isascii (ch) && mbsinit (>cur_state)) { - /* In case of a singlebyte character. */ - pstr->mbs[byte_idx] - = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]); /* The next step uses the assumption that wchar_t is encoded ASCII-safe: all ASCII values can be converted like this. */ - pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx]; - ++byte_idx; - continue; + wchar_t wcu = __towupper (ch); + if (isascii (wcu)) + { + pstr->mbs[byte_idx] = wcu; + pstr->wcs[byte_idx] = wcu; + byte_idx++; + continue; + } } remain_len = end_idx - byte_idx; @@ -348,7 +350,6 @@ build_wcs_upper_buffer (re_string_t *pstr) { /* It is an invalid character, an incomplete character
Re: [PATCH 1/5] posix: Sync regex code with gnulib
On 19/01/2021 11:16, Vaseeharan Vinayagamoorthy wrote: > After this commit [1], I am seeing -Werror=undef when bootstapping glibc on > aarch64-none-linux-gnu : > > In file included from regex.c:70:0: > regex_internal.h:852:26: error: "__clang_major__" is not defined > [-Werror=undef] > # if (__GNUC__ >= 7) || (__clang_major__ >= 10) > ^~~ > > The build/host/target setup is: > Build: aarch64-none-linux-gnu (Ubuntu 14.04) > Host: aarch64-none-linux-gnu > Target: aarch64-none-linux-gnu > > [1] > commit c2a150d089fa096cb5f9e342da80fb30dc0d1953 > Author: Adhemerval Zanella > AuthorDate: Tue Dec 29 17:32:25 2020 -0300 > Commit: Adhemerval Zanella > CommitDate: Mon Jan 4 08:38:52 2021 -0300 > > posix: Sync regex code with gnulib > > It sync with gnulib commit 43ee1a6bf. The main change is 9682f18e9. > (which does not have a meaniful description). > > Checked on x86_64-linux-gnu. Does the following help: -- diff --git a/posix/regex_internal.h b/posix/regex_internal.h index e31ac92674..944de219c3 100644 --- a/posix/regex_internal.h +++ b/posix/regex_internal.h @@ -849,7 +849,7 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx) #endif /* RE_ENABLE_I18N */ #ifndef FALLTHROUGH -# if (__GNUC__ >= 7) || (__clang_major__ >= 10) +# if (__GNUC__ >= 7) || (defined __clang_major__ &&__clang_major__ >= 10) # define FALLTHROUGH __attribute__ ((__fallthrough__)) # else # define FALLTHROUGH ((void) 0) -- Paul, this seemed to a common pattern scatter on multiple file in gnulib. Wouldn't be better to consolidate it on cdefs.h? > On 30/12/2020, 20:15, "Libc-alpha on behalf of Adhemerval Zanella via > Libc-alpha" libc-al...@sourceware.org> wrote: > > It sync with gnulib commit 43ee1a6bf. The main change is 9682f18e9. > (which does not have a meaniful description). > > Checked on x86_64-linux-gnu. > --- > posix/regcomp.c| 2 +- > posix/regex.h | 17 - > posix/regex_internal.c | 19 ++- > posix/regex_internal.h | 16 > 4 files changed, 35 insertions(+), 19 deletions(-) > > diff --git a/posix/regcomp.c b/posix/regcomp.c > index 93bb0a0538..692928b0db 100644 > --- a/posix/regcomp.c > +++ b/posix/regcomp.c > @@ -558,7 +558,7 @@ weak_alias (__regerror, regerror) > static const bitset_t utf8_sb_map = > { >/* Set the first 128 bits. */ > -# if defined __GNUC__ && !defined __STRICT_ANSI__ > +# if (defined __GNUC__ || __clang_major__ >= 4) && !defined > __STRICT_ANSI__ >[0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX > # else > # if 4 * BITSET_WORD_BITS < ASCII_CHARS > diff --git a/posix/regex.h b/posix/regex.h > index 5fe41c8685..7418e6c76f 100644 > --- a/posix/regex.h > +++ b/posix/regex.h > @@ -612,7 +612,9 @@ extern int re_exec (const char *); > 'configure' might #define 'restrict' to those words, so pick a > different name. */ > #ifndef _Restrict_ > -# if defined __restrict || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) > +# if defined __restrict \ > + || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ > + || __clang_major__ >= 3 > # define _Restrict_ __restrict > # elif 199901L <= __STDC_VERSION__ || defined restrict > # define _Restrict_ restrict > @@ -620,13 +622,18 @@ extern int re_exec (const char *); > # define _Restrict_ > # endif > #endif > -/* For [restrict], use glibc's __restrict_arr if available. > - Otherwise, GCC 3.1 (not in C++ mode) and C99 support [restrict]. */ > +/* For the ISO C99 syntax > + array_name[restrict] > + use glibc's __restrict_arr if available. > + Otherwise, GCC 3.1 and clang support this syntax (but not in C++ > mode). > + Other ISO C99 compilers support it as well. */ > #ifndef _Restrict_arr_ > # ifdef __restrict_arr > # define _Restrict_arr_ __restrict_arr > -# elif ((199901L <= __STDC_VERSION__ || 3 < __GNUC__ + (1 <= > __GNUC_MINOR__)) \ > -&& !defined __GNUG__) > +# elif ((199901L <= __STDC_VERSION__ \ > + || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \ > + || __clang_major__ >= 3) \ > +&& !defined __cplusplus) > # define _Restrict_arr_ _Restrict_ > # else > # define _Restrict_arr_ > diff --git a/posix/regex_internal.c b/posix/regex_internal.c > index e1b6b4d5af..ed0a13461b 100644 > --- a/posix/regex_internal.c > +++ b/posix/regex_internal.c > @@ -300,18 +300,20 @@ build_wcs_upper_buffer (re_string_t *pstr) >while (byte_idx < end_idx) > { > wchar_t wc; > + unsigned char ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; > > - if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]) > - && mbsinit (>cur_state)) > + if (isascii