helper: command: use COMMAND_HELPER for converted functions
Use COMMAND_HELPER for command_help_show_indent() and command_help_show_wrap(). Change-Id: Ied0d5d3e1b702524dad0274cc12d146c6032a036 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/9238 Tested-by: jenkins Reviewed-by: Evgeniy Naydanov <eugnay@gmail.com>
This commit is contained in:
@@ -679,12 +679,15 @@ static COMMAND_HELPER(command_help_show_list, bool show_help, const char *cmd_ma
|
|||||||
|
|
||||||
#define HELP_LINE_WIDTH(_n) (int)(76 - (2 * _n))
|
#define HELP_LINE_WIDTH(_n) (int)(76 - (2 * _n))
|
||||||
|
|
||||||
static void command_help_show_indent(struct command_invocation *cmd, unsigned int n)
|
static COMMAND_HELPER(command_help_show_indent, unsigned int n)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < n; i++)
|
for (unsigned int i = 0; i < n; i++)
|
||||||
command_print_sameline(cmd, " ");
|
command_print_sameline(CMD, " ");
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
static void command_help_show_wrap(struct command_invocation *cmd,
|
|
||||||
|
static COMMAND_HELPER(command_help_show_wrap,
|
||||||
const char *str, unsigned int n, unsigned int n2)
|
const char *str, unsigned int n, unsigned int n2)
|
||||||
{
|
{
|
||||||
const char *cp = str, *last = str;
|
const char *cp = str, *last = str;
|
||||||
@@ -698,11 +701,13 @@ static void command_help_show_wrap(struct command_invocation *cmd,
|
|||||||
} while ((next - last < HELP_LINE_WIDTH(n)) && *next != '\0');
|
} while ((next - last < HELP_LINE_WIDTH(n)) && *next != '\0');
|
||||||
if (next - last < HELP_LINE_WIDTH(n))
|
if (next - last < HELP_LINE_WIDTH(n))
|
||||||
cp = next;
|
cp = next;
|
||||||
command_help_show_indent(cmd, n);
|
CALL_COMMAND_HANDLER(command_help_show_indent, n);
|
||||||
command_print(cmd, "%.*s", (int)(cp - last), last);
|
command_print(CMD, "%.*s", (int)(cp - last), last);
|
||||||
last = cp + 1;
|
last = cp + 1;
|
||||||
n = n2;
|
n = n2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static COMMAND_HELPER(command_help_show, struct help_entry *c,
|
static COMMAND_HELPER(command_help_show, struct help_entry *c,
|
||||||
@@ -721,10 +726,10 @@ static COMMAND_HELPER(command_help_show, struct help_entry *c,
|
|||||||
if (is_match) {
|
if (is_match) {
|
||||||
if (c->usage && strlen(c->usage) > 0) {
|
if (c->usage && strlen(c->usage) > 0) {
|
||||||
char *msg = alloc_printf("%s %s", c->cmd_name, c->usage);
|
char *msg = alloc_printf("%s %s", c->cmd_name, c->usage);
|
||||||
command_help_show_wrap(CMD, msg, n, n + 5);
|
CALL_COMMAND_HANDLER(command_help_show_wrap, msg, n, n + 5);
|
||||||
free(msg);
|
free(msg);
|
||||||
} else {
|
} else {
|
||||||
command_help_show_wrap(CMD, c->cmd_name, n, n + 5);
|
CALL_COMMAND_HANDLER(command_help_show_wrap, c->cmd_name, n, n + 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -758,7 +763,7 @@ static COMMAND_HELPER(command_help_show, struct help_entry *c,
|
|||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
command_help_show_wrap(CMD, msg, n + 3, n + 3);
|
CALL_COMMAND_HANDLER(command_help_show_wrap, msg, n + 3, n + 3);
|
||||||
free(msg);
|
free(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user