summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--src/commentscan.l88
-rw-r--r--src/doxygen.cpp25
-rw-r--r--src/markdown.cpp53
-rw-r--r--src/markdown.h2
-rw-r--r--src/marshal.cpp4
-rw-r--r--src/section.h17
-rw-r--r--src/tagreader.cpp2
-rw-r--r--src/util.cpp31
8 files changed, 169 insertions, 53 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,
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index 251f2b4..5b8b379 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -8643,15 +8643,30 @@ static void findMainPage(EntryNav *rootNav)
Doxygen::mainPage->setShowToc(root->stat);
addPageToContext(Doxygen::mainPage,rootNav);
- // a page name is a label as well!
- SectionInfo *si=new SectionInfo(
- indexName,
+ SectionInfo *si = Doxygen::sectionDict->find(Doxygen::mainPage->name());
+ if (si)
+ {
+ if (si->lineNr != -1)
+ {
+ warn(root->fileName,root->startLine,"multiple use of section label '%s', (first occurrence: %s, line %d)",Doxygen::mainPage->name().data(),si->fileName.data(),si->lineNr);
+ }
+ else
+ {
+ warn(root->fileName,root->startLine,"multiple use of section label '%s', (first occurrence: %s)",Doxygen::mainPage->name().data(),si->fileName.data());
+ }
+ }
+ else
+ {
+ // a page name is a label as well! but should no be double either
+ si=new SectionInfo(
+ indexName, root->startLine,
Doxygen::mainPage->name(),
Doxygen::mainPage->title(),
SectionInfo::Page,
0); // level 0
- Doxygen::sectionDict->append(indexName,si);
- Doxygen::mainPage->addSectionsToDefinition(root->anchors);
+ Doxygen::sectionDict->append(indexName,si);
+ Doxygen::mainPage->addSectionsToDefinition(root->anchors);
+ }
}
else
{
diff --git a/src/markdown.cpp b/src/markdown.cpp
index 6ae95fe..9605f31 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -48,6 +48,7 @@
#include "commentcnv.h"
#include "config.h"
#include "section.h"
+#include "message.h"
//-----------
@@ -90,6 +91,7 @@ static QDict<LinkRef> g_linkRefs(257);
static action_t g_actions[256];
static Entry *g_current;
static QCString g_fileName;
+static int g_lineNr;
// In case a markdown page starts with a level1 header, that header is used
// as a title of the page, in effect making it a level0 header, so the
@@ -1690,12 +1692,27 @@ void writeOneLineHeaderOrRuler(GrowBuf &out,const char *data,int size)
out.addStr(" ");
out.addStr(header);
out.addStr("\n");
- SectionInfo *si = new SectionInfo(g_fileName,id,header,type,level);
- if (g_current)
+ SectionInfo *si = Doxygen::sectionDict->find(header);
+ if (si)
{
- g_current->anchors->append(si);
+ if (si->lineNr != -1)
+ {
+ warn(g_fileName,g_lineNr,"multiple use of section label '%s', (first occurrence: %s, line %d)",header.data(),si->fileName.data(),si->lineNr);
+ }
+ else
+ {
+ warn(g_fileName,g_lineNr,"multiple use of section label '%s', (first occurrence: %s)",header.data(),si->fileName.data());
+ }
+ }
+ else
+ {
+ si = new SectionInfo(g_fileName,g_lineNr,id,header,type,level);
+ if (g_current)
+ {
+ g_current->anchors->append(si);
+ }
+ Doxygen::sectionDict->append(header,si);
}
- Doxygen::sectionDict->append(header,si);
}
else
{
@@ -2020,13 +2037,28 @@ static QCString processBlocks(const QCString &s,int indent)
out.addStr(" ");
out.addStr(header);
out.addStr("\n\n");
- SectionInfo *si = new SectionInfo(g_fileName,id,header,
- level==1 ? SectionInfo::Section : SectionInfo::Subsection,level);
- if (g_current)
+ SectionInfo *si = Doxygen::sectionDict->find(header);
+ if (si)
{
- g_current->anchors->append(si);
+ if (si->lineNr != -1)
+ {
+ warn(g_fileName,g_lineNr,"multiple use of section label '%s', (first occurrence: %s, line %d)",header.data(),si->fileName.data(),si->lineNr);
+ }
+ else
+ {
+ warn(g_fileName,g_lineNr,"multiple use of section label '%s', (first occurrence: %s)",header.data(),si->fileName.data());
+ }
+ }
+ else
+ {
+ si = new SectionInfo(g_fileName,g_lineNr,id,header,
+ level==1 ? SectionInfo::Section : SectionInfo::Subsection,level);
+ if (g_current)
+ {
+ g_current->anchors->append(si);
+ }
+ Doxygen::sectionDict->append(header,si);
}
- Doxygen::sectionDict->append(header,si);
}
else
{
@@ -2214,7 +2246,7 @@ static QCString detab(const QCString &s,int &refIndent)
//---------------------------------------------------------------------------
-QCString processMarkdown(const QCString &fileName,Entry *e,const QCString &input)
+QCString processMarkdown(const QCString &fileName,const int lineNr,Entry *e,const QCString &input)
{
static bool init=FALSE;
if (!init)
@@ -2237,6 +2269,7 @@ QCString processMarkdown(const QCString &fileName,Entry *e,const QCString &input
g_linkRefs.clear();
g_current = e;
g_fileName = fileName;
+ g_lineNr = lineNr;
static GrowBuf out;
if (input.isEmpty()) return input;
out.clear();
diff --git a/src/markdown.h b/src/markdown.h
index 8fd7677..5e35259 100644
--- a/src/markdown.h
+++ b/src/markdown.h
@@ -22,7 +22,7 @@
class Entry;
/** processes string \a s and converts markdown into doxygen/html commands. */
-QCString processMarkdown(const QCString &fileName,Entry *e,const QCString &s);
+QCString processMarkdown(const QCString &fileName,const int lineNr,Entry *e,const QCString &s);
QCString markdownFileNameToId(const QCString &fileName);
class MarkdownFileParser : public ParserInterface
diff --git a/src/marshal.cpp b/src/marshal.cpp
index a6b3e75..04f426d 100644
--- a/src/marshal.cpp
+++ b/src/marshal.cpp
@@ -139,6 +139,7 @@ void marshalSectionInfoList(StorageIntf *s, QList<SectionInfo> *anchors)
marshalQCString(s,si->ref);
marshalInt(s,(int)si->type);
marshalQCString(s,si->fileName);
+ marshalInt(s,si->lineNr);
marshalInt(s,si->level);
}
}
@@ -546,8 +547,9 @@ QList<SectionInfo> *unmarshalSectionInfoList(StorageIntf *s)
QCString ref = unmarshalQCString(s);
SectionInfo::SectionType type = (SectionInfo::SectionType)unmarshalInt(s);
QCString fileName = unmarshalQCString(s);
+ int lineNr = unmarshalInt(s);
int level = unmarshalInt(s);
- result->append(new SectionInfo(fileName,label,title,type,level,ref));
+ result->append(new SectionInfo(fileName,lineNr,label,title,type,level,ref));
}
return result;
}
diff --git a/src/section.h b/src/section.h
index 431c63b..7df4166 100644
--- a/src/section.h
+++ b/src/section.h
@@ -33,17 +33,23 @@ struct SectionInfo
Paragraph = 4,
Anchor = 5
};
- SectionInfo(const char *f,const char *l,const char *t,
+ SectionInfo(const char *f,const int lin,const char *l,const char *t,
SectionType st,int lev,const char *r=0) :
label(l), title(t), type(st), ref(r), definition(0),
- fileName(f), generated(FALSE), level(lev)
+ fileName(f), generated(FALSE), level(lev), lineNr(lin)
{
}
SectionInfo(const SectionInfo &s)
{
- label=s.label.copy(); title=s.title.copy(); ref=s.ref.copy();
- type =s.type; definition=s.definition;
- fileName=s.fileName.copy(); generated=s.generated;
+ label=s.label.copy();
+ title=s.title.copy();
+ type =s.type;
+ ref=s.ref.copy();
+ definition=s.definition;
+ fileName=s.fileName.copy();
+ lineNr=s.lineNr;
+ generated=s.generated;
+ level=s.level;
}
~SectionInfo() {}
QCString label;
@@ -52,6 +58,7 @@ struct SectionInfo
QCString ref;
Definition *definition;
QCString fileName;
+ int lineNr;
bool generated;
int level;
};
diff --git a/src/tagreader.cpp b/src/tagreader.cpp
index 467781a..036e24f 100644
--- a/src/tagreader.cpp
+++ b/src/tagreader.cpp
@@ -1120,7 +1120,7 @@ void TagFileParser::addDocAnchors(Entry *e,const TagAnchorInfoList &l)
{
//printf("New sectionInfo file=%s anchor=%s\n",
// ta->fileName.data(),ta->label.data());
- SectionInfo *si=new SectionInfo(ta->fileName,ta->label,ta->title,
+ SectionInfo *si=new SectionInfo(ta->fileName,-1,ta->label,ta->title,
SectionInfo::Anchor,0,m_tagName);
Doxygen::sectionDict->append(ta->label,si);
e->anchors->append(si);
diff --git a/src/util.cpp b/src/util.cpp
index bc93446..0452fbb 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -6280,14 +6280,29 @@ PageDef *addRelatedPage(const char *name,const QCString &ptitle,
{
file=pd->getOutputFileBase();
}
- SectionInfo *si=new SectionInfo(
- file,pd->name(),pd->title(),SectionInfo::Page,0,pd->getReference());
- //printf("si->label=`%s' si->definition=%s si->fileName=`%s'\n",
- // si->label.data(),si->definition?si->definition->name().data():"<none>",
- // si->fileName.data());
- //printf(" SectionInfo: sec=%p sec->fileName=%s\n",si,si->fileName.data());
- //printf("Adding section key=%s si->fileName=%s\n",pageName.data(),si->fileName.data());
- Doxygen::sectionDict->append(pd->name(),si);
+ SectionInfo *si = Doxygen::sectionDict->find(pd->name());
+ if (si)
+ {
+ if (si->lineNr != -1)
+ {
+ warn(file,-1,"multiple use of section label '%s', (first occurrence: %s, line %d)",pd->name().data(),si->fileName.data(),si->lineNr);
+ }
+ else
+ {
+ warn(file,-1,"multiple use of section label '%s', (first occurrence: %s)",pd->name().data(),si->fileName.data());
+ }
+ }
+ else
+ {
+ si=new SectionInfo(
+ file,-1,pd->name(),pd->title(),SectionInfo::Page,0,pd->getReference());
+ //printf("si->label=`%s' si->definition=%s si->fileName=`%s'\n",
+ // si->label.data(),si->definition?si->definition->name().data():"<none>",
+ // si->fileName.data());
+ //printf(" SectionInfo: sec=%p sec->fileName=%s\n",si,si->fileName.data());
+ //printf("Adding section key=%s si->fileName=%s\n",pageName.data(),si->fileName.data());
+ Doxygen::sectionDict->append(pd->name(),si);
+ }
}
}
return pd;