Re: [xml] 1.8.1 defect

Date view Thread view Subject view Author view

From: Clark C. Evans (clark.evans@manhattanproject.com)
Date: Tue Dec 21 1999 - 00:00:51 EST


On Tue, 21 Dec 1999, Daniel Veillard wrote:
> > When compiling 1.8.1 I got a warning for parser.c line 857
> > if ((cur = '&') && (ptr[1] == '#') && (ptr[2] == 'x')) {
> > which should probably read
> > if ((cur == '&') && (ptr[1] == '#') && (ptr[2] == 'x')) {

FYI, there is a C idiom that protects against this
type of problem:

  "Always put a constant as the lvalue for an equality
   test -- a compile time error is then issued if the
   assignment operator is accidently used."

Thus, the above code should have been writen:

  if (('&' == cur) && ('#' == ptr[1]) && ('x' == ptr[2])) {

The idiom has saved me thousands of times... you might
even want to consider writing a converter for your
old code. I had one, but it is now owned by a previous
employer, and since I'm rarely doing C code these days,
I havn't had the need to re-write it.

Best,

Clark

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


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:29:56 EDT