[commit] Deprecate remaining STREQ uses

Daniel Jacobowitz drow@mvista.com
Tue Nov 25 17:57:00 GMT 2003


On Tue, Nov 25, 2003 at 12:54:15PM -0500, Andrew Cagney wrote:
> >On 25 Nov 2003 08:55:33 +0200, Eli Zaretskii <eliz@elta.co.il> said:
> >
> >>>From: David Carlton <carlton@kealia.com>
> >>>Date: Mon, 24 Nov 2003 12:06:24 -0800
> >>>
> >>>I was thinking that just using keyboard macros might do the trick:
> >
> >
> >>For such a simple job, it probably would.  But c-macro-expand is more
> >>trustworthy, IMHO: it actually runs cpp and has provisions for you to
> >>specify the same compiler switches as are used during an actual
> >>compilation, so you don't run a risk of missing some obscure #define
> >>somewhere.
> >
> >
> >Actually, in the case at hand, they would give different results, it
> >turns out!  The definition of STREQ isn't simply strcmp()==0 - there's
> >an optimization (or "optimization", perhaps) there as well.
> 
> You'll now appreciate my paranoia :-)
> 
> So, should the transformation be the strictly mechanical inline expansion:
> 
>   STREQ(a,b) =>  (*(a) == *(b) ? !strcmp ((a), (b)) : 0)
> 
> or also include a simplification leading to:
> 
>   STREQ(a,b) => (strcmp ((a), (b)) == 0)

Personally, I recommend the latter - I think part of the motivation for
eliminating STREQ was to get rid of that extra test, right?  If you
want to do this mechanically, you can just change the definition of
STREQ first, of course.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer



More information about the Gdb-patches mailing list