mirror of
https://github.com/janet-lang/janet
synced 2025-01-13 17:10:27 +00:00
Address #640.
Allow for a zero length match at the end of a string when using the to or thru combinators.
This commit is contained in:
parent
92928d5c4f
commit
742469a8bc
@ -286,7 +286,7 @@ tail:
|
|||||||
const uint8_t *next_text;
|
const uint8_t *next_text;
|
||||||
CapState cs = cap_save(s);
|
CapState cs = cap_save(s);
|
||||||
down1(s);
|
down1(s);
|
||||||
while (text < s->text_end) {
|
while (text <= s->text_end) {
|
||||||
CapState cs2 = cap_save(s);
|
CapState cs2 = cap_save(s);
|
||||||
next_text = peg_rule(s, rule_a, text);
|
next_text = peg_rule(s, rule_a, text);
|
||||||
if (next_text) {
|
if (next_text) {
|
||||||
@ -296,7 +296,7 @@ tail:
|
|||||||
text++;
|
text++;
|
||||||
}
|
}
|
||||||
up1(s);
|
up1(s);
|
||||||
if (text >= s->text_end) {
|
if (text > s->text_end) {
|
||||||
cap_load(s, cs);
|
cap_load(s, cs);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -473,4 +473,12 @@
|
|||||||
|
|
||||||
(check-deep '(* (int 2) -1) "123" nil)
|
(check-deep '(* (int 2) -1) "123" nil)
|
||||||
|
|
||||||
|
# to/thru bug
|
||||||
|
(check-deep '(to -1) "aaaa" @[])
|
||||||
|
(check-deep '(thru -1) "aaaa" @[])
|
||||||
|
(check-deep ''(to -1) "aaaa" @["aaaa"])
|
||||||
|
(check-deep ''(thru -1) "aaaa" @["aaaa"])
|
||||||
|
(check-deep '(to "b") "aaaa" nil)
|
||||||
|
(check-deep '(thru "b") "aaaa" nil)
|
||||||
|
|
||||||
(end-suite)
|
(end-suite)
|
||||||
|
Loading…
Reference in New Issue
Block a user