[Expat-checkins] expat/lib xmlparse.c,1.44,1.45
Karl Waclawek
karl@waclawek.net
Thu Jun 13 13:32:02 2002
> On Thu, Jun 13, 2002 at 02:53:40PM -0400, Karl Waclawek wrote:
> > Btw, to be honest, I don't like this "reverse indentation" style
> > just to make it fit into 80 character lines.
>
> Me neither; I didn't know it was present in the Expat sources. Do you have a
> pointer?
I am not sure I have expressed myself understandably.
What I mean is: when you read xmlparse.c (especially), indentations
seems to go to the left, as the "block nesting level" increases -
apparently to stay within a line length of 80.
Just open up xmlparse.c and check any of the switch cases in doContent,
for example. Follow the indentations - you will see.
On the other hand - maybe this is standard C style.
As you may have guessed, I am not really a hardcore C/C++ programmer.
Here is a snippet:
<snippet>
case XML_TOK_EMPTY_ELEMENT_NO_ATTS:
if (startElementHandler || endElementHandler) {
const char *rawName = s + enc->minBytesPerChar;
enum XML_Error result;
BINDING *bindings = NULL;
TAG_NAME name;
name.str = poolStoreString(&tempPool, enc, rawName,
rawName + XmlNameLength(enc, rawName));
if (!name.str)
return XML_ERROR_NO_MEMORY;
poolFinish(&tempPool);
result = storeAtts(parser, enc, s, &name, &bindings);
if (result)
return result;
poolFinish(&tempPool);
if (startElementHandler)
startElementHandler(handlerArg, name.str, (const XML_Char **)atts);
if (endElementHandler) {
if (startElementHandler)
*eventPP = *eventEndPP;
endElementHandler(handlerArg, name.str);
}
poolClear(&tempPool);
while (bindings) {
BINDING *b = bindings;
if (endNamespaceDeclHandler)
endNamespaceDeclHandler(handlerArg, b->prefix->name);
bindings = bindings->nextTagBinding;
b->nextTagBinding = freeBindingList;
freeBindingList = b;
b->prefix->binding = b->prevPrefixBinding;
}
}
else if (defaultHandler)
reportDefault(parser, enc, s, next);
if (tagLevel == 0)
return epilogProcessor(parser, next, end, nextPtr);
break;
case XML_TOK_END_TAG:
if (tagLevel == startTagLevel)
return XML_ERROR_ASYNC_ENTITY;
else {
int len;
const char *rawName;
TAG *tag = tagStack;
tagStack = tag->parent;
tag->parent = freeTagList;
freeTagList = tag;
rawName = s + enc->minBytesPerChar*2;
len = XmlNameLength(enc, rawName);
if (len != tag->rawNameLength
|| memcmp(tag->rawName, rawName, len) != 0) {
*eventPP = rawName;
return XML_ERROR_TAG_MISMATCH;
}
--tagLevel;
</snippet>
> IMO, I'd be quite happy to toss anything like that. In fact, a big revamp to
> make everything consistent would be quite nice.
Let's check with Fred. Maybe he likes it the way it is.
> One caution (and I guess this applies to untabifying): if people generate
> patches against 1.95.3, then we won't be able to apply them to the source
> code. Thus, it is usually safest to do big revamps right before a release
> (when the patch queue has been emptied).
Absolutely. 1.95.4 is coming up soon, it seems.
I only have the InternalEntityRefhandler still on my plate,
and it is currently being discussed on the mailing list.
Karl