зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
50bf2e550a
Коммит
87fb6fbcc9
|
@ -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.
|
||||
|
|
24
marshal.c
24
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче