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

^ grep op: Skip whitespace #4875

Merged
merged 1 commit into from
Feb 2, 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
5 changes: 4 additions & 1 deletion librz/cons/grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static const char *help_detail_tilde[] = {
" $!", "", "sort in inverse order",
" ,", "", "token to define another keyword",
" +", "", "case insensitive grep (grep -i)",
" ^", "", "words must be placed at the beginning of line",
" ^", "", "words must be placed at the beginning of line, after whitespace if any",
" <", "", "perform zoom operation on the buffer",
" !", "", "negate grep",
" ?", "", "count number of matching lines",
Expand Down Expand Up @@ -794,6 +794,9 @@ RZ_API int rz_cons_grep_line(char *buf, int len) {
continue;
}
if (grep->begin) {
while (p > in && IS_WHITESPACE(*(p - 1))) {
p--;
}
hit = (p == in);
if (grep->neg) {
hit = !hit;
Expand Down
2 changes: 1 addition & 1 deletion librz/core/cmd_descs/cmd_descs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19171,7 +19171,7 @@ static const RzCmdDescDetailEntry grep_Modifiers_detail_entries[] = {
{ .text = "$!", .arg_str = NULL, .comment = "Sort in inverse order" },
{ .text = ",", .arg_str = NULL, .comment = "Token to define another keyword" },
{ .text = "+", .arg_str = NULL, .comment = "Set the grep as the opposite of search.case_sensitive" },
{ .text = "^", .arg_str = NULL, .comment = "Words must be placed at the beginning of line" },
{ .text = "^", .arg_str = NULL, .comment = "Words must be placed at the beginning of line, after whitespace if any" },
{ .text = "<", .arg_str = NULL, .comment = "Perform zoom operation on the buffer" },
{ .text = "!", .arg_str = NULL, .comment = "Negate grep" },
{ .text = "?", .arg_str = NULL, .comment = "Count number of matching lines" },
Expand Down
2 changes: 1 addition & 1 deletion librz/core/cmd_descs/cmd_descs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ commands:
- text: "+"
comment: "Set the grep as the opposite of search.case_sensitive"
- text: "^"
comment: "Words must be placed at the beginning of line"
comment: "Words must be placed at the beginning of line, after whitespace if any"
- text: "<"
comment: "Perform zoom operation on the buffer"
- text: "!"
Expand Down
2 changes: 2 additions & 0 deletions test/db/cmd/cmd_i
Original file line number Diff line number Diff line change
Expand Up @@ -4883,9 +4883,11 @@ FILE==
CMDS=<<EOF
wx 7500 6900 3d25 7325 7325 7300 2573 2c00 2b25 7325 7325 7300 2d25 7325 7325 7300 6361 705f 6368 6f77 6e00 6361 705f 6461
izz:/head/1:quiet
izz~^0
EOF
EXPECT=<<EOF
0 0x00000004 0x00000004 7 8 ascii =%s%s%s
0 0x00000004 0x00000004 7 8 ascii =%s%s%s
EOF
RUN

Expand Down
Loading