public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb/testsuite] Add string cat for tcl version < 8.6.2
@ 2024-06-17 22:09 Tom de Vries
  2024-06-18 16:38 ` Andrew Burgess
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2024-06-17 22:09 UTC (permalink / raw)
  To: gdb-patches

I noticed that we started using "string cat", which has been available since
tcl version 8.6.2.

Add a local implementation for use with older tcl versions.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.testsuite/string-cat.exp | 15 +++++++++
 gdb/testsuite/lib/gdb.exp                  | 37 ++++++++++++++++++----
 2 files changed, 45 insertions(+), 7 deletions(-)
 create mode 100644 gdb/testsuite/gdb.testsuite/string-cat.exp

diff --git a/gdb/testsuite/gdb.testsuite/string-cat.exp b/gdb/testsuite/gdb.testsuite/string-cat.exp
new file mode 100644
index 00000000000..057aeb2e1a7
--- /dev/null
+++ b/gdb/testsuite/gdb.testsuite/string-cat.exp
@@ -0,0 +1,15 @@
+# Copyright 2024 Free Software Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+gdb_assert { [string cat "foo" "bar"] == "foobar" }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 590cd458374..dfe19c9410d 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1607,13 +1607,23 @@ proc python_version_at_least { major minor } {
 		<= [list $python_version_major $python_version_minor]]
 }
 
-# Return 1 if tcl version used is at least MAJOR.MINOR
-proc tcl_version_at_least { major minor } {
-    global tcl_version
-    regexp {^([0-9]+)\.([0-9]+)$} $tcl_version \
-	dummy tcl_version_major tcl_version_minor
-    return [version_compare [list $major $minor] \
-		<= [list $tcl_version_major $tcl_version_minor]]
+# Return 1 if tcl version used is at least MAJOR.MINOR.PATCHLEVEL.
+proc tcl_version_at_least { major minor {patchlevel 0} } {
+    global tcl_patchLevel
+    regexp {^([0-9]+)\.([0-9]+)\.([0-9]+)$} \
+	$tcl_patchLevel dummy \
+	tcl_version_major tcl_version_minor tcl_version_patchlevel
+    return \
+	[version_compare \
+	     [list \
+		  $major \
+		  $minor \
+		  $patchlevel] \
+	     <= \
+	     [list \
+		  $tcl_version_major \
+		  $tcl_version_minor \
+		  $tcl_version_patchlevel]]
 }
 
 if { [tcl_version_at_least 8 5] == 0 } {
@@ -1648,6 +1658,19 @@ if { [tcl_version_at_least 8 6] == 0 } {
     }
 }
 
+if { [tcl_version_at_least 8 6 2] == 0 } {
+    # string cat was added in tcl 8.6.2.  Only add if missing.
+
+    rename string tcl_proc_string
+
+    proc string { what args } {
+	if { $what == "cat" } {
+	    return [join $args ""]
+	}
+	return [tcl_proc_string $what {*}$args]
+    }
+}
+
 # gdb_test_no_output [-prompt PROMPT_REGEXP] [-nopass] COMMAND [MESSAGE]
 # Send a command to GDB and verify that this command generated no output.
 #

base-commit: a6760bd40b44cd1ea4fee264a36e794d362a64bb
-- 
2.35.3


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

* Re: [PATCH] [gdb/testsuite] Add string cat for tcl version < 8.6.2
  2024-06-17 22:09 [PATCH] [gdb/testsuite] Add string cat for tcl version < 8.6.2 Tom de Vries
@ 2024-06-18 16:38 ` Andrew Burgess
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2024-06-18 16:38 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

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

> I noticed that we started using "string cat", which has been available since
> tcl version 8.6.2.
>
> Add a local implementation for use with older tcl versions.

LGTM.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

>
> Tested on x86_64-linux.
> ---
>  gdb/testsuite/gdb.testsuite/string-cat.exp | 15 +++++++++
>  gdb/testsuite/lib/gdb.exp                  | 37 ++++++++++++++++++----
>  2 files changed, 45 insertions(+), 7 deletions(-)
>  create mode 100644 gdb/testsuite/gdb.testsuite/string-cat.exp
>
> diff --git a/gdb/testsuite/gdb.testsuite/string-cat.exp b/gdb/testsuite/gdb.testsuite/string-cat.exp
> new file mode 100644
> index 00000000000..057aeb2e1a7
> --- /dev/null
> +++ b/gdb/testsuite/gdb.testsuite/string-cat.exp
> @@ -0,0 +1,15 @@
> +# Copyright 2024 Free Software Foundation, Inc.
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +gdb_assert { [string cat "foo" "bar"] == "foobar" }
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 590cd458374..dfe19c9410d 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -1607,13 +1607,23 @@ proc python_version_at_least { major minor } {
>  		<= [list $python_version_major $python_version_minor]]
>  }
>  
> -# Return 1 if tcl version used is at least MAJOR.MINOR
> -proc tcl_version_at_least { major minor } {
> -    global tcl_version
> -    regexp {^([0-9]+)\.([0-9]+)$} $tcl_version \
> -	dummy tcl_version_major tcl_version_minor
> -    return [version_compare [list $major $minor] \
> -		<= [list $tcl_version_major $tcl_version_minor]]
> +# Return 1 if tcl version used is at least MAJOR.MINOR.PATCHLEVEL.
> +proc tcl_version_at_least { major minor {patchlevel 0} } {
> +    global tcl_patchLevel
> +    regexp {^([0-9]+)\.([0-9]+)\.([0-9]+)$} \
> +	$tcl_patchLevel dummy \
> +	tcl_version_major tcl_version_minor tcl_version_patchlevel
> +    return \
> +	[version_compare \
> +	     [list \
> +		  $major \
> +		  $minor \
> +		  $patchlevel] \
> +	     <= \
> +	     [list \
> +		  $tcl_version_major \
> +		  $tcl_version_minor \
> +		  $tcl_version_patchlevel]]
>  }
>  
>  if { [tcl_version_at_least 8 5] == 0 } {
> @@ -1648,6 +1658,19 @@ if { [tcl_version_at_least 8 6] == 0 } {
>      }
>  }
>  
> +if { [tcl_version_at_least 8 6 2] == 0 } {
> +    # string cat was added in tcl 8.6.2.  Only add if missing.
> +
> +    rename string tcl_proc_string
> +
> +    proc string { what args } {
> +	if { $what == "cat" } {
> +	    return [join $args ""]
> +	}
> +	return [tcl_proc_string $what {*}$args]
> +    }
> +}
> +
>  # gdb_test_no_output [-prompt PROMPT_REGEXP] [-nopass] COMMAND [MESSAGE]
>  # Send a command to GDB and verify that this command generated no output.
>  #
>
> base-commit: a6760bd40b44cd1ea4fee264a36e794d362a64bb
> -- 
> 2.35.3


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

end of thread, other threads:[~2024-06-18 16:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-17 22:09 [PATCH] [gdb/testsuite] Add string cat for tcl version < 8.6.2 Tom de Vries
2024-06-18 16:38 ` Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).