diff options
author | albert-github <albert.tests@gmail.com> | 2019-01-04 14:45:50 (GMT) |
---|---|---|
committer | albert-github <albert.tests@gmail.com> | 2019-01-04 14:45:50 (GMT) |
commit | f3e0d5b9dabaf9fa2e05469cd42836477de08de4 (patch) | |
tree | 1c547e046fc3838a729a955004f9bfaae6d725f4 /src | |
parent | 5d66d2ea14a173edb3d6b7ffaabd0196392fcb0f (diff) | |
download | Doxygen-f3e0d5b9dabaf9fa2e05469cd42836477de08de4.zip Doxygen-f3e0d5b9dabaf9fa2e05469cd42836477de08de4.tar.gz Doxygen-f3e0d5b9dabaf9fa2e05469cd42836477de08de4.tar.bz2 |
issue #6733 invalid cite anchor id when using crossref
The crossreference possibility was not properly taken into account in bibtex conversion for other formats than LaTeX.
- doxygen.bst: use correct labels (i.e. add 'CITEREF_' in case of crossreferences to the giver name)
- cite.cpp: add the crossreferences to the citation dictionary (to overcome warning message).
- extending test 012
Diffstat (limited to 'src')
-rw-r--r-- | src/cite.cpp | 61 |
1 files changed, 54 insertions, 7 deletions
diff --git a/src/cite.cpp b/src/cite.cpp index 4f88611..fd7b0e4 100644 --- a/src/cite.cpp +++ b/src/cite.cpp @@ -22,11 +22,13 @@ #include "language.h" #include "ftextstream.h" #include "resourcemgr.h" +#include "doxygen.h" #include <qdir.h> //-------------------------------------------------------------------------- const QCString CiteConsts::fileName("citelist"); +/* when changing this also take doxygen.bst into account */ const QCString CiteConsts::anchorPrefix("CITEREF_"); const QCString bibTmpFile("bibTmpFile_"); const QCString bibTmpDir("bibTmpDir/"); @@ -118,8 +120,58 @@ void CiteDict::generatePage() const // do not generate an empty citations page if (isEmpty()) return; // nothing to cite - // 1. generate file with markers and citations to OUTPUT_DIRECTORY + // 0. add cross references from the bib files to the cite dictionary QFile f; + QStrList &citeDataList = Config_getList(CITE_BIB_FILES); + 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()) + { + if (!bibFile.isEmpty()) + { + f.setName(bibFile); + if (!f.open(IO_ReadOnly)) + { + err("could not open file %s for reading\n",bibFile.data()); + } + QCString doc; + QFileInfo fi(bibFile); + QCString input(fi.size()+1); + f.readBlock(input.rawData(),fi.size()); + f.close(); + input.at(fi.size())='\0'; + int p=0,s; + while ((s=input.find('\n',p))!=-1) + { + QCString line = input.mid(p,s-p); + p=s+1; + + int i; + if ((i = line.find("crossref")) != -1) /* assumption crosreference is on one line and the only item */ + { + int j=line.find("{",i); + int k=line.find("}",i); + if (j!=-1 && k!=-1) + { + QCString label = line.mid(j+1,k-j-1); + if (!m_entries.find(label)) Doxygen::citeDict->insert(label.data()); + } + } + } + } + } + else if (!fi.exists()) + { + err("bib file %s not found!\n",bibFile.data()); + } + bibdata = citeDataList.next(); + } + + // 1. generate file with markers and citations to OUTPUT_DIRECTORY QCString outputDir = Config_getString(OUTPUT_DIRECTORY); QCString citeListFile = outputDir+"/citelist.doc"; f.setName(citeListFile); @@ -154,12 +206,11 @@ void CiteDict::generatePage() const // so bibtex can find them without path (bibtex doesn't support paths or // filenames with spaces!) // Strictly not required when only latex is generated - QStrList &citeDataList = Config_getList(CITE_BIB_FILES); QCString bibOutputDir = outputDir+"/"+bibTmpDir; QCString bibOutputFiles = ""; QDir thisDir; thisDir.mkdir(bibOutputDir); - const char *bibdata = citeDataList.first(); + bibdata = citeDataList.first(); int i = 0; while (bibdata) { @@ -175,10 +226,6 @@ void CiteDict::generatePage() const bibOutputFiles = bibOutputFiles + " " + bibTmpDir + bibTmpFile + QCString().setNum(i) + ".bib"; } } - else if (!fi.exists()) - { - err("bib file %s not found!\n",bibFile.data()); - } bibdata = citeDataList.next(); } |