From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31164 invoked by alias); 5 Jan 2007 14:49:16 -0000 Received: (qmail 31152 invoked by uid 22791); 5 Jan 2007 14:49:15 -0000 X-Spam-Check-By: sourceware.org Received: from zigzag.lvk.cs.msu.su (HELO zigzag.lvk.cs.msu.su) (158.250.17.23) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 05 Jan 2007 14:49:11 +0000 Received: from Debian-exim by zigzag.lvk.cs.msu.su with spam-scanned (Exim 4.50) id 1H2qNS-0005QN-It for gdb-patches@sources.redhat.com; Fri, 05 Jan 2007 17:49:07 +0300 Received: from localhost ([127.0.0.1] helo=ip6-localhost) by zigzag.lvk.cs.msu.su with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.50) id 1H2qN4-0005Pl-O9; Fri, 05 Jan 2007 17:48:39 +0300 From: Vladimir Prus To: Daniel Jacobowitz Subject: Re: RFC: MI - Detecting change of string contents with variable objects Date: Fri, 05 Jan 2007 14:49:00 -0000 User-Agent: KMail/1.9.1 Cc: Nick Roberts , gdb-patches@sources.redhat.com References: <17797.65268.689590.797944@kahikatea.snap.net.nz> <17821.42314.506114.619107@kahikatea.snap.net.nz> <20070105144440.GB24554@nevyn.them.org> In-Reply-To: <20070105144440.GB24554@nevyn.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200701051748.33577.ghost@cs.msu.su> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-01/txt/msg00189.txt.bz2 On Friday 05 January 2007 17:44, Daniel Jacobowitz wrote: > On Fri, Jan 05, 2007 at 02:09:30PM +1300, Nick Roberts wrote: > > > Can you use > > > > > > strcmp (var->print_value, print_value) != 0 > > > > Is that more legible? I sometimes see "if (fi != NULL)" but "if (fi)" > > seems clearer. Maybe it comes from programming in Lisp for Emacs. > > Speaking only for myself, I have no preference between "if (fi != > NULL)" and "if (fi)", but I always use "!= 0" with strcmp; that's just > because strcmp's return value is so frequently misused. The != 0 makes > it clear that someone knew what result they were checking for. Yeah, I've learn that for strings a [comparison operator] b is actually written strcmp (a, b) [the same comparison operator] 0 and this conveniention works great, while with "!strcmp" I always need to mentally figure out what's the result. And "if (fi != NULL)" vs. "if (fi)" is much more a matter of personal taste than a legibility matter. - Volodya