From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iMB1AKjH2mY1/iEAWB0awg (envelope-from ) for ; Fri, 06 Sep 2024 05:13:12 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Bmpx+21g; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id EE0FE1E353; Fri, 6 Sep 2024 05:13:11 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-10.1 required=5.0 tests=ARC_SIGNED,ARC_VALID, BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,URIBL_BLOCKED, URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 543951E05C for ; Fri, 6 Sep 2024 05:13:11 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 13334384A49A for ; Fri, 6 Sep 2024 09:13:11 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 4C6EF384A84F for ; Fri, 6 Sep 2024 09:11:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4C6EF384A84F 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 4C6EF384A84F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725613877; cv=none; b=VM/gq89+gZU1ePDePsq/n/KBn7wGyQQT+tpUUroLIhwOD+Hkm8Jl0I/p5z9DBjtGRZibbuCDFPO6JTD36NcUctGpkTisED69hGcTVOowX+vtBaatgE+e/TupfCygx8XhMcxd1hfMzLvfdY3q0e/gXR6qYGB+WwVcKGS4EyMLNzc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725613877; c=relaxed/simple; bh=kCtIQjYOvaN9Ldf0PrTb3F8N/TZPT0vgCnsnW7DHdWQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=L6ndfoEmHQHHIS7JLprU37Q05VYxYiw9wzU3zAYHVfVbg9yA4O/StZJmA7BnfJfY+yztpzFza+AYMbP6Qt3f81m56lXBFlhXIg5FOtgYGOzP2bXBoe6yHBXHnblW67dBzjpUbtRo+6uu8st0EzNYEO3XjFuNA4r/Qdm/UKqSA54= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725613874; 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=Bmpx+21glFwl48v9OEsUzCMI86t1TUZgnfDXVgwq5fxP4vZx+30uT/52zN5vgYne2wPMGA ZrtIgseMcTHEJFlIy0DNn8lHSoJlr2E7Dh0WRoSR/kEiYUSBDdojIFUc0v6mpJx5l2PqSF Df2ANRZv9F0a1Q+yFtoJ8t7pQG8F7Qs= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-331-zptJL446Mj2nDqds9Pe8pQ-1; Fri, 06 Sep 2024 05:11:12 -0400 X-MC-Unique: zptJL446Mj2nDqds9Pe8pQ-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3730b54347cso1035213f8f.1 for ; Fri, 06 Sep 2024 02:11:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725613870; x=1726218670; 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=BVffpaaV8IFRBwpjyNEZJlFWef6OJsS6JgYu9hRGpj9jVoNIqfAY6m8DCEWYpJD+Yf 1lR9qTj+gnJxTPJXfwpuOl1t0DmcA1P2FNeDPD8JIdvJDZGca/yU3ic0bDnt7p5yPr5P R8keWwBySMZA0VrnpMwh1X6NwmrH5IzHMusrsJirFhWlVQl7as4vh1n/f+sg9/pDUWK1 +9LL5v3WcsEO7tEsess7SmB2xmLqicHs8QWYxnMExMx1T0UGa4F5sV5BmEXGaHz3P2TM OMcoiRpEXBI0LRg0GUyuZ3N/dqWrmH1cmbxP+BnYBZn3dLGXYaNppEqW5f5Br0f5Rv5c WnNg== X-Gm-Message-State: AOJu0YxbFSZrx71kUmtibVtLva3Gekz5aYKlDyX2qEfMRQ9eRPlfXE8a SCItTJ4ViA+31auqyUrabivvVupnhtKNxM5IkSVYJHoLbRvG2LKL1BNWAKYdt9q7uiPnLLECfAt dr7dQ12GdewabLfzXEJ/ahJZrD9TjQfQV1o5v5OCSX7WDCNnqtTXmVP8EQKjGAADt+Fz9OLYJs1 Hnsu/Jhx/nbVZhmO9ZpjQPP6mMKmDCU2m/hDDYHRjtRTU= X-Received: by 2002:a5d:688f:0:b0:374:c040:b00e with SMTP id ffacd0b85a97d-378896a4c29mr1461915f8f.39.1725613869598; Fri, 06 Sep 2024 02:11:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6MvEY3+sjWa4aSZbQyNA+4cprO6BSjTpawFBwfj3OPz0t9fv73N6lY4DSCscw4Zrd6hJfbQ== X-Received: by 2002:a5d:688f:0:b0:374:c040:b00e with SMTP id ffacd0b85a97d-378896a4c29mr1461887f8f.39.1725613869057; Fri, 06 Sep 2024 02:11:09 -0700 (PDT) Received: from localhost (178.126.90.146.dyn.plus.net. [146.90.126.178]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374cd205ab0sm11663231f8f.87.2024.09.06.02.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 02:11:08 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv13 2/6] gdb: add another overload of startswith Date: Fri, 6 Sep 2024 10:10:59 +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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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~public-inbox=simark.ca@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 -- 2.25.4