[Patch] opcodes/z8k-opc.h regenerated

Andreas Schwab schwab@redhat.com
Mon Sep 7 13:08:00 GMT 2009


Tristan Gingold <gingold@adacore.com> writes:

> On Sep 7, 2009, at 2:17 PM, Andreas Schwab wrote:
>
>> Alan Modra <amodra@bigpond.net.au> writes:
>>
>>> static int
>>> -func (struct op *a, struct op *b)
>>> +func (const void *p1, const void *p2)
>>> {
>>> -  return strcmp ((a)->name, (b)->name);
>>> +  const struct op *a = p1;
>>> +  const struct op *b = p2;
>>> +  int ret = strcmp (a->name, b->name);
>>> +  if (ret != 0)
>>> +    return ret;
>>> +  return p1 > p2;
>>
>> Shouldn't that handle p1 < p2 as well?
>
> (You reply to Alan but it is not explicitly listed as a recipient !)

That's what Alan asked me to do (see the Mail-Followup-To header).

> Or:
>
>  return (p1 > p2) * 2 - 1;

Not sure whether you can count on p1 != p2.  A common idiom is
(p1 > p2) - (p1 < p2).

Andreas.

-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."



More information about the Binutils mailing list