config: save a block from falling off the RHS of the page.

This patch rearranges the guts of the main parsing loop to keep it
more within the 80th column.  The logic has not been changed.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-22 21:29:45 +02:00
parent 13aec6d133
commit 1e9ffd50ae
1 changed files with 38 additions and 45 deletions

View File

@ -555,13 +555,14 @@ int config_read(char *name, struct config *cfg)
continue;
}
switch (current_section) {
case GLOBAL_SECTION:
case PORT_SECTION:
if (current_section == UNKNOWN_SECTION) {
fprintf(stderr, "line %d is not in a section\n", line_num);
goto parse_error;
}
if (parse_setting_line(line, &option, &value)) {
fprintf(stderr, "could not parse line %d in %s section\n",
line_num,
current_section == GLOBAL_SECTION ?
line_num, current_section == GLOBAL_SECTION ?
"global" : current_port->name);
goto parse_error;
}
@ -579,8 +580,8 @@ int config_read(char *name, struct config *cfg)
case NOT_PARSED:
fprintf(stderr, "unknown option %s at line %d in %s section\n",
option, line_num,
current_section == GLOBAL_SECTION ?
"global" : current_port->name);
current_section == GLOBAL_SECTION ? "global" :
current_port->name);
goto parse_error;
case BAD_VALUE:
fprintf(stderr, "%s is a bad value for option %s at line %d\n",
@ -595,14 +596,6 @@ int config_read(char *name, struct config *cfg)
value, option, line_num);
goto parse_error;
}
break;
case UNKNOWN_SECTION:
fprintf(stderr, "line %d is not in a section\n", line_num);
goto parse_error;
default:
continue;
}
}
fclose(fp);