mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-02 04:40:29 +02:00
(scm_regexp_exec): Remove SCM_CRITICAL_SECTION_START
and SCM_CRITICAL_SECTION_END, believe not needed. Their placement meant #\nul in the input (detected by scm_to_locale_string) and a bad flags arg (detected by scm_to_int) would throw from a critical section, causing an abort().
This commit is contained in:
parent
4920a9b613
commit
3f6c07ff8b
1 changed files with 12 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2004, 2006 Free Software Foundation, Inc.
|
/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2004, 2006, 2007 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -218,6 +218,17 @@ SCM_DEFINE (scm_regexp_exec, "regexp-exec", 2, 2, 0,
|
||||||
"@end table")
|
"@end table")
|
||||||
#define FUNC_NAME s_scm_regexp_exec
|
#define FUNC_NAME s_scm_regexp_exec
|
||||||
{
|
{
|
||||||
|
/* We used to have an SCM_DEFER_INTS, and then later an
|
||||||
|
SCM_CRITICAL_SECTION_START, around the regexec() call. Can't quite
|
||||||
|
remember what defer ints was for, but a critical section would only be
|
||||||
|
wanted now if we think regexec() is not thread-safe. The posix spec
|
||||||
|
|
||||||
|
http://www.opengroup.org/onlinepubs/009695399/functions/regcomp.html
|
||||||
|
|
||||||
|
reads like regexec is meant to be both thread safe and reentrant
|
||||||
|
(mentioning simultaneous use in threads, and in signal handlers). So
|
||||||
|
for now believe no protection needed. */
|
||||||
|
|
||||||
int status, nmatches, offset;
|
int status, nmatches, offset;
|
||||||
regmatch_t *matches;
|
regmatch_t *matches;
|
||||||
char *c_str;
|
char *c_str;
|
||||||
|
@ -245,7 +256,6 @@ SCM_DEFINE (scm_regexp_exec, "regexp-exec", 2, 2, 0,
|
||||||
whole regexp, so add 1 to nmatches. */
|
whole regexp, so add 1 to nmatches. */
|
||||||
|
|
||||||
nmatches = SCM_RGX(rx)->re_nsub + 1;
|
nmatches = SCM_RGX(rx)->re_nsub + 1;
|
||||||
SCM_CRITICAL_SECTION_START;
|
|
||||||
matches = scm_malloc (sizeof (regmatch_t) * nmatches);
|
matches = scm_malloc (sizeof (regmatch_t) * nmatches);
|
||||||
c_str = scm_to_locale_string (substr);
|
c_str = scm_to_locale_string (substr);
|
||||||
status = regexec (SCM_RGX (rx), c_str, nmatches, matches,
|
status = regexec (SCM_RGX (rx), c_str, nmatches, matches,
|
||||||
|
@ -269,7 +279,6 @@ SCM_DEFINE (scm_regexp_exec, "regexp-exec", 2, 2, 0,
|
||||||
scm_from_long (matches[i].rm_eo + offset)));
|
scm_from_long (matches[i].rm_eo + offset)));
|
||||||
}
|
}
|
||||||
free (matches);
|
free (matches);
|
||||||
SCM_CRITICAL_SECTION_END;
|
|
||||||
|
|
||||||
if (status != 0 && status != REG_NOMATCH)
|
if (status != 0 && status != REG_NOMATCH)
|
||||||
scm_error_scm (scm_regexp_error_key,
|
scm_error_scm (scm_regexp_error_key,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue