changeset 6101:c9bcd4ba6b3f

* config/srclist.txt: Add glibc bug 1237. * lib/regcomp.c, lib/regex_internal.c, lib/regex_internal.h: * lib/regexec.c: All uses of recently-renamed identifiers changed to use the new, POSIX-compliant names. The code will build and run just fine without these changes, but it's better to eat our own dog food and use the standard-conforming names. * m4/regex.m4 (gl_REGEX): Use POSIX-compliant spellings when testing for GNU regex features.
author Paul Eggert <eggert@cs.ucla.edu>
date Wed, 24 Aug 2005 23:29:39 +0000
parents b4fe67182e68
children 781f0829b119
files config/srclist.txt lib/regcomp.c lib/regex_internal.c lib/regex_internal.h lib/regexec.c m4/regex.m4
diffstat 6 files changed, 228 insertions(+), 217 deletions(-) [+]
line wrap: on
line diff
--- a/config/srclist.txt
+++ b/config/srclist.txt
@@ -1,4 +1,4 @@
-# $Id: srclist.txt,v 1.82 2005-08-24 22:29:38 eggert Exp $
+# $Id: srclist.txt,v 1.83 2005-08-24 23:29:39 eggert Exp $
 # Files for which we are not the source.  See ./srclistvars.sh for the
 # variable definitions.
 
@@ -99,6 +99,7 @@
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1220
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1223
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1224
+# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1237
 #$LIBCSRC/posix/regcomp.c		lib gpl
 #
 $LIBCSRC/posix/regex.c			lib gpl
@@ -115,10 +116,12 @@
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1220
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1226
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1231
+# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1237
 #$LIBCSRC/posix/regex_internal.c		lib gpl
 #
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1054
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1221
+# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1237
 #$LIBCSRC/posix/regex_internal.h		lib gpl
 #
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1216
@@ -126,6 +129,7 @@
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1225
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1227
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1231
+# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1237
 #$LIBCSRC/posix/regexec.c		lib gpl
 #
 # c89 changes $LIBCSRC/string/strdup.c		lib gpl
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -90,7 +90,7 @@
 					re_charset_t *mbcset,
 					int *equiv_class_alloc,
 					const unsigned char *name);
-static reg_errcode_t build_charclass (unsigned RE_TRANSLATE_TYPE trans,
+static reg_errcode_t build_charclass (unsigned REG_TRANSLATE_TYPE trans,
 				      re_bitset_ptr_t sbcset,
 				      re_charset_t *mbcset,
 				      int *char_class_alloc,
@@ -99,13 +99,13 @@
 #else  /* not RE_ENABLE_I18N */
 static reg_errcode_t build_equiv_class (re_bitset_ptr_t sbcset,
 					const unsigned char *name);
-static reg_errcode_t build_charclass (unsigned RE_TRANSLATE_TYPE trans,
+static reg_errcode_t build_charclass (unsigned REG_TRANSLATE_TYPE trans,
 				      re_bitset_ptr_t sbcset,
 				      const unsigned char *class_name,
 				      reg_syntax_t syntax);
 #endif /* not RE_ENABLE_I18N */
 static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
-				       unsigned RE_TRANSLATE_TYPE trans,
+				       unsigned REG_TRANSLATE_TYPE trans,
 				       const unsigned char *class_name,
 				       const unsigned char *extra,
 				       int non_match, reg_errcode_t *err);
@@ -206,7 +206,7 @@
    compiles PATTERN (of length LENGTH) and puts the result in BUFP.
    Returns 0 if the pattern was valid, otherwise an error string.
 
-   Assumes the `allocated' (and perhaps `buffer') and `translate' fields
+   Assumes the `re_allocated' (and perhaps `re_buffer') and `translate' fields
    are set in BUFP on entry.  */
 
 const char *
@@ -217,11 +217,11 @@
 
   /* And GNU code determines whether or not to get register information
      by passing null for the REGS argument to re_match, etc., not by
-     setting no_sub, unless RE_NO_SUB is set.  */
-  bufp->no_sub = !!(re_syntax_options & RE_NO_SUB);
+     setting re_no_sub, unless REG_NO_SUB is set.  */
+  bufp->re_no_sub = !!(re_syntax_options & REG_NO_SUB);
 
   /* Match anchors at newline.  */
-  bufp->newline_anchor = 1;
+  bufp->re_newline_anchor = 1;
 
   ret = re_compile_internal (bufp, pattern, length, re_syntax_options);
 
@@ -263,8 +263,8 @@
 int
 re_compile_fastmap (struct re_pattern_buffer *bufp)
 {
-  re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
-  char *fastmap = bufp->fastmap;
+  re_dfa_t *dfa = (re_dfa_t *) bufp->re_buffer;
+  char *fastmap = bufp->re_fastmap;
 
   memset (fastmap, '\0', sizeof (char) * SBC_MAX);
   re_compile_fastmap_iter (bufp, dfa->init_state, fastmap);
@@ -274,7 +274,7 @@
     re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap);
   if (dfa->init_state != dfa->init_state_begbuf)
     re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap);
-  bufp->fastmap_accurate = 1;
+  bufp->re_fastmap_accurate = 1;
   return 0;
 }
 #ifdef _LIBC
@@ -297,9 +297,9 @@
 re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
 			 char *fastmap)
 {
-  re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) bufp->re_buffer;
   int node_cnt;
-  int icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
+  int icase = (dfa->mb_cur_max == 1 && (bufp->re_syntax & REG_IGNORE_CASE));
   for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt)
     {
       int node = init_state->nodes.elems[node_cnt];
@@ -309,7 +309,7 @@
 	{
 	  re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
 #ifdef RE_ENABLE_I18N
-	  if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+	  if ((bufp->re_syntax & REG_IGNORE_CASE) && dfa->mb_cur_max > 1)
 	    {
 	      unsigned char *buf = alloca (dfa->mb_cur_max), *p;
 	      wchar_t wc;
@@ -377,7 +377,7 @@
 	      memset (&state, '\0', sizeof (state));
 	      if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
 		re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
-	      if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+	      if ((bufp->re_syntax & REG_IGNORE_CASE) && dfa->mb_cur_max > 1)
 		{
 		  if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state)
 		      != (size_t) -1)
@@ -394,7 +394,7 @@
 	{
 	  memset (fastmap, '\1', sizeof (char) * SBC_MAX);
 	  if (type == END_OF_RE)
-	    bufp->can_be_null = 1;
+	    bufp->re_can_be_null = 1;
 	  return;
 	}
     }
@@ -406,14 +406,14 @@
    PREG is a regex_t *.  We do not expect any fields to be initialized,
    since POSIX says we shouldn't.  Thus, we set
 
-     `buffer' to the compiled pattern;
-     `used' to the length of the compiled pattern;
-     `syntax' to RE_SYNTAX_POSIX_EXTENDED if the
+     `re_buffer' to the compiled pattern;
+     `re_used' to the length of the compiled pattern;
+     `re_syntax' to REG_SYNTAX_POSIX_EXTENDED if the
        REG_EXTENDED bit in CFLAGS is set; otherwise, to
-       RE_SYNTAX_POSIX_BASIC;
-     `newline_anchor' to REG_NEWLINE being set in CFLAGS;
-     `fastmap' to an allocated space for the fastmap;
-     `fastmap_accurate' to zero;
+       REG_SYNTAX_POSIX_BASIC;
+     `re_newline_anchor' to REG_NEWLINE being set in CFLAGS;
+     `re_fastmap' to an allocated space for the fastmap;
+     `re_fastmap_accurate' to zero;
      `re_nsub' to the number of subexpressions in PATTERN.
 
    PATTERN is the address of the pattern string.
@@ -440,32 +440,32 @@
 regcomp (regex_t *__restrict preg, const char *__restrict pattern, int cflags)
 {
   reg_errcode_t ret;
-  reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
-			 : RE_SYNTAX_POSIX_BASIC);
-
-  preg->buffer = NULL;
-  preg->allocated = 0;
-  preg->used = 0;
+  reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? REG_SYNTAX_POSIX_EXTENDED
+			: REG_SYNTAX_POSIX_BASIC);
+
+  preg->re_buffer = NULL;
+  preg->re_allocated = 0;
+  preg->re_used = 0;
 
   /* Try to allocate space for the fastmap.  */
-  preg->fastmap = re_malloc (char, SBC_MAX);
-  if (BE (preg->fastmap == NULL, 0))
+  preg->re_fastmap = re_malloc (char, SBC_MAX);
+  if (BE (preg->re_fastmap == NULL, 0))
     return REG_ESPACE;
 
-  syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0;
+  syntax |= (cflags & REG_ICASE) ? REG_IGNORE_CASE : 0;
 
   /* If REG_NEWLINE is set, newlines are treated differently.  */
   if (cflags & REG_NEWLINE)
     { /* REG_NEWLINE implies neither . nor [^...] match newline.  */
-      syntax &= ~RE_DOT_NEWLINE;
-      syntax |= RE_HAT_LISTS_NOT_NEWLINE;
+      syntax &= ~REG_DOT_NEWLINE;
+      syntax |= REG_HAT_LISTS_NOT_NEWLINE;
       /* It also changes the matching behavior.  */
-      preg->newline_anchor = 1;
+      preg->re_newline_anchor = 1;
     }
   else
-    preg->newline_anchor = 0;
-  preg->no_sub = !!(cflags & REG_NOSUB);
-  preg->translate = NULL;
+    preg->re_newline_anchor = 0;
+  preg->re_no_sub = !!(cflags & REG_NOSUB);
+  preg->re_translate = NULL;
 
   ret = re_compile_internal (preg, pattern, strlen (pattern), syntax);
 
@@ -474,7 +474,7 @@
   if (ret == REG_ERPAREN)
     ret = REG_EPAREN;
 
-  /* We have already checked preg->fastmap != NULL.  */
+  /* We have already checked preg->re_fastmap != NULL.  */
   if (BE (ret == REG_NOERROR, 1))
     /* Compute the fastmap now, since regexec cannot modify the pattern
        buffer.  This function never fails in this implementation.  */
@@ -482,8 +482,8 @@
   else
     {
       /* Some error occurred while compiling the expression.  */
-      re_free (preg->fastmap);
-      preg->fastmap = NULL;
+      re_free (preg->re_fastmap);
+      preg->re_fastmap = NULL;
     }
 
   return (int) ret;
@@ -606,17 +606,17 @@
 void
 regfree (regex_t *preg)
 {
-  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
   if (BE (dfa != NULL, 1))
     free_dfa_content (dfa);
-  preg->buffer = NULL;
-  preg->allocated = 0;
-
-  re_free (preg->fastmap);
-  preg->fastmap = NULL;
-
-  re_free (preg->translate);
-  preg->translate = NULL;
+  preg->re_buffer = NULL;
+  preg->re_allocated = 0;
+
+  re_free (preg->re_fastmap);
+  preg->re_fastmap = NULL;
+
+  re_free (preg->re_translate);
+  preg->re_translate = NULL;
 }
 #ifdef _LIBC
 weak_alias (__regfree, regfree)
@@ -645,24 +645,24 @@
 
   if (!s)
     {
-      if (!re_comp_buf.buffer)
+      if (!re_comp_buf.re_buffer)
 	return gettext ("No previous regular expression");
       return 0;
     }
 
-  if (re_comp_buf.buffer)
+  if (re_comp_buf.re_buffer)
     {
-      fastmap = re_comp_buf.fastmap;
-      re_comp_buf.fastmap = NULL;
+      fastmap = re_comp_buf.re_fastmap;
+      re_comp_buf.re_fastmap = NULL;
       __regfree (&re_comp_buf);
       memset (&re_comp_buf, '\0', sizeof (re_comp_buf));
-      re_comp_buf.fastmap = fastmap;
+      re_comp_buf.re_fastmap = fastmap;
     }
 
-  if (re_comp_buf.fastmap == NULL)
+  if (re_comp_buf.re_fastmap == NULL)
     {
-      re_comp_buf.fastmap = (char *) malloc (SBC_MAX);
-      if (re_comp_buf.fastmap == NULL)
+      re_comp_buf.re_fastmap = (char *) malloc (SBC_MAX);
+      if (re_comp_buf.re_fastmap == NULL)
 	return (char *) gettext (__re_error_msgid
 				 + __re_error_msgid_idx[(int) REG_ESPACE]);
     }
@@ -671,7 +671,7 @@
      don't need to initialize the pattern buffer fields which affect it.  */
 
   /* Match anchors at newlines.  */
-  re_comp_buf.newline_anchor = 1;
+  re_comp_buf.re_newline_anchor = 1;
 
   ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options);
 
@@ -704,29 +704,29 @@
   re_string_t regexp;
 
   /* Initialize the pattern buffer.  */
-  preg->fastmap_accurate = 0;
-  preg->syntax = syntax;
-  preg->not_bol = preg->not_eol = 0;
-  preg->used = 0;
+  preg->re_fastmap_accurate = 0;
+  preg->re_syntax = syntax;
+  preg->re_not_bol = preg->re_not_eol = 0;
+  preg->re_used = 0;
   preg->re_nsub = 0;
-  preg->can_be_null = 0;
-  preg->regs_allocated = REGS_UNALLOCATED;
+  preg->re_can_be_null = 0;
+  preg->re_regs_allocated = REG_UNALLOCATED;
 
   /* Initialize the dfa.  */
-  dfa = (re_dfa_t *) preg->buffer;
-  if (BE (preg->allocated < sizeof (re_dfa_t), 0))
+  dfa = (re_dfa_t *) preg->re_buffer;
+  if (BE (preg->re_allocated < sizeof (re_dfa_t), 0))
     {
       /* If zero allocated, but buffer is non-null, try to realloc
 	 enough space.  This loses if buffer's address is bogus, but
-	 that is the user's responsibility.  If ->buffer is NULL this
+	 that is the user's responsibility.  If buffer is null this
 	 is a simple allocation.  */
-      dfa = re_realloc (preg->buffer, re_dfa_t, 1);
+      dfa = re_realloc (preg->re_buffer, re_dfa_t, 1);
       if (dfa == NULL)
 	return REG_ESPACE;
-      preg->allocated = sizeof (re_dfa_t);
-      preg->buffer = (unsigned char *) dfa;
+      preg->re_allocated = sizeof (re_dfa_t);
+      preg->re_buffer = (unsigned char *) dfa;
     }
-  preg->used = sizeof (re_dfa_t);
+  preg->re_used = sizeof (re_dfa_t);
 
   __libc_lock_init (dfa->lock);
 
@@ -734,8 +734,8 @@
   if (BE (err != REG_NOERROR, 0))
     {
       free_dfa_content (dfa);
-      preg->buffer = NULL;
-      preg->allocated = 0;
+      preg->re_buffer = NULL;
+      preg->re_allocated = 0;
       return err;
     }
 #ifdef DEBUG
@@ -743,16 +743,16 @@
   strncpy (dfa->re_str, pattern, length + 1);
 #endif
 
-  err = re_string_construct (&regexp, pattern, length, preg->translate,
-			     syntax & RE_ICASE, dfa);
+  err = re_string_construct (&regexp, pattern, length, preg->re_translate,
+			     syntax & REG_IGNORE_CASE, dfa);
   if (BE (err != REG_NOERROR, 0))
     {
     re_compile_internal_free_return:
       free_workarea_compile (preg);
       re_string_destruct (&regexp);
       free_dfa_content (dfa);
-      preg->buffer = NULL;
-      preg->allocated = 0;
+      preg->re_buffer = NULL;
+      preg->re_allocated = 0;
       return err;
     }
 
@@ -769,7 +769,7 @@
 
 #ifdef RE_ENABLE_I18N
   /* If possible, do searching in single byte encoding to speed things up.  */
-  if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL)
+  if (dfa->is_utf8 && !(syntax & REG_IGNORE_CASE) && preg->re_translate == NULL)
     optimize_utf8 (dfa);
 #endif
 
@@ -783,8 +783,8 @@
   if (BE (err != REG_NOERROR, 0))
     {
       free_dfa_content (dfa);
-      preg->buffer = NULL;
-      preg->allocated = 0;
+      preg->re_buffer = NULL;
+      preg->re_allocated = 0;
     }
 
   return err;
@@ -907,7 +907,7 @@
 static void
 free_workarea_compile (regex_t *preg)
 {
-  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
   bin_tree_storage_t *storage, *next;
   for (storage = dfa->str_tree_storage; storage; storage = next)
     {
@@ -1075,7 +1075,7 @@
 static reg_errcode_t
 analyze (regex_t *preg)
 {
-  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
   reg_errcode_t ret;
 
   /* Allocate arrays.  */
@@ -1120,7 +1120,7 @@
 
   /* We only need this during the prune_impossible_nodes pass in regexec.c;
      skip it if p_i_n will not run, as calc_inveclosure can be quadratic.  */
-  if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match)
+  if ((!preg->re_no_sub && preg->re_nsub > 0 && dfa->has_plural_match)
       || dfa->nbackref)
     {
       dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len);
@@ -1256,11 +1256,11 @@
 static bin_tree_t *
 lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node)
 {
-  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
   bin_tree_t *body = node->left;
   bin_tree_t *op, *cls, *tree1, *tree;
 
-  if (preg->no_sub
+  if (preg->re_no_sub
       /* We do not optimize empty subexpressions, because otherwise we may
 	 have bad CONCAT nodes with NULL children.  This is obviously not
 	 very common, so we do not lose much.  An example that triggers
@@ -1744,97 +1744,97 @@
       switch (c2)
 	{
 	case '|':
-	  if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_NO_BK_VBAR))
+	  if (!(syntax & REG_LIMITED_OPS) && !(syntax & REG_NO_BK_VBAR))
 	    token->type = OP_ALT;
 	  break;
 	case '1': case '2': case '3': case '4': case '5':
 	case '6': case '7': case '8': case '9':
-	  if (!(syntax & RE_NO_BK_REFS))
+	  if (!(syntax & REG_NO_BK_REFS))
 	    {
 	      token->type = OP_BACK_REF;
 	      token->opr.idx = c2 - '1';
 	    }
 	  break;
 	case '<':
-	  if (!(syntax & RE_NO_GNU_OPS))
+	  if (!(syntax & REG_NO_GNU_OPS))
 	    {
 	      token->type = ANCHOR;
 	      token->opr.ctx_type = WORD_FIRST;
 	    }
 	  break;
 	case '>':
-	  if (!(syntax & RE_NO_GNU_OPS))
+	  if (!(syntax & REG_NO_GNU_OPS))
 	    {
 	      token->type = ANCHOR;
 	      token->opr.ctx_type = WORD_LAST;
 	    }
 	  break;
 	case 'b':
-	  if (!(syntax & RE_NO_GNU_OPS))
+	  if (!(syntax & REG_NO_GNU_OPS))
 	    {
 	      token->type = ANCHOR;
 	      token->opr.ctx_type = WORD_DELIM;
 	    }
 	  break;
 	case 'B':
-	  if (!(syntax & RE_NO_GNU_OPS))
+	  if (!(syntax & REG_NO_GNU_OPS))
 	    {
 	      token->type = ANCHOR;
 	      token->opr.ctx_type = NOT_WORD_DELIM;
 	    }
 	  break;
 	case 'w':
-	  if (!(syntax & RE_NO_GNU_OPS))
+	  if (!(syntax & REG_NO_GNU_OPS))
 	    token->type = OP_WORD;
 	  break;
 	case 'W':
-	  if (!(syntax & RE_NO_GNU_OPS))
+	  if (!(syntax & REG_NO_GNU_OPS))
 	    token->type = OP_NOTWORD;
 	  break;
 	case 's':
-	  if (!(syntax & RE_NO_GNU_OPS))
+	  if (!(syntax & REG_NO_GNU_OPS))
 	    token->type = OP_SPACE;
 	  break;
 	case 'S':
-	  if (!(syntax & RE_NO_GNU_OPS))
+	  if (!(syntax & REG_NO_GNU_OPS))
 	    token->type = OP_NOTSPACE;
 	  break;
 	case '`':
-	  if (!(syntax & RE_NO_GNU_OPS))
+	  if (!(syntax & REG_NO_GNU_OPS))
 	    {
 	      token->type = ANCHOR;
 	      token->opr.ctx_type = BUF_FIRST;
 	    }
 	  break;
 	case '\'':
-	  if (!(syntax & RE_NO_GNU_OPS))
+	  if (!(syntax & REG_NO_GNU_OPS))
 	    {
 	      token->type = ANCHOR;
 	      token->opr.ctx_type = BUF_LAST;
 	    }
 	  break;
 	case '(':
-	  if (!(syntax & RE_NO_BK_PARENS))
+	  if (!(syntax & REG_NO_BK_PARENS))
 	    token->type = OP_OPEN_SUBEXP;
 	  break;
 	case ')':
-	  if (!(syntax & RE_NO_BK_PARENS))
+	  if (!(syntax & REG_NO_BK_PARENS))
 	    token->type = OP_CLOSE_SUBEXP;
 	  break;
 	case '+':
-	  if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
+	  if (!(syntax & REG_LIMITED_OPS) && (syntax & REG_BK_PLUS_QM))
 	    token->type = OP_DUP_PLUS;
 	  break;
 	case '?':
-	  if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
+	  if (!(syntax & REG_LIMITED_OPS) && (syntax & REG_BK_PLUS_QM))
 	    token->type = OP_DUP_QUESTION;
 	  break;
 	case '{':
-	  if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
+	  if ((syntax & REG_INTERVALS) && (!(syntax & REG_NO_BK_BRACES)))
 	    token->type = OP_OPEN_DUP_NUM;
 	  break;
 	case '}':
-	  if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
+	  if ((syntax & REG_INTERVALS) && (!(syntax & REG_NO_BK_BRACES)))
 	    token->type = OP_CLOSE_DUP_NUM;
 	  break;
 	default:
@@ -1857,38 +1857,38 @@
   switch (c)
     {
     case '\n':
-      if (syntax & RE_NEWLINE_ALT)
+      if (syntax & REG_NEWLINE_ALT)
 	token->type = OP_ALT;
       break;
     case '|':
-      if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_NO_BK_VBAR))
+      if (!(syntax & REG_LIMITED_OPS) && (syntax & REG_NO_BK_VBAR))
 	token->type = OP_ALT;
       break;
     case '*':
       token->type = OP_DUP_ASTERISK;
       break;
     case '+':
-      if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
+      if (!(syntax & REG_LIMITED_OPS) && !(syntax & REG_BK_PLUS_QM))
 	token->type = OP_DUP_PLUS;
       break;
     case '?':
-      if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
+      if (!(syntax & REG_LIMITED_OPS) && !(syntax & REG_BK_PLUS_QM))
 	token->type = OP_DUP_QUESTION;
       break;
     case '{':
-      if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
+      if ((syntax & REG_INTERVALS) && (syntax & REG_NO_BK_BRACES))
 	token->type = OP_OPEN_DUP_NUM;
       break;
     case '}':
-      if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
+      if ((syntax & REG_INTERVALS) && (syntax & REG_NO_BK_BRACES))
 	token->type = OP_CLOSE_DUP_NUM;
       break;
     case '(':
-      if (syntax & RE_NO_BK_PARENS)
+      if (syntax & REG_NO_BK_PARENS)
 	token->type = OP_OPEN_SUBEXP;
       break;
     case ')':
-      if (syntax & RE_NO_BK_PARENS)
+      if (syntax & REG_NO_BK_PARENS)
 	token->type = OP_CLOSE_SUBEXP;
       break;
     case '[':
@@ -1898,18 +1898,18 @@
       token->type = OP_PERIOD;
       break;
     case '^':
-      if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) &&
+      if (!(syntax & (REG_CONTEXT_INDEP_ANCHORS | REG_CARET_ANCHORS_HERE)) &&
 	  re_string_cur_idx (input) != 0)
 	{
 	  char prev = re_string_peek_byte (input, -1);
-	  if (!(syntax & RE_NEWLINE_ALT) || prev != '\n')
+	  if (!(syntax & REG_NEWLINE_ALT) || prev != '\n')
 	    break;
 	}
       token->type = ANCHOR;
       token->opr.ctx_type = LINE_FIRST;
       break;
     case '$':
-      if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) &&
+      if (!(syntax & REG_CONTEXT_INDEP_ANCHORS) &&
 	  re_string_cur_idx (input) + 1 != re_string_length (input))
 	{
 	  re_token_t next;
@@ -1952,7 +1952,7 @@
     }
 #endif /* RE_ENABLE_I18N */
 
-  if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
+  if (c == '\\' && (syntax & REG_BACKSLASH_ESCAPE_IN_LISTS)
       && re_string_cur_idx (input) + 1 < re_string_length (input))
     {
       /* In this case, '\' escape a character.  */
@@ -1982,7 +1982,7 @@
 	  token->type = OP_OPEN_EQUIV_CLASS;
 	  break;
 	case ':':
-	  if (syntax & RE_CHAR_CLASSES)
+	  if (syntax & REG_CHAR_CLASSES)
 	    {
 	      token->type = OP_OPEN_CHAR_CLASS;
 	      break;
@@ -2031,11 +2031,11 @@
 parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax,
        reg_errcode_t *err)
 {
-  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
   bin_tree_t *tree, *eor, *root;
   re_token_t current_token;
   dfa->syntax = syntax;
-  fetch_token (&current_token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+  fetch_token (&current_token, regexp, syntax | REG_CARET_ANCHORS_HERE);
   tree = parse_reg_exp (regexp, preg, &current_token, syntax, 0, err);
   if (BE (*err != REG_NOERROR && tree == NULL, 0))
     return NULL;
@@ -2065,7 +2065,7 @@
 parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
 	       reg_syntax_t syntax, int nest, reg_errcode_t *err)
 {
-  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
   bin_tree_t *tree, *branch = NULL;
   tree = parse_branch (regexp, preg, token, syntax, nest, err);
   if (BE (*err != REG_NOERROR && tree == NULL, 0))
@@ -2073,7 +2073,7 @@
 
   while (token->type == OP_ALT)
     {
-      fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+      fetch_token (token, regexp, syntax | REG_CARET_ANCHORS_HERE);
       if (token->type != OP_ALT && token->type != END_OF_RE
 	  && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
 	{
@@ -2107,7 +2107,7 @@
 	      reg_syntax_t syntax, int nest, reg_errcode_t *err)
 {
   bin_tree_t *tree, *exp;
-  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
   tree = parse_expression (regexp, preg, token, syntax, nest, err);
   if (BE (*err != REG_NOERROR && tree == NULL, 0))
     return NULL;
@@ -2146,7 +2146,7 @@
 parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
 		  reg_syntax_t syntax, int nest, reg_errcode_t *err)
 {
-  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
   bin_tree_t *tree;
   switch (token->type)
     {
@@ -2203,7 +2203,7 @@
       dfa->has_mb_node = 1;
       break;
     case OP_OPEN_DUP_NUM:
-      if (syntax & RE_CONTEXT_INVALID_DUP)
+      if (syntax & REG_CONTEXT_INVALID_DUP)
 	{
 	  *err = REG_BADRPT;
 	  return NULL;
@@ -2212,12 +2212,12 @@
     case OP_DUP_ASTERISK:
     case OP_DUP_PLUS:
     case OP_DUP_QUESTION:
-      if (syntax & RE_CONTEXT_INVALID_OPS)
+      if (syntax & REG_CONTEXT_INVALID_OPS)
 	{
 	  *err = REG_BADRPT;
 	  return NULL;
 	}
-      else if (syntax & RE_CONTEXT_INDEP_OPS)
+      else if (syntax & REG_CONTEXT_INDEP_OPS)
 	{
 	  fetch_token (token, regexp, syntax);
 	  return parse_expression (regexp, preg, token, syntax, nest, err);
@@ -2225,7 +2225,7 @@
       /* else fall through  */
     case OP_CLOSE_SUBEXP:
       if ((token->type == OP_CLOSE_SUBEXP) &&
-	  !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD))
+	  !(syntax & REG_UNMATCHED_RIGHT_PAREN_ORD))
 	{
 	  *err = REG_ERPAREN;
 	  return NULL;
@@ -2339,7 +2339,7 @@
       if (BE (*err != REG_NOERROR && tree == NULL, 0))
 	return NULL;
       /* In BRE consecutive duplications are not allowed.  */
-      if ((syntax & RE_CONTEXT_INVALID_DUP)
+      if ((syntax & REG_CONTEXT_INVALID_DUP)
 	  && (token->type == OP_DUP_ASTERISK
 	      || token->type == OP_OPEN_DUP_NUM))
 	{
@@ -2362,12 +2362,12 @@
 parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
 	       reg_syntax_t syntax, int nest, reg_errcode_t *err)
 {
-  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
   bin_tree_t *tree;
   size_t cur_nsub;
   cur_nsub = preg->re_nsub++;
 
-  fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+  fetch_token (token, regexp, syntax | REG_CARET_ANCHORS_HERE);
 
   /* The subexpression may be a null string.  */
   if (token->type == OP_CLOSE_SUBEXP)
@@ -2426,7 +2426,7 @@
       if (BE (start == -2 || end == -2, 0))
 	{
 	  /* Invalid sequence.  */
-	  if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0))
+	  if (BE (!(syntax & REG_INVALID_INTERVAL_ORD), 0))
 	    {
 	      if (token->type == END_OF_RE)
 		*err = REG_EBRACE;
@@ -2813,7 +2813,7 @@
       /* Check start/end collation sequence values.  */
       if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0))
 	return REG_ECOLLATE;
-      if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0))
+      if (BE ((syntax & REG_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0))
 	return REG_ERANGE;
 
       /* Got valid collation sequence values, add them as a new entry.
@@ -2988,7 +2988,7 @@
       mbcset->non_match = 1;
 #endif /* not RE_ENABLE_I18N */
       non_match = 1;
-      if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
+      if (syntax & REG_HAT_LISTS_NOT_NEWLINE)
 	bitset_set (sbcset, '\0');
       re_string_skip_bytes (regexp, token_len); /* Skip a token.  */
       token_len = peek_token_bracket (token, regexp, syntax);
@@ -3403,7 +3403,7 @@
      is a pointer argument sinse we may update it.  */
 
 static reg_errcode_t
-build_charclass (unsigned RE_TRANSLATE_TYPE trans, re_bitset_ptr_t sbcset,
+build_charclass (unsigned REG_TRANSLATE_TYPE trans, re_bitset_ptr_t sbcset,
 #ifdef RE_ENABLE_I18N
 		 re_charset_t *mbcset, int *char_class_alloc,
 #endif
@@ -3414,7 +3414,7 @@
 
   /* In case of REG_ICASE "upper" and "lower" match the both of
      upper and lower cases.  */
-  if ((syntax & RE_ICASE)
+  if ((syntax & REG_IGNORE_CASE)
       && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
     name = "alpha";
 
@@ -3477,7 +3477,7 @@
 }
 
 static bin_tree_t *
-build_charclass_op (re_dfa_t *dfa, unsigned RE_TRANSLATE_TYPE trans,
+build_charclass_op (re_dfa_t *dfa, unsigned REG_TRANSLATE_TYPE trans,
 		    const unsigned char *class_name,
 		    const unsigned char *extra,
 		    int non_match, reg_errcode_t *err)
@@ -3510,7 +3510,7 @@
     {
 #ifdef RE_ENABLE_I18N
       /*
-      if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
+      if (syntax & REG_HAT_LISTS_NOT_NEWLINE)
 	bitset_set(cset->sbcset, '\0');
       */
       mbcset->non_match = 1;
@@ -3608,7 +3608,7 @@
 	break;
       num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2)
 	     ? -2 : ((num == -1) ? c - '0' : num * 10 + c - '0'));
-      num = (num > RE_DUP_MAX) ? -2 : num;
+      num = (num > REG_DUP_MAX) ? -2 : num;
     }
   return num;
 }
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -19,7 +19,7 @@
 
 static void re_string_construct_common (const char *str, int len,
 					re_string_t *pstr,
-					RE_TRANSLATE_TYPE trans, int icase,
+					REG_TRANSLATE_TYPE trans, int icase,
 					const re_dfa_t *dfa) internal_function;
 static re_dfastate_t *create_ci_newstate (re_dfa_t *dfa,
 					  const re_node_set *nodes,
@@ -37,7 +37,7 @@
 static reg_errcode_t
 internal_function
 re_string_allocate (re_string_t *pstr, const char *str, int len, int init_len,
-		    RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
+		    REG_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
 {
   reg_errcode_t ret;
   int init_buf_len;
@@ -65,7 +65,7 @@
 static reg_errcode_t
 internal_function
 re_string_construct (re_string_t *pstr, const char *str, int len,
-		     RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
+		     REG_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
 {
   reg_errcode_t ret;
   memset (pstr, '\0', sizeof (re_string_t));
@@ -161,13 +161,13 @@
 static void
 internal_function
 re_string_construct_common (const char *str, int len, re_string_t *pstr,
-			    RE_TRANSLATE_TYPE trans, int icase,
+			    REG_TRANSLATE_TYPE trans, int icase,
 			    const re_dfa_t *dfa)
 {
   pstr->raw_mbs = (const unsigned char *) str;
   pstr->len = len;
   pstr->raw_len = len;
-  pstr->trans = (unsigned RE_TRANSLATE_TYPE) trans;
+  pstr->trans = (unsigned REG_TRANSLATE_TYPE) trans;
   pstr->icase = icase ? 1 : 0;
   pstr->mbs_allocated = (trans != NULL || icase);
   pstr->mb_cur_max = dfa->mb_cur_max;
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -348,7 +348,7 @@
      the beginning of the input string.  */
   unsigned int tip_context;
   /* The translation passed as a part of an argument of re_compile_pattern.  */
-  unsigned RE_TRANSLATE_TYPE trans;
+  unsigned REG_TRANSLATE_TYPE trans;
   /* Copy of re_dfa_t's word_char.  */
   re_const_bitset_ptr_t word_char;
   /* 1 if REG_ICASE.  */
@@ -377,11 +377,11 @@
 
 static reg_errcode_t re_string_allocate (re_string_t *pstr, const char *str,
 					 int len, int init_len,
-					 RE_TRANSLATE_TYPE trans, int icase,
+					 REG_TRANSLATE_TYPE trans, int icase,
 					 const re_dfa_t *dfa)
      internal_function;
 static reg_errcode_t re_string_construct (re_string_t *pstr, const char *str,
-					  int len, RE_TRANSLATE_TYPE trans,
+					  int len, REG_TRANSLATE_TYPE trans,
 					  int icase, const re_dfa_t *dfa)
      internal_function;
 static reg_errcode_t re_string_reconstruct (re_string_t *pstr, int idx,
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -199,7 +199,7 @@
   reg_errcode_t err;
   int start, length;
 #ifdef _LIBC
-  re_dfa_t *dfa = (re_dfa_t *)preg->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
 #endif
 
   if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
@@ -217,7 +217,7 @@
     }
 
   __libc_lock_lock (dfa->lock);
-  if (preg->no_sub)
+  if (preg->re_no_sub)
     err = re_search_internal (preg, string, length, start, length - start,
 			      length, 0, NULL, eflags);
   else
@@ -267,7 +267,7 @@
    the first STOP characters of the concatenation of the strings should be
    concerned.
 
-   If REGS is not NULL, and BUFP->no_sub is not set, the offsets of the match
+   If REGS is not NULL, and BUFP->re_no_sub is not set, the offsets of the match
    and all groups is stroed in REGS.  (For the "_2" variants, the offsets are
    computed relative to the concatenation, not relative to the individual
    strings.)
@@ -380,7 +380,7 @@
   int nregs, rval;
   int eflags = 0;
 #ifdef _LIBC
-  re_dfa_t *dfa = (re_dfa_t *)bufp->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) bufp->re_buffer;
 #endif
 
   /* Check for out-of-range.  */
@@ -393,23 +393,23 @@
 
   __libc_lock_lock (dfa->lock);
 
-  eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
-  eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
+  eflags |= (bufp->re_not_bol) ? REG_NOTBOL : 0;
+  eflags |= (bufp->re_not_eol) ? REG_NOTEOL : 0;
 
   /* Compile fastmap if we haven't yet.  */
-  if (range > 0 && bufp->fastmap != NULL && !bufp->fastmap_accurate)
+  if (range > 0 && bufp->re_fastmap != NULL && !bufp->re_fastmap_accurate)
     re_compile_fastmap (bufp);
 
-  if (BE (bufp->no_sub, 0))
+  if (BE (bufp->re_no_sub, 0))
     regs = NULL;
 
   /* We need at least 1 register.  */
   if (regs == NULL)
     nregs = 1;
-  else if (BE (bufp->regs_allocated == REGS_FIXED &&
-	       regs->num_regs < bufp->re_nsub + 1, 0))
+  else if (BE (bufp->re_regs_allocated == REG_FIXED
+	       && regs->rm_num_regs < bufp->re_nsub + 1, 0))
     {
-      nregs = regs->num_regs;
+      nregs = regs->rm_num_regs;
       if (BE (nregs < 1, 0))
 	{
 	  /* Nothing can be copied to regs.  */
@@ -437,9 +437,9 @@
   else if (regs != NULL)
     {
       /* If caller wants register contents data back, copy them.  */
-      bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs,
-					   bufp->regs_allocated);
-      if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0))
+      bufp->re_regs_allocated = re_copy_regs (regs, pmatch, nregs,
+					      bufp->re_regs_allocated);
+      if (BE (bufp->re_regs_allocated == REG_UNALLOCATED, 0))
 	rval = -2;
     }
 
@@ -464,52 +464,53 @@
 re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, int nregs,
 	      int regs_allocated)
 {
-  int rval = REGS_REALLOCATE;
+  int rval = REG_REALLOCATE;
   int i;
   int need_regs = nregs + 1;
-  /* We need one extra element beyond `num_regs' for the `-1' marker GNU code
+  /* We need one extra element beyond `rm_num_regs' for the `-1' marker GNU code
      uses.  */
 
   /* Have the register data arrays been allocated?  */
-  if (regs_allocated == REGS_UNALLOCATED)
+  if (regs_allocated == REG_UNALLOCATED)
     { /* No.  So allocate them with malloc.  */
-      regs->start = re_malloc (regoff_t, need_regs);
-      regs->end = re_malloc (regoff_t, need_regs);
-      if (BE (regs->start == NULL, 0) || BE (regs->end == NULL, 0))
-	return REGS_UNALLOCATED;
-      regs->num_regs = need_regs;
+      regs->rm_start = re_malloc (regoff_t, need_regs);
+      regs->rm_end = re_malloc (regoff_t, need_regs);
+      if (BE (regs->rm_start == NULL, 0) || BE (regs->rm_end == NULL, 0))
+	return REG_UNALLOCATED;
+      regs->rm_num_regs = need_regs;
     }
-  else if (regs_allocated == REGS_REALLOCATE)
+  else if (regs_allocated == REG_REALLOCATE)
     { /* Yes.  If we need more elements than were already
 	 allocated, reallocate them.  If we need fewer, just
 	 leave it alone.  */
-      if (BE (need_regs > regs->num_regs, 0))
+      if (BE (need_regs > regs->rm_num_regs, 0))
 	{
-	  regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs);
-	  regoff_t *new_end = re_realloc (regs->end, regoff_t, need_regs);
+	  regoff_t *new_start =
+	    re_realloc (regs->rm_start, regoff_t, need_regs);
+	  regoff_t *new_end = re_realloc (regs->rm_end, regoff_t, need_regs);
 	  if (BE (new_start == NULL, 0) || BE (new_end == NULL, 0))
-	    return REGS_UNALLOCATED;
-	  regs->start = new_start;
-	  regs->end = new_end;
-	  regs->num_regs = need_regs;
+	    return REG_UNALLOCATED;
+	  regs->rm_start = new_start;
+	  regs->rm_end = new_end;
+	  regs->rm_num_regs = need_regs;
 	}
     }
   else
     {
-      assert (regs_allocated == REGS_FIXED);
-      /* This function may not be called with REGS_FIXED and nregs too big.  */
-      assert (regs->num_regs >= nregs);
-      rval = REGS_FIXED;
+      assert (regs_allocated == REG_FIXED);
+      /* This function may not be called with REG_FIXED and nregs too big.  */
+      assert (regs->rm_num_regs >= nregs);
+      rval = REG_FIXED;
     }
 
   /* Copy the regs.  */
   for (i = 0; i < nregs; ++i)
     {
-      regs->start[i] = pmatch[i].rm_so;
-      regs->end[i] = pmatch[i].rm_eo;
+      regs->rm_start[i] = pmatch[i].rm_so;
+      regs->rm_end[i] = pmatch[i].rm_eo;
     }
-  for ( ; i < regs->num_regs; ++i)
-    regs->start[i] = regs->end[i] = -1;
+  for ( ; i < regs->rm_num_regs; ++i)
+    regs->rm_start[i] = regs->rm_end[i] = -1;
 
   return rval;
 }
@@ -533,16 +534,16 @@
 {
   if (num_regs)
     {
-      bufp->regs_allocated = REGS_REALLOCATE;
-      regs->num_regs = num_regs;
-      regs->start = starts;
-      regs->end = ends;
+      bufp->re_regs_allocated = REG_REALLOCATE;
+      regs->rm_num_regs = num_regs;
+      regs->rm_start = starts;
+      regs->rm_end = ends;
     }
   else
     {
-      bufp->regs_allocated = REGS_UNALLOCATED;
-      regs->num_regs = 0;
-      regs->start = regs->end = (regoff_t *) 0;
+      bufp->re_regs_allocated = REG_UNALLOCATED;
+      regs->rm_num_regs = 0;
+      regs->rm_start = regs->rm_end = NULL;
     }
 }
 #ifdef _LIBC
@@ -584,7 +585,7 @@
 		    int eflags)
 {
   reg_errcode_t err;
-  re_dfa_t *dfa = (re_dfa_t *)preg->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
   int left_lim, right_lim, incr;
   int fl_longest_match, match_first, match_kind, match_last = -1;
   int extra_nmatch;
@@ -594,9 +595,10 @@
 #else
   re_match_context_t mctx;
 #endif
-  char *fastmap = (preg->fastmap != NULL && preg->fastmap_accurate
-		   && range && !preg->can_be_null) ? preg->fastmap : NULL;
-  unsigned RE_TRANSLATE_TYPE t = (unsigned RE_TRANSLATE_TYPE) preg->translate;
+  char *fastmap = (preg->re_fastmap != NULL && preg->re_fastmap_accurate
+		   && range && !preg->re_can_be_null) ? preg->re_fastmap : NULL;
+  unsigned REG_TRANSLATE_TYPE t =
+    (unsigned REG_TRANSLATE_TYPE) preg->re_translate;
 
 #if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
   memset (&mctx, '\0', sizeof (re_match_context_t));
@@ -607,7 +609,7 @@
   nmatch -= extra_nmatch;
 
   /* Check if the DFA haven't been compiled.  */
-  if (BE (preg->used == 0 || dfa->init_state == NULL
+  if (BE (preg->re_used == 0 || dfa->init_state == NULL
 	  || dfa->init_state_word == NULL || dfa->init_state_nl == NULL
 	  || dfa->init_state_begbuf == NULL, 0))
     return REG_NOMATCH;
@@ -618,12 +620,12 @@
 #endif
 
   /* If initial states with non-begbuf contexts have no elements,
-     the regex must be anchored.  If preg->newline_anchor is set,
+     the regex must be anchored.  If preg->re_newline_anchor is set,
      we'll never use init_state_nl, so do not check it.  */
   if (dfa->init_state->nodes.nelem == 0
       && dfa->init_state_word->nodes.nelem == 0
       && (dfa->init_state_nl->nodes.nelem == 0
-	  || !preg->newline_anchor))
+	  || !preg->re_newline_anchor))
     {
       if (start != 0 && start + range != 0)
         return REG_NOMATCH;
@@ -634,12 +636,13 @@
   fl_longest_match = (nmatch != 0 || dfa->nbackref);
 
   err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
-			    preg->translate, preg->syntax & RE_ICASE, dfa);
+			    preg->re_translate,
+			    preg->re_syntax & REG_IGNORE_CASE, dfa);
   if (BE (err != REG_NOERROR, 0))
     goto free_return;
   mctx.input.stop = stop;
   mctx.input.raw_stop = stop;
-  mctx.input.newline_anchor = preg->newline_anchor;
+  mctx.input.newline_anchor = preg->re_newline_anchor;
 
   err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
   if (BE (err != REG_NOERROR, 0))
@@ -672,7 +675,7 @@
   sb = dfa->mb_cur_max == 1;
   match_kind =
     (fastmap
-     ? ((sb || !(preg->syntax & RE_ICASE || t) ? 4 : 0)
+     ? ((sb || !(preg->re_syntax & REG_IGNORE_CASE || t) ? 4 : 0)
 	| (range >= 0 ? 2 : 0)
 	| (t != NULL ? 1 : 0))
      : 8);
@@ -794,13 +797,13 @@
 	  else
 	    {
 	      mctx.match_last = match_last;
-	      if ((!preg->no_sub && nmatch > 1) || dfa->nbackref)
+	      if ((!preg->re_no_sub && nmatch > 1) || dfa->nbackref)
 		{
 		  re_dfastate_t *pstate = mctx.state_log[match_last];
 		  mctx.last_node = check_halt_state_context (&mctx, pstate,
 							     match_last);
 		}
-	      if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match)
+	      if ((!preg->re_no_sub && nmatch > 1 && dfa->has_plural_match)
 		  || dfa->nbackref)
 		{
 		  err = prune_impossible_nodes (&mctx);
@@ -836,7 +839,7 @@
       pmatch[0].rm_so = 0;
       pmatch[0].rm_eo = mctx.match_last;
 
-      if (!preg->no_sub && nmatch > 1)
+      if (!preg->re_no_sub && nmatch > 1)
 	{
 	  err = set_regs (preg, &mctx, nmatch, pmatch,
 			  dfa->has_plural_match && dfa->nbackref > 0);
@@ -1346,7 +1349,7 @@
 set_regs (const regex_t *preg, const re_match_context_t *mctx,
 	  size_t nmatch, regmatch_t *pmatch, int fl_backtrack)
 {
-  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
   int idx, cur_node;
   re_node_set eps_via_nodes;
   struct re_fail_stack_t *fs;
@@ -3474,18 +3477,18 @@
 	  else
 #endif
 	    bitset_set_all (accepts);
-	  if (!(dfa->syntax & RE_DOT_NEWLINE))
+	  if (!(dfa->syntax & REG_DOT_NEWLINE))
 	    bitset_clear (accepts, '\n');
-	  if (dfa->syntax & RE_DOT_NOT_NULL)
+	  if (dfa->syntax & REG_DOT_NOT_NULL)
 	    bitset_clear (accepts, '\0');
 	}
 #ifdef RE_ENABLE_I18N
       else if (type == OP_UTF8_PERIOD)
         {
 	  memset (accepts, 255, sizeof (unsigned int) * BITSET_UINTS / 2);
-	  if (!(dfa->syntax & RE_DOT_NEWLINE))
+	  if (!(dfa->syntax & REG_DOT_NEWLINE))
 	    bitset_clear (accepts, '\n');
-	  if (dfa->syntax & RE_DOT_NOT_NULL)
+	  if (dfa->syntax & REG_DOT_NOT_NULL)
 	    bitset_clear (accepts, '\0');
         }
 #endif
@@ -3696,9 +3699,9 @@
       /* FIXME: I don't think this if is needed, as both '\n'
 	 and '\0' are char_len == 1.  */
       /* '.' accepts any one character except the following two cases.  */
-      if ((!(dfa->syntax & RE_DOT_NEWLINE) &&
+      if ((!(dfa->syntax & REG_DOT_NEWLINE) &&
 	   re_string_byte_at (input, str_idx) == '\n') ||
-	  ((dfa->syntax & RE_DOT_NOT_NULL) &&
+	  ((dfa->syntax & REG_DOT_NOT_NULL) &&
 	   re_string_byte_at (input, str_idx) == '\0'))
 	return 0;
       return char_len;
@@ -3954,8 +3957,8 @@
       /* FALLTHROUGH */
 #endif
     case OP_PERIOD:
-      if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
-	  || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL)))
+      if ((ch == '\n' && !(mctx->dfa->syntax & REG_DOT_NEWLINE))
+	  || (ch == '\0' && (mctx->dfa->syntax & REG_DOT_NOT_NULL)))
 	return 0;
       break;
 
--- a/m4/regex.m4
+++ b/m4/regex.m4
@@ -1,4 +1,4 @@
-#serial 26
+#serial 27
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free
 # Software Foundation, Inc.
@@ -36,7 +36,10 @@
 	  [[static struct re_pattern_buffer regex;
 	    const char *s;
 	    struct re_registers regs;
-	    re_set_syntax (RE_SYNTAX_POSIX_EGREP);
+	    /* Use the POSIX-compliant spelling with leading REG_,
+	       rather than the traditional GNU spelling with leading RE_,
+	       so that we reject older libc implementations.  */
+	    re_set_syntax (REG_SYNTAX_POSIX_EGREP);
 	    memset (&regex, 0, sizeof (regex));
 	    s = re_compile_pattern ("a[:@:>@:]b\n", 9, &regex);
 	    /* This should fail with _Invalid character class name_ error.  */
@@ -72,9 +75,10 @@
 	      exit (1);
 
 	    /* The version of regex.c in older versions of gnulib
-	     * ignored RE_ICASE.  Detect that problem too. */
+	       ignored REG_IGNORE_CASE (which was then called RE_ICASE).
+	       Detect that problem too.  */
 	    memset (&regex, 0, sizeof (regex));
-	    re_set_syntax(RE_SYNTAX_EMACS|RE_ICASE);
+	    re_set_syntax (REG_SYNTAX_EMACS | REG_IGNORE_CASE);
 	    s = re_compile_pattern ("x", 1, &regex);
 	    if (s)
 	      exit (1);