[Expat-checkins] expat/lib expat.h, 1.63, 1.64 xmlparse.c, 1.127, 1.128

Karl Waclawek kwaclaw at users.sourceforge.net
Tue Mar 16 15:29:31 EST 2004


Update of /cvsroot/expat/expat/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31106

Modified Files:
	expat.h xmlparse.c 
Log Message:
Removed ability to suspend while parsing an external parameter entity.

The problem is that on return from the externalEntityRefHandler() call-back
the parser currently assumes that parsing of the parameter entity is finished,
and updates its internal state accordingly. I do not have the time at this
point to implement and test a solution. Being able to suspend while parsing
the DTD is also less desirable than doing the same while parsing content.

Index: expat.h
===================================================================
RCS file: /cvsroot/expat/expat/lib/expat.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- expat.h	16 Mar 2004 03:50:21 -0000	1.63
+++ expat.h	16 Mar 2004 20:29:28 -0000	1.64
@@ -165,7 +165,8 @@
   XML_ERROR_SUSPENDED,
   XML_ERROR_NOT_SUSPENDED,
   XML_ERROR_ABORTED,
-  XML_ERROR_FINISHED
+  XML_ERROR_FINISHED,
+  XML_ERROR_SUSPEND_PE
 };
 
 enum XML_Content_Type {
@@ -835,12 +836,15 @@
    - endNameSpaceDeclHandler() when stopped in endElementHandler(), 
    and possibly others.
 
-   Can be called from most handlers, including DTD related call-backs.
+   Can be called from most handlers, including DTD related call-backs,
+   except when parsing an external parameter entity and resumable != 0.
    Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise.
-   Possible error codes: XML_ERROR_SUSPENDED - when the parser is already
-   suspended, XML_ERROR_FINISHED - when the parser has already finished.
+   Possible error codes: 
+   - XML_ERROR_SUSPENDED:  when the parser is already suspended.
+   - XML_ERROR_FINISHED:   when the parser has already finished.
+   - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE.
 
-   When resumable = XML_TRUE then parsing is suspended, that is, 
+   When resumable != 0 (true) then parsing is suspended, that is, 
    XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED. 
    Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer()
    return XML_STATUS_ERROR with error code XML_ERROR_ABORTED.

Index: xmlparse.c
===================================================================
RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -d -r1.127 -r1.128
--- xmlparse.c	16 Mar 2004 04:41:54 -0000	1.127
+++ xmlparse.c	16 Mar 2004 20:29:28 -0000	1.128
@@ -1674,7 +1674,15 @@
     errorCode = XML_ERROR_FINISHED;
     return XML_STATUS_ERROR;
   default:
-    parsing = resumable ? XML_SUSPENDED : XML_FINISHED;
+    if (resumable) {
+      if (isParamEntity) {
+        errorCode = XML_ERROR_SUSPEND_PE;
+        return XML_STATUS_ERROR;
+      }
+      parsing = XML_SUSPENDED;
+    }
+    else
+      parsing = XML_FINISHED;
   }
   return XML_STATUS_OK;
 }
@@ -1851,7 +1859,8 @@
     XML_L("parser suspended"),
     XML_L("parser not suspended"),
     XML_L("parsing aborted"),
-    XML_L("parsing finished")
+    XML_L("parsing finished"),
+    XML_L("cannot suspend in external parameter entity")
   };
   if (code > 0 && code < sizeof(message)/sizeof(message[0]))
     return message[code];




More information about the Expat-checkins mailing list