From patchwork Sun Mar 31 10:31:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 87857 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 394603858282 for ; Sun, 31 Mar 2024 10:33:32 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 72FEF3858C5E for ; Sun, 31 Mar 2024 10:32:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 72FEF3858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 72FEF3858C5E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711881129; cv=none; b=P6lwBj+xs4gmprfDEg6u1PG/CDHBQGW1Ai6G8MFmRXHC1FYEp56upc0w69O4o7mG9s2TBiCeJNcd39nL/1uczTdZ9gu9i3zHAwp7CZUxideYrJgtIiYhaLDk7QEyuM1Smycst3Sb6LWc3mWlgQP+diJsvKrjY14OPc5BtCpVGKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711881129; c=relaxed/simple; bh=kCtIQjYOvaN9Ldf0PrTb3F8N/TZPT0vgCnsnW7DHdWQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Gqm5A78rQW1fie9w1pF3TtxuZP2XvWeBCM8ZhsZ5hL/oYBbAHKCGP941m/uesaXNw4CxmmRoeA6UkOM2Ob6Go4Cw/pJisx9f3oiHiy7bJy8bi5J4AhTMEC4c8114IHutXpB4j03plgSzACtjgOs8H4+Wwl9oaIDtPN/M8zNkWt0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711881127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LgKtFOpjUVEPGsjxTEdDvisJj2JfoHfouWzF2LNmNQI=; b=YcAtmwqXkx2OHYB1xcQBkohZcsEuJtJfE3ZmFCw3Dv3EVWrt7wBKrYRxCTElM2BzW75ZM3 kQqfBQzVdGyq1zdD+HRKmcWOeuxuJM6uTh//9avUELm16h0PTGGsRW1nAG8lMMS6uCzvY7 QXooYChcM1rz7xD24MR9CM7y0RLowFg= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-_EqPUeD0MSuP2iqh6YBzEw-1; Sun, 31 Mar 2024 06:32:05 -0400 X-MC-Unique: _EqPUeD0MSuP2iqh6YBzEw-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a4e53b37d9fso59325966b.3 for ; Sun, 31 Mar 2024 03:32:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711881124; x=1712485924; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LgKtFOpjUVEPGsjxTEdDvisJj2JfoHfouWzF2LNmNQI=; b=xFYDzOdQyjIBM1wTeQ9Zz27r8HgG3GbzpW2H0JT9PzQ3bz0OMwLfjixvRduywplYdu vLQx8YFcfAcej6tlep8tUUrgNpkR6dFsCBmPuToszG0Ydrg2g/G3Hejk617P/M83/dlk bhjLD0mFZBPRWI18KB3zDtYbotuAHKsyOVD+gghZGT7Y8vETkWBI9LnYm8MdKfEBzQXE YVzWvctlTXKh+FHITLAX8TsrOkvzb4P+S73FMGso4ApomyjUwrzohiBSBNgonw2m8zdf 0p6W9f6TXuuV29sMXFztKLvQjYMABlupFkl1PG4lazTwELS5zNiWwnTw9E828q4poD8l 4ANQ== X-Gm-Message-State: AOJu0YznELJG/1u4H5HrFqNOHimirCGHjlL6Py/VwFOxqRQMP3Z5+Pih /N7o7AfEnWvIvIv0UDuFArB+mzoXrzF0buzZ1+BYI8LZbKPU5qNhsuL2QmkI8ypyHKqpxrEm+Qd Ac86dkLCD0PerlZSlhedaeUfdtjUlhnsz8Ii50Xv0PbyjXIWcgObZ/47Ar7TbH40e/7s9LZFKb+ kUZZsteww8cjwM+S+jLry7xxjPxx6SF3LUZS0yH8jgEL8= X-Received: by 2002:a17:906:ca58:b0:a46:5dc4:dab9 with SMTP id jx24-20020a170906ca5800b00a465dc4dab9mr3976482ejb.38.1711881124110; Sun, 31 Mar 2024 03:32:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFI6JYJxhuNpMudK8VjNqg9e/zzKDSwyGRXUIzIM9UqLL1vlVo3yz69ri+xq0LAOXXr/dTJ/A== X-Received: by 2002:a17:906:ca58:b0:a46:5dc4:dab9 with SMTP id jx24-20020a170906ca5800b00a465dc4dab9mr3976467ejb.38.1711881123536; Sun, 31 Mar 2024 03:32:03 -0700 (PDT) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id 17-20020a170906301100b00a45c9945251sm4027371ejz.192.2024.03.31.03.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Mar 2024 03:32:02 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv10 5/9] gdb: add another overload of startswith Date: Sun, 31 Mar 2024 11:31:49 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org We already have one overload of the startswith function that takes a std::string_view for both arguments. A later patch in this series is going to be improved by having an overload that takes one argument as a std::string_view and the other argument as a plain 'char *'. This commit adds the new overload, but doesn't make use of it (yet). There should be no user visible changes after this commit. --- gdbsupport/common-utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h index 23cd40c0207..2fb22916409 100644 --- a/gdbsupport/common-utils.h +++ b/gdbsupport/common-utils.h @@ -100,6 +100,16 @@ startswith (std::string_view string, std::string_view pattern) && strncmp (string.data (), pattern.data (), pattern.length ()) == 0); } +/* Version of startswith that takes a string_view for only one of its + arguments. Return true if STR starts with PREFIX, otherwise return + false. */ + +static inline bool +startswith (const char *str, const std::string_view &prefix) +{ + return strncmp (str, prefix.data (), prefix.length ()) == 0; +} + /* Return true if the strings are equal. */ static inline bool