Re: [RFA] bug in symtab.c:lookup_block_symbol()'s search method

Daniel Berlin
2001-09-10T11:50:00Z

Jason Molenda <jason-swarelist@molenda.com> writes:

> On Mon, Sep 10, 2001 at 11:24:10AM -0700, Michael Snyder wrote:
>
>> > + if (SYMBOL_SOURCE_NAME (sym)[0] > name[0])
>> > + {
>> > + break;
>> > + }
>>
>> If this test works, then wouldn't some sort of strcmp test work too?
>
> It is comparing unmangled names, so there may be space chars which
> are not significant. I don't know enough about mangling to be
> confident that I could put a strcmp in here safely.
You could if they were always mangled, but they aren't.
The unmangled names need to be strcmp_iw'd.

We use demangled names when doing symbol lookups because it is easier
to demangle whatever you type in, and look that up, than it is to take
what you type in, mangle it, and look that up.

*Much* easier.

> out later today and see if the testsuite happens to trip up on it.
> The SYMBOL_MATCHES_NAME() call used for the actual comparison uses
> util.c:strcmp_iw, which skips over whitespace.
Right.

>
> (On the good news side, when I first started working on this loop,
> I found that using strcmp() to detect matches produced a number of
> testsuite regressions, helping to Show Me The Light.)

Your test above isn't quite correct, actually.
There is a corner case of the first character being a space. I don't
think this can ever occur in c or C++, no clue about other languages.

>
> Jason

--
"One time the power went out in my house and I had to use the
flash on my camera to see my way around. I made a sandwich and
took fifty pictures of my face. The neighbors thought there was
lightning in my house.
"-Steven Wright