summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--eval.c2
-rw-r--r--parse.y4
-rw-r--r--re.c110
-rw-r--r--regex.c14
-rw-r--r--regex.h2
6 files changed, 96 insertions, 49 deletions
diff --git a/ChangeLog b/ChangeLog
index 66ac553536..4e9ba373ed 100644
--- a/ChangeLog
+++ b/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.
diff --git a/eval.c b/eval.c
index 484671d65b..d3a3d76dcf 100644
--- a/eval.c
+++ b/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;
diff --git a/parse.y b/parse.y
index 2217cacfe7..213edbbd92 100644
--- a/parse.y
+++ b/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;
diff --git a/re.c b/re.c
index 2488ccba95..a1f69c489e 100644
--- a/re.c
+++ b/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;
diff --git a/regex.c b/regex.c
index 776c5914bb..96f16de7e2 100644
--- a/regex.c
+++ b/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) {
diff --git a/regex.h b/regex.h
index d5eb01d235..fbc29b20ae 100644
--- a/regex.h
+++ b/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)