[PATCH] Add startswith function and use it instead of CONST_STRNEQ.
Martin Liška
mliska@suse.cz
Fri Mar 19 12:44:38 GMT 2021
On 3/19/21 7:37 AM, Alan Modra wrote:
> On Thu, Mar 18, 2021 at 02:29:26PM -0400, Hans-Peter Nilsson wrote:
>> On Thu, 18 Mar 2021, Martin Li?ka wrote:
>>
>>> Hello.
>>>
>>> This patch is the same what I suggested for the GCC project:
>>> https://gcc.gnu.org/pipermail/gcc-patches/2021-March/566897.html
>>>
>>> In case on binutils, it's hard to find a single header file that
>>> is always used after string.h is included. That's why I for now
>>> use __builtin_* functions.
>
> Use of builtin functions will need at least a __GNUC__ test and
> fallback for other compilers, which I guess means you may as well
> simply use strncmp and strlen.
>
>>> Is the binutils community interested in the function?
>>
>> How about instead moving and/or making more use of CONST_STRNEQ
>> from bfd/bfd-in.h?
>
> To me the name CONST_STRNEQ just doesn't parse well. Maybe I'm just
> weird, but I read it as "constant string not equal" which of course is
> wrong. I much prefer startswith as a name.
No, you're not weird! The function name is weird. To be honest, I noticed
the function, but the name was so misleading that I ignored it.
> bfd-in.h ought to work
> for an inline startswith too, since every sysdep.h in binutils already
> includes string.h, and so too does gas/as.h.
Yes, that's a correct location. I tried placing the new function here, but
I didn't notice 'make headers' :)
Anyway, as a first step I'm suggesting to do the renaming and I can carry on
with follow up patches that will use the function more.
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-startswith-function-and-use-it-instead-of-CONST_.patch
Type: text/x-patch
Size: 105027 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20210319/fd64b534/attachment-0001.bin>
More information about the Binutils
mailing list