]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
[BZ #934]
authorUlrich Drepper <drepper@redhat.com>
Fri, 6 May 2005 23:34:44 +0000 (23:34 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 6 May 2005 23:34:44 +0000 (23:34 +0000)
2005-05-06  Jakub Jelinek  <jakub@redhat.com>
[BZ #934]
* posix/regex_internal.h: Include bits/libc-lock.h or define dummy
__libc_lock_* macros if not _LIBC.
(struct re_dfa_t): Add lock.
* posix/regcomp.c (re_compile_internal): Add __libc_lock_init.
* posix/regexec.c (regexec, re_search_stub): Add locking.

ChangeLog
posix/regcomp.c
posix/regexec.c

index 6f3eacbc5f612f4969fa89ab9493f58ff06f9b6f..2416243f1dae6168bc8c1c38daf51862182dfdc7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-05-06  Jakub Jelinek  <jakub@redhat.com>
+
+       [BZ #934]
+       * posix/regex_internal.h: Include bits/libc-lock.h or define dummy
+       __libc_lock_* macros if not _LIBC.
+       (struct re_dfa_t): Add lock.
+       * posix/regcomp.c (re_compile_internal): Add __libc_lock_init.
+       * posix/regexec.c (regexec, re_search_stub): Add locking.
+
 2005-05-04  Jakub Jelinek  <jakub@redhat.com>
 
        * intl/Makefile (tst-gettext[45].out): Pass also $(run-program-prefix)
index 68e2bdab92d1e22418f5ce6804ffca90060f31f5..2053b024dc2bd31229e7e8fd733a36569b2d49c5 100644 (file)
@@ -774,6 +774,8 @@ re_compile_internal (preg, pattern, length, syntax)
     }
   preg->used = sizeof (re_dfa_t);
 
+  __libc_lock_init (dfa->lock);
+
   err = init_dfa (dfa, length);
   if (BE (err != REG_NOERROR, 0))
     {
index 3c226e3c20cd80f59cef4f2090fea717e2e3827f..e635261d05d62005f76b26601a5841aa1fa81f70 100644 (file)
@@ -219,6 +219,7 @@ regexec (preg, string, nmatch, pmatch, eflags)
 {
   reg_errcode_t err;
   int start, length;
+  re_dfa_t *dfa = (re_dfa_t *)preg->buffer;
 
   if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
     return REG_BADPAT;
@@ -233,12 +234,15 @@ regexec (preg, string, nmatch, pmatch, eflags)
       start = 0;
       length = strlen (string);
     }
+
+  __libc_lock_lock (dfa->lock);
   if (preg->no_sub)
     err = re_search_internal (preg, string, length, start, length - start,
                              length, 0, NULL, eflags);
   else
     err = re_search_internal (preg, string, length, start, length - start,
                              length, nmatch, pmatch, eflags);
+  __libc_lock_unlock (dfa->lock);
   return err != REG_NOERROR;
 }
 
@@ -402,6 +406,7 @@ re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
   regmatch_t *pmatch;
   int nregs, rval;
   int eflags = 0;
+  re_dfa_t *dfa = (re_dfa_t *)bufp->buffer;
 
   /* Check for out-of-range.  */
   if (BE (start < 0 || start > length, 0))
@@ -411,6 +416,8 @@ re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
   else if (BE (start + range < 0, 0))
     range = -start;
 
+  __libc_lock_lock (dfa->lock);
+
   eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
   eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
 
@@ -439,7 +446,10 @@ re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
     nregs = bufp->re_nsub + 1;
   pmatch = re_malloc (regmatch_t, nregs);
   if (BE (pmatch == NULL, 0))
-    return -2;
+    {
+      rval = -2;
+      goto out;
+    }
 
   result = re_search_internal (bufp, string, length, start, range, stop,
                               nregs, pmatch, eflags);
@@ -469,6 +479,8 @@ re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
        rval = pmatch[0].rm_so;
     }
   re_free (pmatch);
+ out:
+  __libc_lock_unlock (dfa->lock);
   return rval;
 }