From 7779bf6d6206bc0f78c22100034c44bfdb7f1bc1 Mon Sep 17 00:00:00 2001 From: albert-github Date: Sat, 5 Jul 2014 18:25:55 +0200 Subject: Bug 700510 - Bibliography duplicate filenames fails Problem in the bug report is that the bib files in the different directories have the same name and thus overwrite each other. This patch solves this problem as well as the possibility to have spaces in the file name. For all output formats the bib files are copied to a new numbered name: "bibTmpFile_", for Latex on the LATEX_OUTPUT directory and for all other formats in the subdirectory "bibTmpDir" of the OUTPUT_DIRECTORY. The files for Latex are retained whilst the files for the other formats are removed after usage (as it was before). --- src/cite.cpp | 142 +++++++++++++++++++++++++++-------------------------------- 1 file changed, 64 insertions(+), 78 deletions(-) diff --git a/src/cite.cpp b/src/cite.cpp index f0580ed..a1b964a 100644 --- a/src/cite.cpp +++ b/src/cite.cpp @@ -37,6 +37,8 @@ static const char *bib2xhtml_pl = const QCString CiteConsts::fileName("citelist"); const QCString CiteConsts::anchorPrefix("CITEREF_"); +const QCString bibTmpFile("bibTmpFile_"); +const QCString bibTmpDir("bibTmpDir/"); //-------------------------------------------------------------------------- @@ -45,51 +47,6 @@ CiteDict::CiteDict(int size) : m_entries(size, FALSE) m_entries.setAutoDelete(TRUE); } -static QCString getListOfBibFiles(const QCString &sep,bool namesOnly) -{ - QCString result; - QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); - const char *bibdata = citeDataList.first(); - while (bibdata) - { - int i; - QCString bibFile = bibdata; - if (namesOnly && bibFile.right(4)==".bib") // strip extension - { - bibFile = bibFile.left(bibFile.length()-4); - } - else - { - if (!namesOnly && bibFile.right(4)!=".bib") bibFile += ".bib"; - } - if ((i=bibFile.findRev('/'))!=-1) // strip path - { - bibFile = bibFile.mid(i+1); - } - if (!bibFile.isEmpty()) - { - if (namesOnly) // bare names - { - result+=bibFile; - } - else // add quotes for paths with spaces - { - result+="\""+bibFile+"\""; - } - bibdata = citeDataList.next(); - if (bibdata) - { - result+=sep; - } - } - else - { - bibdata = citeDataList.next(); - } - } - return result; -} - void CiteDict::writeLatexBibliography(FTextStream &t) { if (m_entries.isEmpty()) @@ -108,7 +65,29 @@ void CiteDict::writeLatexBibliography(FTextStream &t) "\\phantomsection\n" "\\addcontentsline{toc}{" << unit << "}{" << theTranslator->trCiteReferences() << "}\n" "\\bibliographystyle{" << style << "}\n" - "\\bibliography{" << getListOfBibFiles(",",TRUE) << "}\n" + "\\bibliography{"; + QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); + QCString latexOutputDir = Config_getString("LATEX_OUTPUT")+"/"; + int i = 0; + const char *bibdata = citeDataList.first(); + while (bibdata) + { + QCString bibFile = bibdata; + // Note: file can now have multiple dots + if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; + QFileInfo fi(bibFile); + if (fi.exists()) + { + if (!bibFile.isEmpty()) + { + if (i) t << ","; + i++; + t << bibTmpFile << QString().setNum(i); + } + } + bibdata = citeDataList.next(); + } + t << "}\n" "\n"; } @@ -186,39 +165,37 @@ void CiteDict::generatePage() const f.writeBlock(bstData, bstData.length()); f.close(); - // 4. for html we just copy the bib files to the output so that - // bibtex can find them without path (bibtex doesn't support path's - // with spaces!) - QList tempFiles; - tempFiles.setAutoDelete(TRUE); + // 4. for all formats we just copy the bib files to as special output directory + // s bibtex can find them without path (bibtex doesn't support paths or + // filenames with spaces!) + // Strictly not required when only latex is generated + // copy bib files to the latex output dir + QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); + QCString bibOutputDir = outputDir+"/"+bibTmpDir; + QCString bibOutputFiles = ""; QDir thisDir; - if (Config_getBool("GENERATE_HTML")) + thisDir.mkdir(bibOutputDir); + const char *bibdata = citeDataList.first(); + int i = 0; + while (bibdata) { - // copy bib files to the latex output dir - QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); - QCString bibOutputDir = outputDir+"/"; - QFileInfo fo(bibOutputDir); - const char *bibdata = citeDataList.first(); - while (bibdata) + QCString bibFile = bibdata; + if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; + QFileInfo fi(bibFile); + if (fi.exists()) { - QCString bibFile = bibdata; - if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; - QFileInfo fi(bibFile); - if (fi.exists() && fi.dirPath(TRUE)!=fo.absFilePath()) - { - if (!bibFile.isEmpty()) - { - QCString destFile=bibOutputDir+fi.fileName().data(); - copyFile(bibFile,destFile); - tempFiles.append(new QCString(destFile)); - } - } - else if (!fi.exists()) + if (!bibFile.isEmpty()) { - err("bib file %s not found!\n",bibFile.data()); + ++i; + copyFile(bibFile,bibOutputDir + bibTmpFile + QCString().setNum(i) + ".bib"); + bibOutputFiles = bibOutputFiles + " " + bibTmpDir + bibTmpFile + QCString().setNum(i) + ".bib"; } - bibdata = citeDataList.next(); } + else if (!fi.exists()) + { + err("bib file %s not found!\n",bibFile.data()); + } + bibdata = citeDataList.next(); } QCString oldDir = QDir::currentDirPath().utf8(); @@ -226,7 +203,7 @@ void CiteDict::generatePage() const // 5. run bib2xhtml perl script on the generated file which will insert the // bibliography in citelist.doc - portable_system("perl","\""+bib2xhtmlFile+"\" "+getListOfBibFiles(" ",FALSE)+" \""+ + portable_system("perl","\""+bib2xhtmlFile+"\" "+bibOutputFiles+" \""+ citeListFile+"\""); QDir::setCurrent(oldDir); @@ -288,17 +265,22 @@ void CiteDict::generatePage() const // copy bib files to the latex output dir QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QCString latexOutputDir = Config_getString("LATEX_OUTPUT")+"/"; + int i = 0; const char *bibdata = citeDataList.first(); while (bibdata) { QCString bibFile = bibdata; + // Note: file can now have multiple dots if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; QFileInfo fi(bibFile); if (fi.exists()) { if (!bibFile.isEmpty()) { - copyFile(bibFile,latexOutputDir+fi.fileName().data()); + // bug_700510, multile times the same name were overwriting; creating new names + // also for names with spaces + ++i; + copyFile(bibFile,latexOutputDir + bibTmpFile + QCString().setNum(i) + ".bib"); } } else @@ -313,10 +295,14 @@ void CiteDict::generatePage() const thisDir.remove(citeListFile); thisDir.remove(doxygenBstFile); thisDir.remove(bib2xhtmlFile); - while (!tempFiles.isEmpty()) + bibdata = citeDataList.first(); + // we might try to remove too many files as empty files didn't get a coresponding new file + // but the remove function does not emit an error for it and we don't catch the error return + // so no problem. + for (unsigned int j = 1; j <= citeDataList.count(); j++) { - QCString *s=tempFiles.take(0); - thisDir.remove(*s); + thisDir.remove(bibOutputDir + bibTmpFile + QCString().setNum(j) + ".bib"); } + thisDir.rmdir(bibOutputDir); } -- cgit v0.12 From da029a3c893df22536cb3635e597fd3f5b2a4862 Mon Sep 17 00:00:00 2001 From: albert-github Date: Sun, 6 Jul 2014 11:59:47 +0200 Subject: =?UTF-8?q?Bug=C2=A0700510=20-=20Bibliography=20duplicate=20filena?= =?UTF-8?q?mes=20fails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Spaces are now allowed in the file names --- src/config.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/config.xml b/src/config.xml index eed486e..e4a6ae5 100644 --- a/src/config.xml +++ b/src/config.xml @@ -1145,9 +1145,7 @@ FILE_VERSION_INFO = "cleartool desc -fmt \%Vn" \c bibtex tool to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. For \f$\mbox{\LaTeX}\f$ the style of the bibliography can be controlled using \ref cfg_latex_bib_style "LATEX_BIB_STYLE". - To use this - feature you need \c bibtex and \c perl available in the search path. Do not use - file names with spaces, \c bibtex cannot handle them. + To use this feature you need \c bibtex and \c perl available in the search path. See also \ref cmdcite "\\cite" for info how to create references. ]]> -- cgit v0.12 From 4074da5b83d37dd1c72c5df015fb2b41e7725a7e Mon Sep 17 00:00:00 2001 From: Jeff Verkoeyen Date: Fri, 27 Jun 2014 00:06:35 +0700 Subject: Add BREAD_CRUMB_TRAIL. This feature enables recursive printing of the bread crumbs for any page, rather than just printing the parent group. --- src/config.xml | 8 ++++++++ src/util.cpp | 30 ++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/config.xml b/src/config.xml index eed486e..89c1422 100644 --- a/src/config.xml +++ b/src/config.xml @@ -3361,6 +3361,14 @@ remove the intermediate dot files that are used to generate the various graphs. ]]> + - - + -