Commit 0e2f8cb2 authored by Pietro Fezzardi's avatar Pietro Fezzardi

config: fixed some error detection and printouts

previously one could use config options without arguments, or
config options with wrong names, and the program did not complain.
now you have to use correct names for config options and only
options with type ARG_NONE can be without arguments.
hardcoded default config file and config string are supposed
always correct so there's still no error check on their parsing.
however for any config options passed from command line with -f or
-C all the checks are enabled. if there are some syntax errors or
options without value the process exits with errors, printing
informations on all the found configuration errors.
parent e6748f4c
......@@ -113,10 +113,12 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
pp_global_flags = pp_diag_parse(a);
break;
case 'C':
pp_config_string(ppg, argv[++i]);
if (pp_config_string(ppg, argv[++i]) != 0)
return -1;
break;
case 'f':
pp_config_file(ppg, 1, argv[++i]);
if (pp_config_file(ppg, 1, argv[++i]) != 0)
return -1;
break;
case 'x':
GOPTS(ppg)->no_rst_clk = 1;
......
......@@ -271,8 +271,13 @@ static int pp_config_line(struct pp_globals *ppg, char *line, int lineno)
break;
if (!l->f) {
pp_diag(NULL, config, 1, "line %i: no such keyword \"%s\"\n",
lineno, word);
pp_error("line %i: no such keyword \"%s\"\n", lineno, word);
return -1;
}
if ((l->t != ARG_NONE) && (!*line)) {
pp_error("line %i: no argument for option \"%s\"\n", lineno,
word);
return -1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment