Skip to content

Commit 02a23b7

Browse files
radaretrufae
authored andcommitted
RCoreHelp should take a const string as argument ##api
1 parent 3c46dc2 commit 02a23b7

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

libr/cons/help.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,24 @@ R_API void r_cons_cmd_help(RCons *cons, RCoreHelpMessage help, bool use_color) {
127127
* If exact is false, will match any command that contains the search text.
128128
* For example, ("pd", 'r', false) matches both `pdr` and `pdr.`.
129129
*/
130-
R_API void r_cons_cmd_help_match(RCons *cons, RCoreHelpMessage help, bool use_color, R_BORROW char * R_NONNULL cmd, char spec, bool exact) {
130+
R_API void r_cons_cmd_help_match(RCons *cons, RCoreHelpMessage help, bool use_color, const char * R_NONNULL cmd, char spec, bool exact) {
131131
RVector/*<int>*/ *match_indices = r_vector_new (sizeof (int), NULL, NULL);
132132
char **matches = NULL;
133133
size_t num_matches;
134134
int *current_index_ptr;
135135
size_t matches_copied;
136136
size_t i;
137+
char *search_cmd = NULL;
137138

138139
if (spec) {
139-
/* We now own cmd */
140-
cmd = r_str_newf ("%s%c", cmd, spec);
140+
search_cmd = r_str_newf ("%s%c", cmd, spec);
141+
} else {
142+
search_cmd = (char *)cmd;
141143
}
142144

143145
/* Collect matching indices */
144146
for (i = 0; help[i]; i += 3) {
145-
if (exact? (bool)!strcmp (help[i], cmd): (bool)strstr (help[i], cmd)) {
147+
if (exact? (bool)!strcmp (help[i], search_cmd): (bool)strstr (help[i], search_cmd)) {
146148
r_vector_push (match_indices, &i);
147149
}
148150
}
@@ -169,6 +171,6 @@ R_API void r_cons_cmd_help_match(RCons *cons, RCoreHelpMessage help, bool use_co
169171
free (matches);
170172
r_vector_free (match_indices);
171173
if (spec) {
172-
free (cmd);
174+
free (search_cmd);
173175
}
174176
}

libr/core/cmd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,19 +462,19 @@ R_API void r_core_cmd_help_json(const RCore *core, RCoreHelpMessage help) {
462462
r_cons_cmd_help_json (core->cons, help);
463463
}
464464

465-
R_API void r_core_cmd_help_match(const RCore *core, RCoreHelpMessage help, R_BORROW char * R_NONNULL cmd) {
465+
R_API void r_core_cmd_help_match(const RCore *core, RCoreHelpMessage help, const char * R_NONNULL cmd) {
466466
r_cons_cmd_help_match (core->cons, help, core->print->flags & R_PRINT_FLAGS_COLOR, cmd, 0, true);
467467
}
468468

469-
R_API void r_core_cmd_help_contains(const RCore *core, RCoreHelpMessage help, R_BORROW char * R_NONNULL cmd) {
469+
R_API void r_core_cmd_help_contains(const RCore *core, RCoreHelpMessage help, const char * R_NONNULL cmd) {
470470
r_cons_cmd_help_match (core->cons, help, core->print->flags & R_PRINT_FLAGS_COLOR, cmd, 0, false);
471471
}
472472

473-
R_API void r_core_cmd_help_match_spec(const RCore *core, RCoreHelpMessage help, R_BORROW char * R_NONNULL cmd, char spec) {
473+
R_API void r_core_cmd_help_match_spec(const RCore *core, RCoreHelpMessage help, const char * R_NONNULL cmd, char spec) {
474474
r_cons_cmd_help_match (core->cons, help, core->print->flags & R_PRINT_FLAGS_COLOR, cmd, spec, true);
475475
}
476476

477-
R_API void r_core_cmd_help_contains_spec(const RCore *core, RCoreHelpMessage help, R_BORROW char * R_NONNULL cmd, char spec) {
477+
R_API void r_core_cmd_help_contains_spec(const RCore *core, RCoreHelpMessage help, const char * R_NONNULL cmd, char spec) {
478478
r_cons_cmd_help_match (core->cons, help, core->print->flags & R_PRINT_FLAGS_COLOR, cmd, spec, false);
479479
}
480480

libr/include/r_cons.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ R_API bool r_cons_is_windows(void);
938938
R_API void r_cons_cmd_help(RCons *cons, RCoreHelpMessage help, bool use_color);
939939
R_API void r_cons_cmd_help(RCons *cons, RCoreHelpMessage help, bool use_color);
940940
R_API void r_cons_cmd_help_json(RCons *cons, const char * const help[]);
941-
R_API void r_cons_cmd_help_match(RCons *cons, RCoreHelpMessage help, bool use_color, char * R_BORROW R_NONNULL cmd, char spec, bool exact);
941+
R_API void r_cons_cmd_help_match(RCons *cons, RCoreHelpMessage help, bool use_color, const char * R_NONNULL cmd, char spec, bool exact);
942942
R_API void r_cons_log_stub(const char *output, const char *funcname, const char *filename,
943943
unsigned int lineno, unsigned int level, const char *tag, const char *fmtstr, ...) R_PRINTF_CHECK(7, 8);
944944

libr/include/r_core.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -956,10 +956,10 @@ R_API RTable *r_core_table_new(RCore *core, const char *title);
956956
/* help */
957957
R_API void r_core_cmd_help(const RCore *core, RCoreHelpMessage help);
958958
R_API void r_core_cmd_help_json(const RCore *core, RCoreHelpMessage help);
959-
R_API void r_core_cmd_help_match(const RCore *core, RCoreHelpMessage help, R_BORROW char * R_NONNULL cmd);
960-
R_API void r_core_cmd_help_contains(const RCore *core, RCoreHelpMessage help, R_BORROW char * R_NONNULL cmd);
961-
R_API void r_core_cmd_help_match_spec(const RCore *core, const char * const help[], R_BORROW char * R_NONNULL cmd, char spec);
962-
R_API void r_core_cmd_help_contains_spec(const RCore *core, const char * const help[], R_BORROW char * R_NONNULL cmd, char spec);
959+
R_API void r_core_cmd_help_match(const RCore *core, RCoreHelpMessage help, const char * R_NONNULL cmd);
960+
R_API void r_core_cmd_help_contains(const RCore *core, RCoreHelpMessage help, const char * R_NONNULL cmd);
961+
R_API void r_core_cmd_help_match_spec(const RCore *core, const char * const help[], const char * R_NONNULL cmd, char spec);
962+
R_API void r_core_cmd_help_contains_spec(const RCore *core, const char * const help[], const char * R_NONNULL cmd, char spec);
963963

964964
/* anal stats */
965965

libr/include/r_lib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ R_LIB_VERSION_HEADER (r_lib);
2121
#define R_LIB_SYMNAME "radare_plugin"
2222
#define R_LIB_SYMFUNC "radare_plugin_function"
2323

24-
#define R2_ABIVERSION 29
24+
#define R2_ABIVERSION 30
2525
#define R2_VERSION_ABI R2_ABIVERSION
2626

2727
#define R_LIB_ENV "R2_LIBR_PLUGINS"

0 commit comments

Comments
 (0)