unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Nick Roberts <nickrob@snap.net.nz>
Cc: emacs-devel@gnu.org, "Kim F. Storm" <storm@cua.dk>
Subject: Re: Suspicious code in search.c
Date: Fri, 21 Oct 2005 15:01:16 +1300	[thread overview]
Message-ID: <17240.19436.738186.836546@kahikatea.snap.net.nz> (raw)
In-Reply-To: <E1ESl3I-00065J-00@etlken>

Kenichi Handa writes:
 > In article <m37jc8i6l1.fsf@kfs-l.imdomain.dk>, storm@cua.dk (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	other threads:[~2005-10-21  2:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-20 14:52 Suspicious code in search.c Kim F. Storm
2005-10-20 23:38 ` Richard M. Stallman
2005-10-21  0:52   ` Kenichi Handa
2005-10-21 17:51     ` Richard M. Stallman
2005-10-21  0:46 ` Kenichi Handa
2005-10-21  2:01   ` Nick Roberts [this message]
2005-10-21  2:27     ` Kenichi Handa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17240.19436.738186.836546@kahikatea.snap.net.nz \
    --to=nickrob@snap.net.nz \
    --cc=emacs-devel@gnu.org \
    --cc=storm@cua.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).