From 303b39e07b28502fe6388a24b7d49261313fdf2e Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Wed, 29 Jan 2025 23:32:24 +0800 Subject: [PATCH] `/e`: Set `RZ_REGEX_MULTILINE` for `^` and `$` (#4868) * `/e`: Set `RZ_REGEX_MULTILINE` for `^` and `$` * Add note in `/e` help for `^` and `$` Co-authored-by: Rot127 <45763064+Rot127@users.noreply.github.com> --- librz/core/cmd/cmd_search.c | 2 +- librz/search/regexp.c | 2 +- test/db/cmd/regexp | 22 ++++++++++++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/librz/core/cmd/cmd_search.c b/librz/core/cmd/cmd_search.c index 2e6b022696e..abe953f2a3c 100644 --- a/librz/core/cmd/cmd_search.c +++ b/librz/core/cmd/cmd_search.c @@ -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", diff --git a/librz/search/regexp.c b/librz/search/regexp.c index cc110f2c006..0168b46bff9 100644 --- a/librz/search/regexp.c +++ b/librz/search/regexp.c @@ -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; diff --git a/test/db/cmd/regexp b/test/db/cmd/regexp index 614bc387fd9..a0ff4d79ea2 100644 --- a/test/db/cmd/regexp +++ b/test/db/cmd/regexp @@ -51,19 +51,29 @@ CMDS=<