From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eIM7LULyMmWQOTMAWB0awg (envelope-from ) for ; Fri, 20 Oct 2023 17:33:54 -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=EV1qz2kc; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B576A1E0C1; Fri, 20 Oct 2023 17:33:54 -0400 (EDT) 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 A35031E091 for ; Fri, 20 Oct 2023 17:33:52 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3D7743861805 for ; Fri, 20 Oct 2023 21:33:52 +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 ESMTPS id ED7C93850861 for ; Fri, 20 Oct 2023 21:33:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED7C93850861 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 ED7C93850861 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=1697837619; cv=none; b=BJdw0PwcHAGuqoswshtePE4WGnLp9ubfwllhI6uX0S0DDbPgjqoEQLdkyIhbgJoeB8VDqUQjytAX3cY5Xr8DwfwxM8rxLEo+u8p3RLhDuR/HeOYlmeIV+vjEyDaMUS0BJJViU0BOd26ni3dmTrt/434qDvfu7CfNpVyTkGx/Srk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697837619; c=relaxed/simple; bh=zDKwo1XOjG3ohsg2cOnxS5UdPan2QwflyzW5M6owyFc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=WbfmpmSNSUSXPXkfv9UEUeWyfVtvlPyOsGZj9VOTzXa2E0w1S3ToNsvu4K6D/qcXEvWUVa2qtdCLHXM8q4+lVYx2aw5OnB5L8VtsxpM5VEO8m32AAsuYmXRRPlbyoR+/HgPV8ezddfioDiB3Vg9v7/ljZLj+iNDOfmpsfgnxUZ0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697837617; 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=rB4lVo0sUWTZkxc6am2dTuMWCQI/jG/HfPdmdl7f5WA=; b=EV1qz2kcmE7eoXC8SF4JxaYLuZ5NB5NB4OuAvozMFMeNiaHWj6L5nf0iQj8bnMHMqN4uin JrJdZtseJF9TAJks14lyynikTmVwIWlMTJCy/pvJPhcAF9XMx/wJZDgysW/ztlDPkHtbZO 38alOGdiUjv15UEGFpROktsefOhcMVo= Received: from mail-oa1-f71.google.com (mail-oa1-f71.google.com [209.85.160.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-151-LV07t9mtNkqZqjS8SyhZ8g-1; Fri, 20 Oct 2023 17:33:21 -0400 X-MC-Unique: LV07t9mtNkqZqjS8SyhZ8g-1 Received: by mail-oa1-f71.google.com with SMTP id 586e51a60fabf-1ea1c5774d2so1643457fac.1 for ; Fri, 20 Oct 2023 14:33:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697837600; x=1698442400; 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=rB4lVo0sUWTZkxc6am2dTuMWCQI/jG/HfPdmdl7f5WA=; b=WNkOciFm5Yc90V2+yqRIbxyN2CA2uWOPGKKoBUFujMX8kcLOdQZJQQGnIIHmMj7vwm uYaZ+vRqbH8+tdoyTE3nniZGK7pUCYKzmybZC4uLV6xWKhhz524c87jP6R75n0zP3xp+ 2QL/RCcHhavRBIsKjxs3l3Du2MH2NF1u1Tb/6hEq9aiVrLq1Wk7Z/9aVSQvLw2WpRaWC TJg9UO+kXkeuQ+QPtl/WwyH9aFdDQJQx4g+GIAvnt9ibXemW63IAy8PxlceQRldP7vlX tBIzdr44WYw1s8O1k70O5S64i6LQEY+HEGpKaOROzA3yTOMtrPFpIMbEFyCzlyXpi8jk csLg== X-Gm-Message-State: AOJu0YxLjOKx5vIjlOsFaUZveD8FVWGJsqblWvW0lTTaxXH7M0loqobI DusoTPwBdKnlTuoCLnFKgE0Nii1phGHgTh/31ULWDanVpkzVGEgsqP0N8SKAnbshSwkc/fZRXgD SwpMliV8Fd83plv0uwxCar6rgqwmv+jKb6Cwt2blOFXxnENCPk9iD9YbrbLUAHerf7j2Lai1bfa qUmcOcnw== X-Received: by 2002:a05:6870:1315:b0:1e9:dd69:2fbf with SMTP id 21-20020a056870131500b001e9dd692fbfmr2994165oab.48.1697837600576; Fri, 20 Oct 2023 14:33:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNq52QattS/Bmz5kGPChIkEgeJe6m+peCJ2F0ONpOPd1R7kkrCzUnLKER4Qmh4s9roIjFXvA== X-Received: by 2002:a05:6870:1315:b0:1e9:dd69:2fbf with SMTP id 21-20020a056870131500b001e9dd692fbfmr2994156oab.48.1697837600097; Fri, 20 Oct 2023 14:33:20 -0700 (PDT) Received: from localhost ([31.111.84.209]) by smtp.gmail.com with ESMTPSA id i18-20020ad44bb2000000b0066d15724feesm969252qvw.68.2023.10.20.14.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 14:33:19 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/3] gdb: make skip_over_slash_fmt available outside printcmd.c Date: Fri, 20 Oct 2023 22:33:10 +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-Spam-Status: No, score=-11.7 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+public-inbox=simark.ca@sourceware.org Move the function skip_over_slash_fmt into completer.c, and make it extern, with a declaration in completer.h. This is a refactor in order to support the next commit. I've not changed any of the code in skip_over_slash_fmt. There should be no user visible changes after this commit. --- gdb/completer.c | 53 ++++++++++++++++++++++++++++++++++++++++ gdb/completer.h | 17 +++++++++++++ gdb/printcmd.c | 65 ------------------------------------------------- 3 files changed, 70 insertions(+), 65 deletions(-) diff --git a/gdb/completer.c b/gdb/completer.c index 2abf3998345..42ac7be297a 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -2991,6 +2991,59 @@ gdb_display_match_list (char **matches, int len, int max, } } +/* See completer.h. */ + +bool +skip_over_slash_fmt (completion_tracker &tracker, const char **args) +{ + const char *text = *args; + + if (text[0] == '/') + { + bool in_fmt; + tracker.set_use_custom_word_point (true); + + if (text[1] == '\0') + { + /* The user tried to complete after typing just the '/' character + of the /FMT string. Step the completer past the '/', but we + don't offer any completions. */ + in_fmt = true; + ++text; + } + else + { + /* The user has typed some characters after the '/', we assume + this is a complete /FMT string, first skip over it. */ + text = skip_to_space (text); + + if (*text == '\0') + { + /* We're at the end of the input string. The user has typed + '/FMT' and asked for a completion. Push an empty + completion string, this will cause readline to insert a + space so the user now has '/FMT '. */ + in_fmt = true; + tracker.add_completion (make_unique_xstrdup (text)); + } + else + { + /* The user has already typed things after the /FMT, skip the + whitespace and return false. Whoever called this function + should then try to complete what comes next. */ + in_fmt = false; + text = skip_spaces (text); + } + } + + tracker.advance_custom_word_point_by (text - *args); + *args = text; + return in_fmt; + } + + return false; +} + void _initialize_completer (); void _initialize_completer () diff --git a/gdb/completer.h b/gdb/completer.h index 67d2fbf9d38..d96c4b515d3 100644 --- a/gdb/completer.h +++ b/gdb/completer.h @@ -657,6 +657,23 @@ extern const char *skip_quoted_chars (const char *, const char *, extern const char *skip_quoted (const char *); +/* Called from command completion function to skip over /FMT + specifications, allowing the rest of the line to be completed. Returns + true if the /FMT is at the end of the current line and there is nothing + left to complete, otherwise false is returned. + + In either case *ARGS can be updated to point after any part of /FMT that + is present. + + This function is designed so that trying to complete '/' will offer no + completions, the user needs to insert the format specification + themselves. Trying to complete '/FMT' (where FMT is any non-empty set + of alpha-numeric characters) will cause readline to insert a single + space, setting the user up to enter the expression. */ + +extern bool skip_over_slash_fmt (completion_tracker &tracker, + const char **args); + /* Maximum number of candidates to consider before the completer bails by throwing MAX_COMPLETIONS_REACHED_ERROR. Negative values disable limiting. */ diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 5e9c8a5b222..fd6e74ec61c 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1378,71 +1378,6 @@ print_command_1 (const char *args, int voidprint) } } -/* Called from command completion function to skip over /FMT - specifications, allowing the rest of the line to be completed. Returns - true if the /FMT is at the end of the current line and there is nothing - left to complete, otherwise false is returned. - - In either case *ARGS can be updated to point after any part of /FMT that - is present. - - This function is designed so that trying to complete '/' will offer no - completions, the user needs to insert the format specification - themselves. Trying to complete '/FMT' (where FMT is any non-empty set - of alpha-numeric characters) will cause readline to insert a single - space, setting the user up to enter the expression. */ - -static bool -skip_over_slash_fmt (completion_tracker &tracker, const char **args) -{ - const char *text = *args; - - if (text[0] == '/') - { - bool in_fmt; - tracker.set_use_custom_word_point (true); - - if (text[1] == '\0') - { - /* The user tried to complete after typing just the '/' character - of the /FMT string. Step the completer past the '/', but we - don't offer any completions. */ - in_fmt = true; - ++text; - } - else - { - /* The user has typed some characters after the '/', we assume - this is a complete /FMT string, first skip over it. */ - text = skip_to_space (text); - - if (*text == '\0') - { - /* We're at the end of the input string. The user has typed - '/FMT' and asked for a completion. Push an empty - completion string, this will cause readline to insert a - space so the user now has '/FMT '. */ - in_fmt = true; - tracker.add_completion (make_unique_xstrdup (text)); - } - else - { - /* The user has already typed things after the /FMT, skip the - whitespace and return false. Whoever called this function - should then try to complete what comes next. */ - in_fmt = false; - text = skip_spaces (text); - } - } - - tracker.advance_custom_word_point_by (text - *args); - *args = text; - return in_fmt; - } - - return false; -} - /* See valprint.h. */ void -- 2.25.4