Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libregexp-opcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ DEF(line_start, 1)
DEF(line_start_m, 1)
DEF(line_end, 1)
DEF(line_end_m, 1)
DEF(line_end_z, 1) /* optional line terminator or "\r\n" followed by buffer end */
DEF(goto, 5)
DEF(split_goto_first, 5)
DEF(split_next_first, 5)
Expand Down
50 changes: 43 additions & 7 deletions libregexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2089,6 +2089,27 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
p = p1;
}
break;
case 'A':
if (s->is_unicode) {
p += 2;
re_emit_op(s, REOP_line_start);
break;
}
goto parse_class_atom;
case 'z':
if (s->is_unicode) {
p += 2;
re_emit_op(s, REOP_line_end);
break;
}
goto parse_class_atom;
case 'Z':
if (s->is_unicode) {
p += 2;
re_emit_op(s, REOP_line_end_z);
break;
}
goto parse_class_atom;
case '0':
p += 2;
c = 0;
Expand Down Expand Up @@ -2994,13 +3015,28 @@ static intptr_t lre_exec_backtrack(REExecContext *s, uint8_t **capture,
break;
case REOP_line_end:
case REOP_line_end_m:
if (cptr == cbuf_end)
break;
if (opcode == REOP_line_end)
goto no_match;
PEEK_CHAR(c, cptr, cbuf_end, cbuf_type);
if (!is_line_terminator(c))
goto no_match;
case REOP_line_end_z:
{
const uint8_t *cptr1 = cptr;
if (cptr1 == cbuf_end)
break;
if (opcode == REOP_line_end)
goto no_match;
GET_CHAR(c, cptr1, cbuf_end, cbuf_type);
if (!is_line_terminator(c))
goto no_match;
if (opcode == REOP_line_end_z && cptr1 != cbuf_end) {
if (c == '\r') {
/* allow "\r\n" at end of buffer */
GET_CHAR(c, cptr1, cbuf_end, cbuf_type);
if (c != '\n' || cptr1 != cbuf_end) {
goto no_match;
}
} else {
goto no_match;
}
}
}
break;
case REOP_dot:
if (cptr == cbuf_end)
Expand Down
1 change: 1 addition & 0 deletions test262.conf
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ Reflect
Reflect.construct
Reflect.set
Reflect.setPrototypeOf
regexp-buffer-boundaries
regexp-dotall
regexp-duplicate-named-groups
regexp-lookbehind
Expand Down