Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Alan Modra <amodra@gmail.com>
Cc: Tom Tromey <tom@tromey.com>,
	Alan Modra via Binutils <binutils@sourceware.org>,
	gdb-patches@sourceware.org
Subject: Re: [PATCH] Add startswith function and use it instead of CONST_STRNEQ.
Date: Wed, 31 Mar 2021 14:18:30 -0600	[thread overview]
Message-ID: <87im57rsa1.fsf@tromey.com> (raw)
In-Reply-To: <20210323000245.GZ6791@bubble.grove.modra.org> (Alan Modra's message of "Tue, 23 Mar 2021 10:32:45 +1030")

Hi.  I'm sorry about the delay on this.

Alan> But all of this horrible old code that likely hasn't been tested is
Alan> eons should simply disappear.

gdb has this issue to a lesser degree as well, where it checks for
headers that have not been missing in 20 years.  This kind of rot is one
of the downsides of the autoconf approach.

Alan> Instead binutils should be using the
Alan> gnulib import already available in the binutils-gdb repository to
Alan> support old systems.  I've had that project on my todo list for quite
Alan> a while.  We'd be able to include stdint.h and stdbool.h for example,
Alan> throwing away bfd_stdint.h and replacing bfd_boolean with bool.

We've had mixed experiences with gnulib in gdb.  Partly that's because
gdb is in C++; but also partly because gnulib is fairly opinionated
about some things, and if you want to be more flexible, it's difficult.

Anyway, I think it would be a good thing to try.  And, it's relatively
easy now that gnulib has moved to the top-level.  The main difficulty
that I would anticipate is that I think there are some gnulib modules
that can't be used for gdb; but if binutils needed these then we'd be in
a bit of a quandary.

I suppose though that the gnulib model is to patch things upstream and
so we could try to work out problems that way.

Alan> Meanwhile, this is a tidied version of the patch I sent you last
Alan> night, Tom.  If you already have one of your own then please ignore
Alan> this.

This looks good to me.  Thank you.

Alan> +#ifndef STR_UTIL_H
Alan> +#define STR_UTIL_H
Alan> +
Alan> +/* Return 1 if the start of STR matches PREFIX, 0 otherwise.  */
Alan> +
Alan> +static inline int
Alan> +startswith (const char *str, const char *prefix)
Alan> +{
Alan> +  return strncmp (str, prefix, strlen (prefix)) == 0;

In keeping with the above, I tend to think that adding a <string.h>
include in this file would be fine, and unlikely to break the build on
any real system.

If there is one, that would be interesting information.

Here's what gnulib has to say about string.h:

https://www.gnu.org/software/gnulib/manual/html_node/string_002eh.html

... if it were missing anywhere, I suppose I'd expect a bullet point to
that effect.

Tom

  parent reply	other threads:[~2021-03-31 20:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4d8880dd-4a83-f0fc-dafd-2079493d4093@suse.cz>
     [not found] ` <alpine.BSF.2.20.16.2103181426260.908@arjuna.pair.com>
     [not found]   ` <20210319063759.GM6791@bubble.grove.modra.org>
     [not found]     ` <b0e46fde-465a-8884-d3e7-2c441a4a62c1@suse.cz>
2021-03-20  7:00       ` Alan Modra via Gdb-patches
2021-03-20 18:58         ` Tom Tromey
2021-03-21 13:12           ` Alan Modra via Gdb-patches
2021-03-22  2:13             ` Tom Tromey
2021-03-22 12:06               ` Alan Modra via Gdb-patches
2021-03-22 16:13                 ` Luis Machado via Gdb-patches
2021-03-22 22:56                   ` Alan Modra via Gdb-patches
2021-03-25 10:53                     ` Luis Machado via Gdb-patches
2021-03-25 11:54                       ` Alan Modra via Gdb-patches
2021-03-25 12:05                         ` Luis Machado via Gdb-patches
2021-03-25 19:47                         ` Luis Machado via Gdb-patches
2021-03-25 22:31                           ` Mike Frysinger via Gdb-patches
2021-03-26 11:44                             ` Luis Machado via Gdb-patches
2021-03-30 11:58                               ` Luis Machado via Gdb-patches
2021-03-31 13:12                                 ` Martin Liška
2021-03-31 13:44                                   ` Luis Machado via Gdb-patches
2021-03-22 16:42                 ` Martin Liška
2021-03-23  0:02                   ` Alan Modra via Gdb-patches
2021-03-23  4:49                     ` Mike Frysinger via Gdb-patches
2021-03-31 20:18                     ` Tom Tromey [this message]
2021-03-22  6:57             ` Mike Frysinger via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87im57rsa1.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox