Skip to content

Commit

Permalink
Resolve inconsistency in formula repositories.
Browse files Browse the repository at this point in the history
HTML and RTF have their own directory with formula repository files. These can get out of sync when HTML and RTF versions are not always build together (and both are required again).
  • Loading branch information
albert-github committed Jun 11, 2018
1 parent 4536982 commit 5d89de2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 11 deletions.
4 changes: 2 additions & 2 deletions doc/formulas.doc
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ the section should contain valid command for the specific environment.

\warning Currently, doxygen is not very fault tolerant in recovering
from typos in formulas. It may be necessary to remove the
file <code>formula.repository</code> that is written to the html directory to
get rid of an incorrect formula.
files <code>formula.repository</code> that are written to the html and rtf directories to
get rid of an incorrect formula as well as the <code>form_*</code> files.

\htmlonly
Go to the <a href="tables.html">next</a> section or return to the
Expand Down
52 changes: 44 additions & 8 deletions src/doxygen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9752,14 +9752,17 @@ int readFileOrDirectory(const char *s,

//----------------------------------------------------------------------------

void readFormulaRepository()
void readFormulaRepository(QCString dir, bool cmp)
{
QFile f(Config_getString(HTML_OUTPUT)+"/formula.repository");
static int current_repository = 0;
int new_repository = 0;
QFile f(dir+"/formula.repository");
if (f.open(IO_ReadOnly)) // open repository
{
msg("Reading formula repository...\n");
QTextStream t(&f);
QCString line;
Formula *f;
while (!t.eof())
{
line=t.readLine().utf8();
Expand All @@ -9773,14 +9776,42 @@ void readFormulaRepository()
{
QCString formName = line.left(se);
QCString formText = line.right(line.length()-se-1);
Formula *f=new Formula(formText);
Doxygen::formulaList->setAutoDelete(TRUE);
Doxygen::formulaList->append(f);
Doxygen::formulaDict->insert(formText,f);
Doxygen::formulaNameDict->insert(formName,f);
if (cmp)
{
if ((f=Doxygen::formulaDict->find(formText))==0)
{
err("discrepancy between formula repositories! Remove "
"formula.repository and from_* files from output directories.");
exit(1);
}
QCString formLabel;
formLabel.sprintf("\\form#%d",f->getId());
if (formLabel != formName)
{
err("discrepancy between formula repositories! Remove "
"formula.repository and from_* files from output directories.");
exit(1);
}
new_repository++;
}
else
{
f=new Formula(formText);
Doxygen::formulaList->setAutoDelete(TRUE);
Doxygen::formulaList->append(f);
Doxygen::formulaDict->insert(formText,f);
Doxygen::formulaNameDict->insert(formName,f);
current_repository++;
}
}
}
}
if (cmp && (current_repository != new_repository))
{
err("size discrepancy between formula repositories! Remove "
"formula.repository and from_* files from output directories.");
exit(1);
}
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -11070,7 +11101,12 @@ void parseInput()

if (Config_getBool(GENERATE_HTML))
{
readFormulaRepository();
readFormulaRepository(Config_getString(HTML_OUTPUT));
}
if (Config_getBool(GENERATE_RTF))
{
// in case GENERRATE_HTML is set we just have to compare, both repositories should be identical
readFormulaRepository(Config_getString(RTF_OUTPUT),Config_getBool(GENERATE_HTML));
}

/**************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion src/doxygen.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void searchInputFiles(StringList &inputFiles);
void parseInput();
void generateOutput();
void readAliases();
void readFormulaRepository();
void readFormulaRepository(QCString dir, bool cmp = FALSE);
void cleanUpDoxygen();
int readFileOrDirectory(const char *s,
FileNameList *fnList,
Expand Down

0 comments on commit 5d89de2

Please sign in to comment.