Skip to content

Commit

Permalink
crossref citations are shown unconditionally
Browse files Browse the repository at this point in the history
Based on the review
- implemented tip `find("{");`  instead of `find("{",0);`
- made `label..` names more expressing their content
- got a few regressions regarding endless loops (it is incorrect bib file syntax), the constructs have to be at the end of the bib file, like (also with extra newlines)
  - `@book ,`
  - `@book { ,`
  • Loading branch information
albert-github committed Jul 30, 2020
1 parent 89f9d11 commit 7894dd7
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions src/cite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void CitationManager::generatePage()
input.at(fi.size())='\0';
int pos=0;
int s;
QCString label1;
QCString citeName;
while ((s=input.find('\n',pos))!=-1)
{
QCString line = input.mid((uint)pos,(uint)(s-pos));
Expand All @@ -152,46 +152,49 @@ void CitationManager::generatePage()
int k=line.find("}",i);
if (j!=-1 && k!=-1)
{
QCString label = line.mid((uint)(j+1),(uint)(k-j-1));
QCString crossrefName = line.mid((uint)(j+1),(uint)(k-j-1));
// 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
if ((p->entries.find(citeName.data())!=p->entries.end()) &&
(p->entries.find(crossrefName.data())==p->entries.end())) // not found yet
{
insert(label);
insert(crossrefName);
}
}
}
else if (line.stripWhiteSpace().startsWith("@"))
{
// assumption entry like: "@book { name," or "@book { name" (spaces optional)
int j=line.find("{",0);
int j=line.find("{");
// 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);
j=line.find("{");
pos=s+1;
}
// search for the name
label1 = "";
while (label1.isEmpty())
citeName = "";
if (j != -1) // to prevent something like "@manual ," and no { found
{
int k=line.find(",",j);
if (k != -1)
while (s != -1 && citeName.isEmpty())
{
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;
int k=line.find(",",j);
if (k != -1)
{
citeName = line.mid((uint)(j+1),(uint)(k-j-1));
}
else
{
citeName = line.mid((uint)(j+1));
}
citeName = citeName.stripWhiteSpace();
j = -1;
if (citeName.isEmpty() && (s=input.find('\n',pos))!=-1)
{
line = input.mid((uint)pos,(uint)(s-pos));
pos=s+1;
}
}
}
}
Expand Down

0 comments on commit 7894dd7

Please sign in to comment.