[03/17] Regex: Bracket call to __libc_lock_define inside ifdef.

Message ID 201712080916.vB89GxlM005495@skeeve.com
State New, archived
Headers

Commit Message

Arnold Robbins Dec. 8, 2017, 9:16 a.m. UTC
  This patch brackets a call to __libc_lock_define inside the correct ifdef.

2017-11-27         Arnold D. Robbins     <arnold@skeeve.com>

	* posix/regex_internal.h (re_dfa_t): Bracket call to
	__libc_lock_define insidef ifdef _LIBC.
  

Comments

Paul Eggert Dec. 19, 2017, 10:24 p.m. UTC | #1
On 12/08/2017 01:16 AM, Arnold Robbins wrote:
> This patch brackets a call to __libc_lock_define inside the correct ifdef.
>
> 2017-11-27         Arnold D. Robbins     <arnold@skeeve.com>
>
> 	* posix/regex_internal.h (re_dfa_t): Bracket call to
> 	__libc_lock_define insidef ifdef _LIBC.
>

The commit message should explain the actual problem here, which is that 
the current code passes an empty argument to a macro, and this does not 
conform to C89 and some older compilers reject it. Also, the change 
should remove the now-unused #define for __libc_lock_define when _LIBC 
is not defined. In short, I suggest something like the following change 
instead:

https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=3ccb7f0727c5154ee91609f30b0fb62b94142c10

This is already in Gnulib.
  

Patch

diff --git a/posix/regex_internal.h b/posix/regex_internal.h
index 79e438a..e9cc2b6 100644
--- a/posix/regex_internal.h
+++ b/posix/regex_internal.h
@@ -639,7 +639,9 @@  struct re_dfa_t
 #ifdef DEBUG
   char* re_str;
 #endif
+#if defined _LIBC
   __libc_lock_define (, lock)
+#endif
 };
 
 #define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))