* eval.c (rb_thread_cleanup): current thread may be THREAD_STOPPED,
for example when terminated from signal handler. * regex.c (re_compile_pattern): remove /p support. * regex.h: ditto. * parse.y (parse_regx): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
75ebf39107
commit
8c3157e43f
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
Fri Apr 19 01:08:20 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (rb_thread_cleanup): current thread may be THREAD_STOPPED,
|
||||||
|
for example when terminated from signal handler.
|
||||||
|
|
||||||
|
Thu Apr 18 19:03:15 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* regex.c (re_compile_pattern): remove /p support.
|
||||||
|
|
||||||
|
* regex.h: ditto.
|
||||||
|
|
||||||
|
* parse.y (parse_regx): ditto.
|
||||||
|
|
||||||
Thu Apr 18 17:01:43 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
|
Thu Apr 18 17:01:43 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
|
||||||
|
|
||||||
* ext/dl/ptr.c (rb_dlptr_cast): removed.
|
* ext/dl/ptr.c (rb_dlptr_cast): removed.
|
||||||
|
2
eval.c
2
eval.c
@ -8693,7 +8693,7 @@ rb_thread_cleanup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
FOREACH_THREAD(th) {
|
FOREACH_THREAD(th) {
|
||||||
if (th != curr_thread && th->status != THREAD_KILLED) {
|
if (th->status != THREAD_KILLED) {
|
||||||
rb_thread_ready(th);
|
rb_thread_ready(th);
|
||||||
th->gid = 0;
|
th->gid = 0;
|
||||||
th->priority = 0;
|
th->priority = 0;
|
||||||
|
4
parse.y
4
parse.y
@ -2596,10 +2596,6 @@ parse_regx(term, paren)
|
|||||||
case 'x':
|
case 'x':
|
||||||
options |= RE_OPTION_EXTENDED;
|
options |= RE_OPTION_EXTENDED;
|
||||||
break;
|
break;
|
||||||
case 'p': /* /p is obsolete */
|
|
||||||
rb_warn("/p option is obsolete; use /m\n\tnote: /m does not change ^, $ behavior");
|
|
||||||
options |= RE_OPTION_POSIXLINE;
|
|
||||||
break;
|
|
||||||
case 'm':
|
case 'm':
|
||||||
options |= RE_OPTION_MULTILINE;
|
options |= RE_OPTION_MULTILINE;
|
||||||
break;
|
break;
|
||||||
|
110
re.c
110
re.c
@ -304,10 +304,7 @@ rb_reg_desc(s, len, re)
|
|||||||
rb_str_buf_cat2(str, "/");
|
rb_str_buf_cat2(str, "/");
|
||||||
if (re) {
|
if (re) {
|
||||||
rb_reg_check(re);
|
rb_reg_check(re);
|
||||||
/* /p is obsolete; to be removed */
|
if (RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE)
|
||||||
if ((RREGEXP(re)->ptr->options & RE_OPTION_POSIXLINE) == RE_OPTION_POSIXLINE)
|
|
||||||
rb_str_buf_cat2(str, "p");
|
|
||||||
else if (RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE)
|
|
||||||
rb_str_buf_cat2(str, "m");
|
rb_str_buf_cat2(str, "m");
|
||||||
if (RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE)
|
if (RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE)
|
||||||
rb_str_buf_cat2(str, "i");
|
rb_str_buf_cat2(str, "i");
|
||||||
@ -359,37 +356,94 @@ static VALUE
|
|||||||
rb_reg_to_s(re)
|
rb_reg_to_s(re)
|
||||||
VALUE re;
|
VALUE re;
|
||||||
{
|
{
|
||||||
int all;
|
int options;
|
||||||
|
const int embeddable = RE_OPTION_MULTILINE|RE_OPTION_IGNORECASE|RE_OPTION_EXTENDED;
|
||||||
|
long len;
|
||||||
|
const char* ptr;
|
||||||
VALUE str = rb_str_buf_new2("(?");
|
VALUE str = rb_str_buf_new2("(?");
|
||||||
|
|
||||||
rb_reg_check(re);
|
rb_reg_check(re);
|
||||||
|
|
||||||
all = 1;
|
options = RREGEXP(re)->ptr->options;
|
||||||
if (RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE)
|
ptr = RREGEXP(re)->str;
|
||||||
rb_str_buf_cat2(str, "m");
|
len = RREGEXP(re)->len;
|
||||||
else
|
if (len >= 4 && ptr[0] == '(' && ptr[1] == '?' && ptr[len-1] == ')') {
|
||||||
all = 0;
|
int nest = 0;
|
||||||
if (RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE)
|
ptr += 2;
|
||||||
rb_str_buf_cat2(str, "i");
|
if ((len -= 3) > 0) {
|
||||||
else
|
do {
|
||||||
all = 0;
|
if (*ptr == 'm') {
|
||||||
if (RREGEXP(re)->ptr->options & RE_OPTION_EXTENDED)
|
options |= RE_OPTION_MULTILINE;
|
||||||
rb_str_buf_cat2(str, "x");
|
}
|
||||||
else
|
else if (*ptr == 'i') {
|
||||||
all = 0;
|
options |= RE_OPTION_IGNORECASE;
|
||||||
|
}
|
||||||
|
else if (*ptr == 'x') {
|
||||||
|
options |= RE_OPTION_EXTENDED;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
++ptr;
|
||||||
|
} while (--len > 0);
|
||||||
|
}
|
||||||
|
if (len > 1 && *ptr == '-') {
|
||||||
|
++ptr;
|
||||||
|
--len;
|
||||||
|
do {
|
||||||
|
if (*ptr == 'm') {
|
||||||
|
options &= ~RE_OPTION_MULTILINE;
|
||||||
|
}
|
||||||
|
else if (*ptr == 'i') {
|
||||||
|
options &= ~RE_OPTION_IGNORECASE;
|
||||||
|
}
|
||||||
|
else if (*ptr == 'x') {
|
||||||
|
options &= ~RE_OPTION_EXTENDED;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
++ptr;
|
||||||
|
} while (--len > 0);
|
||||||
|
}
|
||||||
|
if (*ptr == ':') {
|
||||||
|
const char* p = ++ptr;
|
||||||
|
long l = --len;
|
||||||
|
kcode_set_option(re);
|
||||||
|
while (len > 0) {
|
||||||
|
int n;
|
||||||
|
if (*p == '(') {
|
||||||
|
++nest;
|
||||||
|
}
|
||||||
|
else if (*p == ')') {
|
||||||
|
if (--nest < 0) break;
|
||||||
|
}
|
||||||
|
else if (*p == '\\') {
|
||||||
|
--l;
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
n = mbclen(*p);
|
||||||
|
l -= n;
|
||||||
|
p += n;
|
||||||
|
}
|
||||||
|
kcode_reset_option();
|
||||||
|
}
|
||||||
|
if (nest) {
|
||||||
|
options = RREGEXP(re)->ptr->options;
|
||||||
|
ptr = RREGEXP(re)->str;
|
||||||
|
len = RREGEXP(re)->len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!all) {
|
if (options & RE_OPTION_MULTILINE) rb_str_buf_cat2(str, "m");
|
||||||
|
if (options & RE_OPTION_IGNORECASE) rb_str_buf_cat2(str, "i");
|
||||||
|
if (options & RE_OPTION_EXTENDED) rb_str_buf_cat2(str, "x");
|
||||||
|
|
||||||
|
if ((options & embeddable) != embeddable) {
|
||||||
rb_str_buf_cat2(str, "-");
|
rb_str_buf_cat2(str, "-");
|
||||||
if (!(RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE))
|
if (!(options & RE_OPTION_MULTILINE)) rb_str_buf_cat2(str, "m");
|
||||||
rb_str_buf_cat2(str, "m");
|
if (!(options & RE_OPTION_IGNORECASE)) rb_str_buf_cat2(str, "i");
|
||||||
if (!(RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE))
|
if (!(options & RE_OPTION_EXTENDED)) rb_str_buf_cat2(str, "x");
|
||||||
rb_str_buf_cat2(str, "i");
|
|
||||||
if (!(RREGEXP(re)->ptr->options & RE_OPTION_EXTENDED))
|
|
||||||
rb_str_buf_cat2(str, "x");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_str_buf_cat2(str, ":");
|
rb_str_buf_cat2(str, ":");
|
||||||
rb_reg_expr_str(str, RREGEXP(re)->str, RREGEXP(re)->len);
|
rb_reg_expr_str(str, ptr, len);
|
||||||
rb_str_buf_cat2(str, ")");
|
rb_str_buf_cat2(str, ")");
|
||||||
|
|
||||||
OBJ_INFECT(str, re);
|
OBJ_INFECT(str, re);
|
||||||
@ -1234,9 +1288,7 @@ rb_reg_options(re)
|
|||||||
rb_reg_check(re);
|
rb_reg_check(re);
|
||||||
if (RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE)
|
if (RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE)
|
||||||
options |= RE_OPTION_IGNORECASE;
|
options |= RE_OPTION_IGNORECASE;
|
||||||
if ((RREGEXP(re)->ptr->options & RE_OPTION_POSIXLINE) == RE_OPTION_POSIXLINE)
|
if (RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE)
|
||||||
options |= RE_OPTION_POSIXLINE;
|
|
||||||
else if (RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE)
|
|
||||||
options |= RE_OPTION_MULTILINE;
|
options |= RE_OPTION_MULTILINE;
|
||||||
if (RREGEXP(re)->ptr->options & RE_OPTION_EXTENDED)
|
if (RREGEXP(re)->ptr->options & RE_OPTION_EXTENDED)
|
||||||
options |= RE_OPTION_EXTENDED;
|
options |= RE_OPTION_EXTENDED;
|
||||||
|
14
regex.c
14
regex.c
@ -1698,7 +1698,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||||||
|
|
||||||
PATFETCH_RAW(c);
|
PATFETCH_RAW(c);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'x': case 'p': case 'm': case 'i': case '-':
|
case 'x': case 'm': case 'i': case '-':
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '-':
|
case '-':
|
||||||
@ -1716,18 +1716,6 @@ re_compile_pattern(pattern, size, bufp)
|
|||||||
options |= RE_OPTION_EXTENDED;
|
options |= RE_OPTION_EXTENDED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
|
||||||
if (negative) {
|
|
||||||
if ((options&RE_OPTION_POSIXLINE) == RE_OPTION_POSIXLINE) {
|
|
||||||
options &= ~RE_OPTION_POSIXLINE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((options&RE_OPTION_POSIXLINE) != RE_OPTION_POSIXLINE) {
|
|
||||||
options |= RE_OPTION_POSIXLINE;
|
|
||||||
}
|
|
||||||
push_option = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
if (negative) {
|
if (negative) {
|
||||||
if (options&RE_OPTION_MULTILINE) {
|
if (options&RE_OPTION_MULTILINE) {
|
||||||
|
2
regex.h
2
regex.h
@ -73,8 +73,6 @@
|
|||||||
#define RE_OPTION_MULTILINE (RE_OPTION_EXTENDED<<1)
|
#define RE_OPTION_MULTILINE (RE_OPTION_EXTENDED<<1)
|
||||||
/* ^ and $ ignore newline */
|
/* ^ and $ ignore newline */
|
||||||
#define RE_OPTION_SINGLELINE (RE_OPTION_MULTILINE<<1)
|
#define RE_OPTION_SINGLELINE (RE_OPTION_MULTILINE<<1)
|
||||||
/* works line Perl's /s; it's called POSIX for wrong reason */
|
|
||||||
#define RE_OPTION_POSIXLINE (RE_OPTION_MULTILINE|RE_OPTION_SINGLELINE)
|
|
||||||
/* search for longest match, in accord with POSIX regexp */
|
/* search for longest match, in accord with POSIX regexp */
|
||||||
#define RE_OPTION_LONGEST (RE_OPTION_SINGLELINE<<1)
|
#define RE_OPTION_LONGEST (RE_OPTION_SINGLELINE<<1)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user