* string.c (rb_str_inspect): escape # which starts an expression
substitution. fixed: [ruby-core:03922] * string.c (rb_str_dump): not escape # which isn't a substitution. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b9c6120e07
commit
e326946b35
@ -1,3 +1,10 @@
|
|||||||
|
Thu Dec 9 14:38:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (rb_str_inspect): escape # which starts an expression
|
||||||
|
substitution. fixed: [ruby-core:03922]
|
||||||
|
|
||||||
|
* string.c (rb_str_dump): not escape # which isn't a substitution.
|
||||||
|
|
||||||
Thu Dec 9 12:31:53 2004 WATANABE Hirofumi <eban@ruby-lang.org>
|
Thu Dec 9 12:31:53 2004 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* io.c (pipe_open): should set prog if argc != 0.
|
* io.c (pipe_open): should set prog if argc != 0.
|
||||||
|
12
string.c
12
string.c
@ -2570,6 +2570,8 @@ rb_str_to_s(str)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define IS_EVSTR(p,e) ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{'))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* str.inspect => string
|
* str.inspect => string
|
||||||
@ -2598,7 +2600,7 @@ rb_str_inspect(str)
|
|||||||
rb_str_buf_cat(result, p - 1, len);
|
rb_str_buf_cat(result, p - 1, len);
|
||||||
p += len - 1;
|
p += len - 1;
|
||||||
}
|
}
|
||||||
else if (c == '"'|| c == '\\') {
|
else if (c == '"'|| c == '\\' || (c == '#' && IS_EVSTR(p, pend))) {
|
||||||
s[0] = '\\'; s[1] = c;
|
s[0] = '\\'; s[1] = c;
|
||||||
rb_str_buf_cat(result, s, 2);
|
rb_str_buf_cat(result, s, 2);
|
||||||
}
|
}
|
||||||
@ -2670,11 +2672,15 @@ rb_str_dump(str)
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
case '"': case '\\':
|
case '"': case '\\':
|
||||||
case '\n': case '\r':
|
case '\n': case '\r':
|
||||||
case '\t': case '\f': case '#':
|
case '\t': case '\f':
|
||||||
case '\013': case '\007': case '\033':
|
case '\013': case '\007': case '\033':
|
||||||
len += 2;
|
len += 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case '#':
|
||||||
|
len += IS_EVSTR(p, pend) ? 2 : 1;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (ISPRINT(c)) {
|
if (ISPRINT(c)) {
|
||||||
len++;
|
len++;
|
||||||
@ -2699,7 +2705,7 @@ rb_str_dump(str)
|
|||||||
*q++ = c;
|
*q++ = c;
|
||||||
}
|
}
|
||||||
else if (c == '#') {
|
else if (c == '#') {
|
||||||
*q++ = '\\';
|
if (IS_EVSTR(p, pend)) *q++ = '\\';
|
||||||
*q++ = '#';
|
*q++ = '#';
|
||||||
}
|
}
|
||||||
else if (ISPRINT(c)) {
|
else if (ISPRINT(c)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user