From 9b7e4ffb6c5f7534e4ba11d5798b4eb74d4a2a70 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sun, 16 Nov 2014 00:24:58 +0100 Subject: Fixed several Coverity warnings --- qtools/qfile_unix.cpp | 1 + src/condparser.h | 19 +++++++------- src/context.cpp | 6 +++-- src/definition.cpp | 16 ++++++------ src/dirdef.cpp | 2 +- src/docbookgen.cpp | 12 ++++----- src/docparser.cpp | 23 ++++++++--------- src/filename.cpp | 44 ++++++++++++++++++-------------- src/htmlgen.cpp | 28 +++++++++++++-------- src/markdown.cpp | 2 +- src/memberdef.cpp | 4 +-- src/memberlist.cpp | 21 +++++++++++++++- src/message.cpp | 9 ++++--- src/pre.l | 4 +-- src/searchindex.cpp | 20 --------------- src/searchindex.h | 1 - src/store.cpp | 4 +-- src/tagreader.cpp | 14 ++++++++++- src/template.cpp | 70 ++++++++++++++++++++++++++++++++------------------- src/translator_hr.h | 4 +-- src/util.cpp | 2 +- src/xmlgen.cpp | 31 +++++++++++------------ 22 files changed, 189 insertions(+), 148 deletions(-) diff --git a/qtools/qfile_unix.cpp b/qtools/qfile_unix.cpp index 0422fb4..dd41c4e 100644 --- a/qtools/qfile_unix.cpp +++ b/qtools/qfile_unix.cpp @@ -550,6 +550,7 @@ int QFile::writeBlock( const char *p, uint len ) return -1; } #endif + if (p==0) return 0; int nwritten; // number of bytes written if ( isRaw() ) // raw file nwritten = (int)WRITE( fd, p, len ); diff --git a/src/condparser.h b/src/condparser.h index 0310f36..7c65411 100644 --- a/src/condparser.h +++ b/src/condparser.h @@ -28,24 +28,25 @@ class CondParser { // public functions public: + CondParser() : m_e(0), m_tokenType(NOTHING) {} bool parse(const char *fileName,int lineNr,const char *expr); // enumerations private: - enum TOKENTYPE + enum TOKENTYPE { - NOTHING = -1, - DELIMITER, - VARIABLE, + NOTHING = -1, + DELIMITER, + VARIABLE, UNKNOWN }; - enum OPERATOR_ID + enum OPERATOR_ID { - UNKNOWN_OP = -1, - AND = 1, - OR, + UNKNOWN_OP = -1, + AND = 1, + OR, NOT - }; + }; // data private: diff --git a/src/context.cpp b/src/context.cpp index 4b174b0..ec68e5e 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -5760,7 +5760,8 @@ class ClassTreeContext::Private : public PropertyMapper SharedPtr m_classTree; struct Cachable { - Cachable() : maxDepthComputed(FALSE), preferredDepthComputed(FALSE) {} + Cachable() : maxDepth(0), maxDepthComputed(FALSE), + preferredDepth(0), preferredDepthComputed(FALSE) {} int maxDepth; bool maxDepthComputed; int preferredDepth; @@ -6168,7 +6169,8 @@ class FileTreeContext::Private : public PropertyMapper SharedPtr m_dirFileTree; struct Cachable { - Cachable() : maxDepthComputed(FALSE), preferredDepthComputed(FALSE) {} + Cachable() : maxDepth(0), maxDepthComputed(FALSE), + preferredDepth(0), preferredDepthComputed(FALSE) {} int maxDepth; bool maxDepthComputed; int preferredDepth; diff --git a/src/definition.cpp b/src/definition.cpp index 4491bc4..4e90818 100644 --- a/src/definition.cpp +++ b/src/definition.cpp @@ -58,10 +58,10 @@ class DefinitionImpl SectionDict *sectionDict; // dictionary of all sections, not accessible - MemberSDict *sourceRefByDict; - MemberSDict *sourceRefsDict; - QList *xrefListItems; - GroupList *partOfGroups; + MemberSDict *sourceRefByDict; + MemberSDict *sourceRefsDict; + QList *xrefListItems; + GroupList *partOfGroups; DocInfo *details; // not exported DocInfo *inbodyDocs; // not exported @@ -89,11 +89,11 @@ class DefinitionImpl QCString id; // clang unique id }; -DefinitionImpl::DefinitionImpl() - : sectionDict(0), sourceRefByDict(0), sourceRefsDict(0), +DefinitionImpl::DefinitionImpl() + : sectionDict(0), sourceRefByDict(0), sourceRefsDict(0), xrefListItems(0), partOfGroups(0), - details(0), inbodyDocs(0), brief(0), body(0), - outerScope(0) + details(0), inbodyDocs(0), brief(0), body(0), hidden(FALSE), isArtificial(FALSE), + outerScope(0), lang(SrcLangExt_Unknown) { } diff --git a/src/dirdef.cpp b/src/dirdef.cpp index d2d9684..d4af3f0 100644 --- a/src/dirdef.cpp +++ b/src/dirdef.cpp @@ -18,7 +18,7 @@ static int g_dirCount=0; -DirDef::DirDef(const char *path) : Definition(path,1,1,path) +DirDef::DirDef(const char *path) : Definition(path,1,1,path), visited(FALSE) { bool fullPathNames = Config_getBool("FULL_PATH_NAMES"); // get display name (stipping the paths mentioned in STRIP_FROM_PATH) diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp index cabb7ad..990224e 100644 --- a/src/docbookgen.cpp +++ b/src/docbookgen.cpp @@ -178,14 +178,14 @@ class TextGeneratorDocbookImpl : public TextGeneratorIntf class DocbookCodeGenerator : public CodeOutputInterface { public: - DocbookCodeGenerator(FTextStream &t) : m_t(t), m_lineNumber(-1), + DocbookCodeGenerator(FTextStream &t) : m_t(t), m_lineNumber(-1), m_col(0), m_insideCodeLine(FALSE), m_insideSpecialHL(FALSE) {} virtual ~DocbookCodeGenerator() {} void codify(const char *text) { Docbook_DB(("(codify \"%s\")\n",text)); - writeDocbookCodeString(m_t,text,col); + writeDocbookCodeString(m_t,text,m_col); } void writeCodeLink(const char *ref,const char *file, const char *anchor,const char *name, @@ -193,7 +193,7 @@ class DocbookCodeGenerator : public CodeOutputInterface { Docbook_DB(("(writeCodeLink)\n")); writeDocbookLink(m_t,ref,file,anchor,name,tooltip); - col+=strlen(name); + m_col+=strlen(name); } void writeTooltip(const char *, const DocLinkInfo &, const char *, const char *, const SourceLinkInfo &, const SourceLinkInfo & @@ -217,7 +217,7 @@ class DocbookCodeGenerator : public CodeOutputInterface } } m_insideCodeLine=TRUE; - col=0; + m_col=0; } void endCodeLine() { @@ -255,7 +255,6 @@ class DocbookCodeGenerator : public CodeOutputInterface { m_refId=compId; if (anchorId) m_refId+=(QCString)"_1"+anchorId; - m_isMemberRef = anchorId!=0; if (extRef) m_external=extRef; } } @@ -275,8 +274,7 @@ class DocbookCodeGenerator : public CodeOutputInterface QCString m_refId; QCString m_external; int m_lineNumber; - bool m_isMemberRef; - int col; + int m_col; bool m_insideCodeLine; bool m_insideSpecialHL; }; diff --git a/src/docparser.cpp b/src/docparser.cpp index b21c15c..8c435fa 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -2089,6 +2089,11 @@ DocFormula::DocFormula(DocNode *parent,int id) : m_name.sprintf("form_%d",m_id); m_text = formula->getFormulaText(); } + else // wrong \form# command + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"Wrong formula id %d",id); + m_id = -1; + } } //--------------------------------------------------------------------------- @@ -2366,7 +2371,7 @@ DocRef::DocRef(DocNode *parent,const QCString &target,const QCString &context) : // compound->definitionType()); return; } - else if (compound->definitionType()==Definition::TypeFile && + else if (compound && compound->definitionType()==Definition::TypeFile && ((FileDef*)compound)->generateSourceFile() ) // undocumented file that has source code we can link to { @@ -2485,9 +2490,8 @@ DocCite::DocCite(DocNode *parent,const QCString &target,const QCString &) //cont DocLink::DocLink(DocNode *parent,const QCString &target) { - m_parent = parent; - Definition *compound; - //PageInfo *page; + m_parent = parent; + Definition *compound = 0; QCString anchor; m_refText = target; m_relPath = g_relPath; @@ -2504,7 +2508,7 @@ DocLink::DocLink(DocNode *parent,const QCString &target) m_file = compound->getOutputFileBase(); m_ref = compound->getReference(); } - else if (compound->definitionType()==Definition::TypeFile && + else if (compound && compound->definitionType()==Definition::TypeFile && ((FileDef*)compound)->generateSourceFile() ) // undocumented file that has source code we can link to { @@ -3308,7 +3312,6 @@ int DocIndexEntry::parse() break; } } - if (tok!=0) retval=tok; doctokenizerYYsetStatePara(); m_entry = m_entry.stripWhiteSpace(); endindexentry: @@ -6786,17 +6789,13 @@ int DocSection::parse() } else if ((m_level<=1+Doxygen::subpageNestingLevel && retval==RetVal_Subsubsection) || (m_level<=2+Doxygen::subpageNestingLevel && retval==RetVal_Paragraph) - ) + ) { - int level; - if (retval==RetVal_Subsection) level=2; - else if (retval==RetVal_Subsubsection) level=3; - else level=4; + int level = (retval==RetVal_Subsubsection) ? 3 : 4; warn_doc_error(g_fileName,doctokenizerYYlineno,"Unexpected %s " "command found inside %s!", sectionLevelToName[level],sectionLevelToName[m_level]); retval=0; // stop parsing - } else { diff --git a/src/filename.cpp b/src/filename.cpp index 35a1841..8719f3c 100644 --- a/src/filename.cpp +++ b/src/filename.cpp @@ -45,9 +45,12 @@ void FileName::generateDiskNames() { // skip references for (it.toFirst();(fd=it.current()) && fd->isReference();++it) { } - // name if unique, so diskname is simply the name - //printf("!!!!!!!! Unique disk name=%s for fd=%s\n",name.data(),fd->diskname.data()); - fd->m_diskName=name; + if (fd) + { + // name if unique, so diskname is simply the name + //printf("!!!!!!!! Unique disk name=%s for fd=%s\n",name.data(),fd->diskname.data()); + fd->m_diskName=name; + } } else if (count>1) // multiple occurrences of the same file name { @@ -57,28 +60,31 @@ void FileName::generateDiskNames() while (!found) // search for the common prefix of all paths { for (it.toFirst();(fd=it.current()) && fd->isReference();++it) { } - char c=fd->m_path.at(i); - if (c=='/') j=i; // remember last position of dirname - ++it; - while ((fd=it.current()) && !found) + if (fd) { - if (!fd->isReference()) + char c=fd->m_path.at(i); + if (c=='/') j=i; // remember last position of dirname + ++it; + while ((fd=it.current()) && !found) { - //printf("i=%d j=%d fd->path=`%s' fd->name=`%s'\n",i,j,fd->path.left(i).data(),fd->name().data()); - if (i==(int)fd->m_path.length()) + if (!fd->isReference()) { - //warning("Input file %s found multiple times!\n" - // " The generated documentation for this file may not be correct!\n",fd->absFilePath().data()); - found=TRUE; - } - else if (fd->m_path[i]!=c) - { - found=TRUE; + //printf("i=%d j=%d fd->path=`%s' fd->name=`%s'\n",i,j,fd->path.left(i).data(),fd->name().data()); + if (i==(int)fd->m_path.length()) + { + //warning("Input file %s found multiple times!\n" + // " The generated documentation for this file may not be correct!\n",fd->absFilePath().data()); + found=TRUE; + } + else if (fd->m_path[i]!=c) + { + found=TRUE; + } } + ++it; } - ++it; + i++; } - i++; } for (it.toFirst();(fd=it.current());++it) { diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index c4bd80a..3bb6792 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -737,17 +737,24 @@ void HtmlGenerator::init() if (f.open(IO_WriteOnly)) { const Resource *res = mgr.get("dynsections.js"); - FTextStream t(&f); - t << (const char *)res->data; - if (Config_getBool("SOURCE_BROWSER") && Config_getBool("SOURCE_TOOLTIPS")) + if (res) + { + FTextStream t(&f); + t << (const char *)res->data; + if (Config_getBool("SOURCE_BROWSER") && Config_getBool("SOURCE_TOOLTIPS")) + { + t << endl << + "$(document).ready(function() {\n" + " $('.code,.codeRef').each(function() {\n" + " $(this).data('powertip',$('#'+$(this).attr('href').replace(/.*\\//,'').replace(/[^a-z_A-Z0-9]/g,'_')).html());\n" + " $(this).powerTip({ placement: 's', smartPlacement: true, mouseOnToPopup: true });\n" + " });\n" + "});\n"; + } + } + else { - t << endl << - "$(document).ready(function() {\n" - " $('.code,.codeRef').each(function() {\n" - " $(this).data('powertip',$('#'+$(this).attr('href').replace(/.*\\//,'').replace(/[^a-z_A-Z0-9]/g,'_')).html());\n" - " $(this).powerTip({ placement: 's', smartPlacement: true, mouseOnToPopup: true });\n" - " });\n" - "});\n"; + err("Resource dynsections.js not compiled in"); } } } @@ -896,7 +903,6 @@ void HtmlGenerator::writeSearchInfo(FTextStream &t,const QCString &relPath) t << " onmouseover=\"return searchBox.OnSearchSelectShow()\"\n"; t << " onmouseout=\"return searchBox.OnSearchSelectHide()\"\n"; t << " onkeydown=\"return searchBox.OnSearchSelectKey(event)\">\n"; - writeSearchCategories(t); t << "\n"; t << "\n"; t << "\n"; diff --git a/src/markdown.cpp b/src/markdown.cpp index 72bab84..fdf1b0f 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -2375,7 +2375,7 @@ void MarkdownFileParser::parseInput(const char *fileName, Doxygen::markdownSupport = TRUE; bool needsEntry = FALSE; - Protection prot; + Protection prot=Public; while (parseCommentBlock( this, current, diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 66814a6..83528ef 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -738,7 +738,7 @@ MemberDef::MemberDef(const char *df,int dl,int dc, const char *t,const char *na,const char *a,const char *e, Protection p,Specifier v,bool s,Relationship r,MemberType mt, const ArgumentList *tal,const ArgumentList *al - ) : Definition(df,dl,dc,removeRedundantWhiteSpace(na)) + ) : Definition(df,dl,dc,removeRedundantWhiteSpace(na)), visited(FALSE) { //printf("MemberDef::MemberDef(%s)\n",na); m_impl = new MemberDefImpl; @@ -748,7 +748,7 @@ MemberDef::MemberDef(const char *df,int dl,int dc, m_isDestructorCached = 0; } -MemberDef::MemberDef(const MemberDef &md) : Definition(md) +MemberDef::MemberDef(const MemberDef &md) : Definition(md), visited(FALSE) { m_impl = new MemberDefImpl; m_isLinkableCached = 0; diff --git a/src/memberlist.cpp b/src/memberlist.cpp index 68b3bcb..95726a0 100644 --- a/src/memberlist.cpp +++ b/src/memberlist.cpp @@ -33,16 +33,35 @@ #include "config.h" #include "docparser.h" -MemberList::MemberList() +MemberList::MemberList() : m_listType(MemberListType_pubMethods) { memberGroupList=0; + m_varCnt=0; + m_funcCnt=0; + m_enumCnt=0; + m_enumValCnt=0; + m_typeCnt=0; + m_protoCnt=0; + m_defCnt=0; + m_friendCnt=0; m_numDecMembers=-1; // special value indicating that value needs to be computed m_numDocMembers=-1; // special value indicating that value needs to be computed + m_inGroup=FALSE; + m_inFile=FALSE; + m_needsSorting=FALSE; } MemberList::MemberList(MemberListType lt) : m_listType(lt) { memberGroupList=0; + m_varCnt=0; + m_funcCnt=0; + m_enumCnt=0; + m_enumValCnt=0; + m_typeCnt=0; + m_protoCnt=0; + m_defCnt=0; + m_friendCnt=0; m_numDecMembers=-1; // special value indicating that value needs to be computed m_numDocMembers=-1; // special value indicating that value needs to be computed m_inGroup=FALSE; diff --git a/src/message.cpp b/src/message.cpp index 11b4502..4156720 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -152,15 +152,16 @@ static void format_warn(const char *file,int line,const char *text) static void do_warn(const char *tag, const char *file, int line, const char *prefix, const char *fmt, va_list args) { if (!Config_getBool(tag)) return; // warning type disabled - char text[40960]; + const int bufSize = 40960; + char text[bufSize]; int l=0; if (prefix) { - strcpy(text,prefix); + qstrncpy(text,prefix,bufSize); l=strlen(prefix); } - vsnprintf(text+l, 40960-l, fmt, args); - text[40960-1]='\0'; + vsnprintf(text+l, bufSize-l, fmt, args); + text[bufSize-1]='\0'; format_warn(file,line,text); } diff --git a/src/pre.l b/src/pre.l index 8d2b5f7..9e88b0d 100644 --- a/src/pre.l +++ b/src/pre.l @@ -71,8 +71,8 @@ struct CondCtx struct FileState { - FileState(int size) : fileBuf(size), - oldFileBuf(0), oldFileBufPos(0) {} + FileState(int size) : lineNr(1), fileBuf(size), + oldFileBuf(0), oldFileBufPos(0), bufState(0) {} int lineNr; BufStr fileBuf; BufStr *oldFileBuf; diff --git a/src/searchindex.cpp b/src/searchindex.cpp index da7c391..22727fe 100644 --- a/src/searchindex.cpp +++ b/src/searchindex.cpp @@ -1354,26 +1354,6 @@ void writeJavascriptSearchIndex() Doxygen::indexList->addStyleSheetFile("search/search.js"); } -void writeSearchCategories(FTextStream &t) -{ -#if 0 - static SearchIndexCategoryMapping map; - int i,j=0; - for (i=0;i0) - { - t << "" - << " " - << convertToXML(map.categoryLabel[i]) - << ""; - j++; - } - } -#endif -} - //--------------------------------------------------------------------------------------------- void initSearchIndexer() diff --git a/src/searchindex.h b/src/searchindex.h index 872c0d3..17d39a2 100644 --- a/src/searchindex.h +++ b/src/searchindex.h @@ -110,6 +110,5 @@ class SearchIndexExternal : public SearchIndexIntf //------- client side search index ---------------------- void writeJavascriptSearchIndex(); -void writeSearchCategories(FTextStream &t); #endif diff --git a/src/store.cpp b/src/store.cpp index 8916015..8d9a0cd 100644 --- a/src/store.cpp +++ b/src/store.cpp @@ -382,9 +382,9 @@ int Store::read(char *buf,uint size) void Store::printFreeList() { printf("FreeList: "); - portable_off_t pos = m_head->pos; - while (pos) + while (m_head) { + portable_off_t pos = m_head->pos; printf("%x ",(int)pos); m_head = m_head->next; } diff --git a/src/tagreader.cpp b/src/tagreader.cpp index 4b21047..be0472a 100644 --- a/src/tagreader.cpp +++ b/src/tagreader.cpp @@ -251,8 +251,20 @@ class TagFileParser : public QXmlDefaultHandler { m_startElementHandlers.setAutoDelete(TRUE); m_endElementHandlers.setAutoDelete(TRUE); + m_curClass=0; + m_curFile=0; + m_curNamespace=0; + m_curPackage=0; + m_curGroup=0; + m_curPage=0; + m_curDir=0; + m_curMember=0; + m_curEnumValue=0; + m_curIncludes=0; + m_state = Invalid; + m_locator = 0; } - + void setDocumentLocator ( QXmlLocator * locator ) { m_locator = locator; diff --git a/src/template.cpp b/src/template.cpp index 2a40bfe..100de16 100644 --- a/src/template.cpp +++ b/src/template.cpp @@ -116,7 +116,7 @@ static QCString replace(const char *s,char csrc,char cdst) class TemplateVariant::Private { public: - Private() : raw(FALSE) {} + Private(Type t) : type(t), intVal(0), boolVal(TRUE), strukt(0), list(0), raw(FALSE) {} Type type; int intVal; QCString strVal; @@ -129,60 +129,52 @@ class TemplateVariant::Private TemplateVariant::TemplateVariant() { - p = new Private; - p->type=None; + p = new Private(None); } TemplateVariant::TemplateVariant(bool b) { - p = new Private; - p->type = Bool; + p = new Private(Bool); p->boolVal = b; } TemplateVariant::TemplateVariant(int v) { - p = new Private; - p->type = Integer; + p = new Private(Integer); p->intVal = v; } TemplateVariant::TemplateVariant(const char *s,bool raw) { - p = new Private; - p->type = String; + p = new Private(String); p->strVal = s; p->raw = raw; } TemplateVariant::TemplateVariant(const QCString &s,bool raw) { - p = new Private; - p->type = String; + p = new Private(String); p->strVal = s; p->raw = raw; } TemplateVariant::TemplateVariant(TemplateStructIntf *s) { - p = new Private; - p->type = Struct; + p = new Private(Struct); p->strukt = s; p->strukt->addRef(); } TemplateVariant::TemplateVariant(TemplateListIntf *l) { - p = new Private; - p->type = List; + p = new Private(List); p->list = l; p->list->addRef(); } TemplateVariant::TemplateVariant(const TemplateVariant::Delegate &delegate) { - p = new Private; - p->type = Function; + p = new Private(Function); p->delegate = delegate; } @@ -195,8 +187,7 @@ TemplateVariant::~TemplateVariant() TemplateVariant::TemplateVariant(const TemplateVariant &v) { - p = new Private; - p->type = v.p->type; + p = new Private(v.p->type); p->raw = v.p->raw; switch (p->type) { @@ -1436,11 +1427,11 @@ class ExprAstVariable : public ExprAst const QCString &name() const { return m_name; } virtual TemplateVariant resolve(TemplateContext *c) { - TemplateContextImpl *ci = dynamic_cast(c); TemplateVariant v = c->get(m_name); + TemplateContextImpl *ci = dynamic_cast(c); if (!v.isValid()) { - ci->warn(ci->templateName(),ci->line(),"undefined variable '%s' in expression",m_name.data()); + if (ci) ci->warn(ci->templateName(),ci->line(),"undefined variable '%s' in expression",m_name.data()); } return v; } @@ -1487,6 +1478,7 @@ class ExprAstFilter : public ExprAst TemplateVariant apply(const TemplateVariant &v,TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast(c); + if (ci==0) return v; // should not happen TRACE(("Applying filter '%s' to '%s' (type=%d)\n",m_name.data(),v.toString().data(),v.type())); TemplateVariant arg; if (m_arg) arg = m_arg->resolve(c); @@ -1578,6 +1570,7 @@ class ExprAstBinary : public ExprAst virtual TemplateVariant resolve(TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast(c); + if (ci==0) return TemplateVariant(); // should not happen TemplateVariant lhs = m_lhs->resolve(c); TemplateVariant rhs = m_rhs ? m_rhs->resolve(c) : TemplateVariant(); switch(m_operator) @@ -2609,6 +2602,7 @@ class TemplateNodeText : public TemplateNode { //printf("TemplateNodeText::render(%s)\n",m_data.data()); TemplateContextImpl* ci = dynamic_cast(c); + if (ci==0) return; // should not happen if (ci->spacelessEnabled()) { ts << ci->spacelessIntf()->remove(m_data); @@ -2647,6 +2641,7 @@ class TemplateNodeVariable : public TemplateNode void render(FTextStream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); if (m_var) { @@ -2797,6 +2792,7 @@ class TemplateNodeIf : public TemplateNodeCreator void render(FTextStream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); //printf("TemplateNodeIf::render #trueNodes=%d #falseNodes=%d\n",m_trueNodes.count(),m_falseNodes.count()); bool processed=FALSE; @@ -2861,6 +2857,7 @@ class TemplateNodeRepeat : public TemplateNodeCreator void render(FTextStream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); TemplateVariant v; if (m_expr && (v=m_expr->resolve(c)).type()==TemplateVariant::Integer) @@ -2973,6 +2970,7 @@ class TemplateNodeRange : public TemplateNodeCreator void render(FTextStream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); //printf("TemplateNodeRange::render #loopNodes=%d\n", // m_loopNodes.count()); @@ -3134,6 +3132,7 @@ class TemplateNodeFor : public TemplateNodeCreator void render(FTextStream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); //printf("TemplateNodeFor::render #loopNodes=%d #emptyNodes=%d\n", // m_loopNodes.count(),m_emptyNodes.count()); @@ -3235,6 +3234,7 @@ class TemplateNodeMsg : public TemplateNodeCreator void render(FTextStream &, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); TemplateEscapeIntf *escIntf = ci->escapeIntf(); ci->setActiveEscapeIntf(0); // avoid escaping things we send to standard out @@ -3276,6 +3276,7 @@ class TemplateNodeBlock : public TemplateNodeCreator void render(FTextStream &ts, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); TemplateImpl *t = getTemplate(); if (t) @@ -3356,6 +3357,7 @@ class TemplateNodeExtend : public TemplateNodeCreator void render(FTextStream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); if (m_extendExpr==0) return; @@ -3374,7 +3376,6 @@ class TemplateNodeExtend : public TemplateNodeCreator if (baseTemplate) { // fill block context - TemplateContextImpl *ci = dynamic_cast(c); TemplateBlockContext *bc = ci->blockContext(); // add overruling blocks to the context @@ -3435,6 +3436,7 @@ class TemplateNodeInclude : public TemplateNodeCreator void render(FTextStream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); if (m_includeExpr) { @@ -3514,6 +3516,7 @@ class TemplateNodeCreate : public TemplateNodeCreator void render(FTextStream &, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); if (m_templateExpr && m_fileExpr) { @@ -3661,6 +3664,7 @@ class TemplateNodeTree : public TemplateNodeCreator { //printf("TemplateNodeTree::render()\n"); TemplateContextImpl* ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); TemplateVariant v = m_treeExpr->resolve(c); const TemplateListIntf *list = v.toList(); @@ -3732,9 +3736,10 @@ class TemplateNodeIndexEntry : public TemplateNodeCreator(c); + if (ci==0) return; // should not happen if (!m_name.isEmpty()) { - TemplateContextImpl *ci = dynamic_cast(c); ci->setLocation(m_templateName,m_line); QListIterator it(m_args); Mapping *mapping; @@ -3775,9 +3780,10 @@ class TemplateNodeOpenSubIndex : public TemplateNodeCreator(c); + if (ci==0) return; // should not happen if (!m_name.isEmpty()) { - TemplateContextImpl *ci = dynamic_cast(c); ci->setLocation(m_templateName,m_line); ci->openSubIndex(m_name); } @@ -3810,9 +3816,10 @@ class TemplateNodeCloseSubIndex : public TemplateNodeCreator(c); + if (ci==0) return; // should not happen if (!m_name.isEmpty()) { - TemplateContextImpl *ci = dynamic_cast(c); ci->setLocation(m_templateName,m_line); ci->closeSubIndex(m_name); } @@ -3873,6 +3880,7 @@ class TemplateNodeWith : public TemplateNodeCreator void render(FTextStream &ts, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); c->push(); QListIterator it(m_args); @@ -3984,6 +3992,7 @@ class TemplateNodeSet : public TemplateNodeCreator void render(FTextStream &, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); if (m_mapping) { @@ -4014,6 +4023,7 @@ class TemplateNodeSpaceless : public TemplateNodeCreator void render(FTextStream &ts, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); bool wasSpaceless = ci->spacelessEnabled(); ci->enableSpaceless(TRUE); @@ -4056,6 +4066,7 @@ class TemplateNodeMarkers : public TemplateNodeCreator void render(FTextStream &ts, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); if (!m_var.isEmpty() && m_listExpr && m_patternExpr) { @@ -4152,9 +4163,15 @@ class TemplateNodeResource : public TemplateNodeCreator } TRACE(("}TemplateNodeResource(%s)\n",data.data())); } + ~TemplateNodeResource() + { + delete m_resExpr; + delete m_asExpr; + } void render(FTextStream &, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast(c); + if (ci==0) return; // should not happen ci->setLocation(m_templateName,m_line); if (m_resExpr) { @@ -4712,12 +4729,13 @@ TemplateImpl::TemplateImpl(TemplateEngine *engine,const QCString &name,const cha void TemplateImpl::render(FTextStream &ts, TemplateContext *c) { + TemplateContextImpl *ci = dynamic_cast(c); + if (ci==0) return; // should not happen if (!m_nodes.isEmpty()) { TemplateNodeExtend *ne = dynamic_cast(m_nodes.getFirst()); if (ne==0) // normal template, add blocks to block context { - TemplateContextImpl *ci = dynamic_cast(c); TemplateBlockContext *bc = ci->blockContext(); QListIterator li(m_nodes); TemplateNode *n; diff --git a/src/translator_hr.h b/src/translator_hr.h index 70dba21..98a746a 100644 --- a/src/translator_hr.h +++ b/src/translator_hr.h @@ -943,9 +943,9 @@ class TranslatorCroatian : public TranslatorAdapter_1_8_2 * be followed by a single name or by a list of names * of the category. */ - virtual QCString trMember(bool first_capital, bool singular) + virtual QCString trMember(bool, bool singular) { - QCString result((first_capital ? "član" : "član")); + QCString result("član"); if (!singular) result+="ovi"; return result; } diff --git a/src/util.cpp b/src/util.cpp index bc39cfb..101d6b3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -3700,7 +3700,7 @@ void mergeArguments(ArgumentList *srcAl,ArgumentList *dstAl,bool forceNameOverwr ArgumentListIterator srcAli(*srcAl),dstAli(*dstAl); Argument *srcA,*dstA; - for (;(srcA=srcAli.current(),dstA=dstAli.current());++srcAli,++dstAli) + for (;(srcA=srcAli.current()) && (dstA=dstAli.current());++srcAli,++dstAli) { if (srcA->defval.isEmpty() && !dstA->defval.isEmpty()) { diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp index 28da1eb..8e1d02f 100644 --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -224,12 +224,11 @@ class XMLCodeGenerator : public CodeOutputInterface { public: - XMLCodeGenerator(FTextStream &t) : m_t(t), m_lineNumber(-1), - m_insideCodeLine(FALSE), m_normalHLNeedStartTag(TRUE), - m_insideSpecialHL(FALSE) {} + XMLCodeGenerator(FTextStream &t) : m_t(t), m_lineNumber(-1), m_isMemberRef(FALSE), m_col(0), + m_insideCodeLine(FALSE), m_normalHLNeedStartTag(TRUE), m_insideSpecialHL(FALSE) {} virtual ~XMLCodeGenerator() { } - - void codify(const char *text) + + void codify(const char *text) { XML_DB(("(codify \"%s\")\n",text)); if (m_insideCodeLine && !m_insideSpecialHL && m_normalHLNeedStartTag) @@ -237,11 +236,11 @@ class XMLCodeGenerator : public CodeOutputInterface m_t << ""; m_normalHLNeedStartTag=FALSE; } - writeXMLCodeString(m_t,text,col); + writeXMLCodeString(m_t,text,m_col); } void writeCodeLink(const char *ref,const char *file, const char *anchor,const char *name, - const char *tooltip) + const char *tooltip) { XML_DB(("(writeCodeLink)\n")); if (m_insideCodeLine && !m_insideSpecialHL && m_normalHLNeedStartTag) @@ -250,7 +249,7 @@ class XMLCodeGenerator : public CodeOutputInterface m_normalHLNeedStartTag=FALSE; } writeXMLLink(m_t,ref,file,anchor,name,tooltip); - col+=qstrlen(name); + m_col+=qstrlen(name); } void writeTooltip(const char *, const DocLinkInfo &, const char *, const char *, const SourceLinkInfo &, const SourceLinkInfo & @@ -258,7 +257,7 @@ class XMLCodeGenerator : public CodeOutputInterface { XML_DB(("(writeToolTip)\n")); } - void startCodeLine(bool) + void startCodeLine(bool) { XML_DB(("(startCodeLine)\n")); m_t << ""; + m_t << ">"; m_insideCodeLine=TRUE; - col=0; + m_col=0; } - void endCodeLine() + void endCodeLine() { XML_DB(("(endCodeLine)\n")); if (!m_insideSpecialHL && !m_normalHLNeedStartTag) @@ -300,7 +299,7 @@ class XMLCodeGenerator : public CodeOutputInterface m_external.resize(0); m_insideCodeLine=FALSE; } - void startFontClass(const char *colorClass) + void startFontClass(const char *colorClass) { XML_DB(("(startFontClass)\n")); if (m_insideCodeLine && !m_insideSpecialHL && !m_normalHLNeedStartTag) @@ -325,7 +324,7 @@ class XMLCodeGenerator : public CodeOutputInterface const char *anchorId,int l) { XML_DB(("(writeLineNumber)\n")); - // we remember the information provided here to use it + // we remember the information provided here to use it // at the start tag. m_lineNumber = l; if (compId) @@ -349,12 +348,12 @@ class XMLCodeGenerator : public CodeOutputInterface } private: - FTextStream &m_t; + FTextStream &m_t; QCString m_refId; QCString m_external; int m_lineNumber; bool m_isMemberRef; - int col; + int m_col; bool m_insideCodeLine; bool m_normalHLNeedStartTag; -- cgit v0.12