From f16a63d6d5d9fd11a2f1c57bdfad7f1d4b175f0e Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Thu, 1 Aug 2019 11:17:36 +0200 Subject: issue 7068: "QGDict::hashAsciiKey: Invalid null key" error messages (part 3) --- src/code.l | 10 +++--- src/docparser.cpp | 91 +++++++++++++++++++++++++++++++++++++------------------ src/scanner.l | 4 +-- src/tclscanner.l | 19 ++++++++---- 4 files changed, 82 insertions(+), 42 deletions(-) diff --git a/src/code.l b/src/code.l index ad9447b..56bf75c 100644 --- a/src/code.l +++ b/src/code.l @@ -1513,7 +1513,7 @@ static void writeObjCMethodCall(ObjCCallCtx *ctx) { ctx->objectType = stripClassName(ctx->objectVar->typeString()); //printf(" ctx->objectType=%p\n",ctx->objectType); - if (ctx->objectType) + if (ctx->objectType && !ctx->methodName.isEmpty()) { ctx->method = ctx->objectType->getMemberByName(ctx->methodName); //printf(" ctx->method=%p\n",ctx->method); @@ -1525,7 +1525,7 @@ static void writeObjCMethodCall(ObjCCallCtx *ctx) else // local variable { //printf(" object is local variable\n"); - if (cd!=VariableContext::dummyContext) + if (cd!=VariableContext::dummyContext && !ctx->methodName.isEmpty()) { ctx->method = cd->getMemberByName(ctx->methodName); //printf(" class=%p method=%p\n",cd,ctx->method); @@ -1594,7 +1594,7 @@ static void writeObjCMethodCall(ObjCCallCtx *ctx) { ctx->objectType = ctx->objectType->categoryOf(); } - if (ctx->objectType) + if (ctx->objectType && !ctx->methodName.isEmpty()) { ctx->method = ctx->objectType->getMemberByName(ctx->methodName); } @@ -1623,7 +1623,7 @@ static void writeObjCMethodCall(ObjCCallCtx *ctx) if (bclass->classDef->compoundType()!=ClassDef::Protocol) { ctx->objectType = bclass->classDef; - if (ctx->objectType) + if (ctx->objectType && !ctx->methodName.isEmpty()) { ctx->method = ctx->objectType->getMemberByName(ctx->methodName); } @@ -1701,7 +1701,7 @@ static void writeObjCMethodCall(ObjCCallCtx *ctx) else { ctx->objectType = stripClassName(ictx->method->typeString()); - if (ctx->objectType) + if (ctx->objectType && !ctx->methodName.isEmpty()) { ctx->method = ctx->objectType->getMemberByName(ctx->methodName); } diff --git a/src/docparser.cpp b/src/docparser.cpp index 4ef9de6..790fbb5 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -1869,6 +1869,7 @@ DocAnchor::DocAnchor(DocNode *parent,const QCString &id,bool newAnchor) if (id.isEmpty()) { warn_doc_error(g_fileName,doctokenizerYYlineno,"Empty anchor label"); + return; } if (id.left(CiteConsts::anchorPrefix.length()) == CiteConsts::anchorPrefix) @@ -3193,7 +3194,7 @@ DocHtmlCaption::DocHtmlCaption(DocNode *parent,const HtmlAttribList &attribs) HtmlAttrib *opt; for (li.toFirst();(opt=li.current());++li) { - if (opt->name=="id") // interpret id attribute as an anchor + if (opt->name=="id" && !opt->value.isEmpty()) // interpret id attribute as an anchor { SectionInfo *sec = Doxygen::sectionDict->find(opt->value); if (sec) @@ -7041,17 +7042,25 @@ void DocRoot::parse() warn_doc_error(g_fileName,doctokenizerYYlineno,"found paragraph command outside of subsubsection context!"); while (retval==RetVal_Paragraph) { - SectionInfo *sec=Doxygen::sectionDict->find(g_token->sectionId); - if (sec) + if (!g_token->sectionId.isEmpty()) { - DocSection *s=new DocSection(this, - QMIN(4+Doxygen::subpageNestingLevel,5),g_token->sectionId); - m_children.append(s); - retval = s->parse(); + SectionInfo *sec=Doxygen::sectionDict->find(g_token->sectionId); + if (sec) + { + DocSection *s=new DocSection(this, + QMIN(4+Doxygen::subpageNestingLevel,5),g_token->sectionId); + m_children.append(s); + retval = s->parse(); + } + else + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"Invalid paragraph id `%s'; ignoring paragraph",qPrint(g_token->sectionId)); + retval = 0; + } } else { - warn_doc_error(g_fileName,doctokenizerYYlineno,"Invalid paragraph id `%s'; ignoring paragraph",qPrint(g_token->sectionId)); + warn_doc_error(g_fileName,doctokenizerYYlineno,"Missing id for paragraph; ignoring paragraph"); retval = 0; } } @@ -7062,17 +7071,25 @@ void DocRoot::parse() warn_doc_error(g_fileName,doctokenizerYYlineno,"found subsubsection command outside of subsection context!"); while (retval==RetVal_Subsubsection) { - SectionInfo *sec=Doxygen::sectionDict->find(g_token->sectionId); - if (sec) + if (!g_token->sectionId.isEmpty()) { - DocSection *s=new DocSection(this, - QMIN(3+Doxygen::subpageNestingLevel,5),g_token->sectionId); - m_children.append(s); - retval = s->parse(); + SectionInfo *sec=Doxygen::sectionDict->find(g_token->sectionId); + if (sec) + { + DocSection *s=new DocSection(this, + QMIN(3+Doxygen::subpageNestingLevel,5),g_token->sectionId); + m_children.append(s); + retval = s->parse(); + } + else + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"Invalid subsubsection id `%s'; ignoring subsubsection",qPrint(g_token->sectionId)); + retval = 0; + } } else { - warn_doc_error(g_fileName,doctokenizerYYlineno,"Invalid subsubsection id `%s'; ignoring subsubsection",qPrint(g_token->sectionId)); + warn_doc_error(g_fileName,doctokenizerYYlineno,"Missing id for subsubsection; ignoring subsubsection"); retval = 0; } } @@ -7083,17 +7100,25 @@ void DocRoot::parse() warn_doc_error(g_fileName,doctokenizerYYlineno,"found subsection command outside of section context!"); while (retval==RetVal_Subsection) { - SectionInfo *sec=Doxygen::sectionDict->find(g_token->sectionId); - if (sec) + if (!g_token->sectionId.isEmpty()) { - DocSection *s=new DocSection(this, - QMIN(2+Doxygen::subpageNestingLevel,5),g_token->sectionId); - m_children.append(s); - retval = s->parse(); + SectionInfo *sec=Doxygen::sectionDict->find(g_token->sectionId); + if (sec) + { + DocSection *s=new DocSection(this, + QMIN(2+Doxygen::subpageNestingLevel,5),g_token->sectionId); + m_children.append(s); + retval = s->parse(); + } + else + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"Invalid subsection id `%s'; ignoring subsection",qPrint(g_token->sectionId)); + retval = 0; + } } else { - warn_doc_error(g_fileName,doctokenizerYYlineno,"Invalid subsection id `%s'; ignoring subsection",qPrint(g_token->sectionId)); + warn_doc_error(g_fileName,doctokenizerYYlineno,"Missing id for subsection; ignoring subsection"); retval = 0; } } @@ -7115,17 +7140,25 @@ void DocRoot::parse() // then parse any number of level1 sections while (retval==RetVal_Section) { - SectionInfo *sec=Doxygen::sectionDict->find(g_token->sectionId); - if (sec) + if (!g_token->sectionId.isEmpty()) { - DocSection *s=new DocSection(this, - QMIN(1+Doxygen::subpageNestingLevel,5),g_token->sectionId); - m_children.append(s); - retval = s->parse(); + SectionInfo *sec=Doxygen::sectionDict->find(g_token->sectionId); + if (sec) + { + DocSection *s=new DocSection(this, + QMIN(1+Doxygen::subpageNestingLevel,5),g_token->sectionId); + m_children.append(s); + retval = s->parse(); + } + else + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"Invalid section id `%s'; ignoring section",qPrint(g_token->sectionId)); + retval = 0; + } } else { - warn_doc_error(g_fileName,doctokenizerYYlineno,"Invalid section id `%s'; ignoring section",qPrint(g_token->sectionId)); + warn_doc_error(g_fileName,doctokenizerYYlineno,"Missing id for section; ignoring section"); retval = 0; } } diff --git a/src/scanner.l b/src/scanner.l index 1b948dd..615c92f 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -1143,9 +1143,9 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) ")" { BEGIN( ObjCMethod ); } -({ID})?":" { // Keyword of parameter +({ID})?{BN}*":" { // Keyword of parameter QCString keyw = yytext; - keyw=keyw.left(keyw.length()-1); // strip : + keyw=keyw.left(keyw.length()-1).stripWhiteSpace(); // strip : if (keyw.isEmpty()) { current->name += " :"; diff --git a/src/tclscanner.l b/src/tclscanner.l index 9ec512a..7ee458b 100644 --- a/src/tclscanner.l +++ b/src/tclscanner.l @@ -2274,21 +2274,22 @@ D } //! Handle \c namespace statements. -static void tcl_command_NAMESPACE() +static bool tcl_command_NAMESPACE() { D QCString myNs, myName, myStr; //Entry *myEntryNs=NULL; tcl_scan *myScan = tcl.scan.at(0); + tcl_name(myScan->ns,(*tcl.list_commandwords.at(4)),myNs,myName); + if (myName.isEmpty()) return false; // not a namespace tcl_codify_cmd("keyword",0); tcl_codify_cmd(NULL,1); tcl_codify_cmd("keyword",2); tcl_codify_cmd(NULL,3); tcl_codify_cmd(NULL,4); tcl_codify_cmd(NULL,5); - tcl_name(myScan->ns,(*tcl.list_commandwords.at(4)),myNs,myName); - if (myNs.length()) + if (!myNs.isEmpty()) { myName = myNs+"::"+myName; } @@ -2310,6 +2311,7 @@ D tcl.word_is=' '; } myScan = tcl_scan_start(tcl.word_is,myStr, myName, NULL, NULL); + return true; } //! Handle \c itcl::class statements. @@ -2636,11 +2638,16 @@ tcl_inf("->\n"); if ((*tcl.list_commandwords.at(2))=="eval") { if (tcl.list_commandwords.count() < 7) {myLine=__LINE__;goto command_warn;} - tcl_command_NAMESPACE(); + if (tcl_command_NAMESPACE()) + { + goto command_end; + } + } + else + { + tcl_command_OTHER(); goto command_end; } - tcl_command_OTHER(); - goto command_end; } if (myStr=="itcl::class") { -- cgit v0.12