Re: [xml] Why the strncasecmp() avoidance?

Date view Thread view Subject view Author view

From: Wayne Davison (wayned@blorf.net)
Date: Fri Sep 22 2000 - 05:14:32 EDT


On Fri, 22 Sep 2000, Daniel Veillard wrote:
> I see no problem if you provide xmlStrncasecmp(), yes go ahead !

Excellent! I had started working on this earlier today (before running
off to play some music with my friends), and now I've taken the time to
finish it up.

One of the reasons I decided to dive in was that I noticed that the
xmlStrcmp() functions had a minor problems: if presented with two zero-
length strings, the comparison would run past the end of the strings. I
also noticed that the xmlStrncmp() function didn't do quite the same
preliminary pointer-equality test as xmlStrcmp().

My patch fixes both these problems, adds case-ignoring versions of both
these functions, and also adds a case-ignoring version of xmlStrstr():
xmlStrcasestr(). For those that care to look at my revised strcmp loop
algorithm, keep in mind that it always returns a difference from inside
the loop (even if one string ends before the other does) and that the
while condition only gets reached if both strings are still in agreement
(so there's no need to check both string pointers for the end).

My patch also changes several places in the code to use the new case-
ignoring string functions. You'll have to check what I've done to see if
it goes too far (i.e., if XML expects a case-significant string comparison
in instances where HTML does not) or not far enough. For instance, I did
change xmlHasProp() and xmlGetProp() to use xmlStrcasecmp(), but I'm not
sure if that was the right thing to do (or if the code really needs html
versions of these functions).

Also, I added an include of tree.h to nanohttp.c just to get the BAD_CAST
define. That seems like overkill to me, but I think that is what's
currently required.

..wayne..


----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Fri Sep 22 2000 - 05:43:18 EDT