Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/e: Set RZ_REGEX_MULTILINE for ^ and $ #4868

Merged
merged 4 commits into from
Jan 29, 2025
Merged
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
2 changes: 1 addition & 1 deletion librz/core/cmd/cmd_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static const char *help_msg_slash[] = {
"/b", "", "search backwards, command modifier, followed by other command",
"/c", "[?][adr]", "search for crypto materials",
"/d", " 101112", "search for a deltified sequence of bytes",
"/e", " /pattern/[i]", "match regular expression",
"/e", " /pattern/[i]", "match regular expression (beginning-of-string for ^ and $ is '\\0')",
"/E", " esil-expr", "offset matching given esil expressions $$ = here",
"/f", "", "search forwards, (command modifier)",
"/F", " file [off] [sz]", "search contents of file with offset and size",
Expand Down
2 changes: 1 addition & 1 deletion librz/search/regexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RZ_API int rz_search_regexp_update(RzSearch *s, ut64 from, const ut8 *buf, int l
rz_regex_set_nul_as_newline(ccontext);

rz_list_foreach (s->kws, iter, kw) {
int cflags = RZ_REGEX_EXTENDED;
int cflags = RZ_REGEX_EXTENDED | RZ_REGEX_MULTILINE;

if (kw->icase) {
cflags |= RZ_REGEX_CASELESS;
Expand Down
22 changes: 18 additions & 4 deletions test/db/cmd/regexp
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,29 @@ CMDS=<<EOF
w abcd
w bcccde @ 0x10
e scr.color=1
echo -- 1 --
/e /b.*d/
echo ----
echo -- 2 --
/e /b.*D/
echo ----
echo -- 3 --
/e /b.*D/i
echo -- 4 --
/e /b.*d$/
echo -- 5 --
/e /^b.*d/
EOF
EXPECT=<<EOF
-- 1 --
0x00000001 hit0_0 .abcdbccc.
0x00000010 hit0_1 .abcdbcccde.
----
----
-- 2 --
-- 3 --
0x00000001 hit2_0 .abcdbccc.
0x00000010 hit2_1 .abcdbcccde.
-- 4 --
0x00000001 hit3_0 .abcdbccc.
-- 5 --
0x00000010 hit4_0 .abcdbcccde.
EOF
EXPECT_ERR=<<EOF
Searching in [0x0-0x200]
Expand All @@ -72,5 +82,9 @@ Searching in [0x0-0x200]
hits: 0
Searching in [0x0-0x200]
hits: 2
Searching in [0x0-0x200]
hits: 1
Searching in [0x0-0x200]
hits: 1
EOF
RUN
Expand Down
Loading