#if defined HAVE_WCTYPE_H || defined _LIBC
# include <wctype.h>
#endif /* HAVE_WCTYPE_H || _LIBC */
+#if defined _LIBC
+# include <bits/libc-lock.h>
+#else
+# define __libc_lock_define(CLASS,NAME)
+# define __libc_lock_init(NAME) do { } while (0)
+# define __libc_lock_lock(NAME) do { } while (0)
+# define __libc_lock_unlock(NAME) do { } while (0)
+#endif
/* In case that the system doesn't have isblank(). */
#if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank
#ifdef DEBUG
char* re_str;
#endif
+ __libc_lock_define (, lock)
};
#ifndef RE_NO_INTERNAL_PROTOTYPES
{
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;
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;
}
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))
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;
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);
rval = pmatch[0].rm_so;
}
re_free (pmatch);
+ out:
+ __libc_lock_unlock (dfa->lock);
return rval;
}