Fix separator for args_print.

This commit is contained in:
Nicholas Marriott
2026-10-06 17:41:16 +01:00
parent 16f46700f4
commit 9c8b33ad63
3 changed files with 10 additions and 6 deletions

View File

@@ -114,8 +114,10 @@ args_value_as_string(struct args_value *value)
case ARGS_NONE:
return ("");
case ARGS_COMMANDS:
if (value->cached == NULL)
value->cached = cmd_parse_print(value->cmd, 0);
if (value->cached == NULL) {
value->cached = cmd_parse_print(value->cmd,
CMD_PARSE_PRINT_RAW);
}
return (value->cached);
case ARGS_STRING:
return (value->string);

View File

@@ -1174,9 +1174,9 @@ cmd_parse_print_string(char **buf, struct cmd_parse_node *string)
}
static const char *
cmd_parse_print_separator(u_int depth)
cmd_parse_print_separator(u_int depth, int flags)
{
if (depth == 0)
if (depth == 0 && (~flags & CMD_PARSE_PRINT_RAW))
return (" \\; ");
return (" ; ");
}
@@ -1318,7 +1318,7 @@ cmd_parse_print_sequence(char **buf, struct cmd_parse_node *seq, u_int depth,
int flags)
{
struct cmd_parse_node *child, *first_child;
const char *sep = cmd_parse_print_separator(depth);
const char *sep = cmd_parse_print_separator(depth, flags);
int first = 1;
/*
@@ -1343,6 +1343,7 @@ char *
cmd_parse_print(struct cmd_parse_tree *tree, int flags)
{
struct cmd_parse_node *root = tree->root, *child;
const char *sep = cmd_parse_print_separator(0, flags);
char *buf = NULL;
int first = 1;
@@ -1351,7 +1352,7 @@ cmd_parse_print(struct cmd_parse_tree *tree, int flags)
if (flags & CMD_PARSE_PRINT_MULTILINE)
cmd_parse_strcat(&buf, "\n");
else
cmd_parse_strcat(&buf, " \\; ");
cmd_parse_strcat(&buf, "%s", sep);
}
first = 0;
cmd_parse_print_sequence(&buf, child, 0, flags);

View File

@@ -72,6 +72,7 @@ enum cmd_parse_node_type {
};
#define CMD_PARSE_PRINT_MULTILINE 0x1
#define CMD_PARSE_PRINT_RAW 0x2
struct cmd_parse_tree *cmd_parse_from_file(FILE *, struct cmd_parse_input *,
char **);