From bc83eb68e2fd31faa4b1ca7bb6610b30c0a24659 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Thu, 9 Apr 2020 20:59:23 +0200 Subject: Fixed shadowing issue in getFortranDefs and other shadowing cases --- cmake/CompilerWarnings.cmake | 4 +- src/clangparser.cpp | 9 ++- src/code.l | 4 +- src/doxygen.cpp | 4 +- src/fortrancode.l | 25 +++--- src/index.cpp | 11 ++- src/pre.l | 4 +- src/rtfdocvisitor.cpp | 188 +++++++++++++++++++++---------------------- src/rtfgen.cpp | 77 +++++++++--------- src/rtfstyle.cpp | 34 +++----- src/rtfstyle.h | 30 +++---- src/sqlite3gen.cpp | 4 +- src/util.cpp | 14 ++-- 13 files changed, 197 insertions(+), 211 deletions(-) diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index b7c6a54..41ee545 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -71,8 +71,8 @@ function(set_project_warnings project_name) set(GCC_WARNINGS -Wall -Wextra # reasonable and standard - #-Wshadow # warn the user if a variable declaration shadows one from a - # # parent context + -Wshadow # warn the user if a variable declaration shadows one from a + # parent context $<$:-Wnon-virtual-dtor> # warn the user if a class with virtual functions has a # non-virtual destructor. This helps catch hard to diff --git a/src/clangparser.cpp b/src/clangparser.cpp index 1ff30b0..c7639ea 100644 --- a/src/clangparser.cpp +++ b/src/clangparser.cpp @@ -276,7 +276,7 @@ void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit) static bool filterSourceFiles = Config_getBool(FILTER_SOURCE_FILES); //printf("source %s ----------\n%s\n-------------\n\n", // fileName,p->source.data()); - uint numUnsavedFiles = filesInTranslationUnit.count()+1; + int numUnsavedFiles = filesInTranslationUnit.count()+1; p->numFiles = numUnsavedFiles; p->sources = new QCString[numUnsavedFiles]; p->ufs = new CXUnsavedFile[numUnsavedFiles]; @@ -285,7 +285,7 @@ void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit) p->ufs[0].Contents = p->sources[0].data(); p->ufs[0].Length = p->sources[0].length(); QStrListIterator it(filesInTranslationUnit); - uint i=1; + int i=1; for (it.toFirst();it.current() && ifileMapping.insert(it.current(),new uint(i)); @@ -300,7 +300,7 @@ void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit) argv, argc, p->ufs, numUnsavedFiles, CXTranslationUnit_DetailedPreprocessingRecord); // free arguments - for (int i=0;itu); i!=n; ++i) + int n=clang_getNumDiagnostics(p->tu); + for (i=0; i!=n; ++i) { CXDiagnostic diag = clang_getDiagnostic(p->tu, i); CXString string = clang_formatDiagnostic(diag, diff --git a/src/code.l b/src/code.l index a5222f7..a01f0f8 100644 --- a/src/code.l +++ b/src/code.l @@ -588,8 +588,8 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" auto it = std::find_if(fn->begin(), fn->end(), [&sfd=yyextra->sourceFileDef] - (const auto &fd) - { return sfd->isIncluded(fd->absFilePath()); }); + (const auto &lfd) + { return sfd->isIncluded(lfd->absFilePath()); }); found = it!=fn->end(); } } diff --git a/src/doxygen.cpp b/src/doxygen.cpp index c1b8745..3cf3596 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -5825,7 +5825,7 @@ static void addMemberSpecialization(const Entry *root, //------------------------------------------------------------------------------------------- -static void addOverloaded(const Entry *root,MemberName *mn,ClassDef *cd, +static void addOverloaded(const Entry *root,MemberName *mn, const QCString &funcType,const QCString &funcName,const QCString &funcArgs, const QCString &funcDecl,const QCString &exceptions,uint64 spec) { @@ -6249,7 +6249,7 @@ static void findMember(const Entry *root, } else if (overloaded) // check if the function belongs to only one class { - addOverloaded(root,mn,cd,funcType,funcName,funcArgs,funcDecl,exceptions,spec); + addOverloaded(root,mn,funcType,funcName,funcArgs,funcDecl,exceptions,spec); } else // unrelated function with the same name as a member { diff --git a/src/fortrancode.l b/src/fortrancode.l index d7b006f..b2e2e7b 100644 --- a/src/fortrancode.l +++ b/src/fortrancode.l @@ -434,14 +434,13 @@ static bool getFortranTypeDefs(const QCString &tname, const QCString &moduleName searches for definition of function memberName @param memberName the name of the function/variable @param moduleName name of enclosing module or null, if global entry - @param md the entry, if found or null @param usedict array of data of USE-statement - @returns true, if found + @returns MemberDef pointer, if found, or nullptr otherwise */ -static bool getFortranDefs(const QCString &memberName, const QCString &moduleName, - MemberDef *&md, UseSDict *usedict=0) +static MemberDef *getFortranDefs(const QCString &memberName, const QCString &moduleName, + UseSDict *usedict=0) { - if (memberName.isEmpty()) return FALSE; /* empty name => nothing to link */ + if (memberName.isEmpty()) return nullptr; /* empty name => nothing to link */ // look in local variables QListIterator it(scopeStack); @@ -449,7 +448,9 @@ static bool getFortranDefs(const QCString &memberName, const QCString &moduleNam for (it.toLast();(scope=it.current());--it) { if (scope->localVars.find(memberName) && (!scope->externalVars.find(memberName))) - return FALSE; + { + return nullptr; + } } // search for function @@ -479,12 +480,12 @@ static bool getFortranDefs(const QCString &memberName, const QCString &moduleNam { // found function in global scope if(cd == 0) { // Skip if bound to type - return TRUE; + return md.get(); } } else if (moduleName == nspace->name()) { // found in local scope - return TRUE; + return md.get(); } else { // else search in used modules @@ -497,7 +498,7 @@ static bool getFortranDefs(const QCString &memberName, const QCString &moduleNam if (only.isEmpty()) { //cout << " found in module " << usedModuleName << " entry " << memberName << endl; - return TRUE; // whole module used + return md.get(); // whole module used } else { @@ -506,7 +507,7 @@ static bool getFortranDefs(const QCString &memberName, const QCString &moduleNam //cout << " search in only: " << usedModuleName << ":: " << memberName << "==" << (*it)<< endl; if (memberName == *lit) { - return TRUE; // found in ONLY-part of use list + return md.get(); // found in ONLY-part of use list } } } @@ -515,7 +516,7 @@ static bool getFortranDefs(const QCString &memberName, const QCString &moduleNam } // if linkable } // for } - return FALSE; + return nullptr; } /** @@ -540,7 +541,7 @@ static bool getLink(UseSDict *usedict, // dictionary with used modules MemberDef *md=0; QCString memberName= removeRedundantWhiteSpace(memberText); - if (getFortranDefs(memberName, currentModule, md, usedict) && md->isLinkable()) + if ((md=getFortranDefs(memberName, currentModule, usedict)) && md->isLinkable()) { if (md->isVariable() && (md->getLanguage()!=SrcLangExt_Fortran)) return FALSE; // Non Fortran variables aren't handled yet, // see also linkifyText in util.cpp diff --git a/src/index.cpp b/src/index.cpp index 7890898..fd61a45 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -760,7 +760,7 @@ static void writeDirHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex) ol.pushGeneratorState(); ol.disable(OutputGenerator::Html); } - static bool fullPathNames = Config_getBool(FULL_PATH_NAMES); + bool fullPathNames = Config_getBool(FULL_PATH_NAMES); startIndexHierarchy(ol,0); if (fullPathNames) { @@ -780,11 +780,10 @@ static void writeDirHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex) { for (const auto &fd : *fn) { - static bool fullPathNames = Config_getBool(FULL_PATH_NAMES); if (!fullPathNames || fd->getDirDef()==0) // top level file { - bool doc,src; - doc = fileVisibleInIndex(fd.get(),src); + bool src; + bool doc = fileVisibleInIndex(fd.get(),src); QCString reference, outputBase; if (doc) { @@ -2021,8 +2020,8 @@ class AlphaIndexTableRows : public QList class AlphaIndexTableRowsIterator : public QListIterator { public: - AlphaIndexTableRowsIterator(const AlphaIndexTableRows &list) : - QListIterator(list) {} + AlphaIndexTableRowsIterator(const AlphaIndexTableRows &list_) : + QListIterator(list_) {} }; /** Class representing the columns in the alphabetical class index. */ diff --git a/src/pre.l b/src/pre.l index 3e3d2f8..18394ad 100644 --- a/src/pre.l +++ b/src/pre.l @@ -1791,8 +1791,8 @@ static FileState *checkAndOpenFile(yyscan_t yyscanner,const QCString &fileName,b alreadyIncluded = std::any_of( state->includeStack.begin(), state->includeStack.end(), - [absName](const std::unique_ptr &fs) - { return fs->fileName==absName; } + [absName](const std::unique_ptr &lfs) + { return lfs->fileName==absName; } ); if (alreadyIncluded) diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp index f9b30f7..fbe7cc1 100644 --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -1,13 +1,13 @@ /****************************************************************************** * - * + * * * * Copyright (C) 1997-2015 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. * @@ -44,13 +44,13 @@ static QCString align(DocHtmlCell *cell) { HtmlAttribList attrs = cell->attribs(); uint i; - for (i=0; iname.lower()=="align") { - if (attrs.at(i)->value.lower()=="center") + if (attrs.at(i)->value.lower()=="center") return "\\qc "; - else if (attrs.at(i)->value.lower()=="right") + else if (attrs.at(i)->value.lower()=="right") return "\\qr "; else return ""; } @@ -59,8 +59,8 @@ static QCString align(DocHtmlCell *cell) } RTFDocVisitor::RTFDocVisitor(FTextStream &t,CodeOutputInterface &ci, - const char *langExt) - : DocVisitor(DocVisitor_RTF), m_t(t), m_ci(ci), m_insidePre(FALSE), + const char *langExt) + : DocVisitor(DocVisitor_RTF), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE), m_indentLevel(0), m_lastIsPara(FALSE), m_langExt(langExt) { } @@ -71,7 +71,7 @@ QCString RTFDocVisitor::getStyle(const char *name) n.sprintf("%s%d",name,m_indentLevel); StyleData *sd = rtf_Style[n]; ASSERT(sd!=0); - return sd->reference; + return sd->reference(); } void RTFDocVisitor::incIndentLevel() @@ -213,7 +213,7 @@ void RTFDocVisitor::visit(DocLineBreak *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visit(DocLineBreak)}\n"); - m_t << "\\par" << endl; + m_t << "\\par" << endl; m_lastIsPara=TRUE; } @@ -309,34 +309,34 @@ void RTFDocVisitor::visit(DocVerbatim *s) Doxygen::parserManager->getCodeParser(lang) .parseCode(m_ci,s->context(),s->text(),langExt, s->isExample(),s->exampleFile()); - //m_t << "\\par" << endl; + //m_t << "\\par" << endl; m_t << "}" << endl; break; - case DocVerbatim::Verbatim: + case DocVerbatim::Verbatim: m_t << "{" << endl; m_t << "\\par" << endl; m_t << rtf_Style_Reset << getStyle("CodeExample"); filter(s->text(),TRUE); - //m_t << "\\par" << endl; + //m_t << "\\par" << endl; m_t << "}" << endl; break; - case DocVerbatim::RtfOnly: - m_t << s->text(); + case DocVerbatim::RtfOnly: + m_t << s->text(); break; - case DocVerbatim::HtmlOnly: - case DocVerbatim::LatexOnly: - case DocVerbatim::XmlOnly: + case DocVerbatim::HtmlOnly: + case DocVerbatim::LatexOnly: + case DocVerbatim::XmlOnly: case DocVerbatim::ManOnly: case DocVerbatim::DocbookOnly: /* nothing */ break; - case DocVerbatim::Dot: + case DocVerbatim::Dot: { static int dotindex = 1; QCString fileName(4096); - fileName.sprintf("%s%d%s", - (Config_getString(RTF_OUTPUT)+"/inline_dotgraph_").data(), + fileName.sprintf("%s%d%s", + (Config_getString(RTF_OUTPUT)+"/inline_dotgraph_").data(), dotindex++, ".dot" ); @@ -355,13 +355,13 @@ void RTFDocVisitor::visit(DocVerbatim *s) if (Config_getBool(DOT_CLEANUP)) file.remove(); } break; - case DocVerbatim::Msc: + case DocVerbatim::Msc: { static int mscindex = 1; QCString baseName(4096); baseName.sprintf("%s%d%s", - (Config_getString(RTF_OUTPUT)+"/inline_mscgraph_").data(), + (Config_getString(RTF_OUTPUT)+"/inline_mscgraph_").data(), mscindex++, ".msc" ); @@ -427,7 +427,7 @@ void RTFDocVisitor::visit(DocInclude *inc) switch(inc->type()) { case DocInclude::IncWithLines: - { + { m_t << "{" << endl; m_t << "\\par" << endl; m_t << rtf_Style_Reset << getStyle("CodeExample"); @@ -451,7 +451,7 @@ void RTFDocVisitor::visit(DocInclude *inc) m_t << "}" << endl; } break; - case DocInclude::Include: + case DocInclude::Include: m_t << "{" << endl; m_t << "\\par" << endl; m_t << rtf_Style_Reset << getStyle("CodeExample"); @@ -480,7 +480,7 @@ void RTFDocVisitor::visit(DocInclude *inc) case DocInclude::RtfInclude: m_t << inc->text(); break; - case DocInclude::VerbInclude: + case DocInclude::VerbInclude: m_t << "{" << endl; m_t << "\\par" << endl; m_t << rtf_Style_Reset << getStyle("CodeExample"); @@ -515,7 +515,7 @@ void RTFDocVisitor::visit(DocInclude *inc) extractBlock(inc->text(),inc->blockId()), langExt, inc->isExample(), - inc->exampleFile(), + inc->exampleFile(), fd, lineBlock(inc->text(),inc->blockId()), -1, // endLine @@ -527,8 +527,8 @@ void RTFDocVisitor::visit(DocInclude *inc) m_t << "}"; } break; - case DocInclude::SnippetDoc: - case DocInclude::IncludeDoc: + case DocInclude::SnippetDoc: + case DocInclude::IncludeDoc: err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s" "Please create a bug report\n",__FILE__); break; @@ -544,7 +544,7 @@ void RTFDocVisitor::visit(DocIncOperator *op) QCString locLangExt = getFileNameExtension(op->includeFileName()); if (locLangExt.isEmpty()) locLangExt = m_langExt; SrcLangExt langExt = getLanguageFromFileName(locLangExt); - if (op->isFirst()) + if (op->isFirst()) { if (!m_hide) { @@ -555,10 +555,10 @@ void RTFDocVisitor::visit(DocIncOperator *op) pushEnabled(); m_hide = TRUE; } - if (op->type()!=DocIncOperator::Skip) + if (op->type()!=DocIncOperator::Skip) { popEnabled(); - if (!m_hide) + if (!m_hide) { FileDef *fd = 0; if (!op->includeFileName().isEmpty()) @@ -582,7 +582,7 @@ void RTFDocVisitor::visit(DocIncOperator *op) pushEnabled(); m_hide=TRUE; } - if (op->isLast()) + if (op->isLast()) { popEnabled(); if (!m_hide) @@ -604,7 +604,7 @@ void RTFDocVisitor::visit(DocFormula *f) if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visit(DocFormula)}\n"); bool bDisplay = !f->isInline(); - if (bDisplay) + if (bDisplay) { m_t << "\\par"; m_t << "{"; @@ -613,7 +613,7 @@ void RTFDocVisitor::visit(DocFormula *f) m_t << "\\qc"; } m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"" << f->relPath() << f->name() << ".png\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}"; - if (bDisplay) + if (bDisplay) { m_t << "\\par}"; } @@ -636,7 +636,7 @@ void RTFDocVisitor::visit(DocCite *cite) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocCite)}\n"); - if (!cite->file().isEmpty()) + if (!cite->file().isEmpty()) { startLink(cite->ref(),cite->file(),cite->anchor()); } @@ -645,7 +645,7 @@ void RTFDocVisitor::visit(DocCite *cite) m_t << "{\\b "; } filter(cite->text()); - if (!cite->file().isEmpty()) + if (!cite->file().isEmpty()) { endLink(cite->ref()); } @@ -700,13 +700,13 @@ void RTFDocVisitor::visitPre(DocAutoListItem *) m_lastIsPara=FALSE; } -void RTFDocVisitor::visitPost(DocAutoListItem *) +void RTFDocVisitor::visitPost(DocAutoListItem *) { decIndentLevel(); DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocAutoListItem)}\n"); } -void RTFDocVisitor::visitPre(DocPara *) +void RTFDocVisitor::visitPre(DocPara *) { DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocPara)}\n"); } @@ -720,7 +720,7 @@ void RTFDocVisitor::visitPost(DocPara *p) !(p->parent() && // and for parameters & sections p->parent()->kind()==DocNode::Kind_ParamSect ) - ) + ) { m_t << "\\par" << endl; m_lastIsPara=TRUE; @@ -732,7 +732,7 @@ void RTFDocVisitor::visitPre(DocRoot *r) if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocRoot)}\n"); if (r->indent()) incIndentLevel(); - m_t << "{" << rtf_Style["BodyText"]->reference << endl; + m_t << "{" << rtf_Style["BodyText"]->reference() << endl; } void RTFDocVisitor::visitPost(DocRoot *r) @@ -752,24 +752,24 @@ void RTFDocVisitor::visitPre(DocSimpleSect *s) if (!m_lastIsPara) m_t << "\\par" << endl; m_t << "{"; // start desc //m_t << "{\\b "; // start bold - m_t << "{" << rtf_Style["Heading5"]->reference << endl; + m_t << "{" << rtf_Style["Heading5"]->reference() << endl; switch(s->type()) { - case DocSimpleSect::See: + case DocSimpleSect::See: m_t << theTranslator->trSeeAlso(); break; - case DocSimpleSect::Return: + case DocSimpleSect::Return: m_t << theTranslator->trReturns(); break; - case DocSimpleSect::Author: + case DocSimpleSect::Author: m_t << theTranslator->trAuthor(TRUE,TRUE); break; - case DocSimpleSect::Authors: + case DocSimpleSect::Authors: m_t << theTranslator->trAuthor(TRUE,FALSE); break; - case DocSimpleSect::Version: + case DocSimpleSect::Version: m_t << theTranslator->trVersion(); break; - case DocSimpleSect::Since: + case DocSimpleSect::Since: m_t << theTranslator->trSince(); break; - case DocSimpleSect::Date: + case DocSimpleSect::Date: m_t << theTranslator->trDate(); break; - case DocSimpleSect::Note: + case DocSimpleSect::Note: m_t << theTranslator->trNote(); break; case DocSimpleSect::Warning: m_t << theTranslator->trWarning(); break; @@ -856,7 +856,7 @@ void RTFDocVisitor::visitPre(DocSimpleListItem *) incIndentLevel(); } -void RTFDocVisitor::visitPost(DocSimpleListItem *) +void RTFDocVisitor::visitPost(DocSimpleListItem *) { decIndentLevel(); DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleListItem)}\n"); @@ -875,7 +875,7 @@ void RTFDocVisitor::visitPre(DocSection *s) int level = QMIN(s->level()+1,4); heading.sprintf("Heading%d",level); // set style - m_t << rtf_Style[heading]->reference << endl; + m_t << rtf_Style[heading]->reference() << endl; // make table of contents entry filter(s->title()); m_t << endl << "\\par" << "}" << endl; @@ -885,7 +885,7 @@ void RTFDocVisitor::visitPre(DocSection *s) m_lastIsPara=TRUE; } -void RTFDocVisitor::visitPost(DocSection *) +void RTFDocVisitor::visitPost(DocSection *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSection)}\n"); @@ -898,12 +898,12 @@ void RTFDocVisitor::visitPre(DocHtmlList *l) if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlList)}\n"); m_t << "{" << endl; - rtf_listItemInfo[m_indentLevel].isEnum = l->type()==DocHtmlList::Ordered; + rtf_listItemInfo[m_indentLevel].isEnum = l->type()==DocHtmlList::Ordered; rtf_listItemInfo[m_indentLevel].number = 1; m_lastIsPara=FALSE; } -void RTFDocVisitor::visitPost(DocHtmlList *) +void RTFDocVisitor::visitPost(DocHtmlList *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlList)}\n"); @@ -931,7 +931,7 @@ void RTFDocVisitor::visitPre(DocHtmlListItem *) m_lastIsPara=FALSE; } -void RTFDocVisitor::visitPost(DocHtmlListItem *) +void RTFDocVisitor::visitPost(DocHtmlListItem *) { decIndentLevel(); DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlListItem)}\n"); @@ -946,7 +946,7 @@ void RTFDocVisitor::visitPre(DocHtmlDescList *) //m_lastIsPara=FALSE; } -void RTFDocVisitor::visitPost(DocHtmlDescList *) +void RTFDocVisitor::visitPost(DocHtmlDescList *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlDescList)}\n"); @@ -961,11 +961,11 @@ void RTFDocVisitor::visitPre(DocHtmlDescTitle *) DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlDescTitle)}\n"); //m_t << "\\par" << endl; //m_t << "{\\b "; - m_t << "{" << rtf_Style["Heading5"]->reference << endl; + m_t << "{" << rtf_Style["Heading5"]->reference() << endl; m_lastIsPara=FALSE; } -void RTFDocVisitor::visitPost(DocHtmlDescTitle *) +void RTFDocVisitor::visitPost(DocHtmlDescTitle *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlDescTitle)}\n"); @@ -982,7 +982,7 @@ void RTFDocVisitor::visitPre(DocHtmlDescData *) m_t << "{" << rtf_Style_Reset << getStyle("DescContinue"); } -void RTFDocVisitor::visitPost(DocHtmlDescData *) +void RTFDocVisitor::visitPost(DocHtmlDescData *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlDescData)}\n"); @@ -1000,7 +1000,7 @@ void RTFDocVisitor::visitPre(DocHtmlTable *) m_lastIsPara=TRUE; } -void RTFDocVisitor::visitPost(DocHtmlTable *) +void RTFDocVisitor::visitPost(DocHtmlTable *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlTable)}\n"); @@ -1016,7 +1016,7 @@ void RTFDocVisitor::visitPre(DocHtmlCaption *) m_t << "{Table \\field\\flddirty{\\*\\fldinst { SEQ Table \\\\*Arabic }}{\\fldrslt {\\noproof 1}} "; } -void RTFDocVisitor::visitPost(DocHtmlCaption *) +void RTFDocVisitor::visitPost(DocHtmlCaption *) { DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlCaption)}\n"); m_t << "}\n\\par" << endl; @@ -1051,7 +1051,7 @@ void RTFDocVisitor::visitPre(DocHtmlRow *r) m_lastIsPara=FALSE; } -void RTFDocVisitor::visitPost(DocHtmlRow *) +void RTFDocVisitor::visitPost(DocHtmlRow *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlRow)}\n"); @@ -1069,7 +1069,7 @@ void RTFDocVisitor::visitPre(DocHtmlCell *c) m_lastIsPara=FALSE; } -void RTFDocVisitor::visitPost(DocHtmlCell *) +void RTFDocVisitor::visitPost(DocHtmlCell *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlCell)}\n"); @@ -1091,7 +1091,7 @@ void RTFDocVisitor::visitPre(DocInternal *) //m_lastIsPara=FALSE; } -void RTFDocVisitor::visitPost(DocInternal *) +void RTFDocVisitor::visitPost(DocInternal *) { if (m_hide) return; //DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocInternal)}\n"); @@ -1139,12 +1139,12 @@ void RTFDocVisitor::visitPre(DocHRef *href) m_lastIsPara=FALSE; } -void RTFDocVisitor::visitPost(DocHRef *) +void RTFDocVisitor::visitPost(DocHRef *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHRef)}\n"); if (Config_getBool(RTF_HYPERLINKS)) - { + { m_t << "}" "}" "}"; @@ -1166,13 +1166,13 @@ void RTFDocVisitor::visitPre(DocHtmlHeader *header) int level = QMIN(header->level(),5); heading.sprintf("Heading%d",level); // set style - m_t << rtf_Style[heading]->reference; + m_t << rtf_Style[heading]->reference(); // make open table of contents entry that will be closed in visitPost method m_t << "{\\tc\\tcl" << level << " "; m_lastIsPara=FALSE; } -void RTFDocVisitor::visitPost(DocHtmlHeader *) +void RTFDocVisitor::visitPost(DocHtmlHeader *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlHeader)}\n"); @@ -1264,7 +1264,7 @@ void RTFDocVisitor::visitPre(DocDotFile *df) writeDotFile(df); } -void RTFDocVisitor::visitPost(DocDotFile *df) +void RTFDocVisitor::visitPost(DocDotFile *df) { DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocDotFile)}\n"); includePicturePostRTF(true, df->hasCaption()); @@ -1275,7 +1275,7 @@ void RTFDocVisitor::visitPre(DocMscFile *df) writeMscFile(df); } -void RTFDocVisitor::visitPost(DocMscFile *df) +void RTFDocVisitor::visitPost(DocMscFile *df) { DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocMscFile)}\n"); includePicturePostRTF(true, df->hasCaption()); @@ -1300,7 +1300,7 @@ void RTFDocVisitor::visitPre(DocLink *lnk) startLink(lnk->ref(),lnk->file(),lnk->anchor()); } -void RTFDocVisitor::visitPost(DocLink *lnk) +void RTFDocVisitor::visitPost(DocLink *lnk) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocLink)}\n"); @@ -1324,7 +1324,7 @@ void RTFDocVisitor::visitPre(DocRef *ref) if (!ref->hasLinkText()) filter(ref->targetTitle()); } -void RTFDocVisitor::visitPost(DocRef *ref) +void RTFDocVisitor::visitPost(DocRef *ref) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocRef)}\n"); @@ -1338,7 +1338,7 @@ void RTFDocVisitor::visitPre(DocSecRefItem *) DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocSecRefItem)}\n"); } -void RTFDocVisitor::visitPost(DocSecRefItem *) +void RTFDocVisitor::visitPost(DocSecRefItem *) { DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSecRefItem)}\n"); } @@ -1354,7 +1354,7 @@ void RTFDocVisitor::visitPre(DocSecRefList *) m_lastIsPara=TRUE; } -void RTFDocVisitor::visitPost(DocSecRefList *) +void RTFDocVisitor::visitPost(DocSecRefList *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSecRefList)}\n"); @@ -1375,7 +1375,7 @@ void RTFDocVisitor::visitPost(DocSecRefList *) // } //} // -//void RTFDocVisitor::visitPost(DocLanguage *l) +//void RTFDocVisitor::visitPost(DocLanguage *l) //{ // DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocLanguage)}\n"); // QCString langId = Config_getEnum(OUTPUT_LANGUAGE); @@ -1392,16 +1392,16 @@ void RTFDocVisitor::visitPre(DocParamSect *s) m_t << "{"; // start param list if (!m_lastIsPara) m_t << "\\par" << endl; //m_t << "{\\b "; // start bold - m_t << "{" << rtf_Style["Heading5"]->reference << endl; + m_t << "{" << rtf_Style["Heading5"]->reference() << endl; switch(s->type()) { - case DocParamSect::Param: + case DocParamSect::Param: m_t << theTranslator->trParameters(); break; - case DocParamSect::RetVal: + case DocParamSect::RetVal: m_t << theTranslator->trReturnValues(); break; - case DocParamSect::Exception: + case DocParamSect::Exception: m_t << theTranslator->trExceptions(); break; - case DocParamSect::TemplateParam: + case DocParamSect::TemplateParam: m_t << theTranslator->trTemplateParameters(); break; default: ASSERT(0); @@ -1438,7 +1438,7 @@ void RTFDocVisitor::visitPost(DocParamSect *s) void RTFDocVisitor::visitPre(DocParamList *pl) { - static int columnPos[4][5] = + static int columnPos[4][5] = { { 2, 25, 100, 100, 100 }, // no inout, no type { 3, 14, 35, 100, 100 }, // inout, no type { 3, 25, 50, 100, 100 }, // no inout, type @@ -1525,11 +1525,11 @@ void RTFDocVisitor::visitPre(DocParamList *pl) { if (type->kind()==DocNode::Kind_Word) { - visit((DocWord*)type); + visit((DocWord*)type); } else if (type->kind()==DocNode::Kind_LinkedWord) { - visit((DocLinkedWord*)type); + visit((DocLinkedWord*)type); } else if (type->kind()==DocNode::Kind_Sep) { @@ -1541,7 +1541,7 @@ void RTFDocVisitor::visitPre(DocParamList *pl) m_t << "\\cell }"; } } - + if (useTable) { @@ -1559,11 +1559,11 @@ void RTFDocVisitor::visitPre(DocParamList *pl) if (!first) m_t << ","; else first=FALSE; if (param->kind()==DocNode::Kind_Word) { - visit((DocWord*)param); + visit((DocWord*)param); } else if (param->kind()==DocNode::Kind_LinkedWord) { - visit((DocLinkedWord*)param); + visit((DocLinkedWord*)param); } } m_t << "} "; @@ -1618,7 +1618,7 @@ void RTFDocVisitor::visitPre(DocXRefItem *x) } m_t << "{"; // start param list //m_t << "{\\b "; // start bold - m_t << "{" << rtf_Style["Heading5"]->reference << endl; + m_t << "{" << rtf_Style["Heading5"]->reference() << endl; if (Config_getBool(RTF_HYPERLINKS) && !anonymousEnum) { QCString refName; @@ -1677,7 +1677,7 @@ void RTFDocVisitor::visitPre(DocInternalRef *ref) startLink("",ref->file(),ref->anchor()); } -void RTFDocVisitor::visitPost(DocInternalRef *) +void RTFDocVisitor::visitPost(DocInternalRef *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocInternalRef)}\n"); @@ -1704,7 +1704,7 @@ void RTFDocVisitor::visitPre(DocHtmlBlockQuote *) if (!m_lastIsPara) m_t << "\\par" << endl; m_t << "{"; // start desc incIndentLevel(); - m_t << rtf_Style_Reset << getStyle("DescContinue"); + m_t << rtf_Style_Reset << getStyle("DescContinue"); } void RTFDocVisitor::visitPost(DocHtmlBlockQuote *) @@ -1746,7 +1746,7 @@ void RTFDocVisitor::visitPost(DocParBlock *) //} void RTFDocVisitor::filter(const char *str,bool verbatim) -{ +{ if (str) { const unsigned char *p=(const unsigned char *)str; @@ -1777,7 +1777,7 @@ void RTFDocVisitor::filter(const char *str,bool verbatim) case '\\': m_t << "\\\\"; break; case '\n': if (verbatim) { - m_t << "\\par" << endl; + m_t << "\\par" << endl; } else { @@ -1858,7 +1858,7 @@ void RTFDocVisitor::writeDotFile(const QCString &filename, bool hasCaption) if ((i=baseName.findRev('/'))!=-1) { baseName=baseName.right(baseName.length()-i-1); - } + } QCString outDir = Config_getString(RTF_OUTPUT); writeDotGraphFromFile(filename,outDir,baseName,GOF_BITMAP); QCString imgExt = getDotImageExtension(); @@ -1876,7 +1876,7 @@ void RTFDocVisitor::writeMscFile(const QCString &fileName, bool hasCaption) if ((i=baseName.findRev('/'))!=-1) { baseName=baseName.right(baseName.length()-i-1); - } + } QCString outDir = Config_getString(RTF_OUTPUT); writeMscGraphFromFile(fileName,outDir,baseName,MSC_BITMAP); includePicturePreRTF(baseName + ".png", true, hasCaption); diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index 77455cb..97d96d2 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -287,7 +287,7 @@ void RTFGenerator::beginRTFDocument() unsigned maxIndex = 0; for(; (style = iter.current()); ++iter) { - unsigned index = style->index; + uint index = style->index(); if (maxIndex < index) maxIndex = index; } std::vector array(maxIndex + 1, 0); @@ -296,7 +296,7 @@ void RTFGenerator::beginRTFDocument() iter.toFirst(); for(; (style = iter.current()); ++iter) { - unsigned index = style->index; + uint index = style->index(); if (array.at(index) != 0) { QCString key(iter.currentKey()); @@ -311,7 +311,9 @@ void RTFGenerator::beginRTFDocument() { style = array.at(i); if (style != 0) - t <<"{" << style->reference << style->definition << ";}\n"; + { + t <<"{" << style->reference() << style->definition() << ";}\n"; + } } t <<"}" << endl; @@ -337,7 +339,7 @@ void RTFGenerator::beginRTFChapter() t <<"\\sect\\sbkpage\n"; //t <<"\\sect\\sectd\\sbkpage\n"; - t << rtf_Style["Heading1"]->reference << "\n"; + t << rtf_Style["Heading1"]->reference() << "\n"; } void RTFGenerator::beginRTFSection() @@ -349,15 +351,15 @@ void RTFGenerator::beginRTFSection() // if we are compact, no extra page breaks... if (Config_getBool(COMPACT_RTF)) { - // t <<"\\sect\\sectd\\sbknone\n"; t <<"\\sect\\sbknone\n"; rtfwriteRuler_emboss(); } else + { t <<"\\sect\\sbkpage\n"; - //t <<"\\sect\\sectd\\sbkpage\n"; + } - t << rtf_Style["Heading2"]->reference << "\n"; + t << rtf_Style["Heading2"]->reference() << "\n"; } void RTFGenerator::startFile(const char *name,const char *,const char *) @@ -590,12 +592,12 @@ void RTFGenerator::endIndexSection(IndexSections is) // setup for this section t << rtf_Style_Reset <<"\n"; t <<"\\sectd\\pgnlcrm\n"; - t <<"{\\footer "<reference << "{\\chpgn}}\n"; + t <<"{\\footer "<reference() << "{\\chpgn}}\n"; // the title entry DBG_RTF(t << "{\\comment begin title page}\n") - t << rtf_Style_Reset << rtf_Style["SubTitle"]->reference << endl; // set to title style + t << rtf_Style_Reset << rtf_Style["SubTitle"]->reference() << endl; // set to title style t << "\\vertalc\\qc\\par\\par\\par\\par\\par\\par\\par\n"; if (rtf_logoFilename) @@ -608,7 +610,7 @@ void RTFGenerator::endIndexSection(IndexSections is) t << rtf_company << "\\par\\par\n"; } - t << rtf_Style_Reset << rtf_Style["Title"]->reference << endl; // set to title style + t << rtf_Style_Reset << rtf_Style["Title"]->reference() << endl; // set to title style if (rtf_title) // User has overridden document title in extensions file t << "{\\field\\fldedit {\\*\\fldinst TITLE \\\\*MERGEFORMAT}{\\fldrslt " << rtf_title << "}}\\par" << endl; @@ -621,7 +623,7 @@ void RTFGenerator::endIndexSection(IndexSections is) } - t << rtf_Style_Reset << rtf_Style["SubTitle"]->reference << endl; // set to title style + t << rtf_Style_Reset << rtf_Style["SubTitle"]->reference() << endl; // set to title style t << "\\par\n"; if (rtf_documentType) { @@ -633,7 +635,7 @@ void RTFGenerator::endIndexSection(IndexSections is) } t << "\\par\\par\\par\\par\\par\\par\\par\\par\\par\\par\\par\\par\n"; - t << rtf_Style_Reset << rtf_Style["SubTitle"]->reference << endl; // set to subtitle style + t << rtf_Style_Reset << rtf_Style["SubTitle"]->reference() << endl; // set to subtitle style if (rtf_author) t << "{\\field\\fldedit {\\*\\fldinst AUTHOR \\\\*MERGEFORMAT}{\\fldrslt "<< rtf_author << " }}\\par" << endl; else @@ -649,7 +651,7 @@ void RTFGenerator::endIndexSection(IndexSections is) DBG_RTF(t << "{\\comment Table of contents}\n") t << "\\vertalt\n"; t << rtf_Style_Reset << endl; - t << rtf_Style["Heading1"]->reference; + t << rtf_Style["Heading1"]->reference(); t << theTranslator->trRTFTableOfContents() << "\\par"<< endl; t << rtf_Style_Reset << "\\par" << endl; t << "{\\field\\fldedit {\\*\\fldinst TOC \\\\f \\\\*MERGEFORMAT}{\\fldrslt Table of contents}}\\par\n"; @@ -931,7 +933,7 @@ void RTFGenerator::endIndexSection(IndexSections is) break; case isEndIndex: beginRTFChapter(); - t << rtf_Style["Heading1"]->reference; + t << rtf_Style["Heading1"]->reference(); t << theTranslator->trRTFGeneralIndex() << "\\par "<< endl; t << rtf_Style_Reset << endl; t << "{\\tc \\v " << theTranslator->trRTFGeneralIndex() << "}" << endl; @@ -957,8 +959,7 @@ void RTFGenerator::lastIndexPage() t <<"\\sect \\sectd \\sbknone\n"; // set new footer with arabic numbers - t <<"{\\footer "<< rtf_Style["Footer"]->reference << "{\\chpgn}}\n"; - //t << rtf_Style["Heading1"]->reference << "\n"; + t <<"{\\footer "<< rtf_Style["Footer"]->reference() << "{\\chpgn}}\n"; } @@ -1216,7 +1217,7 @@ void RTFGenerator::startSubsection() t <<"\n"; DBG_RTF(t << "{\\comment Begin SubSection}\n") t << rtf_Style_Reset; - t << rtf_Style["Heading3"]->reference << "\n"; + t << rtf_Style["Heading3"]->reference() << "\n"; } void RTFGenerator::endSubsection() @@ -1231,7 +1232,7 @@ void RTFGenerator::startSubsubsection() t << "\n"; DBG_RTF(t << "{\\comment Begin SubSubSection}\n") t << "{" << endl; - t << rtf_Style_Reset << rtf_Style["Heading4"]->reference << "\n"; + t << rtf_Style_Reset << rtf_Style["Heading4"]->reference() << "\n"; } void RTFGenerator::endSubsubsection() @@ -1439,7 +1440,7 @@ void RTFGenerator::startTitleHead(const char *) DBG_RTF(t <<"{\\comment startTitleHead}" << endl) // beginRTFSection(); - t << rtf_Style_Reset << rtf_Style["Heading2"]->reference << endl; + t << rtf_Style_Reset << rtf_Style["Heading2"]->reference() << endl; } void RTFGenerator::endTitleHead(const char *fileName,const char *name) @@ -1484,15 +1485,15 @@ void RTFGenerator::startGroupHeader(int extraIndent) t << rtf_Style_Reset; if (extraIndent==2) { - t << rtf_Style["Heading5"]->reference; + t << rtf_Style["Heading5"]->reference(); } else if (extraIndent==1) { - t << rtf_Style["Heading4"]->reference; + t << rtf_Style["Heading4"]->reference(); } else // extraIndent==0 { - t << rtf_Style["Heading3"]->reference; + t << rtf_Style["Heading3"]->reference(); } t << endl; } @@ -1518,10 +1519,10 @@ void RTFGenerator::startMemberDoc(const char *clname, addIndexItem(memname,clname); addIndexItem(clname,memname); } - t << rtf_Style_Reset << rtf_Style[showInline ? "Heading5" : "Heading4"]->reference; + t << rtf_Style_Reset << rtf_Style[showInline ? "Heading5" : "Heading4"]->reference(); //styleStack.push(rtf_Style_Heading4); t << "{" << endl; - //printf("RTFGenerator::startMemberDoc() '%s'\n",rtf_Style["Heading4"]->reference); + //printf("RTFGenerator::startMemberDoc() '%s'\n",rtf_Style["Heading4"]->reference()); startBold(); t << endl; } @@ -1531,7 +1532,7 @@ void RTFGenerator::endMemberDoc(bool) DBG_RTF(t << "{\\comment endMemberDoc}" << endl) //const char *style = styleStack.pop(); //printf("RTFGenerator::endMemberDoc() '%s'\n",style); - //ASSERT(style==rtf_Style["Heading4"]->reference); + //ASSERT(style==rtf_Style["Heading4"]->reference()); endBold(); t << "}" << endl; newParagraph(); @@ -1708,7 +1709,7 @@ void RTFGenerator::startSection(const char *,const char *title,SectionType type) QCString heading; heading.sprintf("Heading%d",num); // set style - t << rtf_Style[heading]->reference; + t << rtf_Style[heading]->reference(); // make table of contents entry t << "{\\tc\\tcl" << num << " \\v "; docify(title); @@ -2016,7 +2017,7 @@ void RTFGenerator::startDescTable(const char *title) { DBG_RTF(t << "{\\comment (startDescTable) }" << endl) t << "{\\par" << endl; - t << "{" << rtf_Style["Heading5"]->reference << endl; + t << "{" << rtf_Style["Heading5"]->reference() << endl; docify(title); t << ":\\par}" << endl; t << rtf_Style_Reset << rtf_DList_DepthStyle(); @@ -2104,40 +2105,40 @@ void RTFGenerator::decrementIndentLevel() const char * RTFGenerator::rtf_CList_DepthStyle() { QCString n=makeIndexName("ListContinue",m_listLevel); - return rtf_Style[n]->reference; + return rtf_Style[n]->reference(); } // a style for list formatted as a "latext style" table of contents const char * RTFGenerator::rtf_LCList_DepthStyle() { QCString n=makeIndexName("LatexTOC",m_listLevel); - return rtf_Style[n]->reference; + return rtf_Style[n]->reference(); } // a style for list formatted as a "bullet" style const char * RTFGenerator::rtf_BList_DepthStyle() { QCString n=makeIndexName("ListBullet",m_listLevel); - return rtf_Style[n]->reference; + return rtf_Style[n]->reference(); } // a style for list formatted as a "enumeration" style const char * RTFGenerator::rtf_EList_DepthStyle() { QCString n=makeIndexName("ListEnum",m_listLevel); - return rtf_Style[n]->reference; + return rtf_Style[n]->reference(); } const char * RTFGenerator::rtf_DList_DepthStyle() { QCString n=makeIndexName("DescContinue",m_listLevel); - return rtf_Style[n]->reference; + return rtf_Style[n]->reference(); } const char * RTFGenerator::rtf_Code_DepthStyle() { QCString n=makeIndexName("CodeExample",m_listLevel); - return rtf_Style[n]->reference; + return rtf_Style[n]->reference(); } void RTFGenerator::startTextBlock(bool dense) @@ -2147,11 +2148,11 @@ void RTFGenerator::startTextBlock(bool dense) t << rtf_Style_Reset; if (dense) // no spacing between "paragraphs" { - t << rtf_Style["DenseText"]->reference; + t << rtf_Style["DenseText"]->reference(); } else // some spacing { - t << rtf_Style["BodyText"]->reference; + t << rtf_Style["BodyText"]->reference(); } } @@ -2685,7 +2686,7 @@ void RTFGenerator::startMemberGroupHeader(bool hasHeader) DBG_RTF(t << "{\\comment startMemberGroupHeader}" << endl) t << "{" << endl; if (hasHeader) incrementIndentLevel(); - t << rtf_Style_Reset << rtf_Style["GroupHeader"]->reference; + t << rtf_Style_Reset << rtf_Style["GroupHeader"]->reference(); } void RTFGenerator::endMemberGroupHeader() @@ -2934,7 +2935,7 @@ void RTFGenerator::startInlineHeader() { DBG_RTF(t << "{\\comment (startInlineHeader)}" << endl) t << "{" << endl; - t << rtf_Style_Reset << rtf_Style["Heading5"]->reference; + t << rtf_Style_Reset << rtf_Style["Heading5"]->reference(); startBold(); } @@ -2950,7 +2951,7 @@ void RTFGenerator::startMemberDocSimple(bool isEnum) { DBG_RTF(t << "{\\comment (startMemberDocSimple)}" << endl) t << "{\\par" << endl; - t << "{" << rtf_Style["Heading5"]->reference << endl; + t << "{" << rtf_Style["Heading5"]->reference() << endl; if (isEnum) { t << theTranslator->trEnumerationValues(); diff --git a/src/rtfstyle.cpp b/src/rtfstyle.cpp index 163d5b8..98581bb 100644 --- a/src/rtfstyle.cpp +++ b/src/rtfstyle.cpp @@ -1,13 +1,13 @@ /****************************************************************************** * - * + * * * * Copyright (C) 1997-2015 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. * @@ -224,30 +224,22 @@ Rtf_Style_Default rtf_Style_Default[] = } }; -const QRegExp StyleData::s_clause("\\\\s[0-9]+\\s*"); +static const QRegExp s_clause("\\\\s[0-9]+\\s*"); StyleData::StyleData(const char* reference, const char* definition) { const char *ref = reference; - const char *def = definition; int start = s_clause.match(ref); ASSERT(start >= 0); ref += start; - index = (int)atol(ref + 2); ASSERT(index > 0); - - ASSERT(ref != 0); - size_t size = 1 + strlen(ref); - memcpy(this->reference = new char[size], ref, size); + m_index = (int)atol(ref + 2); ASSERT(m_index > 0); - ASSERT(def != 0); - size = 1 + strlen(def); - memcpy(this->definition = new char[size], def, size); + m_reference = ref; + m_definition = definition; } StyleData::~StyleData() { - delete[] reference; - delete[] definition; } bool StyleData::setStyle(const char* s, const char* styleName) @@ -264,7 +256,7 @@ bool StyleData::setStyle(const char* s, const char* styleName) return FALSE; } s += start; - index = (int)atol(s + 2); ASSERT(index > 0); + m_index = (int)atol(s + 2); ASSERT(m_index > 0); // search for the end of pure formatting codes const char* end = s + len; @@ -302,16 +294,10 @@ bool StyleData::setStyle(const char* s, const char* styleName) else // plain name without leading \\snext break; } - delete[] reference; - reference = new char[ref_len + 1]; - memcpy(reference, s, ref_len); - reference[ref_len] = 0; + m_reference = s; if (haveNewDefinition) { - delete[] definition; - size_t size = 1 + strlen(end); - definition = new char[size]; - memcpy(definition, end, size); + m_definition = end; } return TRUE; } diff --git a/src/rtfstyle.h b/src/rtfstyle.h index 1058351..d45972c 100644 --- a/src/rtfstyle.h +++ b/src/rtfstyle.h @@ -1,13 +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. * @@ -63,15 +60,18 @@ struct StyleData // to define a tag in the header reference + definition is required // to use a tag in the body of the document only reference is required - unsigned index; // index in style-sheet, i.e. number in s-clause - char* reference; // everything required to apply the style - char* definition; // additional tags like \snext and style name - - StyleData(const char* reference, const char* definition); - ~StyleData(); - bool setStyle(const char* s, const char* styleName); - - static const QRegExp s_clause; + public: + StyleData(const char* reference, const char* definition); + ~StyleData(); + bool setStyle(const char* s, const char* styleName); + const char *reference() const { return m_reference.c_str(); } + const char *definition() const { return m_definition.c_str(); } + uint index() const { return m_index; } + + private: + uint m_index; // index in style-sheet, i.e. number in s-clause + std::string m_reference; // everything required to apply the style + std::string m_definition; // additional tags like \snext and style name }; extern QDict rtf_Style; diff --git a/src/sqlite3gen.cpp b/src/sqlite3gen.cpp index 4cbb18f..62e5576 100644 --- a/src/sqlite3gen.cpp +++ b/src/sqlite3gen.cpp @@ -1736,7 +1736,7 @@ static void generateSqlite3ForMember(const MemberDef *md, struct Refid scope_ref } const MemberDef *rmd = md->reimplements(); - if(rmd) + if (rmd) { QCString qreimplemented_refid = rmd->getOutputFileBase() + "_1" + rmd->anchor(); @@ -1862,7 +1862,6 @@ static void generateSqlite3ForMember(const MemberDef *md, struct Refid scope_ref if (mdict!=0) { MemberSDict::IteratorDict mdi(*mdict); - const MemberDef *rmd; for (mdi.toFirst();(rmd=mdi.current());++mdi) { insertMemberReference(md,rmd, "inline"); @@ -1873,7 +1872,6 @@ static void generateSqlite3ForMember(const MemberDef *md, struct Refid scope_ref if (mdict!=0) { MemberSDict::IteratorDict mdi(*mdict); - const MemberDef *rmd; for (mdi.toFirst();(rmd=mdi.current());++mdi) { insertMemberReference(rmd,md, "inline"); diff --git a/src/util.cpp b/src/util.cpp index 7fc98a7..4de28cf 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -3865,18 +3865,18 @@ bool getDefs(const QCString &scName, //for (mni.toLast();(md=mni.current());--mni) for (auto it = mn->rbegin(); it!=mn->rend(); ++it) { - const auto &md = *it; - //printf("Found member '%s'\n",md->name().data()); - //printf("member is linkable md->name()='%s'\n",md->name().data()); - fd=md->getFileDef(); - gd=md->getGroupDef(); - const MemberDef *tmd = md->getEnumScope(); + const auto &mmd = *it; + //printf("Found member '%s'\n",mmd->name().data()); + //printf("member is linkable mmd->name()='%s'\n",mmd->name().data()); + fd=mmd->getFileDef(); + gd=mmd->getGroupDef(); + const MemberDef *tmd = mmd->getEnumScope(); if ( (gd && gd->isLinkable()) || (fd && fd->isLinkable()) || (tmd && tmd->isStrong()) ) { - members.append(md.get()); + members.append(mmd.get()); } } } -- cgit v0.12