From patchwork Fri Dec 29 09:27:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 82991 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 C480E385842D for ; Fri, 29 Dec 2023 09:37:56 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id 4DAE93858416 for ; Fri, 29 Dec 2023 09:27:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DAE93858416 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 4DAE93858416 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=1703842071; cv=none; b=kYT1FccUEy7yTl9NAMl34Iz1FzHlrB608+KqOC3WfFvd7RJ/DacgBkjm5qSFtU4z6HHGIUsqmUZl8Xrzj18Mf2OE9J/+AAJERQCXVRNEZIgBvosKAml0hvg3Cw6I3+SrLoytg8dvL2VzQp+XNS1+eCpyEPO6RNOfsfktDP+DABA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703842071; c=relaxed/simple; bh=K/jQZXzJncm+vbDeWaZZi7gSTmVc71n7wVWeB10KvZI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=almJdCcsWdPT5llSMV3meQvB2o+4lCmqHBsLCJ/X5UURqmD4cdfU3gOky3Adad7by/Aru1uXT+vDhMl2J7kskUvjpe8D2BV1i9WfV8Cf8fgDbuCSVGvarUPFbmjnaTxJRhtNC3WJkAC2Skzcu5psQ1BzWCB54K19m/Fw1zavK3U= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703842051; 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=X+apucMSALpa2NtCbrGxwg1bAagioM60kqwUeEpnB8o=; b=LlZcTepXzDAuPsh/8yk1q/8m7890Ajxri+DcDawXNrUpcNMKpHldzpEvoeW0Vu42DOV1rb MB+PBASXlTYrWCJhwrk+Mt9UhMuptUwXB7hS0KqVIupNNsrqoExvX2tKsChg3HoIqw0lLA nDAOPk9ikBzcdWzLdt4zlRDldYaagQ8= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-aGGxLYuKOrqIlBk_jzOU7Q-1; Fri, 29 Dec 2023 04:27:29 -0500 X-MC-Unique: aGGxLYuKOrqIlBk_jzOU7Q-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-40d5ab2fbc9so25242905e9.3 for ; Fri, 29 Dec 2023 01:27:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703842048; x=1704446848; 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=X+apucMSALpa2NtCbrGxwg1bAagioM60kqwUeEpnB8o=; b=ST5BnKOdWM+YqwtgVKk6Zy136VzLdoZPQLnMCJamhuEQ+whBv78j/tGOhNlbZAfEXo whIo596dq/yCI4nWcftarNYJKHdbSgcK7GG9Pdghk7flzDtvTAvO9AcegzfgH6EF1tF8 zsie3oApxSppcaxeMTldjcybPGjanxO42Xytz4HZQPRCqqoMminiCb1D9AsMvnptKvfI /jbPmDDlCJqnBxOh+j6uAAOIq04KkX3ojJ0gJ65qbI2tCmLcH6IbO9/AodWHwUFQpHcB gHd6dwwV7cukClEK3YgeY1EggvLnpvb6dL5G9trNT3MU2nbDWMIG7AEMjkO4W9MvpcnZ hF2w== X-Gm-Message-State: AOJu0Yy9nVi0hk0H8AXOWuV7MsYK1lzeGzooxLGFXivXftJIhYztQTud u8HCG4YZxgsd7hJ9IKwCrIqd+mQ9XRT6phu2X9jHJy4kPyieKInvVCoYxPU5EoCYWzObLBV0kXC K8e5KO3Dr7XIwaAwgxDe3Q+hVJcX3J+K6JRtnIHq8IABQ4mUNANpC/r1s6Xdx5r5firXHnBZ8Sh zHSefVcvx2rnJOag== X-Received: by 2002:a05:600c:1f8b:b0:40d:3b17:2db9 with SMTP id je11-20020a05600c1f8b00b0040d3b172db9mr6500860wmb.163.1703842048179; Fri, 29 Dec 2023 01:27:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2H7d6c83v0zbGXiQfMogzKOQuIWaQbihuE9KpewPs/eN+JoNWR48zov3VaJdUCUpx59IhHg== X-Received: by 2002:a05:600c:1f8b:b0:40d:3b17:2db9 with SMTP id je11-20020a05600c1f8b00b0040d3b172db9mr6500854wmb.163.1703842047938; Fri, 29 Dec 2023 01:27:27 -0800 (PST) Received: from localhost ([2a00:23c7:c696:e701:85a5:8a0c:1403:2dc]) by smtp.gmail.com with ESMTPSA id l1-20020a05600c1d0100b0040d5e53d7c3sm8369466wms.23.2023.12.29.01.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:27:27 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv8 10/14] gdb: add another overload of startswith Date: Fri, 29 Dec 2023 09:27:05 +0000 Message-Id: <7021beada7f2ce4c7f388d3668d57a9d2dffbc63.1703841366.git.aburgess@redhat.com> 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=-13.4 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, T_SCC_BODY_TEXT_LINE 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 1efc5bbf459..17bd5389351 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