From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id jWbMBCHZZGBkFQAAWB0awg (envelope-from ) for ; Wed, 31 Mar 2021 16:18:41 -0400 Received: by simark.ca (Postfix, from userid 112) id 068A71EE1B; Wed, 31 Mar 2021 16:18:41 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DKIM_SIGNED,MAILING_LIST_MULTI, RCVD_IN_BL_SPAMCOP_NET,T_DKIM_INVALID,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0E39A1EE0E for ; Wed, 31 Mar 2021 16:18:40 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ABD503846403; Wed, 31 Mar 2021 20:18:39 +0000 (GMT) Received: from gateway20.websitewelcome.com (gateway20.websitewelcome.com [192.185.48.38]) by sourceware.org (Postfix) with ESMTPS id A5A793846403 for ; Wed, 31 Mar 2021 20:18:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A5A793846403 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 19F1D400EBE9C for ; Wed, 31 Mar 2021 15:08:32 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id RhINllLB1mJLsRhINlN8JX; Wed, 31 Mar 2021 15:18:31 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=kR5PvRUq/uoGWvDAYDz5+O448J5jGSmw0rtg5Y4kXBs=; b=flIhOuTYroVLAkxds+FhJhUAAW 6D+DV4okhHP0TQPlKUK8gZKdiCWs3cTcI1R3mviUDUBJ+Z8vMgz0zwKuLUd8owAkKxMx+S7VHpHkO SsdVhXOFryGGJFCubDFeQFfDW; Received: from 71-211-182-15.hlrn.qwest.net ([71.211.182.15]:51810 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lRhIN-002XLF-CD; Wed, 31 Mar 2021 14:18:31 -0600 From: Tom Tromey To: Alan Modra Subject: Re: [PATCH] Add startswith function and use it instead of CONST_STRNEQ. References: <4d8880dd-4a83-f0fc-dafd-2079493d4093@suse.cz> <20210319063759.GM6791@bubble.grove.modra.org> <20210320070037.GR6791@bubble.grove.modra.org> <87wnu1k5z1.fsf@tromey.com> <20210321131254.GS6791@bubble.grove.modra.org> <87k0q0j5ql.fsf@tromey.com> <20210322120652.GV6791@bubble.grove.modra.org> <20210323000245.GZ6791@bubble.grove.modra.org> X-Attribution: Tom Date: Wed, 31 Mar 2021 14:18:30 -0600 In-Reply-To: <20210323000245.GZ6791@bubble.grove.modra.org> (Alan Modra's message of "Tue, 23 Mar 2021 10:32:45 +1030") Message-ID: <87im57rsa1.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.182.15 X-Source-L: No X-Exim-ID: 1lRhIN-002XLF-CD X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-182-15.hlrn.qwest.net (murgatroyd) [71.211.182.15]:51810 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Tromey , Alan Modra via Binutils , gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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 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