Project

General

Profile

Actions

Backport #8583

closed

A problem of condition regexp with a named capture

Added by ohai (Ippei Obayashi) almost 11 years ago. Updated almost 11 years ago.


Description

以下の条件分岐を含む正規表現は "xy" "yx" にマッチし、"xx" "yy" にはマッチしません。
/\A((x)|(y))(?(2)y|x)\z/
名前付きキャプチャを用いた以下の正規表現も同じ挙動をするはずですが、そうはなっていません。
/\A((?x)|(?y))(?()y|x)\z/

"xx" "yy" にマッチして "xy" "yx" にはマッチしない。

2.0.0-p247, trunk の両方で確認しました。

この問題について調べた所、 名前付きキャプチャを使うときキャプチャの番号をrenumberしている
所で renumber がもれています。

添付したパッチのように修正すれば直ると思います。


Files

regexp-condition-name.patch (528 Bytes) regexp-condition-name.patch ohai (Ippei Obayashi), 06/30/2013 04:35 PM

Updated by nagachika (Tomoyuki Chikanaga) almost 11 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: UNKNOWN, 2.0.0: REQUIRED

Updated by usa (Usaku NAKAMURA) almost 11 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: REQUIRED to 1.9.3: DONTNEED, 2.0.0: REQUIRED

Updated by knu (Akinori MUSHA) almost 11 years ago

Thank you. I've just reported this to the upstream with the given test cases: https://github.com/k-takata/Onigmo/pull/20

Updated by knu (Akinori MUSHA) almost 11 years ago

Onigmo 5.13.5 has been released, which includes the fix.

Actions #5

Updated by naruse (Yui NARUSE) almost 11 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport200
  • Target version deleted (2.1.0)

Merged as r41764,41765

Updated by nagachika (Tomoyuki Chikanaga) almost 11 years ago

  • Status changed from Open to Assigned
  • Assignee set to nagachika (Tomoyuki Chikanaga)
Actions #7

Updated by nagachika (Tomoyuki Chikanaga) almost 11 years ago

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

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


merge revision(s) 41764,41765,41767: [Backport #8583]

* regcomp.c (): Merge Onigmo 5.13.5 23b523076d6f1161.
  https://bugs.ruby-lang.org/issues/8583
  * [bug]  (thanks Akinori MUSHA and Ippei Obayashi)
           Fix a renumbering bug in condition regexp with a named
           capture. [Bug #8583]
  * [spec] (thanks Akinori MUSHA)
    Allow ENCLOSE_OPTION in look-behind.
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0