Commit bcd90114 authored by Dimitri van Heesch's avatar Dimitri van Heesch
Browse files

Merge pull request #131 from albert-github/feature/bug_725516

Bug 725516 - In case of sections with the same name they are not reported.
parents 4c707ade ac611be4
Loading
Loading
Loading
Loading
+66 −22
Original line number Original line Diff line number Diff line
@@ -553,7 +553,7 @@ static void addXRefItem(const char *listName,const char *itemTitle,
    item->text += " <p>";
    item->text += " <p>";
    if (Doxygen::markdownSupport)
    if (Doxygen::markdownSupport)
    {
    {
      item->text += processMarkdown(yyFileName,current,outputXRef);
      item->text += processMarkdown(yyFileName,yyLineNr,current,outputXRef);
    }
    }
    else
    else
    {
    {
@@ -575,7 +575,7 @@ static void addXRefItem(const char *listName,const char *itemTitle,
    ASSERT(item!=0);
    ASSERT(item!=0);
    if (Doxygen::markdownSupport)
    if (Doxygen::markdownSupport)
    {
    {
      item->text = processMarkdown(yyFileName,current,outputXRef);
      item->text = processMarkdown(yyFileName,yyLineNr,current,outputXRef);
    }
    }
    else
    else
    {
    {
@@ -593,12 +593,27 @@ static void addXRefItem(const char *listName,const char *itemTitle,
    {
    {
      docEntry->doc += cmdString;
      docEntry->doc += cmdString;
    }
    }
    SectionInfo *si=new SectionInfo(listName,anchorLabel,
    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_sectionTitle,SectionInfo::Anchor,
                         g_sectionLevel);
                         g_sectionLevel);
      Doxygen::sectionDict->append(anchorLabel,si);
      Doxygen::sectionDict->append(anchorLabel,si);
      docEntry->anchors->append(si);
      docEntry->anchors->append(si);
    }
    }
  }
  outputXRef.resize(0);
  outputXRef.resize(0);
}
}


@@ -642,11 +657,25 @@ static SectionInfo::SectionType sectionLevelToType(int level)
}
}


static void addSection()
static void addSection()
{
  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
    // create a new section element
    g_sectionTitle+=yytext;
    g_sectionTitle+=yytext;
    g_sectionTitle=g_sectionTitle.stripWhiteSpace();
    g_sectionTitle=g_sectionTitle.stripWhiteSpace();
  SectionInfo *si = new SectionInfo(yyFileName,g_sectionLabel,
    si = new SectionInfo(yyFileName,yyLineNr,g_sectionLabel,
                          g_sectionTitle,sectionLevelToType(g_sectionLevel),g_sectionLevel);
                          g_sectionTitle,sectionLevelToType(g_sectionLevel),g_sectionLevel);


    // add section to this entry
    // add section to this entry
@@ -654,7 +683,7 @@ static void addSection()


    // add section to the global dictionary
    // add section to the global dictionary
    Doxygen::sectionDict->append(g_sectionLabel,si);
    Doxygen::sectionDict->append(g_sectionLabel,si);

  }
}
}


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@@ -1701,9 +1730,24 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
  /* ----- handle arguments of the anchor command ------- */
  /* ----- handle arguments of the anchor command ------- */


<AnchorLabel>{LABELID}			{ // found argument
<AnchorLabel>{LABELID}			{ // found argument
                                          SectionInfo  *si = new SectionInfo(yyFileName,yytext,0,SectionInfo::Anchor,0);
                                          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);
                                            Doxygen::sectionDict->append(yytext,si);
  					    current->anchors->append(si);
  					    current->anchors->append(si);
                                          }
					  addOutput(yytext);
					  addOutput(yytext);
					  BEGIN( Comment );
					  BEGIN( Comment );
  					}
  					}
@@ -2876,9 +2920,9 @@ bool parseCommentBlock(/* in */ ParserInterface *parser,


  if (Doxygen::markdownSupport)
  if (Doxygen::markdownSupport)
  {
  {
    current->brief      = processMarkdown(fileName,current,current->brief);
    current->brief      = processMarkdown(fileName,lineNr,current,current->brief);
    current->doc        = processMarkdown(fileName,current,current->doc);
    current->doc        = processMarkdown(fileName,lineNr,current,current->doc);
    current->inbodyDocs = processMarkdown(fileName,current,current->inbodyDocs);
    current->inbodyDocs = processMarkdown(fileName,lineNr,current,current->inbodyDocs);
  }
  }


  Debug::print(Debug::CommentScan,0,
  Debug::print(Debug::CommentScan,0,
+20 −5
Original line number Original line Diff line number Diff line
@@ -8643,9 +8643,23 @@ static void findMainPage(EntryNav *rootNav)
      Doxygen::mainPage->setShowToc(root->stat);
      Doxygen::mainPage->setShowToc(root->stat);
      addPageToContext(Doxygen::mainPage,rootNav);
      addPageToContext(Doxygen::mainPage,rootNav);
          
          
      // a page name is a label as well!
      SectionInfo *si = Doxygen::sectionDict->find(Doxygen::mainPage->name());
      SectionInfo *si=new SectionInfo(
      if (si)
          indexName,
      {
        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->name(),
          Doxygen::mainPage->title(),
          Doxygen::mainPage->title(),
          SectionInfo::Page,
          SectionInfo::Page,
@@ -8653,6 +8667,7 @@ static void findMainPage(EntryNav *rootNav)
        Doxygen::sectionDict->append(indexName,si);
        Doxygen::sectionDict->append(indexName,si);
        Doxygen::mainPage->addSectionsToDefinition(root->anchors);
        Doxygen::mainPage->addSectionsToDefinition(root->anchors);
      }
      }
    }
    else
    else
    {
    {
      warn(root->fileName,root->startLine,
      warn(root->fileName,root->startLine,
+43 −10
Original line number Original line Diff line number Diff line
@@ -48,6 +48,7 @@
#include "commentcnv.h"
#include "commentcnv.h"
#include "config.h"
#include "config.h"
#include "section.h"
#include "section.h"
#include "message.h"


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


@@ -90,6 +91,7 @@ static QDict<LinkRef> g_linkRefs(257);
static action_t       g_actions[256];
static action_t       g_actions[256];
static Entry         *g_current;
static Entry         *g_current;
static QCString       g_fileName;
static QCString       g_fileName;
static int            g_lineNr;


// In case a markdown page starts with a level1 header, that header is used
// 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
// as a title of the page, in effect making it a level0 header, so the
@@ -1690,13 +1692,28 @@ void writeOneLineHeaderOrRuler(GrowBuf &out,const char *data,int size)
      out.addStr(" ");
      out.addStr(" ");
      out.addStr(header);
      out.addStr(header);
      out.addStr("\n");
      out.addStr("\n");
      SectionInfo *si = new SectionInfo(g_fileName,id,header,type,level);
      SectionInfo *si = Doxygen::sectionDict->find(header);
      if (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)
        if (g_current)
        {
        {
          g_current->anchors->append(si);
          g_current->anchors->append(si);
        }
        }
        Doxygen::sectionDict->append(header,si);
        Doxygen::sectionDict->append(header,si);
      }
      }
    }
    else
    else
    {
    {
      if (!id.isEmpty())
      if (!id.isEmpty())
@@ -2020,7 +2037,21 @@ static QCString processBlocks(const QCString &s,int indent)
            out.addStr(" ");
            out.addStr(" ");
            out.addStr(header);
            out.addStr(header);
            out.addStr("\n\n");
            out.addStr("\n\n");
            SectionInfo *si = new SectionInfo(g_fileName,id,header,
            SectionInfo *si = Doxygen::sectionDict->find(header);
            if (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);
                      level==1 ? SectionInfo::Section : SectionInfo::Subsection,level);
              if (g_current)
              if (g_current)
              {
              {
@@ -2028,6 +2059,7 @@ static QCString processBlocks(const QCString &s,int indent)
              }
              }
              Doxygen::sectionDict->append(header,si);
              Doxygen::sectionDict->append(header,si);
            }
            }
          }
          else
          else
          {
          {
            out.addStr(level==1?"<h1>":"<h2>");
            out.addStr(level==1?"<h1>":"<h2>");
@@ -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;
  static bool init=FALSE;
  if (!init)
  if (!init)
@@ -2237,6 +2269,7 @@ QCString processMarkdown(const QCString &fileName,Entry *e,const QCString &input
  g_linkRefs.clear();
  g_linkRefs.clear();
  g_current = e;
  g_current = e;
  g_fileName = fileName;
  g_fileName = fileName;
  g_lineNr   = lineNr;
  static GrowBuf out;
  static GrowBuf out;
  if (input.isEmpty()) return input;
  if (input.isEmpty()) return input;
  out.clear();
  out.clear();
+1 −1
Original line number Original line Diff line number Diff line
@@ -22,7 +22,7 @@
class Entry;
class Entry;


/** processes string \a s and converts markdown into doxygen/html commands. */
/** 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);
QCString markdownFileNameToId(const QCString &fileName);


class MarkdownFileParser : public ParserInterface
class MarkdownFileParser : public ParserInterface
+3 −1
Original line number Original line Diff line number Diff line
@@ -139,6 +139,7 @@ void marshalSectionInfoList(StorageIntf *s, QList<SectionInfo> *anchors)
      marshalQCString(s,si->ref);
      marshalQCString(s,si->ref);
      marshalInt(s,(int)si->type);
      marshalInt(s,(int)si->type);
      marshalQCString(s,si->fileName);
      marshalQCString(s,si->fileName);
      marshalInt(s,si->lineNr);
      marshalInt(s,si->level);
      marshalInt(s,si->level);
    }
    }
  }
  }
@@ -546,8 +547,9 @@ QList<SectionInfo> *unmarshalSectionInfoList(StorageIntf *s)
    QCString ref   = unmarshalQCString(s);
    QCString ref   = unmarshalQCString(s);
    SectionInfo::SectionType type = (SectionInfo::SectionType)unmarshalInt(s);
    SectionInfo::SectionType type = (SectionInfo::SectionType)unmarshalInt(s);
    QCString fileName = unmarshalQCString(s);
    QCString fileName = unmarshalQCString(s);
    int lineNr = unmarshalInt(s);
    int level = 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;
  return result;
}
}
Loading