This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFC: MI - Detecting change of string contents with variable objects
- From: Vladimir Prus <ghost at cs dot msu dot su>
- To: Daniel Jacobowitz <drow at false dot org>
- Cc: Nick Roberts <nickrob at snap dot net dot nz>, gdb-patches at sources dot redhat dot com
- Date: Fri, 5 Jan 2007 17:48:32 +0300
- Subject: Re: RFC: MI - Detecting change of string contents with variable objects
- References: <17797.65268.689590.797944@kahikatea.snap.net.nz> <17821.42314.506114.619107@kahikatea.snap.net.nz> <20070105144440.GB24554@nevyn.them.org>
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