[Expat-discuss] isFinal parameter in XML_Parser() and XML_ParseBuffer()

Albrecht Fritzsche ali at mental.com
Mon Oct 22 15:52:36 CEST 2007


Hi,

I cannot find much documentation about this isFinal parameter in calls 
like XML_Parser() and XML_ParseBuffer(). Is it vital that this one was
called or can I get away w/o using it?

My parsing loop looks like

     const size_t BUFFSIZE = 8192;
     char buffer[BUFFSIZE];

     bool done = false;
     while (!done) {
	int size = m_reader->read(buffer, BUFFSIZE);
	if (size == 0) {
	    // (Debug, "End of file reached");  //<--
	    break;
	}
	else if (size < BUFFSIZE) {
	    done = true;
	}

	if (XML_Parse(parser, buffer, int(size), done) == 0) {
	    // (Warning, "Parse error");
	    return false;
         }
     }

So, if the file size is exactly equal to BUFFSIZE then the XML_Parser() 
gets called only once, the second iteration in the while loop terminates 
because the reader returns now 0.

Do I have to add in line //<-- a

   XML_Parse(parser, buffer, 0, true);

just for the sake of passing the EndOfFile indication?

Thanks
Ali



More information about the Expat-discuss mailing list