]> Savannah Git Hosting - gnulib.git/commitdiff
regex: simplify by assuming C99
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Oct 2019 00:33:58 +0000 (17:33 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Oct 2019 01:34:05 +0000 (18:34 -0700)
* config/srclist.txt: Comment out regex_internal.h and regexec.c
temporarily.
* lib/regex_internal.h (lock_define, re_match_context_t):
Simplify by assuming C99 macros and const.
* lib/regexec.c (re_search_internal): Simplify by assuming C99
initializers.  Remove unnecessary assignment, as mctx is now
safely initialized earlier.

ChangeLog
config/srclist.txt
lib/regex_internal.h
lib/regexec.c

index 8251b83969aaa543d936a5f151892a595ca208f0..4f96c8cbff987bc18305e84923efae30f401efc5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2019-10-09  Paul Eggert  <eggert@cs.ucla.edu>
 
+       regex: simplify by assuming C99
+       * config/srclist.txt: Comment out regex_internal.h and regexec.c
+       temporarily.
+       * lib/regex_internal.h (lock_define, re_match_context_t):
+       Simplify by assuming C99 macros and const.
+       * lib/regexec.c (re_search_internal): Simplify by assuming C99
+       initializers.  Remove unnecessary assignment, as mctx is now
+       safely initialized earlier.
+
        regex: avoid copying of uninitialized storage
        * config/srclist.txt: Comment out regcomp.c temporarily.
        * lib/regcomp.c (build_charclass_op, create_tree) [! (GCC_LINT||lint)]:
index bceaee8631ec3b6e3956cf3abd63ce4f152770e0..c53fb90a85a60501c3819e6b59e220aa476377ee 100644 (file)
@@ -56,8 +56,8 @@ $LIBCSRC malloc/scratch_buffer_set_array_size.c       lib/malloc
 $LIBCSRC posix/regex.c                 lib
 $LIBCSRC posix/regex.h                 lib
 $LIBCSRC posix/regex_internal.c                lib
-$LIBCSRC posix/regex_internal.h                lib
-$LIBCSRC posix/regexec.c               lib
+#$LIBCSRC posix/regex_internal.h       lib
+#$LIBCSRC posix/regexec.c              lib
 $LIBCSRC time/timegm.c                 lib
 $LIBCSRC time/mktime.c                 lib
 $LIBCSRC time/mktime-internal.h                lib
index 5462419b7878b2c3e125e0e20244766844672916..9c0e1f1d17ea64281248201d41accce20c3e1450 100644 (file)
 # define lock_unlock(lock) __libc_lock_unlock (lock)
 #elif defined GNULIB_LOCK && !defined USE_UNLOCKED_IO
 # include "glthread/lock.h"
-  /* 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_define(name) gl_lock_define (, name)
 # define lock_init(lock) glthread_lock_init (&(lock))
 # define lock_fini(lock) glthread_lock_destroy (&(lock))
 # define lock_lock(lock) glthread_lock_lock (&(lock))
@@ -618,11 +603,7 @@ typedef struct
 {
   /* The string object corresponding to the input string.  */
   re_string_t input;
-#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
   const re_dfa_t *const dfa;
-#else
-  const re_dfa_t *dfa;
-#endif
   /* EFLAGS of the argument of regexec.  */
   int eflags;
   /* Where the matching ends.  */
index 4ff30a79c09a86f8f36127ed453a3b29349ebfa6..f7d2b5b20dfcc069f4cf5977be6561cc34494107 100644 (file)
@@ -597,21 +597,12 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
   Idx extra_nmatch;
   bool sb;
   int ch;
-#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
   re_match_context_t mctx = { .dfa = dfa };
-#else
-  re_match_context_t mctx;
-#endif
   char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate
                    && start != last_start && !preg->can_be_null)
                   ? preg->fastmap : NULL);
   RE_TRANSLATE_TYPE t = preg->translate;
 
-#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
-  memset (&mctx, '\0', sizeof (re_match_context_t));
-  mctx.dfa = dfa;
-#endif
-
   extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0;
   nmatch -= extra_nmatch;
 
@@ -677,8 +668,6 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
          goto free_return;
        }
     }
-  else
-    mctx.state_log = NULL;
 
   match_first = start;
   mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF