public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [pushed] c++: don't use strchrnul [PR107781]
Date: Tue, 22 Nov 2022 09:29:55 -0500	[thread overview]
Message-ID: <20221122142955.677712-1-jason@redhat.com> (raw)
In-Reply-To: <Y3yul3XQBF+kGxeF@tucnak>

As Jonathan suggested.

Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

The contracts implementation was using strchrnul, which is a glibc
extension, so bootstrap broke on non-glibc targets.  Use C89 strcspn
instead.

	PR c++/107781

gcc/cp/ChangeLog:

	* contracts.cc (role_name_equal): Use strcspn instead
	of strchrnul.
---
 gcc/cp/contracts.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
index f3afcc62ba0..a9097016768 100644
--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -210,8 +210,8 @@ lookup_concrete_semantic (const char *name)
 static bool
 role_name_equal (const char *role, const char *name)
 {
-  size_t role_len = strchrnul (role, ':') - role;
-  size_t name_len = strchrnul (name, ':') - name;
+  size_t role_len = strcspn (role, ":");
+  size_t name_len = strcspn (name, ":");
   if (role_len != name_len)
     return false;
   return strncmp (role, name, role_len) == 0;

base-commit: 4eb3a48698b2ca43967a4e7e7cfc0408192e85b2
-- 
2.31.1


      reply	other threads:[~2022-11-22 14:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 23:31 [PATCH RFA(configure)] c++: provide strchrnul on targets without it [PR107781] Jason Merrill
2022-11-22  8:41 ` Jakub Jelinek
2022-11-22 11:12   ` Jakub Jelinek
2022-11-22 14:29     ` Jason Merrill [this message]

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=20221122142955.677712-1-jason@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).