summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2019-01-10 18:34:14 (GMT)
committerGitHub <noreply@github.com>2019-01-10 18:34:14 (GMT)
commit121ec253945f6563ac6731e3596cd9beaa39cb72 (patch)
tree10a16082118b5c7d644fb0a543b6a2e5bf01383c /src
parent7f6815973d3d4db95b4a97a851c7839da632fab8 (diff)
parent6296ca32abf74dff4883b2f476ee311c2cd0324f (diff)
downloadDoxygen-121ec253945f6563ac6731e3596cd9beaa39cb72.zip
Doxygen-121ec253945f6563ac6731e3596cd9beaa39cb72.tar.gz
Doxygen-121ec253945f6563ac6731e3596cd9beaa39cb72.tar.bz2
Merge pull request #6738 from albert-github/feature/issue_6733
issue #6733 invalid cite anchor id when using crossref
Diffstat (limited to 'src')
-rw-r--r--src/cite.cpp61
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();
}