Projects

Ticket #612 (closed defect: fixed)

Opened 2 years ago

Last modified 21 months ago

RegexpError: U_REGEX_BAD_ESCAPE_SEQUENCE

Reported by: cehoffman@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby 0.7
Component: MacRuby Keywords:
Cc:

Description

Introduced in r3459 it seems that regular expressions that use escape codes fail with a RegexpError.

MacRuby r3459

$ macruby -e "p MACRUBY_REVISION; Regexp.compile('[^\0-\177]')"
"git commit b078cfc15060a60cdd72f7764d9c3809bfc1427a"
-e:1:in `<main>': too short escaped multibyte character: /[^\0-\177]/ (RegexpError)

MacRuby r3458

$ macruby -e "p MACRUBY_REVISION; Regexp.compile('[^\0-\177]'))"
"git commit 2311cf7d47b64218069fde17de290d75034a0fa3"

Ruby 1.9.1

$ ruby -e "p RUBY_VERSION; Regexp.compile('[^\0-\177]')"
"1.9.1"

Change History

Changed 2 years ago by cehoffman@…

These changes are specifically the ones that bring up the RegexpError.

diff --git a/array.c b/array.c
index c4f7e7f..7cf2d4a 100644
--- a/array.c
+++ b/array.c
@@ -2887,11 +2887,12 @@ rary_sample(VALUE ary, SEL sel, int argc, VALUE *argv)
            memmove(&sorted[j+1], &sorted[j], sizeof(sorted[0])*(i-j));
            sorted[j] = idx[i] = k;
        }
-       VALUE *elems = (VALUE *)alloca(sizeof(VALUE) * n);
+       VALUE *elems = (VALUE *)malloc(sizeof(VALUE) * n);
        for (i = 0; i < n; i++) {
            elems[i] = RARRAY_AT(ary, idx[i]);
        }
        result = rb_ary_new4(n, elems);
+       free(elems);
     }
     else {
        VALUE *elems = (VALUE *)malloc(sizeof(VALUE) * n);

Changed 2 years ago by lsansonetti@…

It looks like the re.c bug is haunting us again. Let's hope it will disappear forever once we merge the new string/regexp.

Changed 2 years ago by martinlagardette@…

Should we close this bug? We have plenty of bug report about errors from re.c with too short escaped etc. or premature end of char-class, and they should be fixed when we have the new string/regexp

Changed 23 months ago by lsansonetti@…

  • summary changed from RegexpError: too short escaped multibyte character to RegexpError: U_REGEX_BAD_ESCAPE_SEQUENCE

The snippet above now causes the following error on trunk:

$ ./miniruby -e "p MACRUBY_REVISION; Regexp.compile('[^\0-\177]')"
"svn revision 3849 from http://svn.macosforge.org/repository/ruby/MacRuby/trunk"
/Users/lrz/src/macruby-trunk/-e:1:in `<main>': regexp `[^\0-\177] 'compilation error: U_REGEX_BAD_ESCAPE_SEQUENCE (RegexpError)

This error comes from ICU. Renamed the title accordingly.

Changed 21 months ago by lsansonetti@…

Also happens with:

> macruby -e "p /\0/"
-e:1: regexp `\0 'compilation error: U_REGEX_BAD_ESCAPE_SEQUENCE

< rdar://problem/7942071>

Changed 21 months ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to MacRuby 0.7

This should be fixed in r4042. I didn't test all the cases but it should work.

Note: See TracTickets for help on using tickets.