/* Display full help syntax if we don't have subcommands */
if (noOpcodes)
PrintFlagHelp(ts);
- code = CMD_USAGE;
+ code = CMD_HELP;
goto out;
}
int code;
code = cmd_Parse(argc, argv, &ts);
- if (code)
+ if (code) {
+ if (code == CMD_HELP) {
+ code = 0; /* displaying help is not an error */
+ }
return code;
+ }
/*
* Before calling the beforeProc and afterProc and all the implications
const char *str;
int code;
- if (*value)
- free(*value);
-
code = _get_config_string(syn, pos, &str);
if (code)
return code;
if (str == NULL)
return CMD_MISSING;
+ if (*value)
+ free(*value);
*value = strdup(str);
return 0;
const char *str;
struct cmd_item *item, **last;
const char *start, *end;
+ size_t len;
int code;
if (pos > syn->nParms)
start = str;
while ((end = strchr(start, ' '))) {
item = calloc(1, sizeof(struct cmd_item));
- item->data = malloc(end - start + 1);
- strlcpy(item->data, start, end - start + 1);
+ len = end - start + 1;
+ item->data = malloc(len);
+ strlcpy(item->data, start, len);
*last = item;
last = &item->next;
for (start = end; *start == ' '; start++); /* skip any whitespace */
/* Catch the final element */
if (*start != '\0') {
item = calloc(1, sizeof(struct cmd_item));
- item->data = malloc(strlen(start) + 1);
- strlcpy(item->data, start, strlen(start) + 1);
+ len = strlen(start) + 1;
+ item->data = malloc(len);
+ strlcpy(item->data, start, len);
*last = item;
}