emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suspicious code in search.c


From: Nick Roberts
Subject: Re: Suspicious code in search.c
Date: Fri, 21 Oct 2005 15:01:16 +1300

Kenichi Handa writes:
 > In article <address@hidden>, address@hidden (Kim F. Storm) writes:
 > 
 > > See search.c line 1711-1712:
 > 
 > >      if (ASCII_BYTE_P (*ptr) || ! multibyte)
 > >        ch = *ptr;
 > -->    else if (charset_base
 > -->             && (pat_end - ptr) == 1 || CHAR_HEAD_P (ptr[1]))
 > >        {
 > >          unsigned char *charstart = ptr - 1;
 > 
 > 
 > > Based on the indentation, I would assume the following interpretation
 > > is intended:
 > 
 > >      else if (charset_base
 > >               && ((pat_end - ptr) == 1 || CHAR_HEAD_P (ptr[1])))
 > >                  ^                                            ^
 > 
 > Yes, and a compiler should interpret that part as above.
 > But, I agree that it's better to add that explicit parentheses.

The original expression is equivalent to:

          else if ((charset_base
                   && (pat_end - ptr) == 1) || CHAR_HEAD_P (ptr[1]))

I don't know which expression is right, but you've changed the logic.

Nick


main ()
{
  if (0 && 0 || 1) printf ("1\n");
  if ((0 && 0) || 1) printf ("2\n");
  if (0 && (0 || 1)) printf ("3\n");
}

nickrob/38 mytest
1
2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]