Trim grep expression before processing it. (#4227)

This commit is contained in:
Rot127 2024-02-14 13:43:42 +00:00 committed by GitHub
parent 766886d706
commit f0435d94cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 6 deletions

View file

@ -433,11 +433,13 @@ RZ_API char *rz_cons_grep_strip(char *cmd, const char *quotestr) {
return ptr;
}
RZ_API void rz_cons_grep_process(char *grep) {
if (grep) {
parse_grep_expression(grep);
free(grep);
RZ_API void rz_cons_grep_process(RZ_OWN char *grep) {
if (!grep) {
return;
}
rz_str_trim_tail(grep);
parse_grep_expression(grep);
free(grep);
}
static int cmp(const void *a, const void *b, void *user) {

View file

@ -1023,7 +1023,7 @@ RZ_API int rz_cons_get_buffer_len(void);
RZ_API void rz_cons_grep_help(void);
RZ_API void rz_cons_grep_parsecmd(char *cmd, const char *quotestr);
RZ_API char *rz_cons_grep_strip(char *cmd, const char *quotestr);
RZ_API void rz_cons_grep_process(char *grep);
RZ_API void rz_cons_grep_process(RZ_OWN char *grep);
RZ_API int rz_cons_grep_line(char *buf, int len); // must be static
RZ_API void rz_cons_grepbuf(void);

View file

@ -107,7 +107,7 @@ RZ_API const char *rz_str_trim_head_wp(RZ_NONNULL const char *str) {
/**
* \brief Removes whitespace characters (space, tab, newline etc.)
* from the end of a string.
* from the beginning of a string.
* The string is changed in place.
*
* \param str The string to trim.