about summary refs log tree commit diff
path: root/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-10-09 11:04:04 +0000
committerUlrich Drepper <drepper@redhat.com>1998-10-09 11:04:04 +0000
commita5d1d726704c6e3c4f8457e30cbd3d2840531ee5 (patch)
tree850cd0384fb85c2fab291560a835835d91244a7a /posix
parentea1dfb4a9a504558296e216f7f9d95a5f2700db9 (diff)
downloadglibc-a5d1d726704c6e3c4f8457e30cbd3d2840531ee5.tar.gz
glibc-a5d1d726704c6e3c4f8457e30cbd3d2840531ee5.tar.xz
glibc-a5d1d726704c6e3c4f8457e30cbd3d2840531ee5.zip
Update.
1998-10-09  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/i386/i686/pt-machine.h: Remove unused inline
	definitions.
Diffstat (limited to 'posix')
-rw-r--r--posix/ptestcases.h2
-rw-r--r--posix/regex.c30
2 files changed, 21 insertions, 11 deletions
diff --git a/posix/ptestcases.h b/posix/ptestcases.h
index 0669380853..e025ab870f 100644
--- a/posix/ptestcases.h
+++ b/posix/ptestcases.h
@@ -66,7 +66,7 @@
   { 1, 2, "\\$a", "$a",  },
   { 3, 3, "\\$$", "ab$",  },
   { 2, 6, "A\\([34]$[34]\\)B", "XA4$3BY",  },
-  { 0, 0, "2.8.3.1.3  Perios in BREs", NULL, },
+  { 0, 0, "2.8.3.1.3  Periods in BREs", NULL, },
   { 0, 0, "GA116", NULL, },
   { 1, 1, ".", "abc",  },
   { -1, -1, ".ab", "abc",  },
diff --git a/posix/regex.c b/posix/regex.c
index 98ff8dfcbd..5f8e38c791 100644
--- a/posix/regex.c
+++ b/posix/regex.c
@@ -5570,7 +5570,8 @@ re_exec (s)
        REG_EXTENDED bit in CFLAGS is set; otherwise, to
        RE_SYNTAX_POSIX_BASIC;
      `newline_anchor' to REG_NEWLINE being set in CFLAGS;
-     `fastmap' and `fastmap_accurate' to zero;
+     `fastmap' to an allocated space for the fastmap;
+     `fastmap_accurate' to zero;
      `re_nsub' to the number of subexpressions in PATTERN.
 
    PATTERN is the address of the pattern string.
@@ -5609,11 +5610,8 @@ regcomp (preg, pattern, cflags)
   preg->allocated = 0;
   preg->used = 0;
 
-  /* Don't bother to use a fastmap when searching.  This simplifies the
-     REG_NEWLINE case: if we used a fastmap, we'd have to put all the
-     characters after newlines into the fastmap.  This way, we just try
-     every character.  */
-  preg->fastmap = 0;
+  /* Try to allocate space for the fastmap.  */
+  preg->fastmap = (char *) malloc (1 << BYTEWIDTH);
 
   if (cflags & REG_ICASE)
     {
@@ -5653,6 +5651,19 @@ regcomp (preg, pattern, cflags)
      unmatched close-group: both are REG_EPAREN.  */
   if (ret == REG_ERPAREN) ret = REG_EPAREN;
 
+  if (ret == REG_NOERROR && preg->fastmap)
+    {
+      /* Compute the fastmap now, since regexec cannot modify the pattern
+	 buffer.  */
+      if (re_compile_fastmap (preg) == -2)
+	{
+	  /* Some error occured while computing the fastmap, just forget
+	     about it.  */
+	  free (preg->fastmap);
+	  preg->fastmap = NULL;
+	}
+    }
+
   return (int) ret;
 }
 #ifdef _LIBC
@@ -5701,10 +5712,10 @@ regexec (preg, string, nmatch, pmatch, eflags)
   if (want_reg_info)
     {
       regs.num_regs = nmatch;
-      regs.start = TALLOC (nmatch, regoff_t);
-      regs.end = TALLOC (nmatch, regoff_t);
-      if (regs.start == NULL || regs.end == NULL)
+      regs.start = TALLOC (nmatch * 2, regoff_t);
+      if (regs.start == NULL)
         return (int) REG_NOMATCH;
+      regs.end = regs.start + nmatch;
     }
 
   /* Perform the searching operation.  */
@@ -5728,7 +5739,6 @@ regexec (preg, string, nmatch, pmatch, eflags)
 
       /* If we needed the temporary register info, free the space now.  */
       free (regs.start);
-      free (regs.end);
     }
 
   /* We want zero return to mean success, unlike `re_search'.  */