sconfig parser:
- print erroneous string in error message - print line numbers starting from 1 instead of 0 - exit with return code 1 on errors - check return values of fopen operations - only create output file if input file was parsed without errors Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Patrick Georgi <patrick.georgi@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5701 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
154931c66f
commit
7c1f6b8489
|
@ -89,7 +89,9 @@ int yywrap(void) {
|
||||||
|
|
||||||
void yyerror (char const *str)
|
void yyerror (char const *str)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "line %d: %s\n", linenum, str);
|
extern char *yytext;
|
||||||
|
fprintf (stderr, "line %d: %s: %s\n", linenum + 1, yytext, str);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void postprocess_devtree(void) {
|
void postprocess_devtree(void) {
|
||||||
|
@ -408,12 +410,18 @@ int main(int argc, char** argv) {
|
||||||
sprintf(headers.next->name, "mainboard/%s", mainboard);
|
sprintf(headers.next->name, "mainboard/%s", mainboard);
|
||||||
|
|
||||||
FILE *filec = fopen(devtree, "r");
|
FILE *filec = fopen(devtree, "r");
|
||||||
|
if (!filec) {
|
||||||
|
fprintf(stderr, "Could not open file '%s' for reading: ", devtree);
|
||||||
|
perror(NULL);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
yyrestart(filec);
|
yyrestart(filec);
|
||||||
|
|
||||||
FILE *staticc = fopen(outputc, "w");
|
|
||||||
|
|
||||||
lastdev = head = &root;
|
lastdev = head = &root;
|
||||||
|
|
||||||
yyparse();
|
yyparse();
|
||||||
|
|
||||||
fclose(filec);
|
fclose(filec);
|
||||||
|
|
||||||
if ((head->type == chip) && (!head->chiph_exists)) {
|
if ((head->type == chip) && (!head->chiph_exists)) {
|
||||||
|
@ -422,6 +430,13 @@ int main(int argc, char** argv) {
|
||||||
while (head->next != tmp) head = head->next;
|
while (head->next != tmp) head = head->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FILE *staticc = fopen(outputc, "w");
|
||||||
|
if (!staticc) {
|
||||||
|
fprintf(stderr, "Could not open file '%s' for writing: ", outputc);
|
||||||
|
perror(NULL);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(staticc, "#include <device/device.h>\n");
|
fprintf(staticc, "#include <device/device.h>\n");
|
||||||
fprintf(staticc, "#include <device/pci.h>\n");
|
fprintf(staticc, "#include <device/pci.h>\n");
|
||||||
struct header *h = &headers;
|
struct header *h = &headers;
|
||||||
|
@ -435,5 +450,6 @@ int main(int argc, char** argv) {
|
||||||
walk_device_tree(staticc, &root, pass1, NULL);
|
walk_device_tree(staticc, &root, pass1, NULL);
|
||||||
|
|
||||||
fclose(staticc);
|
fclose(staticc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue