Commit 11ae581
committed
Fix handling of control/meta escapes in literal regexps
Ruby uses a recursive algorithm for handling control/meta escapes
in strings (read_escape). However, the equivalent code for regexps
(tokadd_escape) in did not use a recursive algorithm. Due to this,
Handling of control/meta escapes in regexp did not have the same
behavior as in strings, leading to behavior such as the following
returning nil:
```ruby
/\c\xFF/ =~ "\c\xFF"
```
Switch the code for handling \c, \C and \M in literal regexps to
use the same code as for strings (read_escape), to keep behavior
consistent between the two.
Fixes [Bug #14367]1 parent 9484f9e commit 11ae581
File tree
3 files changed
+36
-34
lines changed- spec/ruby/language/regexp
- test/ruby
3 files changed
+36
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6902 | 6902 | | |
6903 | 6903 | | |
6904 | 6904 | | |
6905 | | - | |
6906 | 6905 | | |
6907 | 6906 | | |
6908 | | - | |
6909 | 6907 | | |
6910 | 6908 | | |
6911 | 6909 | | |
| |||
6928 | 6926 | | |
6929 | 6927 | | |
6930 | 6928 | | |
6931 | | - | |
6932 | | - | |
6933 | | - | |
6934 | | - | |
6935 | | - | |
6936 | | - | |
6937 | | - | |
6938 | | - | |
6939 | | - | |
6940 | | - | |
6941 | | - | |
6942 | | - | |
6943 | | - | |
6944 | | - | |
6945 | | - | |
6946 | | - | |
6947 | | - | |
6948 | | - | |
6949 | | - | |
6950 | | - | |
6951 | | - | |
6952 | | - | |
6953 | | - | |
6954 | | - | |
6955 | | - | |
6956 | | - | |
6957 | | - | |
6958 | | - | |
6959 | | - | |
6960 | | - | |
6961 | | - | |
6962 | 6929 | | |
6963 | 6930 | | |
6964 | 6931 | | |
| |||
7151 | 7118 | | |
7152 | 7119 | | |
7153 | 7120 | | |
| 7121 | + | |
| 7122 | + | |
| 7123 | + | |
| 7124 | + | |
| 7125 | + | |
| 7126 | + | |
| 7127 | + | |
| 7128 | + | |
| 7129 | + | |
| 7130 | + | |
| 7131 | + | |
| 7132 | + | |
| 7133 | + | |
| 7134 | + | |
| 7135 | + | |
| 7136 | + | |
| 7137 | + | |
7154 | 7138 | | |
7155 | 7139 | | |
7156 | 7140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
499 | 517 | | |
500 | 518 | | |
501 | 519 | | |
| |||
0 commit comments