Skip to content

Commit cbbd26b

Browse files
committed
Bug 335614 - HTML link incorrect when using tagfile
- 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.
1 parent 4e21d19 commit cbbd26b

File tree

6 files changed

+37
-24
lines changed

6 files changed

+37
-24
lines changed

src/definition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ void DefinitionImpl::writeDocAnchorsToTagFile(FTextStream &tagFile) const
545545
{
546546
//printf("write an entry!\n");
547547
if (definitionType()==TypeMember) tagFile << " ";
548-
tagFile << " <docanchor file=\"" << si->fileName << "\"";
548+
tagFile << " <docanchor file=\"" << si->fileName << (hasExtension(si->fileName) ? "" : Doxygen::htmlFileExtension) << "\"";
549549
if (!si->title.isEmpty())
550550
{
551551
tagFile << " title=\"" << convertToXML(si->title) << "\"";

src/filedef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ void FileDefImpl::writeTagFile(FTextStream &tagFile)
349349
tagFile << " <compound kind=\"file\">" << endl;
350350
tagFile << " <name>" << convertToXML(name()) << "</name>" << endl;
351351
tagFile << " <path>" << convertToXML(getPath()) << "</path>" << endl;
352-
tagFile << " <filename>" << convertToXML(getOutputFileBase()) << "</filename>" << endl;
352+
tagFile << " <filename>" << convertToXML(getOutputFileBase()) << (hasExtension(getOutputFileBase()) ? "" : Doxygen::htmlFileExtension) << "</filename>" << endl;
353353
if (m_includeList && m_includeList->count()>0)
354354
{
355355
QListIterator<IncludeInfo> ili(*m_includeList);

src/htmldocvisitor.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,11 +1913,7 @@ void HtmlDocVisitor::visitPre(DocSecRefItem *ref)
19131913
{
19141914
if (m_hide) return;
19151915
QCString refName=ref->file();
1916-
if (refName.right(Doxygen::htmlFileExtension.length())!=
1917-
QCString(Doxygen::htmlFileExtension))
1918-
{
1919-
refName+=Doxygen::htmlFileExtension;
1920-
}
1916+
refName+=(hasExtension(refName) ? "" : Doxygen::htmlFileExtension);
19211917
m_t << "<li><a href=\"" << refName << "#" << ref->anchor() << "\">";
19221918

19231919
}
@@ -2098,7 +2094,7 @@ void HtmlDocVisitor::visitPre(DocXRefItem *x)
20982094
{
20992095
m_t << "<dl" << getDirHtmlClassOfNode(getTextDirByConfig(x), x->key())
21002096
<< "><dt><b><a class=\"el\" href=\""
2101-
<< x->relPath() << x->file() << Doxygen::htmlFileExtension
2097+
<< x->relPath() << x->file() << (hasExtension(x->file()) ? "" : Doxygen::htmlFileExtension)
21022098
<< "#" << x->anchor() << "\">";
21032099
}
21042100
else
@@ -2262,7 +2258,10 @@ void HtmlDocVisitor::startLink(const QCString &ref,const QCString &file,
22622258
}
22632259
m_t << "href=\"";
22642260
m_t << externalRef(relPath,ref,TRUE);
2265-
if (!file.isEmpty()) m_t << file << Doxygen::htmlFileExtension;
2261+
if (!file.isEmpty())
2262+
{
2263+
m_t << file << (hasExtension(file) ? "" : Doxygen::htmlFileExtension);
2264+
}
22662265
if (!anchor.isEmpty()) m_t << "#" << anchor;
22672266
m_t << "\"";
22682267
if (!tooltip.isEmpty()) m_t << " title=\"" << convertToHtml(tooltip) << "\"";

src/htmlgen.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ void HtmlCodeGenerator::_writeCodeLink(const char *className,
575575
}
576576
m_t << "href=\"";
577577
m_t << externalRef(m_relPath,ref,TRUE);
578-
if (f) m_t << f << Doxygen::htmlFileExtension;
578+
if (f) m_t << f << (hasExtension(f) ? "" : Doxygen::htmlFileExtension);
579579
if (anchor) m_t << "#" << anchor;
580580
m_t << "\"";
581581
if (tooltip) m_t << " title=\"" << convertToHtml(tooltip) << "\"";
@@ -596,7 +596,7 @@ void HtmlCodeGenerator::writeTooltip(const char *id, const DocLinkInfo &docInfo,
596596
{
597597
m_t << "<a href=\"";
598598
m_t << externalRef(m_relPath,docInfo.ref,TRUE);
599-
m_t << docInfo.url << Doxygen::htmlFileExtension;
599+
m_t << docInfo.url << (hasExtension(docInfo.url) ? "" : Doxygen::htmlFileExtension);
600600
if (!docInfo.anchor.isEmpty())
601601
{
602602
m_t << "#" << docInfo.anchor;
@@ -628,7 +628,7 @@ void HtmlCodeGenerator::writeTooltip(const char *id, const DocLinkInfo &docInfo,
628628
{
629629
m_t << "<a href=\"";
630630
m_t << externalRef(m_relPath,defInfo.ref,TRUE);
631-
m_t << defInfo.url << Doxygen::htmlFileExtension;
631+
m_t << defInfo.url << (hasExtension(docInfo.url) ? "" : Doxygen::htmlFileExtension);
632632
if (!defInfo.anchor.isEmpty())
633633
{
634634
m_t << "#" << defInfo.anchor;
@@ -649,7 +649,7 @@ void HtmlCodeGenerator::writeTooltip(const char *id, const DocLinkInfo &docInfo,
649649
{
650650
m_t << "<a href=\"";
651651
m_t << externalRef(m_relPath,declInfo.ref,TRUE);
652-
m_t << declInfo.url << Doxygen::htmlFileExtension;
652+
m_t << declInfo.url << (hasExtension(docInfo.url) ? "" : Doxygen::htmlFileExtension);
653653
if (!declInfo.anchor.isEmpty())
654654
{
655655
m_t << "#" << declInfo.anchor;
@@ -912,10 +912,7 @@ void HtmlGenerator::startFile(const char *name,const char *,
912912
lastTitle=title;
913913
relPath = relativePathToRoot(fileName);
914914

915-
if (fileName.right(Doxygen::htmlFileExtension.length())!=Doxygen::htmlFileExtension)
916-
{
917-
fileName+=Doxygen::htmlFileExtension;
918-
}
915+
fileName+=(hasExtension(fileName) ? "" : Doxygen::htmlFileExtension);
919916
startPlainFile(fileName);
920917
m_codeGen.setTextStream(t);
921918
m_codeGen.setRelativePath(relPath);
@@ -1149,7 +1146,7 @@ void HtmlGenerator::startIndexItem(const char *ref,const char *f)
11491146
}
11501147
t << "href=\"";
11511148
t << externalRef(relPath,ref,TRUE);
1152-
if (f) t << f << Doxygen::htmlFileExtension;
1149+
if (f) t << f << (hasExtension(f) ? "" : Doxygen::htmlFileExtension);
11531150
t << "\">";
11541151
}
11551152
else
@@ -1176,7 +1173,7 @@ void HtmlGenerator::writeStartAnnoItem(const char *,const char *f,
11761173
{
11771174
t << "<li>";
11781175
if (path) docify(path);
1179-
t << "<a class=\"el\" href=\"" << f << Doxygen::htmlFileExtension << "\">";
1176+
t << "<a class=\"el\" href=\"" << f << (hasExtension(f) ? "" : Doxygen::htmlFileExtension) << "\">";
11801177
docify(name);
11811178
t << "</a> ";
11821179
}
@@ -1195,7 +1192,7 @@ void HtmlGenerator::writeObjectLink(const char *ref,const char *f,
11951192
}
11961193
t << "href=\"";
11971194
t << externalRef(relPath,ref,TRUE);
1198-
if (f) t << f << Doxygen::htmlFileExtension;
1195+
if (f) t << f << (hasExtension(f) ? "" : Doxygen::htmlFileExtension);
11991196
if (anchor) t << "#" << anchor;
12001197
t << "\">";
12011198
docify(name);
@@ -1205,7 +1202,7 @@ void HtmlGenerator::writeObjectLink(const char *ref,const char *f,
12051202
void HtmlGenerator::startTextLink(const char *f,const char *anchor)
12061203
{
12071204
t << "<a href=\"";
1208-
if (f) t << relPath << f << Doxygen::htmlFileExtension;
1205+
if (f) t << relPath << f << (hasExtension(f) ? "" : Doxygen::htmlFileExtension);
12091206
if (anchor) t << "#" << anchor;
12101207
t << "\">";
12111208
}
@@ -2369,7 +2366,7 @@ QCString HtmlGenerator::writeSplitBarAsString(const char *name,const char *relpa
23692366
"<script type=\"text/javascript\">\n"
23702367
"/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */\n"
23712368
"$(document).ready(function(){initNavTree('") +
2372-
QCString(name) + Doxygen::htmlFileExtension +
2369+
QCString(name) + (hasExtension(name) ? "" : Doxygen::htmlFileExtension) +
23732370
QCString("','") + relpath +
23742371
QCString("');});\n"
23752372
"/* @license-end */\n"
@@ -2807,7 +2804,7 @@ void HtmlGenerator::writeInheritedSectionTitle(
28072804
classLink += "href=\"";
28082805
classLink+=relPath;
28092806
}
2810-
classLink+=file+Doxygen::htmlFileExtension+a;
2807+
classLink=classLink+file+(hasExtension(file) ? "" : Doxygen::htmlFileExtension)+a;
28112808
classLink+=QCString("\">")+convertToHtml(name,FALSE)+"</a>";
28122809
t << "<tr class=\"inherit_header " << id << "\">"
28132810
<< "<td colspan=\"2\" onclick=\"javascript:toggleInherit('" << id << "')\">"
@@ -2830,7 +2827,7 @@ void HtmlGenerator::writeSummaryLink(const char *file,const char *anchor,const c
28302827
if (file)
28312828
{
28322829
t << relPath << file;
2833-
t << Doxygen::htmlFileExtension;
2830+
t << (hasExtension(file) ? "" : Doxygen::htmlFileExtension);
28342831
}
28352832
else
28362833
{

src/util.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7220,6 +7220,19 @@ bool checkExtension(const char *fName, const char *ext)
72207220
return (QCString(fName).right(QCString(ext).length())==ext);
72217221
}
72227222

7223+
bool hasExtension(const char *fName)
7224+
{
7225+
return !(QFileInfo(fName).extension(FALSE).isEmpty());
7226+
}
7227+
bool hasExtension(QCString fName)
7228+
{
7229+
return !(QFileInfo(fName).extension(FALSE).isEmpty());
7230+
}
7231+
bool hasExtension(QString fName)
7232+
{
7233+
return !(QFileInfo(fName).extension(FALSE).isEmpty());
7234+
}
7235+
72237236
QCString stripExtensionGeneral(const char *fName, const char *ext)
72247237
{
72257238
QCString result=fName;

src/util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ QCString linkToText(SrcLangExt lang,const char *link,bool isFileName);
363363

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

366+
bool hasExtension(const char *fName);
367+
bool hasExtension(QCString fName);
368+
bool hasExtension(QString fName);
369+
366370
QCString stripExtensionGeneral(const char *fName, const char *ext);
367371

368372
QCString stripExtension(const char *fName);

0 commit comments

Comments
 (0)