From 89f9d113d0d788552a32b699a89f273f6ce58c0f Mon Sep 17 00:00:00 2001 From: albert-github Date: Wed, 29 Jul 2020 18:00:57 +0200 Subject: crossref citations are shown unconditionally The crossref items in a bib file are unconditionally added to the list of used citations although the the citation to which the crossref belongs to is not used. This has been fixed. The problem was seen in the CGAL output. Note: a crossref in LaTeX is a bit different from the normal understanding of cross-reference, from https://tex.stackexchange.com/questions/401138/what-is-the-bibtex-crossref-field-used-for: "crossref can be used if you have multiple entries referring to the same proceeding, book or similar." --- src/cite.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/cite.cpp b/src/cite.cpp index 78df0c3..d02cb75 100644 --- a/src/cite.cpp +++ b/src/cite.cpp @@ -139,6 +139,7 @@ void CitationManager::generatePage() input.at(fi.size())='\0'; int pos=0; int s; + QCString label1; while ((s=input.find('\n',pos))!=-1) { QCString line = input.mid((uint)pos,(uint)(s-pos)); @@ -152,12 +153,48 @@ void CitationManager::generatePage() if (j!=-1 && k!=-1) { QCString label = line.mid((uint)(j+1),(uint)(k-j-1)); - if (p->entries.find(label.data())==p->entries.end()) // not found yet + // check if the reference with the cross reference is used + // insert cross refererence when cross reference has not yet been added. + if ((p->entries.find(label1.data())!=p->entries.end()) && + (p->entries.find(label.data())==p->entries.end())) // not found yet { insert(label); } } } + else if (line.stripWhiteSpace().startsWith("@")) + { + // assumption entry like: "@book { name," or "@book { name" (spaces optional) + int j=line.find("{",0); + // when no {, go hunting for it + while (j==-1 && (s=input.find('\n',pos))!=-1) + { + line = input.mid((uint)pos,(uint)(s-pos)); + j=line.find("{",0); + pos=s+1; + } + // search for the name + label1 = ""; + while (label1.isEmpty()) + { + int k=line.find(",",j); + if (k != -1) + { + label1 = line.mid((uint)(j+1),(uint)(k-j-1)); + } + else + { + label1 = line.mid((uint)(j+1)); + } + label1 = label1.stripWhiteSpace(); + j = -1; + if (label1.isEmpty() && (s=input.find('\n',pos))!=-1) + { + line = input.mid((uint)pos,(uint)(s-pos)); + pos=s+1; + } + } + } } } } -- cgit v0.12