From kwaclaw at users.sourceforge.net Wed Feb 11 11:42:42 2004 From: kwaclaw at users.sourceforge.net (Karl Waclawek) Date: Wed Feb 11 11:46:13 2004 Subject: [Expat-checkins] expat/lib xmlparse.c,1.121,1.122 Message-ID: Update of /cvsroot/expat/expat/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24960 Modified Files: xmlparse.c Log Message: Made these compiler warnings go away: - not all cases handled for switch based an enumeration: added default: ; where appropriate - char* passed where const char* was expected: changed variable declarations to const char* Index: xmlparse.c =================================================================== RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v retrieving revision 1.121 retrieving revision 1.122 diff -u -d -r1.121 -r1.122 --- xmlparse.c 7 Jan 2004 17:10:52 -0000 1.121 +++ xmlparse.c 11 Feb 2004 16:42:40 -0000 1.122 @@ -1424,8 +1424,9 @@ case XML_FINISHED: errorCode = XML_ERROR_FINISHED; return XML_STATUS_ERROR; + default: + parsing = XML_PARSING; } - parsing = XML_PARSING; if (len == 0) { finalBuffer = (XML_Bool)isFinal; @@ -1449,8 +1450,10 @@ case XML_INITIALIZED: case XML_PARSING: parsing = XML_FINISHED; + /* fall through */ + default: + return XML_STATUS_OK; } - return XML_STATUS_OK; } eventEndPtr = eventPtr; processor = errorProcessor; @@ -1531,7 +1534,7 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal) { const char *start; - enum XML_Error result; + enum XML_Error result = XML_STATUS_OK; switch (parsing) { case XML_SUSPENDED: @@ -1540,8 +1543,9 @@ case XML_FINISHED: errorCode = XML_ERROR_FINISHED; return XML_STATUS_ERROR; + default: + parsing = XML_PARSING; } - parsing = XML_PARSING; start = bufferPtr; positionPtr = start; @@ -1564,11 +1568,11 @@ break; case XML_INITIALIZED: case XML_PARSING: - result = XML_STATUS_OK; if (isFinal) { parsing = XML_FINISHED; return result; } + default: ; /* should not happen */ } } @@ -1587,7 +1591,9 @@ case XML_FINISHED: errorCode = XML_ERROR_FINISHED; return NULL; + default: ; } + if (len > bufferLim - bufferEnd) { /* FIXME avoid integer overflow */ int neededSize = len + (bufferEnd - bufferPtr); @@ -1664,15 +1670,16 @@ case XML_FINISHED: errorCode = XML_ERROR_FINISHED; return XML_STATUS_ERROR; + default: + parsing = resumable ? XML_SUSPENDED : XML_FINISHED; } - parsing = resumable ? XML_SUSPENDED : XML_FINISHED; return XML_STATUS_OK; } enum XML_Status XMLCALL XML_ResumeParser(XML_Parser parser) { - enum XML_Error result; + enum XML_Error result = XML_STATUS_OK; if (parsing != XML_SUSPENDED) { errorCode = XML_ERROR_NOT_SUSPENDED; @@ -1694,11 +1701,11 @@ break; case XML_INITIALIZED: case XML_PARSING: - result = XML_STATUS_OK; if (finalBuffer) { parsing = XML_FINISHED; return result; } + default: ; } } @@ -2049,8 +2056,9 @@ return XML_ERROR_NONE; case XML_FINISHED: return XML_ERROR_ABORTED; + default: + start = next; } - start = next; } break; case XML_TOK_PARTIAL: @@ -2536,6 +2544,7 @@ return XML_ERROR_NONE; case XML_FINISHED: return XML_ERROR_ABORTED; + default: ; } } /* not reached */ @@ -3068,6 +3077,7 @@ return XML_ERROR_NONE; case XML_FINISHED: return XML_ERROR_ABORTED; + default: ; } } /* not reached */ @@ -3393,8 +3403,9 @@ return XML_ERROR_NONE; case XML_FINISHED: return XML_ERROR_ABORTED; + default: + *nextPtr = next; } - *nextPtr = next; /* stop scanning for text declaration - we found one */ processor = entityValueProcessor; return entityValueProcessor(parser, next, end, nextPtr); @@ -4448,10 +4459,10 @@ return XML_ERROR_NONE; case XML_FINISHED: return XML_ERROR_ABORTED; + default: + s = next; + tok = XmlPrologTok(enc, s, end, &next); } - - s = next; - tok = XmlPrologTok(enc, s, end, &next); } /* not reached */ } @@ -4519,6 +4530,7 @@ return XML_ERROR_NONE; case XML_FINISHED: return XML_ERROR_ABORTED; + default: ; } } } @@ -4527,7 +4539,7 @@ processInternalEntity(XML_Parser parser, ENTITY *entity) { const char *textStart, *textEnd; - char *next; + const char *next; enum XML_Error result; OPEN_INTERNAL_ENTITY *openEntity; @@ -4585,7 +4597,7 @@ { ENTITY *entity; const char *textStart, *textEnd; - char *next; + const char *next; int processorTagLevel; enum XML_Error result; OPEN_INTERNAL_ENTITY *openEntity = openInternalEntities; From kwaclaw at users.sourceforge.net Fri Feb 13 13:11:54 2004 From: kwaclaw at users.sourceforge.net (Karl Waclawek) Date: Fri Feb 13 13:15:48 2004 Subject: [Expat-checkins] expat/lib xmlparse.c, 1.122, 1.123 xmlrole.c, 1.15, 1.16 Message-ID: Update of /cvsroot/expat/expat/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3081 Modified Files: xmlparse.c xmlrole.c Log Message: Applied a simplified version of Jeremy Kloth's patch for bug #896188. Also removed some code that was never executed, because the condition (prologState.documentEntity && role == XML_ROLE_INNER_PARAM_ENTITY_REF) can never be true. Improved some comments as well. Index: xmlparse.c =================================================================== RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v retrieving revision 1.122 retrieving revision 1.123 diff -u -d -r1.122 -r1.123 --- xmlparse.c 11 Feb 2004 16:42:40 -0000 1.122 +++ xmlparse.c 13 Feb 2004 18:11:51 -0000 1.123 @@ -284,6 +284,7 @@ const char *internalEventEndPtr; struct open_internal_entity *next; ENTITY *entity; + XML_Bool betweenDecl; /* WFC: PE Between Declarations */ } OPEN_INTERNAL_ENTITY; typedef enum XML_Error PTRCALL Processor(XML_Parser parser, @@ -322,7 +323,8 @@ const char *end, int tok, const char *next, const char **nextPtr, XML_Bool haveMore); static enum XML_Error -processInternalEntity(XML_Parser parser, ENTITY *entity); +processInternalEntity(XML_Parser parser, ENTITY *entity, + XML_Bool betweenDecl); static enum XML_Error doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, const char *start, const char *end, const char **endPtr, @@ -2224,7 +2226,7 @@ reportDefault(parser, enc, s, next); break; } - result = processInternalEntity(parser, entity); + result = processInternalEntity(parser, entity, XML_FALSE); if (result != XML_ERROR_NONE) return result; } @@ -3581,11 +3583,16 @@ return XML_ERROR_PARTIAL_CHAR; case XML_TOK_NONE: #ifdef XML_DTD - if (enc != encoding) { + /* for internal PE NOT referenced between declarations */ + if (enc != encoding && !openInternalEntities->betweenDecl) { *nextPtr = s; return XML_ERROR_NONE; } - if (isParamEntity) { + /* WFC: PE Between Declarations - must check that PE contains + complete markup, not only for external PEs, but also for + internal PEs if the reference occurs between declarations. + */ + if (isParamEntity || enc != encoding) { if (XmlTokenRole(&prologState, XML_TOK_NONE, end, end, enc) == XML_ROLE_ERROR) return XML_ERROR_SYNTAX; @@ -4136,6 +4143,8 @@ case XML_ROLE_ERROR: switch (tok) { case XML_TOK_PARAM_ENTITY_REF: + /* PE references in internal subset are + not allowed within declarations. */ return XML_ERROR_PARAM_ENTITY_REF; case XML_TOK_XML_DECL: return XML_ERROR_MISPLACED_XML_PI; @@ -4217,11 +4226,6 @@ case XML_ROLE_PARAM_ENTITY_REF: #ifdef XML_DTD case XML_ROLE_INNER_PARAM_ENTITY_REF: - /* PE references in internal subset are - not allowed within declarations */ - if (prologState.documentEntity && - role == XML_ROLE_INNER_PARAM_ENTITY_REF) - return XML_ERROR_PARAM_ENTITY_REF; dtd->hasParamEntityRefs = XML_TRUE; if (!paramEntityParsing) dtd->keepProcessing = dtd->standalone; @@ -4261,7 +4265,9 @@ return XML_ERROR_RECURSIVE_ENTITY_REF; if (entity->textPtr) { enum XML_Error result; - result = processInternalEntity(parser, entity); + XML_Bool betweenDecl = + (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE); + result = processInternalEntity(parser, entity, betweenDecl); if (result != XML_ERROR_NONE) return result; handleDefault = XML_FALSE; @@ -4536,7 +4542,8 @@ } static enum XML_Error -processInternalEntity(XML_Parser parser, ENTITY *entity) +processInternalEntity(XML_Parser parser, ENTITY *entity, + XML_Bool betweenDecl) { const char *textStart, *textEnd; const char *next; @@ -4557,6 +4564,7 @@ openEntity->next = openInternalEntities; openInternalEntities = openEntity; openEntity->entity = entity; + openEntity->betweenDecl = betweenDecl; openEntity->internalEventPtr = NULL; openEntity->internalEventEndPtr = NULL; textStart = (char *)entity->textPtr; @@ -4917,8 +4925,8 @@ break; } #endif /* XML_DTD */ - /* in the internal subset, PE references are not legal - within markup declarations, e.g entity values in this case */ + /* In the internal subset, PE references are not legal + within markup declarations, e.g entity values in this case. */ eventPtr = entityTextPtr; result = XML_ERROR_PARAM_ENTITY_REF; goto endEntityValue; Index: xmlrole.c =================================================================== RCS file: /cvsroot/expat/expat/lib/xmlrole.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- xmlrole.c 16 Oct 2003 04:51:11 -0000 1.15 +++ xmlrole.c 13 Feb 2004 18:11:51 -0000 1.16 @@ -370,6 +370,8 @@ case XML_TOK_CLOSE_BRACKET: state->handler = doctype5; return XML_ROLE_DOCTYPE_NONE; + case XML_TOK_NONE: + return XML_ROLE_NONE; } return common(state, tok); }