Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Don't nest double quotes in tuiterm.exp
@ 2025-07-30 18:07 Tom Tromey
  2025-07-31  5:16 ` Tom de Vries
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2025-07-30 18:07 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I found a line in tuiterm.exp that causes Emacs paren-matching to go
awry.  This patch fixes the problem by changing some apparent nested
double quotes (which I think isn't really possible in Tcl but this
seems to be the intent) to be more correct; which fixes the Emacs
issue as well.
---
 gdb/testsuite/lib/tuiterm.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index cc8e852690a..b83b8afdcec 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -1291,7 +1291,7 @@ namespace eval Term {
 
 	for {set y 0} {$y < $_rows} {incr y} {
 	    set fmt [format %5d $y]
-	    verbose -log "$fmt [get_line_1 $y "" $attrs]"
+	    verbose -log "$fmt [get_line_1 $y {} $attrs]"
 	}
     }
 

base-commit: 303045d9539d9032208b8b67f222943ff4c96b05
-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Don't nest double quotes in tuiterm.exp
  2025-07-30 18:07 [PATCH] Don't nest double quotes in tuiterm.exp Tom Tromey
@ 2025-07-31  5:16 ` Tom de Vries
  2025-09-09  7:18   ` Tom de Vries
  0 siblings, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2025-07-31  5:16 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 7/30/25 20:07, Tom Tromey wrote:
> I found a line in tuiterm.exp that causes Emacs paren-matching to go
> awry.

Hi Tom,

thanks for finding this.

I played around a bit with this and was able to observe the following.

If I type foo between the double quotes:
...
             verbose -log "$fmt [get_line_1 $y "foo" $attrs]"
...
I observe that the foo gets highlighted as not part of a string.

If I change the double quotes to curly braces, that changes.  I'm not 
sure if that is the issue you observed though.

But yeah, I agree there is a problem with syntax highlighting.

Anyway, normally I don't observe this because I use emacs with 
TERM=xterm-old forcing monochrome to be able to read diffs.

> This patch fixes the problem by changing some apparent nested
> double quotes (which I think isn't really possible in Tcl but this
> seems to be the intent) to be more correct; which fixes the Emacs
> issue as well.

This was my code, so I build a small tcl example to understand if it 
made a difference or not:
...
#!/usr/bin/tclsh

proc verbose { args } {
     foreach arg $args {
	puts "$arg"
     }
}

set y "y z"
set attrs "attrs attrs2"

proc get_line_1 { args } {
     set str ""
     foreach arg $args {
	set str "$str<$arg>"
     }
     return $str
}

verbose -log "[get_line_1 $y "" $attrs]"
verbose -log "[get_line_1 $y {} $attrs]"
...
and it seems not:
...
$ ./test.tcl
-log
<y z><><attrs attrs2>
-log
<y z><><attrs attrs2>
...

Anyway, my understanding of TCL is purely operational, so you may be 
right that it's not proper TCL. FWIW, I looked here ( 
https://www.tcl-lang.org/man/tcl8.6/TclCmd/Tcl.htm#M11 ) and didn't see 
anything forbidding this usage.

I'll try to avoid this in the future.

LGTM.

Approved-By: Tom de Vries <tdevries@suse.de>


Thanks,
- Tom

> ---
>   gdb/testsuite/lib/tuiterm.exp | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
> index cc8e852690a..b83b8afdcec 100644
> --- a/gdb/testsuite/lib/tuiterm.exp
> +++ b/gdb/testsuite/lib/tuiterm.exp
> @@ -1291,7 +1291,7 @@ namespace eval Term {
>   
>   	for {set y 0} {$y < $_rows} {incr y} {
>   	    set fmt [format %5d $y]
> -	    verbose -log "$fmt [get_line_1 $y "" $attrs]"
> +	    verbose -log "$fmt [get_line_1 $y {} $attrs]"
>   	}
>       }
>   
> 
> base-commit: 303045d9539d9032208b8b67f222943ff4c96b05


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Don't nest double quotes in tuiterm.exp
  2025-07-31  5:16 ` Tom de Vries
@ 2025-09-09  7:18   ` Tom de Vries
  2025-09-09 17:56     ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2025-09-09  7:18 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 7/31/25 07:16, Tom de Vries wrote:
> Anyway, my understanding of TCL is purely operational, so you may be 
> right that it's not proper TCL. FWIW, I looked here ( https://www.tcl- 
> lang.org/man/tcl8.6/TclCmd/Tcl.htm#M11 ) and didn't see anything 
> forbidding this usage.

I've filed a request for clarification here ( 
https://core.tcl-lang.org/tcl/tktview/e1053b00394c6ed4bd9446e521fe17a9002a156d 
).

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Don't nest double quotes in tuiterm.exp
  2025-09-09  7:18   ` Tom de Vries
@ 2025-09-09 17:56     ` Tom Tromey
  2025-09-09 19:01       ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2025-09-09 17:56 UTC (permalink / raw)
  To: Tom de Vries; +Cc: Tom Tromey, gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> On 7/31/25 07:16, Tom de Vries wrote:
>> Anyway, my understanding of TCL is purely operational, so you may be
>> right that it's not proper TCL. FWIW, I looked here (
>> https://www.tcl- lang.org/man/tcl8.6/TclCmd/Tcl.htm#M11 ) and didn't
>> see anything forbidding this usage.

Tom> I've filed a request for clarification here (
Tom> https://core.tcl-lang.org/tcl/tktview/e1053b00394c6ed4bd9446e521fe17a9002a156d
Tom> ).

Thanks.

I wouldn't be overly surprised if I was mistaken about this, but on the
other hand, nested double-quotes seems quite strange and I'd prefer us
to avoid it even if it is legal somehow.

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Don't nest double quotes in tuiterm.exp
  2025-09-09 17:56     ` Tom Tromey
@ 2025-09-09 19:01       ` Andreas Schwab
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Schwab @ 2025-09-09 19:01 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Tom de Vries, Tom Tromey, gdb-patches

On Sep 09 2025, Tom Tromey wrote:

> I wouldn't be overly surprised if I was mistaken about this, but on the
> other hand, nested double-quotes seems quite strange and I'd prefer us
> to avoid it even if it is legal somehow.

There are no nested double quotes in tcl, but a nested command
substitution can contain any valid tcl script, including double quoted
words (Tcl(n) explains this pretty well).  This is similar to how
command substitutions are handled in the posix shell (when using $(...))
when they occur in a double quoted context.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-09-09 19:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-30 18:07 [PATCH] Don't nest double quotes in tuiterm.exp Tom Tromey
2025-07-31  5:16 ` Tom de Vries
2025-09-09  7:18   ` Tom de Vries
2025-09-09 17:56     ` Tom Tromey
2025-09-09 19:01       ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox