summaryrefslogtreecommitdiffstats
path: root/src/commentscan.l
diff options
context:
space:
mode:
authoralbert-github <albert.tests@gmail.com>2014-03-02 19:32:42 (GMT)
committeralbert-github <albert.tests@gmail.com>2014-03-02 19:32:42 (GMT)
commitac611be473c2d9bf65bcafb53b0577274c4ae706 (patch)
tree3fa0e5b2798121b937fce6169d6a23e2575d4e1d /src/commentscan.l
parent8eeaae0b06fd320745f22efe176e0f19d6c8e2a6 (diff)
downloadDoxygen-ac611be473c2d9bf65bcafb53b0577274c4ae706.zip
Doxygen-ac611be473c2d9bf65bcafb53b0577274c4ae706.tar.gz
Doxygen-ac611be473c2d9bf65bcafb53b0577274c4ae706.tar.bz2
In case of sections with the same name they are not reported.
In this patch it is checked if a section label has been used before and if so a warning is given with file name and line number (when possible) where the section label was used the first time. Note in section.h the item level was not initialized in the past in case of a copy constructor.
Diffstat (limited to 'src/commentscan.l')
-rw-r--r--src/commentscan.l88
1 files changed, 66 insertions, 22 deletions
diff --git a/src/commentscan.l b/src/commentscan.l
index fc53c57..3cd8f5f 100644
--- a/src/commentscan.l
+++ b/src/commentscan.l
@@ -553,7 +553,7 @@ static void addXRefItem(const char *listName,const char *itemTitle,
item->text += " <p>";
if (Doxygen::markdownSupport)
{
- item->text += processMarkdown(yyFileName,current,outputXRef);
+ item->text += processMarkdown(yyFileName,yyLineNr,current,outputXRef);
}
else
{
@@ -575,7 +575,7 @@ static void addXRefItem(const char *listName,const char *itemTitle,
ASSERT(item!=0);
if (Doxygen::markdownSupport)
{
- item->text = processMarkdown(yyFileName,current,outputXRef);
+ item->text = processMarkdown(yyFileName,yyLineNr,current,outputXRef);
}
else
{
@@ -593,11 +593,26 @@ static void addXRefItem(const char *listName,const char *itemTitle,
{
docEntry->doc += cmdString;
}
- SectionInfo *si=new SectionInfo(listName,anchorLabel,
- g_sectionTitle,SectionInfo::Anchor,
- g_sectionLevel);
- Doxygen::sectionDict->append(anchorLabel,si);
- docEntry->anchors->append(si);
+ SectionInfo *si = Doxygen::sectionDict->find(anchorLabel);
+ if (si)
+ {
+ if (si->lineNr != -1)
+ {
+ warn(listName,yyLineNr,"multiple use of section label '%s', (first occurrence: %s, line %d)",anchorLabel,si->fileName.data(),si->lineNr);
+ }
+ else
+ {
+ warn(listName,yyLineNr,"multiple use of section label '%s', (first occurrence: %s)",anchorLabel,si->fileName.data());
+ }
+ }
+ else
+ {
+ si=new SectionInfo(listName,yyLineNr,anchorLabel,
+ g_sectionTitle,SectionInfo::Anchor,
+ g_sectionLevel);
+ Doxygen::sectionDict->append(anchorLabel,si);
+ docEntry->anchors->append(si);
+ }
}
outputXRef.resize(0);
}
@@ -643,18 +658,32 @@ static SectionInfo::SectionType sectionLevelToType(int level)
static void addSection()
{
- // create a new section element
- g_sectionTitle+=yytext;
- g_sectionTitle=g_sectionTitle.stripWhiteSpace();
- SectionInfo *si = new SectionInfo(yyFileName,g_sectionLabel,
+ SectionInfo *si = Doxygen::sectionDict->find(g_sectionLabel);
+ if (si)
+ {
+ if (si->lineNr != -1)
+ {
+ warn(yyFileName,yyLineNr,"multiple use of section label '%s', (first occurrence: %s, line %d)",g_sectionLabel.data(),si->fileName.data(),si->lineNr);
+ }
+ else
+ {
+ warn(yyFileName,yyLineNr,"multiple use of section label '%s', (first occurrence: %s)",g_sectionLabel.data(),si->fileName.data());
+ }
+ }
+ else
+ {
+ // create a new section element
+ g_sectionTitle+=yytext;
+ g_sectionTitle=g_sectionTitle.stripWhiteSpace();
+ si = new SectionInfo(yyFileName,yyLineNr,g_sectionLabel,
g_sectionTitle,sectionLevelToType(g_sectionLevel),g_sectionLevel);
- // add section to this entry
- current->anchors->append(si);
-
- // add section to the global dictionary
- Doxygen::sectionDict->append(g_sectionLabel,si);
+ // add section to this entry
+ current->anchors->append(si);
+ // add section to the global dictionary
+ Doxygen::sectionDict->append(g_sectionLabel,si);
+ }
}
//-----------------------------------------------------------------------------
@@ -1701,9 +1730,24 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
/* ----- handle arguments of the anchor command ------- */
<AnchorLabel>{LABELID} { // found argument
- SectionInfo *si = new SectionInfo(yyFileName,yytext,0,SectionInfo::Anchor,0);
- Doxygen::sectionDict->append(yytext,si);
- current->anchors->append(si);
+ SectionInfo *si = Doxygen::sectionDict->find(yytext);
+ if (si)
+ {
+ if (si->lineNr != -1)
+ {
+ warn(yyFileName,yyLineNr,"multiple use of section label '%s', (first occurrence: %s, line %d)",yytext,si->fileName.data(),si->lineNr);
+ }
+ else
+ {
+ warn(yyFileName,yyLineNr,"multiple use of section label '%s', (first occurrence: %s)",yytext,si->fileName.data());
+ }
+ }
+ else
+ {
+ si = new SectionInfo(yyFileName,yyLineNr,yytext,0,SectionInfo::Anchor,0);
+ Doxygen::sectionDict->append(yytext,si);
+ current->anchors->append(si);
+ }
addOutput(yytext);
BEGIN( Comment );
}
@@ -2876,9 +2920,9 @@ bool parseCommentBlock(/* in */ ParserInterface *parser,
if (Doxygen::markdownSupport)
{
- current->brief = processMarkdown(fileName,current,current->brief);
- current->doc = processMarkdown(fileName,current,current->doc);
- current->inbodyDocs = processMarkdown(fileName,current,current->inbodyDocs);
+ current->brief = processMarkdown(fileName,lineNr,current,current->brief);
+ current->doc = processMarkdown(fileName,lineNr,current,current->doc);
+ current->inbodyDocs = processMarkdown(fileName,lineNr,current,current->inbodyDocs);
}
Debug::print(Debug::CommentScan,0,