Project

General

Profile

Backport #6069

シングルクォート内のマルチバイト直前のバックスラッシュが消える

Added by wanabe (_ wanabe) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
[ruby-dev:45278]

Description

http://toro.2ch.net/test/read.cgi/tech/1324826777/710 で指摘があったのですが
| シングルクォート文字列リテラルで
| マルチバイト文字直前のバックスラッシュが一つだけだと
| バックスラッシュが消え去ってました
とのことです。具体的には以下の例のようになります。

coding: UTF-8

p 'foo\ほげ' # => "fooほげ"

git bisect で追ってみると、r33161 からのようでした。
http://d.hatena.ne.jp/nagachika/20110902/ruby_trunk_changes_33158_33164

たとえば ruby -e "p '\b'" などは "\b" となりますので、
バックスラッシュは無視するのでなくそのまま残す方が嬉しいように思うのですがいかがでしょうか。

Associated revisions

Revision 45c6daee
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string, parser_yylex): insert a backslash if the next character is non-ascii. [ruby-dev:45278] [Bug #6069]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 34776
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string, parser_yylex): insert a backslash if the next character is non-ascii. [ruby-dev:45278] [Bug #6069]

Revision 34776
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string, parser_yylex): insert a backslash if the next character is non-ascii. [ruby-dev:45278] [Bug #6069]

Revision 34776
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string, parser_yylex): insert a backslash if the next character is non-ascii. [ruby-dev:45278] [Bug #6069]

Revision 34776
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string, parser_yylex): insert a backslash if the next character is non-ascii. [ruby-dev:45278] [Bug #6069]

Revision 34776
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string, parser_yylex): insert a backslash if the next character is non-ascii. [ruby-dev:45278] [Bug #6069]

Revision 34776
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string, parser_yylex): insert a backslash if the next character is non-ascii. [ruby-dev:45278] [Bug #6069]

Revision b329509a
Added by nobu (Nobuyoshi Nakada) over 7 years ago

merge revision(s) 34776:

    * parse.y (parser_tokadd_string, parser_yylex): insert a backslash
      if the next character is non-ascii.  [ruby-dev:45278] [Bug #6069]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 34777
Added by nobu (Nobuyoshi Nakada) over 7 years ago

merge revision(s) 34776:

* parse.y (parser_tokadd_string, parser_yylex): insert a backslash
  if the next character is non-ascii.  [ruby-dev:45278] [Bug #6069]

Revision 785521bd
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string): insert a backslash only if quoted by single quotes. [ruby-dev:45281] [Bug #6069]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 34796
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string): insert a backslash only if quoted by single quotes. [ruby-dev:45281] [Bug #6069]

Revision 34796
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string): insert a backslash only if quoted by single quotes. [ruby-dev:45281] [Bug #6069]

Revision 34796
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string): insert a backslash only if quoted by single quotes. [ruby-dev:45281] [Bug #6069]

Revision 34796
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string): insert a backslash only if quoted by single quotes. [ruby-dev:45281] [Bug #6069]

Revision 34796
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string): insert a backslash only if quoted by single quotes. [ruby-dev:45281] [Bug #6069]

Revision 34796
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • parse.y (parser_tokadd_string): insert a backslash only if quoted by single quotes. [ruby-dev:45281] [Bug #6069]

Revision 3d55c375
Added by naruse (Yui NARUSE) over 7 years ago

merge revision(s) 34796:

    * parse.y (parser_tokadd_string): insert a backslash only if
      quoted by single quotes.  [ruby-dev:45281] [Bug #6069]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 35643
Added by naruse (Yui NARUSE) over 7 years ago

merge revision(s) 34796:

* parse.y (parser_tokadd_string): insert a backslash only if
  quoted by single quotes.  [ruby-dev:45281] [Bug #6069]

History

#1

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r34776.
_, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • parse.y (parser_tokadd_string, parser_yylex): insert a backslash if the next character is non-ascii. [ruby-dev:45278] [Bug #6069]

Updated by nagachika (Tomoyuki Chikanaga) over 7 years ago

  • Category set to core
  • Status changed from Closed to Open
  • Assignee set to nobu (Nobuyoshi Nakada)

r34776 での対応はダブルクオートも含めて文字列リテラル内の non-ascii 文字の前のバックスラッシュは残すようになっていると思うのですが、このチケットの意図としては ascii 文字の時と同じくダブルクオートの時は消す、シングルクオートの時は残す、という挙動をして欲しいということではないでしょうか?

"\z" # => "z"

'\z' # => "\z"

ということで reopen します。

#3

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Status changed from Open to Closed

This issue was solved with changeset r34796.
_, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • parse.y (parser_tokadd_string): insert a backslash only if quoted by single quotes. [ruby-dev:45281] [Bug #6069]
#4

Updated by wanabe (_ wanabe) over 7 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193
  • Category deleted (core)
  • Status changed from Closed to Assigned

r34776 はバックポートされているようですので(ありがとうございます)、
r34796 も同様にバックポートしていただけるとありがたいです。

#5

Updated by naruse (Yui NARUSE) over 7 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r35643.
_, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 34796:

* parse.y (parser_tokadd_string): insert a backslash only if
  quoted by single quotes.  [ruby-dev:45281] [Bug #6069]

Also available in: Atom PDF