Skip to content

Commit

Permalink
Bug 335614 - HTML link incorrect when using tagfile
Browse files Browse the repository at this point in the history
- See to it that when an extension is already present this extension is used and not a second extension is added
- let the tag file know what the original extension was.
  • Loading branch information
albert-github committed Sep 30, 2019
1 parent 4e21d19 commit cbbd26b
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ void DefinitionImpl::writeDocAnchorsToTagFile(FTextStream &tagFile) const
{
//printf("write an entry!\n");
if (definitionType()==TypeMember) tagFile << " ";
tagFile << " <docanchor file=\"" << si->fileName << "\"";
tagFile << " <docanchor file=\"" << si->fileName << (hasExtension(si->fileName) ? "" : Doxygen::htmlFileExtension) << "\"";
if (!si->title.isEmpty())
{
tagFile << " title=\"" << convertToXML(si->title) << "\"";
Expand Down
2 changes: 1 addition & 1 deletion src/filedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void FileDefImpl::writeTagFile(FTextStream &tagFile)
tagFile << " <compound kind=\"file\">" << endl;
tagFile << " <name>" << convertToXML(name()) << "</name>" << endl;
tagFile << " <path>" << convertToXML(getPath()) << "</path>" << endl;
tagFile << " <filename>" << convertToXML(getOutputFileBase()) << "</filename>" << endl;
tagFile << " <filename>" << convertToXML(getOutputFileBase()) << (hasExtension(getOutputFileBase()) ? "" : Doxygen::htmlFileExtension) << "</filename>" << endl;
if (m_includeList && m_includeList->count()>0)
{
QListIterator<IncludeInfo> ili(*m_includeList);
Expand Down
13 changes: 6 additions & 7 deletions src/htmldocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1913,11 +1913,7 @@ void HtmlDocVisitor::visitPre(DocSecRefItem *ref)
{
if (m_hide) return;
QCString refName=ref->file();
if (refName.right(Doxygen::htmlFileExtension.length())!=
QCString(Doxygen::htmlFileExtension))
{
refName+=Doxygen::htmlFileExtension;
}
refName+=(hasExtension(refName) ? "" : Doxygen::htmlFileExtension);
m_t << "<li><a href=\"" << refName << "#" << ref->anchor() << "\">";

}
Expand Down Expand Up @@ -2098,7 +2094,7 @@ void HtmlDocVisitor::visitPre(DocXRefItem *x)
{
m_t << "<dl" << getDirHtmlClassOfNode(getTextDirByConfig(x), x->key())
<< "><dt><b><a class=\"el\" href=\""
<< x->relPath() << x->file() << Doxygen::htmlFileExtension
<< x->relPath() << x->file() << (hasExtension(x->file()) ? "" : Doxygen::htmlFileExtension)
<< "#" << x->anchor() << "\">";
}
else
Expand Down Expand Up @@ -2262,7 +2258,10 @@ void HtmlDocVisitor::startLink(const QCString &ref,const QCString &file,
}
m_t << "href=\"";
m_t << externalRef(relPath,ref,TRUE);
if (!file.isEmpty()) m_t << file << Doxygen::htmlFileExtension;
if (!file.isEmpty())
{
m_t << file << (hasExtension(file) ? "" : Doxygen::htmlFileExtension);
}
if (!anchor.isEmpty()) m_t << "#" << anchor;
m_t << "\"";
if (!tooltip.isEmpty()) m_t << " title=\"" << convertToHtml(tooltip) << "\"";
Expand Down
27 changes: 12 additions & 15 deletions src/htmlgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ void HtmlCodeGenerator::_writeCodeLink(const char *className,
}
m_t << "href=\"";
m_t << externalRef(m_relPath,ref,TRUE);
if (f) m_t << f << Doxygen::htmlFileExtension;
if (f) m_t << f << (hasExtension(f) ? "" : Doxygen::htmlFileExtension);
if (anchor) m_t << "#" << anchor;
m_t << "\"";
if (tooltip) m_t << " title=\"" << convertToHtml(tooltip) << "\"";
Expand All @@ -596,7 +596,7 @@ void HtmlCodeGenerator::writeTooltip(const char *id, const DocLinkInfo &docInfo,
{
m_t << "<a href=\"";
m_t << externalRef(m_relPath,docInfo.ref,TRUE);
m_t << docInfo.url << Doxygen::htmlFileExtension;
m_t << docInfo.url << (hasExtension(docInfo.url) ? "" : Doxygen::htmlFileExtension);
if (!docInfo.anchor.isEmpty())
{
m_t << "#" << docInfo.anchor;
Expand Down Expand Up @@ -628,7 +628,7 @@ void HtmlCodeGenerator::writeTooltip(const char *id, const DocLinkInfo &docInfo,
{
m_t << "<a href=\"";
m_t << externalRef(m_relPath,defInfo.ref,TRUE);
m_t << defInfo.url << Doxygen::htmlFileExtension;
m_t << defInfo.url << (hasExtension(docInfo.url) ? "" : Doxygen::htmlFileExtension);
if (!defInfo.anchor.isEmpty())
{
m_t << "#" << defInfo.anchor;
Expand All @@ -649,7 +649,7 @@ void HtmlCodeGenerator::writeTooltip(const char *id, const DocLinkInfo &docInfo,
{
m_t << "<a href=\"";
m_t << externalRef(m_relPath,declInfo.ref,TRUE);
m_t << declInfo.url << Doxygen::htmlFileExtension;
m_t << declInfo.url << (hasExtension(docInfo.url) ? "" : Doxygen::htmlFileExtension);
if (!declInfo.anchor.isEmpty())
{
m_t << "#" << declInfo.anchor;
Expand Down Expand Up @@ -912,10 +912,7 @@ void HtmlGenerator::startFile(const char *name,const char *,
lastTitle=title;
relPath = relativePathToRoot(fileName);

if (fileName.right(Doxygen::htmlFileExtension.length())!=Doxygen::htmlFileExtension)
{
fileName+=Doxygen::htmlFileExtension;
}
fileName+=(hasExtension(fileName) ? "" : Doxygen::htmlFileExtension);
startPlainFile(fileName);
m_codeGen.setTextStream(t);
m_codeGen.setRelativePath(relPath);
Expand Down Expand Up @@ -1149,7 +1146,7 @@ void HtmlGenerator::startIndexItem(const char *ref,const char *f)
}
t << "href=\"";
t << externalRef(relPath,ref,TRUE);
if (f) t << f << Doxygen::htmlFileExtension;
if (f) t << f << (hasExtension(f) ? "" : Doxygen::htmlFileExtension);
t << "\">";
}
else
Expand All @@ -1176,7 +1173,7 @@ void HtmlGenerator::writeStartAnnoItem(const char *,const char *f,
{
t << "<li>";
if (path) docify(path);
t << "<a class=\"el\" href=\"" << f << Doxygen::htmlFileExtension << "\">";
t << "<a class=\"el\" href=\"" << f << (hasExtension(f) ? "" : Doxygen::htmlFileExtension) << "\">";
docify(name);
t << "</a> ";
}
Expand All @@ -1195,7 +1192,7 @@ void HtmlGenerator::writeObjectLink(const char *ref,const char *f,
}
t << "href=\"";
t << externalRef(relPath,ref,TRUE);
if (f) t << f << Doxygen::htmlFileExtension;
if (f) t << f << (hasExtension(f) ? "" : Doxygen::htmlFileExtension);
if (anchor) t << "#" << anchor;
t << "\">";
docify(name);
Expand All @@ -1205,7 +1202,7 @@ void HtmlGenerator::writeObjectLink(const char *ref,const char *f,
void HtmlGenerator::startTextLink(const char *f,const char *anchor)
{
t << "<a href=\"";
if (f) t << relPath << f << Doxygen::htmlFileExtension;
if (f) t << relPath << f << (hasExtension(f) ? "" : Doxygen::htmlFileExtension);
if (anchor) t << "#" << anchor;
t << "\">";
}
Expand Down Expand Up @@ -2369,7 +2366,7 @@ QCString HtmlGenerator::writeSplitBarAsString(const char *name,const char *relpa
"<script type=\"text/javascript\">\n"
"/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */\n"
"$(document).ready(function(){initNavTree('") +
QCString(name) + Doxygen::htmlFileExtension +
QCString(name) + (hasExtension(name) ? "" : Doxygen::htmlFileExtension) +
QCString("','") + relpath +
QCString("');});\n"
"/* @license-end */\n"
Expand Down Expand Up @@ -2807,7 +2804,7 @@ void HtmlGenerator::writeInheritedSectionTitle(
classLink += "href=\"";
classLink+=relPath;
}
classLink+=file+Doxygen::htmlFileExtension+a;
classLink=classLink+file+(hasExtension(file) ? "" : Doxygen::htmlFileExtension)+a;
classLink+=QCString("\">")+convertToHtml(name,FALSE)+"</a>";
t << "<tr class=\"inherit_header " << id << "\">"
<< "<td colspan=\"2\" onclick=\"javascript:toggleInherit('" << id << "')\">"
Expand All @@ -2830,7 +2827,7 @@ void HtmlGenerator::writeSummaryLink(const char *file,const char *anchor,const c
if (file)
{
t << relPath << file;
t << Doxygen::htmlFileExtension;
t << (hasExtension(file) ? "" : Doxygen::htmlFileExtension);
}
else
{
Expand Down
13 changes: 13 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7220,6 +7220,19 @@ bool checkExtension(const char *fName, const char *ext)
return (QCString(fName).right(QCString(ext).length())==ext);
}

bool hasExtension(const char *fName)
{
return !(QFileInfo(fName).extension(FALSE).isEmpty());
}
bool hasExtension(QCString fName)
{
return !(QFileInfo(fName).extension(FALSE).isEmpty());
}
bool hasExtension(QString fName)
{
return !(QFileInfo(fName).extension(FALSE).isEmpty());
}

QCString stripExtensionGeneral(const char *fName, const char *ext)
{
QCString result=fName;
Expand Down
4 changes: 4 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ QCString linkToText(SrcLangExt lang,const char *link,bool isFileName);

bool checkExtension(const char *fName, const char *ext);

bool hasExtension(const char *fName);
bool hasExtension(QCString fName);
bool hasExtension(QString fName);

QCString stripExtensionGeneral(const char *fName, const char *ext);

QCString stripExtension(const char *fName);
Expand Down

0 comments on commit cbbd26b

Please sign in to comment.