From c46e7ae8a25ec64b91ab39bf5246aa69e729d25b Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sun, 4 Oct 2020 20:42:41 +0200 Subject: Reworked changes a bit - topLine is replaced by startLine - changed unputDocnl macro into a more self contained function-like macro --- src/commentscan.l | 40 ++++++++++++++++++++-------------------- src/context.cpp | 2 +- src/doxygen.cpp | 12 ++++++++---- src/entry.cpp | 2 -- src/entry.h | 1 - src/index.cpp | 2 +- src/pagedef.cpp | 26 ++++++-------------------- src/pagedef.h | 12 ++++-------- src/util.cpp | 15 +++++++++------ src/util.h | 4 +++- 10 files changed, 52 insertions(+), 64 deletions(-) diff --git a/src/commentscan.l b/src/commentscan.l index 25086f5..ccf71f6 100644 --- a/src/commentscan.l +++ b/src/commentscan.l @@ -438,7 +438,7 @@ static void handleGuard(yyscan_t yyscanner,const QCString &expr); static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size); static void addCite(yyscan_t yyscanner); -#define unputDocnl for (int i=(int)yyleng-1;i>=0;i--) unput(yytext[i]); +#define unput_string(yytext,yyleng) do { for (int i=(int)yyleng-1;i>=0;i--) unput(yytext[i]); } while(0) //----------------------------------------------------------------------------- @@ -956,7 +956,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" warn(yyextra->fileName,yyextra->lineNr, "missing argument after \\enum." ); - unputDocnl; + unput_string(yytext,yyleng); //addOutput(yyscanner,'\n'); //if (*yytext=='\n') yyextra->lineNr++; BEGIN( Comment ); @@ -979,7 +979,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" "missing argument after " "\\namespace." ); - unputDocnl; + unput_string(yytext,yyleng); //addOutput(yyscanner,'\n'); //if (*yytext=='\n') yyextra->lineNr++; BEGIN( Comment ); @@ -1002,7 +1002,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" "missing argument after " "\\package." ); - unputDocnl; + unput_string(yytext,yyleng); //addOutput(yyscanner,'\n'); //if (*yytext=='\n') yyextra->lineNr++; BEGIN( Comment ); @@ -1040,7 +1040,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" ); //addOutput(yyscanner,'\n'); //if (*yytext=='\n') yyextra->lineNr++; - unputDocnl; + unput_string(yytext,yyleng); BEGIN( Comment ); } . { // ignore other stuff @@ -1049,7 +1049,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" {DOCNL} { //addOutput(yyscanner,'\n'); //if (*yytext=='\n') yyextra->lineNr++; - unputDocnl; + unput_string(yytext,yyleng); BEGIN( Comment ); } {FILE}|"<>" { // second argument; include file @@ -1073,7 +1073,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" } {DOCNL} { //if (*yytext=='\n') yyextra->lineNr++; - unputDocnl; + unput_string(yytext,yyleng); BEGIN( Comment ); } . { // ignore other stuff @@ -1104,7 +1104,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" ); //addOutput(yyscanner,'\n'); //if (*yytext=='\n') yyextra->lineNr++; - unputDocnl; + unput_string(yytext,yyleng); BEGIN( Comment ); } . { // ignore other stuff @@ -1127,7 +1127,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" "\\defgroup %s", yyextra->current->name.data() ); } - unputDocnl; + unput_string(yytext,yyleng); //if (*yytext=='\n') yyextra->lineNr++; //addOutput(yyscanner,'\n'); BEGIN( Comment ); @@ -1152,7 +1152,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" "missing argument after " "\\page." ); - unputDocnl; + unput_string(yytext,yyleng); //if (*yytext=='\n') yyextra->lineNr++; //addOutput(yyscanner,'\n'); BEGIN( Comment ); @@ -1160,7 +1160,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" . { // ignore other stuff } {DOCNL} { // second argument; page title - unputDocnl; + unput_string(yytext,yyleng); //if (*yytext=='\n') yyextra->lineNr++; //addOutput(yyscanner,'\n'); BEGIN( Comment ); @@ -1194,7 +1194,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" /* --------- handle arguments of the file/dir/example command ------------ */ {DOCNL} { // no file name specified - unputDocnl; + unput_string(yytext,yyleng); //if (*yytext=='\n') yyextra->lineNr++; //addOutput(yyscanner,'\n'); BEGIN( Comment ); @@ -1292,7 +1292,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" warn(yyextra->fileName,yyextra->lineNr, "Missing argument of '\\%s' command",yyextra->currentCmd.data() ); - unputDocnl; + unput_string(yytext,yyleng); //if (*yytext=='\n') yyextra->lineNr++; //addOutput(yyscanner,'\n'); BEGIN( Comment ); @@ -1306,7 +1306,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" {DOCNL} { // end of argument //if (*yytext=='\n') yyextra->lineNr++; //addOutput(yyscanner,'\n'); - unputDocnl; + unput_string(yytext,yyleng); BEGIN( Comment ); } {LC} { // line continuation @@ -1670,7 +1670,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" {DOCNL} { // end of argument //if (*yytext=='\n') yyextra->lineNr++; //addOutput(yyscanner,'\n'); - unputDocnl; + unput_string(yytext,yyleng); BEGIN( Comment ); } {LC} { // line continuation @@ -1708,7 +1708,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" } //if (*yytext=='\n') yyextra->lineNr++; //addOutput(yyscanner,'\n'); - unputDocnl; + unput_string(yytext,yyleng); BEGIN( Comment ); } {LC} { // line continuation @@ -1726,7 +1726,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" { //if (*yytext=='\n') yyextra->lineNr++; //addOutput(yyscanner,'\n'); - unputDocnl; + unput_string(yytext,yyleng); yyextra->langParser->parsePrototype(yyextra->functionProto); BEGIN( Comment ); } @@ -1813,7 +1813,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" ); //if (*yytext=='\n') yyextra->lineNr++; //addOutput(yyscanner,'\n'); - unputDocnl; + unput_string(yytext,yyleng); BEGIN( Comment ); } . { // ignore other stuff @@ -1850,7 +1850,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" ); //if (*yytext=='\n') yyextra->lineNr++; //addOutput(yyscanner,'\n'); - unputDocnl; + unput_string(yytext,yyleng); BEGIN( Comment ); } . { // invalid character for cite label @@ -2785,7 +2785,7 @@ static bool makeStructuralIndicator(yyscan_t yyscanner,Entry::Sections s) yyextra->current->section = s; yyextra->current->fileName = yyextra->fileName; yyextra->current->startLine = yyextra->lineNr; - yyextra->current->topLine = yyextra->lineNr; + yyextra->current->docLine = yyextra->lineNr; return FALSE; } } diff --git a/src/context.cpp b/src/context.cpp index 3f31747..ee394d4 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -10248,7 +10248,7 @@ void generateOutputViaTemplate() else { // TODO: for LaTeX output index should be main... => solve in template - Doxygen::mainPage = createPageDef("[generated]",1,1,"index","",theTranslator->trMainPage()); + Doxygen::mainPage = createPageDef("[generated]",1,"index","",theTranslator->trMainPage()); Doxygen::mainPage->setFileName("index"); SharedPtr mainPage(PageContext::alloc(Doxygen::mainPage,TRUE,FALSE)); ctx->set("mainPage",mainPage.get()); diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 9a27934..c606250 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -347,7 +347,9 @@ static void addRelatedPage(Entry *root) } PageDef *pd = addRelatedPage(root->name,root->args,doc, - root->docFile,root->docLine,root->topLine, + root->docFile, + root->docLine, + root->startLine, root->sli, gd,root->tagInfo(), FALSE, @@ -8442,14 +8444,16 @@ static void findMainPage(Entry *root) { if (Doxygen::mainPage==0 && root->tagInfo()==0) { + //printf("mainpage: docLine=%d startLine=%d\n",root->docLine,root->startLine); //printf("Found main page! \n======\n%s\n=======\n",root->doc.data()); QCString title=root->args.stripWhiteSpace(); //QCString indexName=Config_getBool(GENERATE_TREEVIEW)?"main":"index"; QCString indexName="index"; - Doxygen::mainPage = createPageDef(root->docFile,root->docLine,root->topLine, + Doxygen::mainPage = createPageDef(root->docFile,root->docLine, indexName, root->brief+root->doc+root->inbodyDocs,title); //setFileNameForSections(root->anchors,"index",Doxygen::mainPage); Doxygen::mainPage->setBriefDescription(root->brief,root->briefFile,root->briefLine); + Doxygen::mainPage->setBodySegment(root->startLine,root->startLine,-1); Doxygen::mainPage->setFileName(indexName); Doxygen::mainPage->setLocalToc(root->localToc); addPageToContext(Doxygen::mainPage,root); @@ -8485,7 +8489,7 @@ static void findMainPage(Entry *root) { warn(root->fileName,root->startLine, "found more than one \\mainpage comment block! (first occurrence: %s, line %d), Skipping current block!", - Doxygen::mainPage->docFile().data(),Doxygen::mainPage->topLine()); + Doxygen::mainPage->docFile().data(),Doxygen::mainPage->getStartBodyLine()); } } for (const auto &e : root->children()) findMainPage(e.get()); @@ -8663,7 +8667,7 @@ static void buildExampleList(Entry *root) } else { - PageDef *pd=createPageDef(root->fileName,root->startLine,root->startLine, + PageDef *pd=createPageDef(root->fileName,root->startLine, root->name,root->brief+root->doc+root->inbodyDocs,root->args); pd->setBriefDescription(root->brief,root->briefFile,root->briefLine); pd->setFileName(convertNameToFile(pd->name()+"-example",FALSE,TRUE)); diff --git a/src/entry.cpp b/src/entry.cpp index 78522f7..6e343b0 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -78,7 +78,6 @@ Entry::Entry(const Entry &e) doc = e.doc; docLine = e.docLine; docFile = e.docFile; - topLine = e.topLine; brief = e.brief; briefLine = e.briefLine; briefFile = e.briefFile; @@ -197,7 +196,6 @@ void Entry::reset() doc.resize(0); docFile.resize(0); docLine=-1; - topLine=-1; relates.resize(0); relatesType=Simple; brief.resize(0); diff --git a/src/entry.h b/src/entry.h index f98eda6..d6c0936 100644 --- a/src/entry.h +++ b/src/entry.h @@ -264,7 +264,6 @@ class Entry QCString includeName; //!< include name (3 arg of \\class) QCString doc; //!< documentation block (partly parsed) int docLine; //!< line number at which the documentation was found - int topLine; //!< line number at which the page / section definition was found QCString docFile; //!< file in which the documentation was found QCString brief; //!< brief description (doc block) int briefLine; //!< line number at which the brief desc. was found diff --git a/src/index.cpp b/src/index.cpp index 78a1838..4df2ce4 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -4499,7 +4499,7 @@ static void writeIndex(OutputList &ol) { ol.startHeaderSection(); ol.startTitleHead(0); - ol.generateDoc(Doxygen::mainPage->docFile(),Doxygen::mainPage->topLine(), + ol.generateDoc(Doxygen::mainPage->docFile(),Doxygen::mainPage->getStartBodyLine(), Doxygen::mainPage,0,Doxygen::mainPage->title(),TRUE,FALSE, 0,TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); headerWritten = TRUE; diff --git a/src/pagedef.cpp b/src/pagedef.cpp index cad0615..12a7bdc 100644 --- a/src/pagedef.cpp +++ b/src/pagedef.cpp @@ -32,13 +32,12 @@ class PageDefImpl : public DefinitionImpl, public PageDef { public: - PageDefImpl(const char *f,int l,int p,const char *n,const char *d,const char *t); + PageDefImpl(const char *f,int l,const char *n,const char *d,const char *t); virtual ~PageDefImpl(); virtual void setFileName(const char *name); virtual void setLocalToc(const LocalToc &tl); virtual void setShowLineNo(bool); - virtual void setTopLine(int); virtual DefType definitionType() const { return TypePage; } virtual bool isLinkableInProject() const { return /*hasDocumentation() &&*/ !isReference(); } virtual bool isLinkable() const { return isLinkableInProject() || isReference(); } @@ -59,7 +58,6 @@ class PageDefImpl : public DefinitionImpl, public PageDef virtual Definition *getPageScope() const { return m_pageScope; } virtual QCString displayName(bool=TRUE) const { return hasTitle() ? m_title : DefinitionImpl::name(); } virtual bool showLineNo() const; - virtual int topLine() const; virtual void writeDocumentation(OutputList &ol); virtual void writeTagFile(FTextStream &); virtual void setNestingLevel(int l); @@ -73,17 +71,16 @@ class PageDefImpl : public DefinitionImpl, public PageDef int m_nestingLevel; LocalToc m_localToc; bool m_showLineNo; - int m_topLine; }; -PageDef *createPageDef(const char *f,int l,int p,const char *n,const char *d,const char *t) +PageDef *createPageDef(const char *f,int l,const char *n,const char *d,const char *t) { - return new PageDefImpl(f,l,p,n,d,t); + return new PageDefImpl(f,l,n,d,t); } //------------------------------------------------------------------------------------------ -PageDefImpl::PageDefImpl(const char *f,int l,int p,const char *n, +PageDefImpl::PageDefImpl(const char *f,int l,const char *n, const char *d,const char *t) : DefinitionImpl(f,l,1,n), m_title(t) { @@ -93,7 +90,6 @@ PageDefImpl::PageDefImpl(const char *f,int l,int p,const char *n, m_nestingLevel = 0; m_fileName = ::convertNameToFile(n,FALSE,TRUE); m_showLineNo = FALSE; - m_topLine=p; } PageDefImpl::~PageDefImpl() @@ -234,7 +230,7 @@ void PageDefImpl::writeDocumentation(OutputList &ol) if (si->title() != manPageName) { - ol.generateDoc(docFile(),topLine(),this,0,si->title(),TRUE,FALSE, + ol.generateDoc(docFile(),getStartBodyLine(),this,0,si->title(),TRUE,FALSE, 0,TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); ol.endSection(si->label(),si->type()); } @@ -254,7 +250,7 @@ void PageDefImpl::writeDocumentation(OutputList &ol) ol.startPageDoc(si->title()); //ol.startSection(si->label,si->title,si->type); startTitle(ol,getOutputFileBase(),this); - ol.generateDoc(docFile(),topLine(),this,0,si->title(),TRUE,FALSE, + ol.generateDoc(docFile(),getStartBodyLine(),this,0,si->title(),TRUE,FALSE, 0,TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); //stringToSearchIndex(getOutputFileBase(), // theTranslator->trPage(TRUE,TRUE)+" "+si->title, @@ -398,16 +394,6 @@ bool PageDefImpl::showLineNo() const return m_showLineNo; } -void PageDefImpl::setTopLine(int p) -{ - m_topLine = p; -} - -int PageDefImpl::topLine() const -{ - return m_topLine; -} - bool PageDefImpl::hasTitle() const { return !m_title.isEmpty() && m_title.lower()!="notitle"; diff --git a/src/pagedef.h b/src/pagedef.h index 5190405..a1f08a5 100644 --- a/src/pagedef.h +++ b/src/pagedef.h @@ -1,12 +1,10 @@ /****************************************************************************** * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2020 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -35,7 +33,6 @@ class PageDef : virtual public Definition virtual void setFileName(const char *name) = 0; virtual void setLocalToc(const LocalToc &tl) = 0; virtual void setShowLineNo(bool) = 0; - virtual void setTopLine(int) = 0; // getters virtual DefType definitionType() const = 0; @@ -58,7 +55,6 @@ class PageDef : virtual public Definition virtual Definition *getPageScope() const = 0; virtual QCString displayName(bool=TRUE) const = 0; virtual bool showLineNo() const = 0; - virtual int topLine() const = 0; virtual void writeDocumentation(OutputList &) = 0; virtual void writeTagFile(FTextStream &) = 0; @@ -67,7 +63,7 @@ class PageDef : virtual public Definition }; -PageDef *createPageDef(const char *f,int l,int p,const char *n,const char *d,const char *t); +PageDef *createPageDef(const char *f,int l,const char *n,const char *d,const char *t); class PageSDict : public SDict { diff --git a/src/util.cpp b/src/util.cpp index 84e197b..e8c431f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -6004,7 +6004,9 @@ found: PageDef *addRelatedPage(const char *name,const QCString &ptitle, const QCString &doc, - const char *fileName,int startLine,int topLine, + const char *fileName, + int docLine, + int startLine, const RefItemVector &sli, GroupDef *gd, const TagInfo *tagInfo, @@ -6016,10 +6018,10 @@ PageDef *addRelatedPage(const char *name,const QCString &ptitle, //printf("addRelatedPage(name=%s gd=%p)\n",name,gd); if ((pd=Doxygen::pageSDict->find(name)) && !tagInfo) { - if (!xref) warn(fileName,topLine,"multiple use of page label '%s', (other occurrence: %s, line: %d)", - name,pd->docFile().data(),pd->topLine()); + if (!xref) warn(fileName,startLine,"multiple use of page label '%s', (other occurrence: %s, line: %d)", + name,pd->docFile().data(),pd->getStartBodyLine()); // append documentation block to the page. - pd->setDocumentation(doc,fileName,startLine); + pd->setDocumentation(doc,fileName,docLine); //printf("Adding page docs '%s' pi=%p name=%s\n",doc.data(),pd,name); // append (x)refitems to the page. pd->setRefItems(sli); @@ -6033,7 +6035,8 @@ PageDef *addRelatedPage(const char *name,const QCString &ptitle, baseName=baseName.left(baseName.length()-Doxygen::htmlFileExtension.length()); QCString title=ptitle.stripWhiteSpace(); - pd=createPageDef(fileName,startLine,topLine,baseName,doc,title); + pd=createPageDef(fileName,docLine,baseName,doc,title); + pd->setBodySegment(startLine,startLine,-1); pd->setRefItems(sli); pd->setLanguage(lang); @@ -6066,7 +6069,7 @@ PageDef *addRelatedPage(const char *name,const QCString &ptitle, { file=pd->getOutputFileBase(); orgFile=pd->docFile(); - line = pd->topLine(); + line = pd->getStartBodyLine(); } const SectionInfo *si = SectionManager::instance().find(pd->name()); if (si) diff --git a/src/util.h b/src/util.h index 3a5df60..6d80256 100644 --- a/src/util.h +++ b/src/util.h @@ -337,7 +337,9 @@ void addRefItem(const RefItemVector &sli, PageDef *addRelatedPage(const char *name, const QCString &ptitle, const QCString &doc, - const char *fileName,int startLine,int topLine, + const char *fileName, + int docLine, + int startLine, const RefItemVector &sli = RefItemVector(), GroupDef *gd=0, const TagInfo *tagInfo=0, -- cgit v0.12