Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Guinevere Larsen <guinevere@redhat.com>
To: Tom Tromey <tom@tromey.com>, "Kartik K. Agaram" <ak@akkartik.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] RFC: gdb: redo whitespace-stripping from commands
Date: Thu, 29 May 2025 10:53:54 -0300	[thread overview]
Message-ID: <80eeb206-6685-4e3e-93f7-599aa9c0c77b@redhat.com> (raw)
In-Reply-To: <87y0ufy1wi.fsf@tromey.com>

On 5/29/25 10:36 AM, Tom Tromey wrote:
>>>>>> "Kartik" == Kartik K Agaram <ak@akkartik.com> writes:
> Thanks for the patch.
>
> Kartik> Before this patch, trailing whitespace was not stripped:
> Kartik>   - from 'set'/'show' commands
> Kartik>   - from 'complete' commands
>
> Kartik> Now I've added the 'with' commands to that list because it contains a
> Kartik> 'complete' subcommand. To accomplish this, I'm trying to fix a TODO to
> Kartik> provide a per-command flag controlling whitespace-stripping.
>
> Kartik> I've also cleaned up some seemingly TODOs that are either fixed by this
> Kartik> patch or obsolete.
>
> Kartik> Open question: This patch stops stripping trailing whitespace from all
> Kartik> 'with' commands. Might that create issues with other 'with' commands
> Kartik> besides 'with ... -- complete'?
>
> Maybe it would cause problems with trailing whitespace showing up in
> filenames?  Or with commands that don't expect an argument.  For those
> commands, completion might add a trailing space, causing the function to
> be called with " " rather than nullptr.
>
> I wonder if the 'with' command itself -- and any other commands that
> invoke commands, like 'eval' -- should strip whitespace as appropriate
> before invocation.  That is, move the whitespace stripping code
> somewhere else.  (Assuming it's in the wrong spot, I don't recall off
> the top of my head where this stuff happens.)

Removing trailing whitespace is done in the execute_command function in 
top.c. The command "with" will already call execute_command itself to 
invoke the correct command, so I think the correct way to go about it is 
for those commands to never strip whitespace, and then always call 
execute_command, which will do the right thing based on the inner command.

>
> Kartik> +  complete_cmd->strip_trailing_white_space_p = 0;
>   
> Kartik> +  c->strip_trailing_white_space_p = 0;
>   
> Kartik> +      strip_trailing_white_space_p (1),
>
> Kartik> +  unsigned int strip_trailing_white_space_p : 1;
>
> This should be bool and the constants above should be true/false.
Should the name end in _p? I would think _p is for pointers, and this is 
just a bool, but maybe I'm mistaken.

-- 
Cheers,
Guinevere Larsen
She/Her/Hers

>
> Tom
>


  parent reply	other threads:[~2025-05-29 13:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-29 12:51 Kartik K. Agaram
2025-05-29 13:36 ` Tom Tromey
2025-05-29 13:53   ` Kartik Agaram
2025-05-29 13:53   ` Guinevere Larsen [this message]
2025-05-29 13:59     ` Kartik Agaram
2025-05-29 15:35     ` Tom Tromey
2025-06-01  1:17 ` Kartik K. Agaram
2025-06-01  1:17   ` [PATCH] " Kartik K. Agaram
2025-06-02 16:30     ` Guinevere Larsen
2025-06-02 16:42       ` Kartik Agaram
2025-06-02 23:39     ` [PATCH v3] " Kartik K. Agaram
2025-06-06 16:10       ` [PATCH v4] " Kartik K. Agaram
2025-07-07 17:59         ` Kartik Agaram
2025-07-08  9:27         ` Andrew Burgess

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=80eeb206-6685-4e3e-93f7-599aa9c0c77b@redhat.com \
    --to=guinevere@redhat.com \
    --cc=ak@akkartik.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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