diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2019-12-22 15:43:21 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2019-12-22 15:43:21 (GMT) |
commit | 0ea72fdd522e6bc3bc442e7d2ae40e7607546e55 (patch) | |
tree | f6db48d3500b0c68464be9fe92ca1eb8a193427b | |
parent | 369c65635de29af6fd92c835879d70fdac7d2270 (diff) | |
parent | 146bec22e9ff91e8274becd719149f7ab9c7cfb9 (diff) | |
download | Doxygen-0ea72fdd522e6bc3bc442e7d2ae40e7607546e55.zip Doxygen-0ea72fdd522e6bc3bc442e7d2ae40e7607546e55.tar.gz Doxygen-0ea72fdd522e6bc3bc442e7d2ae40e7607546e55.tar.bz2 |
Merge branch 'feature/bug_terminate' of https://github.com/albert-github/doxygen into albert-github-feature/bug_terminate
-rw-r--r-- | src/commentscan.l | 3 | ||||
-rw-r--r-- | src/configimpl.l | 73 | ||||
-rw-r--r-- | src/defgen.cpp | 3 | ||||
-rw-r--r-- | src/diagram.cpp | 3 | ||||
-rw-r--r-- | src/docbookgen.cpp | 3 | ||||
-rw-r--r-- | src/docsets.cpp | 12 | ||||
-rw-r--r-- | src/dot.cpp | 4 | ||||
-rw-r--r-- | src/dotgfxhierarchytable.cpp | 2 | ||||
-rw-r--r-- | src/dotgraph.cpp | 2 | ||||
-rw-r--r-- | src/doxygen.cpp | 24 | ||||
-rw-r--r-- | src/eclipsehelp.cpp | 3 | ||||
-rw-r--r-- | src/formula.cpp | 5 | ||||
-rw-r--r-- | src/htmlgen.cpp | 3 | ||||
-rw-r--r-- | src/htmlhelp.cpp | 9 | ||||
-rw-r--r-- | src/latexgen.cpp | 9 | ||||
-rw-r--r-- | src/mangen.cpp | 6 | ||||
-rw-r--r-- | src/message.cpp | 28 | ||||
-rw-r--r-- | src/message.h | 2 | ||||
-rw-r--r-- | src/outputgen.cpp | 3 | ||||
-rw-r--r-- | src/perlmodgen.cpp | 3 | ||||
-rw-r--r-- | src/qhp.cpp | 3 | ||||
-rw-r--r-- | src/rtfgen.cpp | 3 | ||||
-rw-r--r-- | src/util.cpp | 6 |
23 files changed, 101 insertions, 111 deletions
diff --git a/src/commentscan.l b/src/commentscan.l index fa454e5..89a97e3 100644 --- a/src/commentscan.l +++ b/src/commentscan.l @@ -327,8 +327,7 @@ class DocCmdMapper { if (m_map.find(p->cmdName)!=0) { - err("DocCmdMapper: command %s already added\n",p->cmdName); - exit(1); + term(1,"DocCmdMapper: command %s already added\n",p->cmdName); } Cmd *cmd = new Cmd; cmd->func = p->handler; diff --git a/src/configimpl.l b/src/configimpl.l index a05293f..9aae6f6 100644 --- a/src/configimpl.l +++ b/src/configimpl.l @@ -56,6 +56,16 @@ void config_err(const char *fmt, ...) vfprintf(stderr, (QCString(error_str) + fmt).data(), args); va_end(args); } +void config_term(const int exitVal, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + vfprintf(stderr, (QCString(error_str) + fmt).data(), args); + va_end(args); + fprintf(stderr, "%s\n", "Exiting..."); + exit(exitVal); +} + void config_warn(const char *fmt, ...) { va_list args; @@ -213,13 +223,11 @@ QCString &ConfigImpl::getString(const char *fileName,int num,const char *name) c ConfigOption *opt = m_dict->find(name); if (opt==0) { - config_err("%s<%d>: Internal error: Requested unknown option %s!\n",fileName,num,name); - exit(1); + config_term(1,"%s<%d>: Internal error: Requested unknown option %s!\n",fileName,num,name); } else if (opt->kind()!=ConfigOption::O_String) { - config_err("%s<%d>: Internal error: Requested option %s not of string type!\n",fileName,num,name); - exit(1); + config_term(1,"%s<%d>: Internal error: Requested option %s not of string type!\n",fileName,num,name); } return *((ConfigString *)opt)->valueRef(); } @@ -229,13 +237,11 @@ QStrList &ConfigImpl::getList(const char *fileName,int num,const char *name) con ConfigOption *opt = m_dict->find(name); if (opt==0) { - config_err("%s<%d>: Internal error: Requested unknown option %s!\n",fileName,num,name); - exit(1); + config_term(1,"%s<%d>: Internal error: Requested unknown option %s!\n",fileName,num,name); } else if (opt->kind()!=ConfigOption::O_List) { - config_err("%s<%d>: Internal error: Requested option %s not of list type!\n",fileName,num,name); - exit(1); + config_term(1,"%s<%d>: Internal error: Requested option %s not of list type!\n",fileName,num,name); } return *((ConfigList *)opt)->valueRef(); } @@ -245,13 +251,11 @@ QCString &ConfigImpl::getEnum(const char *fileName,int num,const char *name) con ConfigOption *opt = m_dict->find(name); if (opt==0) { - config_err("%s<%d>: Internal error: Requested unknown option %s!\n",fileName,num,name); - exit(1); + config_term(1,"%s<%d>: Internal error: Requested unknown option %s!\n",fileName,num,name); } else if (opt->kind()!=ConfigOption::O_Enum) { - config_err("%s<%d>: Internal error: Requested option %s not of enum type!\n",fileName,num,name); - exit(1); + config_term(1,"%s<%d>: Internal error: Requested option %s not of enum type!\n",fileName,num,name); } return *((ConfigEnum *)opt)->valueRef(); } @@ -261,13 +265,11 @@ int &ConfigImpl::getInt(const char *fileName,int num,const char *name) const ConfigOption *opt = m_dict->find(name); if (opt==0) { - config_err("%s<%d>: Internal error: Requested unknown option %s!\n",fileName,num,name); - exit(1); + config_term(1,"%s<%d>: Internal error: Requested unknown option %s!\n",fileName,num,name); } else if (opt->kind()!=ConfigOption::O_Int) { - config_err("%s<%d>: Internal error: Requested option %s not of integer type!\n",fileName,num,name); - exit(1); + config_term(1,"%s<%d>: Internal error: Requested option %s not of integer type!\n",fileName,num,name); } return *((ConfigInt *)opt)->valueRef(); } @@ -277,13 +279,11 @@ bool &ConfigImpl::getBool(const char *fileName,int num,const char *name) const ConfigOption *opt = m_dict->find(name); if (opt==0) { - config_err("%s<%d>: Internal error: Requested unknown option %s!\n",fileName,num,name); - exit(1); + config_term(1,"%s<%d>: Internal error: Requested unknown option %s!\n",fileName,num,name); } else if (opt->kind()!=ConfigOption::O_Bool) { - config_err("%s<%d>: Internal error: Requested option %s not of boolean type!\n",fileName,num,name); - exit(1); + config_term(1,"%s<%d>: Internal error: Requested option %s not of boolean type!\n",fileName,num,name); } return *((ConfigBool *)opt)->valueRef(); } @@ -566,9 +566,8 @@ static QCString configStringRecode( void *cd = portable_iconv_open(outputEncoding,inputEncoding); if (cd==(void *)(-1)) { - fprintf(stderr,"Error: unsupported character conversion: '%s'->'%s'\n", + config_term(1,"Error: unsupported character conversion: '%s'->'%s'\n", inputEncoding.data(),outputEncoding.data()); - exit(1); } size_t iLeft=(size_t)inputSize; size_t oLeft=(size_t)outputSize; @@ -583,9 +582,8 @@ static QCString configStringRecode( } else { - fprintf(stderr,"Error: failed to translate characters from %s to %s: %s\n", + config_term(1,"Error: failed to translate characters from %s to %s: %s\n", inputEncoding.data(),outputEncoding.data(),strerror(errno)); - exit(1); } portable_iconv_close(cd); return output; @@ -638,9 +636,8 @@ static FILE *findFile(const char *fileName) static void readIncludeFile(const char *incName) { if (includeDepth==MAX_INCLUDE_DEPTH) { - config_err("maximum include depth (%d) reached, %s is not included. Aborting...\n", + config_term(1,"maximum include depth (%d) reached, %s is not included. Aborting...\n", MAX_INCLUDE_DEPTH,incName); - exit(1); } QCString inc = incName; @@ -678,8 +675,7 @@ static void readIncludeFile(const char *incName) } else { - config_err("@INCLUDE = %s: not found!\n",inc.data()); - exit(1); + config_term(1,"@INCLUDE = %s: not found!\n",inc.data()); } } @@ -1161,9 +1157,8 @@ void ConfigImpl::init() ConfigOption * opt = ConfigImpl::instance()->get(depName); if (opt==0) { - config_warn("Config option '%s' has invalid depends relation on unknown option '%s'\n", + config_term(1,"Config option '%s' has invalid depends relation on unknown option '%s'\n", option->name().data(),depName.data()); - exit(1); } } } @@ -1229,8 +1224,7 @@ static QCString configFileToString(const char *name) } if (!fileOpened) { - config_err("cannot open file '%s' for reading\n",name); - exit(1); + config_term(1,"cannot open file '%s' for reading\n",name); } return ""; } @@ -1440,9 +1434,8 @@ void Config::checkAndCorrect() QFileInfo fi(headerFile); if (!fi.exists()) { - err("tag HTML_HEADER: header file '%s' " + term(1,"tag HTML_HEADER: header file '%s' " "does not exist\n",headerFile.data()); - exit(1); } } // Test to see if HTML footer is valid @@ -1452,9 +1445,8 @@ void Config::checkAndCorrect() QFileInfo fi(footerFile); if (!fi.exists()) { - err("tag HTML_FOOTER: footer file '%s' " + term(1,"tag HTML_FOOTER: footer file '%s' " "does not exist\n",footerFile.data()); - exit(1); } } @@ -1467,9 +1459,8 @@ void Config::checkAndCorrect() QFileInfo fi(MathJaxCodefile); if (!fi.exists()) { - err("tag MATHJAX_CODEFILE file '%s' " + term(1,"tag MATHJAX_CODEFILE file '%s' " "does not exist\n",MathJaxCodefile.data()); - exit(1); } } QCString &path = Config_getString(MATHJAX_RELPATH); @@ -1487,9 +1478,8 @@ void Config::checkAndCorrect() QFileInfo fi(latexHeaderFile); if (!fi.exists()) { - err("tag LATEX_HEADER: header file '%s' " + term(1,"tag LATEX_HEADER: header file '%s' " "does not exist\n",latexHeaderFile.data()); - exit(1); } } // Test to see if LaTeX footer is valid @@ -1499,9 +1489,8 @@ void Config::checkAndCorrect() QFileInfo fi(latexFooterFile); if (!fi.exists()) { - err("tag LATEX_FOOTER: footer file '%s' " + term(1,"tag LATEX_FOOTER: footer file '%s' " "does not exist\n",latexFooterFile.data()); - exit(1); } } diff --git a/src/defgen.cpp b/src/defgen.cpp index 7590a7e..23fb674 100644 --- a/src/defgen.cpp +++ b/src/defgen.cpp @@ -572,9 +572,8 @@ void generateDEF() dir.setPath(QDir::currentDirPath()); if (!dir.mkdir(outputDirectory)) { - err("tag OUTPUT_DIRECTORY: Output directory '%s' does not " + term(1,"tag OUTPUT_DIRECTORY: Output directory '%s' does not " "exist and cannot be created\n",outputDirectory.data()); - exit(1); } else { diff --git a/src/diagram.cpp b/src/diagram.cpp index e8dc83a..cce06ab 100644 --- a/src/diagram.cpp +++ b/src/diagram.cpp @@ -1101,8 +1101,7 @@ void ClassDiagram::writeFigure(FTextStream &output,const char *path, f1.setName(epsName.data()); if (!f1.open(IO_WriteOnly)) { - err("Could not open file %s for writing\n",f1.name().data()); - exit(1); + term(1,"Could not open file %s for writing\n",f1.name().data()); } FTextStream t(&f1); diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp index 083aac3..8040c92 100644 --- a/src/docbookgen.cpp +++ b/src/docbookgen.cpp @@ -289,8 +289,7 @@ void DocbookGenerator::init() QDir d(dir); if (!d.exists() && !d.mkdir(dir)) { - err("Could not create output directory %s\n",dir.data()); - exit(1); + term(1,"Could not create output directory %s\n",dir.data()); } createSubDirs(d); diff --git a/src/docsets.cpp b/src/docsets.cpp index 055532a..b33aea5 100644 --- a/src/docsets.cpp +++ b/src/docsets.cpp @@ -62,8 +62,7 @@ void DocSets::initialize() QFile makefile(mfName); if (!makefile.open(IO_WriteOnly)) { - err("Could not open file %s for writing\n",mfName.data()); - exit(1); + term(1,"Could not open file %s for writing\n",mfName.data()); } FTextStream ts(&makefile); @@ -113,8 +112,7 @@ void DocSets::initialize() QFile plist(plName); if (!plist.open(IO_WriteOnly)) { - err("Could not open file %s for writing\n",plName.data()); - exit(1); + term(1,"Could not open file %s for writing\n",plName.data()); } FTextStream ts(&plist); @@ -149,8 +147,7 @@ void DocSets::initialize() m_nf = new QFile(notes); if (!m_nf->open(IO_WriteOnly)) { - err("Could not open file %s for writing\n",notes.data()); - exit(1); + term(1,"Could not open file %s for writing\n",notes.data()); } //QCString indexName=Config_getBool(GENERATE_TREEVIEW)?"main":"index"; QCString indexName="index"; @@ -170,8 +167,7 @@ void DocSets::initialize() m_tf = new QFile(tokens); if (!m_tf->open(IO_WriteOnly)) { - err("Could not open file %s for writing\n",tokens.data()); - exit(1); + term(1,"Could not open file %s for writing\n",tokens.data()); } m_tts.setDevice(m_tf); m_tts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; diff --git a/src/dot.cpp b/src/dot.cpp index 4e4c4bc..2ba5e92 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -272,7 +272,7 @@ void writeDotGraphFromFile(const char *inFile,const char *outDir, QDir d(outDir); if (!d.exists()) { - err("Output dir %s does not exist!\n",outDir); exit(1); + term(1,"Output dir %s does not exist!\n",outDir); } QCString imgExt = getDotImageExtension(); @@ -325,7 +325,7 @@ void writeDotImageMapFromFile(FTextStream &t, QDir d(outDir); if (!d.exists()) { - err("Output dir %s does not exist!\n",outDir.data()); exit(1); + term(1,"Output dir %s does not exist!\n",outDir.data()); } QCString mapName = baseName+".map"; diff --git a/src/dotgfxhierarchytable.cpp b/src/dotgfxhierarchytable.cpp index 0a7942f..df9f48f 100644 --- a/src/dotgfxhierarchytable.cpp +++ b/src/dotgfxhierarchytable.cpp @@ -86,7 +86,7 @@ void DotGfxHierarchyTable::writeGraph(FTextStream &out, // store the original directory if (!d.exists()) { - err("Output dir %s does not exist!\n",path); exit(1); + term(1,"Output dir %s does not exist!\n",path); } // put each connected subgraph of the hierarchy in a row of the HTML output diff --git a/src/dotgraph.cpp b/src/dotgraph.cpp index 9b7ddb7..c17523b 100644 --- a/src/dotgraph.cpp +++ b/src/dotgraph.cpp @@ -147,7 +147,7 @@ bool DotGraph::prepareDotFile() { if (!m_dir.exists()) { - err("Output dir %s does not exist!\n", m_dir.path().data()); exit(1); + term(1,"Output dir %s does not exist!\n", m_dir.path().data()); } QCString sigStr(33); diff --git a/src/doxygen.cpp b/src/doxygen.cpp index c36c5ce..f42838f 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -8584,10 +8584,9 @@ static void computePageRelations(Entry *root) PageDef *subPd = Doxygen::pageSDict->find(bi.name); if (pd==subPd) { - err("page defined at line %d of file %s with label %s is a direct " + term(1,"page defined at line %d of file %s with label %s is a direct " "subpage of itself! Please remove this cyclic dependency.\n", pd->docLine(),pd->docFile().data(),pd->name().data()); - exit(1); } else if (subPd) { @@ -8612,10 +8611,9 @@ static void checkPageRelations() { if (ppd==pd) { - err("page defined at line %d of file %s with label %s is a subpage " + term(1,"page defined at line %d of file %s with label %s is a subpage " "of itself! Please remove this cyclic dependency.\n", pd->docLine(),pd->docFile().data(),pd->name().data()); - exit(1); } ppd=ppd->getOuterScope(); } @@ -8948,8 +8946,7 @@ static void generateConfigFile(const char *configFile,bool shortList, } else { - err("Cannot open file %s for writing\n",configFile); - exit(1); + term(1,"Cannot open file %s for writing\n",configFile); } } static void compareDoxyfile() @@ -8966,8 +8963,7 @@ static void compareDoxyfile() } else { - err("Cannot open file %s for writing\n",configFile); - exit(1); + term(1,"Cannot open file %s for writing\n",configFile); } } //---------------------------------------------------------------------------- @@ -9606,17 +9602,15 @@ void readFormulaRepository(QCString dir, bool cmp) { if ((f=Doxygen::formulaDict->find(formText))==0) { - err("discrepancy between formula repositories! Remove " + term(1,"discrepancy between formula repositories! Remove " "formula.repository and from_* files from output directories."); - exit(1); } QCString formLabel; formLabel.sprintf("\\form#%d",f->getId()); if (formLabel != formName) { - err("discrepancy between formula repositories! Remove " + term(1,"discrepancy between formula repositories! Remove " "formula.repository and from_* files from output directories."); - exit(1); } new_repository++; } @@ -9633,9 +9627,8 @@ void readFormulaRepository(QCString dir, bool cmp) } if (cmp && (current_repository != new_repository)) { - err("size discrepancy between formula repositories! Remove " + term(1,"size discrepancy between formula repositories! Remove " "formula.repository and from_* files from output directories."); - exit(1); } } @@ -11475,9 +11468,8 @@ void generateOutput() QDir searchDir(searchDirName); if (!searchDir.exists() && !searchDir.mkdir(searchDirName)) { - err("Could not create search results directory '%s' $PWD='%s'\n", + term(1,"Could not create search results directory '%s' $PWD='%s'\n", searchDirName.data(),QDir::currentDirPath().data()); - exit(1); } HtmlGenerator::writeSearchData(searchDirName); if (!serverBasedSearch) // client side search index diff --git a/src/eclipsehelp.cpp b/src/eclipsehelp.cpp index 2757308..04f2947 100644 --- a/src/eclipsehelp.cpp +++ b/src/eclipsehelp.cpp @@ -72,8 +72,7 @@ void EclipseHelp::initialize() m_tocfile = new QFile(name); if (!m_tocfile->open(IO_WriteOnly)) { - err("Could not open file %s for writing\n", name.data()); - exit(1); + term(1,"Could not open file %s for writing\n", name.data()); } // -- initialize its text stream diff --git a/src/formula.cpp b/src/formula.cpp index c884eba..d74681a 100644 --- a/src/formula.cpp +++ b/src/formula.cpp @@ -51,7 +51,10 @@ void FormulaList::generateBitmaps(const char *path) int x1,y1,x2,y2; QDir d(path); // store the original directory - if (!d.exists()) { err("Output dir %s does not exist!\n",path); exit(1); } + if (!d.exists()) + { + term(1,"Output dir %s does not exist!\n",path); + } QCString oldDir = QDir::currentDirPath().utf8(); // go to the html output directory (i.e. path) QDir::setCurrent(d.absPath()); diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index 19a1869..926e04d 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -728,8 +728,7 @@ void HtmlGenerator::init() QDir d(dname); if (!d.exists() && !d.mkdir(dname)) { - err("Could not create output directory %s\n",dname.data()); - exit(1); + term(1,"Could not create output directory %s\n",dname.data()); } //writeLogo(dname); if (!Config_getString(HTML_HEADER).isEmpty()) diff --git a/src/htmlhelp.cpp b/src/htmlhelp.cpp index c514102..6101984 100644 --- a/src/htmlhelp.cpp +++ b/src/htmlhelp.cpp @@ -308,8 +308,7 @@ void HtmlHelp::initialize() m_fromUtf8 = portable_iconv_open(str,"UTF-8"); if (m_fromUtf8==(void *)(-1)) { - err("unsupported character conversion for CHM_INDEX_ENCODING: '%s'->'UTF-8'\n", str); - exit(1); + term(1,"unsupported character conversion for CHM_INDEX_ENCODING: '%s'->'UTF-8'\n", str); } /* open the contents file */ @@ -317,8 +316,7 @@ void HtmlHelp::initialize() cf = new QFile(fName); if (!cf->open(IO_WriteOnly)) { - err("Could not open file %s for writing\n",fName.data()); - exit(1); + term(1,"Could not open file %s for writing\n",fName.data()); } /* Write the header of the contents file */ cts.setDevice(cf); @@ -334,8 +332,7 @@ void HtmlHelp::initialize() kf = new QFile(fName); if (!kf->open(IO_WriteOnly)) { - err("Could not open file %s for writing\n",fName.data()); - exit(1); + term(1,"Could not open file %s for writing\n",fName.data()); } /* Write the header of the contents file */ kts.setDevice(kf); diff --git a/src/latexgen.cpp b/src/latexgen.cpp index b7eefe3..27be5b3 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -288,8 +288,7 @@ static void writeLatexMakefile() QFile file(fileName); if (!file.open(IO_WriteOnly)) { - err("Could not open file %s for writing\n",fileName.data()); - exit(1); + term(1,"Could not open file %s for writing\n",fileName.data()); } // inserted by KONNO Akihisa <konno@researchers.jp> 2002-03-05 QCString latex_command = theTranslator->latexCommandName(); @@ -387,8 +386,7 @@ static void writeMakeBat() bool generateBib = !Doxygen::citeDict->isEmpty(); if (!file.open(IO_WriteOnly)) { - err("Could not open file %s for writing\n",fileName.data()); - exit(1); + term(1,"Could not open file %s for writing\n",fileName.data()); } FTextStream t(&file); t << "set Dir_Old=%cd%\n"; @@ -468,8 +466,7 @@ void LatexGenerator::init() QDir d(dir); if (!d.exists() && !d.mkdir(dir)) { - err("Could not create output directory %s\n",dir.data()); - exit(1); + term(1,"Could not create output directory %s\n",dir.data()); } writeLatexMakefile(); diff --git a/src/mangen.cpp b/src/mangen.cpp index 06d3c4a..f4eba20 100644 --- a/src/mangen.cpp +++ b/src/mangen.cpp @@ -112,14 +112,12 @@ void ManGenerator::init() QDir d(manOutput); if (!d.exists() && !d.mkdir(manOutput)) { - err("Could not create output directory %s\n",manOutput.data()); - exit(1); + term(1,"Could not create output directory %s\n",manOutput.data()); } d.setPath(manOutput + "/" + getSubdir()); if (!d.exists() && !d.mkdir(manOutput + "/" + getSubdir())) { - err("Could not create output directory %s/%s\n",manOutput.data(), getSubdir().data()); - exit(1); + term(1,"Could not create output directory %s/%s\n",manOutput.data(), getSubdir().data()); } createSubDirs(d); } diff --git a/src/message.cpp b/src/message.cpp index 591267d..70bcaac 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -251,6 +251,34 @@ extern void err_full(const char *file,int line,const char *fmt, ...) va_end(args); } +void term(const int exitVal, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + vfprintf(warnFile, (QCString(error_str) + fmt).data(), args); + va_end(args); + if (warnFile != stderr) + { + for (int i = 0; i < strlen(error_str); i++) fprintf(warnFile, " "); + fprintf(warnFile, "%s\n", "Exiting..."); + } + exit(exitVal); +} + +extern void term_full(const int exitVal, const char *file,int line,const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + do_warn(TRUE, file, line, error_str, fmt, args); + va_end(args); + if (warnFile != stderr) + { + for (int i = 0; i < strlen(error_str); i++) fprintf(warnFile, " "); + fprintf(warnFile, "%s\n", "Exiting..."); + } + exit(exitVal); +} + void printlex(int dbg, bool enter, const char *lexName, const char *fileName) { const char *enter_txt = "entering"; diff --git a/src/message.h b/src/message.h index 3b1a294..56e7e27 100644 --- a/src/message.h +++ b/src/message.h @@ -30,6 +30,8 @@ extern void warn_doc_error(const char *file,int line,const char *fmt, ...); extern void warn_uncond(const char *fmt, ...); extern void err(const char *fmt, ...); extern void err_full(const char *file,int line,const char *fmt, ...); +extern void term(const int exitVal, const char *fmt, ...); +extern void term_full(const int exitVal, const char *file,int line,const char *fmt, ...); void initWarningFormat(); extern void printlex(int dbg, bool enter, const char *lexName, const char *fileName); diff --git a/src/outputgen.cpp b/src/outputgen.cpp index 53d2d7f..ea8fd5e 100644 --- a/src/outputgen.cpp +++ b/src/outputgen.cpp @@ -46,8 +46,7 @@ void OutputGenerator::startPlainFile(const char *name) file = new QFile(fileName); if (!file->open(IO_WriteOnly)) { - err("Could not open file %s for writing\n",fileName.data()); - exit(1); + term(1,"Could not open file %s for writing\n",fileName.data()); } t.setDevice(file); } diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp index be226b7..bf20d45 100644 --- a/src/perlmodgen.cpp +++ b/src/perlmodgen.cpp @@ -2271,9 +2271,8 @@ bool PerlModGenerator::createOutputDir(QDir &perlModDir) dir.setPath(QDir::currentDirPath()); if (!dir.mkdir(outputDirectory)) { - err("tag OUTPUT_DIRECTORY: Output directory '%s' does not " + term(1,"tag OUTPUT_DIRECTORY: Output directory '%s' does not " "exist and cannot be created\n",outputDirectory.data()); - exit(1); } else { diff --git a/src/qhp.cpp b/src/qhp.cpp index 6260d09..484475c 100644 --- a/src/qhp.cpp +++ b/src/qhp.cpp @@ -168,8 +168,7 @@ void Qhp::finalize() QFile file(fileName); if (!file.open(IO_WriteOnly)) { - err("Could not open file %s for writing\n", fileName.data()); - exit(1); + term(1,"Could not open file %s for writing\n", fileName.data()); } m_doc.dumpTo(file); } diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index 92740f4..2702cca 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -175,8 +175,7 @@ void RTFGenerator::init() QDir d(dir); if (!d.exists() && !d.mkdir(dir)) { - err("Could not create output directory %s\n",dir.data()); - exit(1); + term(1,"Could not create output directory %s\n",dir.data()); } rtf_Style.setAutoDelete(TRUE); diff --git a/src/util.cpp b/src/util.cpp index aac0d4f..9cff297 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -7958,10 +7958,9 @@ static int transcodeCharacterBuffer(const char *fileName,BufStr &srcBuf,int size void *cd = portable_iconv_open(outputEncoding,inputEncoding); if (cd==(void *)(-1)) { - err("unsupported character conversion: '%s'->'%s': %s\n" + term(1,"unsupported character conversion: '%s'->'%s': %s\n" "Check the INPUT_ENCODING setting in the config file!\n", inputEncoding,outputEncoding,strerror(errno)); - exit(1); } int tmpBufSize=size*4+1; BufStr tmpBuf(tmpBufSize); @@ -7979,9 +7978,8 @@ static int transcodeCharacterBuffer(const char *fileName,BufStr &srcBuf,int size } else { - err("%s: failed to translate characters from %s to %s: check INPUT_ENCODING\n", + term(1,"%s: failed to translate characters from %s to %s: check INPUT_ENCODING\n", fileName,inputEncoding,outputEncoding); - exit(1); } portable_iconv_close(cd); return newSize; |