Project

General

Profile

Actions

Backport #6069

closed

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

Added by wanabe (_ wanabe) about 12 years ago. Updated almost 12 years ago.


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" となりますので、
バックスラッシュは無視するのでなくそのまま残す方が嬉しいように思うのですがいかがでしょうか。

Actions #1

Updated by nobu (Nobuyoshi Nakada) about 12 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) about 12 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 します。

Actions #3

Updated by nobu (Nobuyoshi Nakada) about 12 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]
Actions #4

Updated by wanabe (_ wanabe) almost 12 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 も同様にバックポートしていただけるとありがたいです。

Actions #5

Updated by naruse (Yui NARUSE) almost 12 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]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0