From 947cf31babc8a98c7af45ce2fe16359f90d1f8ec Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 9 Dec 2004 05:38:59 +0000 Subject: * 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/branches/ruby_1_8@7519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 19 +++++++++++++------ string.c | 12 +++++++++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5cd8394085..b70ac48715 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Dec 9 14:38:35 2004 Nobuyoshi Nakada + + * 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 10:54:36 2004 Yukihiro Matsumoto * ext/dbm/dbm.c (fdbm_select): [ruby-dev:25132] @@ -9,29 +16,29 @@ Thu Dec 9 10:54:36 2004 Yukihiro Matsumoto Thu Dec 9 03:08:36 2004 Hidetoshi NAGAI * ext/tcltklib/tcltklib.c (ip_init): set root-win title to "ruby" when - the running script is '-e one-liner' or '-' (stdin). + the running script is '-e one-liner' or '-' (stdin). * ext/tcltklib/extconf.rb: add find_library("#{lib}#{ver}",..) for - stub libs + stub libs * ext/tk/lib/tk/textmark.rb: TkTextMarkCurrent and TkTextMarkAnchor - have a wrong parent class. + have a wrong parent class. - * ext/tk/lib/tk/dialog.rb: rename TkDialog2 --> TkDialogObj and + * ext/tk/lib/tk/dialog.rb: rename TkDialog2 --> TkDialogObj and TkWarning2 --> TkWarningObj (old names are changed to alias names) * ext/tk/lib/tk/dialog.rb: bug fix of treatment of 'prev_command' option and hashes for configuration * ext/tk/lib/tk/dialog.rb: add TkDialogObj#name to return the - button name + button name * ext/tk/lib/tk/radiobutton.rb: rename enbugged method value() ==> get_value() and value=(val) ==> set_value(val). * ext/tk/lib/tk/menu.rb: add TkMenu.new_menuspec - * ext/tk/lib/tk/menu.rb: add alias (TkMenuButton = TkMenubutton, + * ext/tk/lib/tk/menu.rb: add alias (TkMenuButton = TkMenubutton, TkOptionMenuButton = TkOptionMenubutton) * ext/tk/lib/tk/event.rb: new method aliases (same as option keys of diff --git a/string.c b/string.c index aac1f2bf6c..464bb49c07 100644 --- a/string.c +++ b/string.c @@ -946,6 +946,8 @@ rb_str_equal(str1, str2) return Qfalse; } +#define IS_EVSTR(p,e) ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{')) + /* * call-seq: * str.eql?(other) => true or false @@ -2568,7 +2570,7 @@ rb_str_inspect(str) rb_str_buf_cat(result, p - 1, len); p += len - 1; } - else if (c == '"'|| c == '\\') { + else if (c == '"'|| c == '\\' || (c == '#' && IS_EVSTR(p, pend))) { s[0] = '\\'; s[1] = c; rb_str_buf_cat(result, s, 2); } @@ -2640,11 +2642,15 @@ rb_str_dump(str) switch (c) { case '"': case '\\': case '\n': case '\r': - case '\t': case '\f': case '#': + case '\t': case '\f': case '\013': case '\007': case '\033': len += 2; break; + case '#': + len += IS_EVSTR(p, pend) ? 2 : 1; + break; + default: if (ISPRINT(c)) { len++; @@ -2669,7 +2675,7 @@ rb_str_dump(str) *q++ = c; } else if (c == '#') { - *q++ = '\\'; + if (IS_EVSTR(p, pend)) *q++ = '\\'; *q++ = '#'; } else if (ISPRINT(c)) { -- cgit v1.2.3