Flush errlog before exit on input errors.

This commit is contained in:
Andrew Johnson
2008-08-05 22:48:45 +00:00
parent bbb4e83f43
commit 30d860c323
3 changed files with 30 additions and 27 deletions

View File

@@ -95,6 +95,7 @@ int main(int argc,char **argv)
if (status) returnStatus = status;
}
if (returnStatus) {
errlogFlush();
fprintf(stderr, "dbExpand: Input errors, no output generated\n");
exit(1);
}

View File

@@ -74,34 +74,35 @@ int main(int argc,char **argv)
fprintf(stderr,"usage: dbToMenu -Idir -Idir file.dbd [outfile]\n");
exit(0);
}
if (argc==2) {
/*remove path so that outFile is created where program is executed*/
plastSlash = strrchr(argv[1],'/');
if(!plastSlash) plastSlash = strrchr(argv[1],'\\');
plastSlash = (plastSlash ? plastSlash+1 : argv[1]);
outFilename = dbCalloc(1,strlen(plastSlash)+1);
strcpy(outFilename,plastSlash);
pext = strstr(outFilename,".dbd");
if(!pext) {
fprintf(stderr,"Input file MUST have .dbd extension\n");
exit(-1);
}
strcpy(pext,".h");
} else {
outFilename = dbCalloc(1,strlen(argv[2])+1);
strcpy(outFilename,argv[2]);
if (argc==2) {
/*remove path so that outFile is created where program is executed*/
plastSlash = strrchr(argv[1],'/');
if(!plastSlash) plastSlash = strrchr(argv[1],'\\');
plastSlash = (plastSlash ? plastSlash+1 : argv[1]);
outFilename = dbCalloc(1,strlen(plastSlash)+1);
strcpy(outFilename,plastSlash);
pext = strstr(outFilename,".dbd");
if (!pext) {
fprintf(stderr,"Input file MUST have .dbd extension\n");
exit(-1);
}
strcpy(pext,".h");
} else {
outFilename = dbCalloc(1,strlen(argv[2])+1);
strcpy(outFilename,argv[2]);
}
pdbbase = dbAllocBase();
pdbbase->ignoreMissingMenus = TRUE;
status = dbReadDatabase(&pdbbase,argv[1],path,sub);
if(status) {
fprintf(stderr,"Terminal error For input file %s\n",argv[1]);
exit(-1);
if (status) {
errlogFlush();
fprintf(stderr, "dbToMenuH: Input errors, no output generated\n");
exit(1);
}
outFile = fopen(outFilename,"w");
if(!outFile) {
errPrintf(0,__FILE__,__LINE__,"Error opening %s\n",outFilename);
exit(-1);
outFile = fopen(outFilename, "w");
if (!outFile) {
epicsPrintf("Error creating output file \"%s\"\n", outFilename);
exit(1);
}
pdbMenu = (dbMenu *)ellFirst(&pdbbase->menuList);
while(pdbMenu) {

View File

@@ -108,13 +108,14 @@ int main(int argc,char **argv)
pdbbase->loadCdefs = TRUE;
status = dbReadDatabase(&pdbbase,argv[1],path,sub);
if(status) {
fprintf(stderr,"Terminal error For input file %s\n",argv[1]);
exit(-1);
errlogFlush();
fprintf(stderr, "dbToMenuH: Input errors, no output generated\n");
exit(1);
}
outFile = fopen(outFilename,"w");
if(!outFile) {
errPrintf(0,__FILE__,__LINE__,"Error opening %s\n",outFilename);
exit(-1);
epicsPrintf("Error creating output file \"%s\"\n", outFilename);
exit(1);
}
pdbMenu = (dbMenu *)ellFirst(&pdbbase->menuList);