mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
6 changed files with 96 additions and 49 deletions
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>
|
||||
|
||||
* ext/dl/ptr.c (rb_dlptr_cast): removed.
|
||||
|
|
2
eval.c
2
eval.c
|
@ -8693,7 +8693,7 @@ rb_thread_cleanup()
|
|||
}
|
||||
|
||||
FOREACH_THREAD(th) {
|
||||
if (th != curr_thread && th->status != THREAD_KILLED) {
|
||||
if (th->status != THREAD_KILLED) {
|
||||
rb_thread_ready(th);
|
||||
th->gid = 0;
|
||||
th->priority = 0;
|
||||
|
|
4
parse.y
4
parse.y
|
@ -2596,10 +2596,6 @@ parse_regx(term, paren)
|
|||
case 'x':
|
||||
options |= RE_OPTION_EXTENDED;
|
||||
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':
|
||||
options |= RE_OPTION_MULTILINE;
|
||||
break;
|
||||
|
|
110
re.c
110
re.c
|
@ -304,10 +304,7 @@ rb_reg_desc(s, len, re)
|
|||
rb_str_buf_cat2(str, "/");
|
||||
if (re) {
|
||||
rb_reg_check(re);
|
||||
/* /p is obsolete; to be removed */
|
||||
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)
|
||||
if (RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE)
|
||||
rb_str_buf_cat2(str, "m");
|
||||
if (RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE)
|
||||
rb_str_buf_cat2(str, "i");
|
||||
|
@ -359,37 +356,94 @@ static VALUE
|
|||
rb_reg_to_s(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("(?");
|
||||
|
||||
rb_reg_check(re);
|
||||
|
||||
all = 1;
|
||||
if (RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE)
|
||||
rb_str_buf_cat2(str, "m");
|
||||
else
|
||||
all = 0;
|
||||
if (RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE)
|
||||
rb_str_buf_cat2(str, "i");
|
||||
else
|
||||
all = 0;
|
||||
if (RREGEXP(re)->ptr->options & RE_OPTION_EXTENDED)
|
||||
rb_str_buf_cat2(str, "x");
|
||||
else
|
||||
all = 0;
|
||||
options = RREGEXP(re)->ptr->options;
|
||||
ptr = RREGEXP(re)->str;
|
||||
len = RREGEXP(re)->len;
|
||||
if (len >= 4 && ptr[0] == '(' && ptr[1] == '?' && ptr[len-1] == ')') {
|
||||
int nest = 0;
|
||||
ptr += 2;
|
||||
if ((len -= 3) > 0) {
|
||||
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 (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, "-");
|
||||
if (!(RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE))
|
||||
rb_str_buf_cat2(str, "m");
|
||||
if (!(RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE))
|
||||
rb_str_buf_cat2(str, "i");
|
||||
if (!(RREGEXP(re)->ptr->options & RE_OPTION_EXTENDED))
|
||||
rb_str_buf_cat2(str, "x");
|
||||
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");
|
||||
}
|
||||
|
||||
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, ")");
|
||||
|
||||
OBJ_INFECT(str, re);
|
||||
|
@ -1234,9 +1288,7 @@ rb_reg_options(re)
|
|||
rb_reg_check(re);
|
||||
if (RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE)
|
||||
options |= RE_OPTION_IGNORECASE;
|
||||
if ((RREGEXP(re)->ptr->options & RE_OPTION_POSIXLINE) == RE_OPTION_POSIXLINE)
|
||||
options |= RE_OPTION_POSIXLINE;
|
||||
else if (RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE)
|
||||
if (RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE)
|
||||
options |= RE_OPTION_MULTILINE;
|
||||
if (RREGEXP(re)->ptr->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);
|
||||
switch (c) {
|
||||
case 'x': case 'p': case 'm': case 'i': case '-':
|
||||
case 'x': case 'm': case 'i': case '-':
|
||||
for (;;) {
|
||||
switch (c) {
|
||||
case '-':
|
||||
|
@ -1716,18 +1716,6 @@ re_compile_pattern(pattern, size, bufp)
|
|||
options |= RE_OPTION_EXTENDED;
|
||||
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':
|
||||
if (negative) {
|
||||
if (options&RE_OPTION_MULTILINE) {
|
||||
|
|
2
regex.h
2
regex.h
|
@ -73,8 +73,6 @@
|
|||
#define RE_OPTION_MULTILINE (RE_OPTION_EXTENDED<<1)
|
||||
/* ^ and $ ignore newline */
|
||||
#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 */
|
||||
#define RE_OPTION_LONGEST (RE_OPTION_SINGLELINE<<1)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue