[PATCH] [RFC] Come up with startswith function.
Fri Mar 19 06:37:59 GMT 2021
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. 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.
Australia Development Lab, IBM
More information about the Binutils