summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-11 05:43:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-11 05:43:19 +0000
commit87fb6fbcc9558255dc87cf22dd34e0b094ba4f35 (patch)
tree022280b645aa8506c1fb266caab0f2def961bd0e
parent50bf2e550a6fb7cfa197d8429cf4a1e4f5e3e9c7 (diff)
* marshal.c (r_object0): replace non-1.8 escapes directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--marshal.c24
2 files changed, 20 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 087bc85540c..ee7b795b3d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,10 @@
-Thu Feb 11 14:37:39 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Feb 11 14:43:16 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (r_object0): read sequentially since marshal source
may not be possible to rewind. [ruby-dev:40386]
+ * marshal.c (r_object0): replace non-1.8 escapes directly.
+
Thu Feb 11 09:49:31 2010 Tanaka Akira <akr@fsij.org>
* lib/resolv.rb: fix [ruby-core:28144] reported by Hans de Graaff.
diff --git a/marshal.c b/marshal.c
index 395254094fd..e5ede8c659e 100644
--- a/marshal.c
+++ b/marshal.c
@@ -1501,13 +1501,23 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
*ivp = FALSE;
}
if (!has_encoding) {
- VALUE pat;
- VALUE dst;
- static const char rsrc[] =
- "(?<!\\\\)((?:\\\\\\\\)*)\\\\([ghijklmopquyEFHIJKLNOPQRSTUVXY])";
- pat = rb_reg_new(rsrc, sizeof(rsrc)-1, 0);
- dst = rb_usascii_str_new_cstr("\\1\\2");
- rb_funcall(str, rb_intern("gsub!"), 2, pat, dst);
+ /* 1.8 compatibility; remove escapes undefined in 1.8 */
+ char *ptr = RSTRING_PTR(str), *dst = ptr, *src = ptr;
+ long len = RSTRING_LEN(str);
+ long bs = 0;
+ for (; len-- > 0; *dst++ = *src++) {
+ switch (*src) {
+ case '\\': bs++; break;
+ case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+ case 'm': case 'o': case 'p': case 'q': case 'u': case 'y':
+ case 'E': case 'F': case 'H': case 'I': case 'J': case 'K':
+ case 'L': case 'N': case 'O': case 'P': case 'Q': case 'R':
+ case 'S': case 'T': case 'U': case 'V': case 'X': case 'Y':
+ if (bs & 1) --dst;
+ default: bs = 0; break;
+ }
+ }
+ rb_str_set_len(str, dst - ptr);
}
v = r_entry(rb_reg_new_str(str, options), arg);
v = r_leave(v, arg);