[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PATCH: fix isbuild, ishost, istarget defaults
From: |
Ben Elliston |
Subject: |
PATCH: fix isbuild, ishost, istarget defaults |
Date: |
Thu, 29 Nov 2018 21:57:39 +1100 |
User-agent: |
Mutt/1.9.4 (2018-02-28) |
The documentation implies that you can call procs isbuild, ishost and
istarget with no argument to return these triplets. However, passing
"" is not the same as passing nothing in Tcl:
% proc foo {arg} { puts $arg }
% foo ""
% foo
wrong # args: should be "foo arg"
This patch fixes these procs so that they can be called without an
argument. This remains compatible with the existing behaviour.
OK to commit?
Cheers,
Ben
2018-11-29 Ben Elliston <address@hidden>
* lib/framework.exp (istarget, ishost, istarget): Set the argument
default value to the empty string.
* doc/dejagnu.texi (find procedure): Remove reference to "NULL".
(getenv procedure): Re-word this node.
(isbuild procedure): Update.
(ishost procedure): Likewise.
(istarget procedure): Likewise.
* testsuite/runtest.all/config.test: Add test cases.
diff --git a/lib/framework.exp b/lib/framework.exp
index 9288cb9..ef1baa5 100644
--- a/lib/framework.exp
+++ b/lib/framework.exp
@@ -96,7 +96,7 @@ proc close_logs { } {
# Check build host triplet for PATTERN.
# With no arguments it returns the triplet string.
#
-proc isbuild { pattern } {
+proc isbuild { { pattern "" } } {
global build_triplet
global host_triplet
@@ -188,7 +188,7 @@ proc is3way {} {
# Check host triplet for PATTERN.
# With no arguments it returns the triplet string.
#
-proc ishost { pattern } {
+proc ishost { { pattern "" } } {
global host_triplet
if {[string match "" $pattern]} {
@@ -208,7 +208,7 @@ proc ishost { pattern } {
# With no arguments it returns the triplet string.
# Returns 1 if the target looked for, or 0 if not.
#
-proc istarget { args } {
+proc istarget { { args "" } } {
global target_triplet
# if no arg, return the config string
diff --git a/doc/dejagnu.texi b/doc/dejagnu.texi
index 1b2e11d..0ed2f0c 100644
--- a/doc/dejagnu.texi
+++ b/doc/dejagnu.texi
@@ -2288,10 +2288,10 @@ Close the output logs.
Tests for a particular build host environment. If the currently
configured host matches the argument string, the result is @emph{1};
otherwise the result is @emph{0}. @emph{host} must be a full three-part
-configure host name; in particular, you may not use the shorter
-nicknames supported by configure (but you can use wildcard characters,
-using shell syntax, to specify sets of names). If it is passed a NULL
-string, then it returns the name of the build canonical configuration.
+configure triplet; in particular, you may not use the shorter aliases
+supported by configure (but you can use wildcard characters, using shell
+syntax, to specify sets of names). If called with no arguments, this
+procedure returns the build system triplet.
@quotation
@address@hidden@address@hidden@}}
@@ -2327,10 +2327,11 @@ result is @emph{1}; otherwise @emph{0}.
Tests for a particular host environment. If the currently configured
host matches the argument string, the result is @emph{1}; otherwise the
-result is @emph{0}. @emph{host} must be a full three-part configure host
-name; in particular, you may not use the shorter nicknames supported by
-configure (but you can use wildcard characters, using shell syntax, to
-specify sets of names).
+result is @emph{0}. @emph{host} must be a full three-part host
+triplet. You may not use the shorter aliases supported by configure (but
+you can use wildcard characters, using shell syntax, to specify sets of
+triplets). If called with no arguments, this procedure returns the host
+triplet.
@quotation
@address@hidden@address@hidden@}}
@@ -2347,10 +2348,10 @@ specify sets of names).
Tests for a particular target environment. If the currently configured
target matches the argument string, the result is @emph{1} ; otherwise
the result is @emph{0}. target must be a full three-part configure
-target name; in particular, you may not use the shorter nicknames
-supported by configure (but you can use wildcard characters, using shell
-syntax, to specify sets of names). If it is passed a @emph{NULL} string,
-then it returns the name of the build canonical configuration.
+target name. You may not use the shorter aliases supported by configure
+(but you can use wildcard characters, using shell syntax, to specify
+sets of names). If called with no arguments, this procedure returns the
+target triplet.
@quotation
@address@hidden @{ @i{args} @}}
@@ -4569,7 +4570,7 @@ characters for filename expansion). Search
subdirectories recursively,
starting at @emph{rootdir}. The result is the list of files whose names
match; if no files match, the result is empty. Filenames in the result
include all intervening subdirectory names. If no files match the
-pattern, then a NULL string is returned.
+pattern, then an empty string is returned.
@quotation
@address@hidden@address@hidden
@@ -4733,8 +4734,8 @@ The environment variable to unset.
@node getenv procedure, prune_system_crud procedure, unsetenv procedure,
Utility Procedures
@subsubsection getenv Procedure
-Returns the value of @emph{var} in the environment if it exists,
-otherwise it returns NULL.
+Returns the value of the envrionment variable @emph{var} if it is
+defined, otherwise an empty string is returned.
@quotation
@address@hidden@address@hidden@}}
diff --git a/testsuite/runtest.all/config.test
b/testsuite/runtest.all/config.test
index 50c701e..8153ecd 100644
--- a/testsuite/runtest.all/config.test
+++ b/testsuite/runtest.all/config.test
@@ -52,6 +52,13 @@ if [isbuild hppa-ibm-macos ] {
puts "PASSED: isbuild, native bogus config string"
}
+# test default argument for isbuild
+if [string compare [isbuild] $build_triplet] {
+ puts "FAILED: isbuild with no arguments"
+} else {
+ puts "PASSED: isbuild with no arguments"
+}
+
# ishost tests
if [ishost $host_triplet] {
puts "PASSED: ishost, native"
@@ -71,6 +78,13 @@ if [ishost hppa-ibm-macos] {
puts "PASSED: ishost, native bogus config string"
}
+# test default argument for ishost
+if [string compare [ishost] $host_triplet] {
+ puts "FAILED: ishost with no arguments"
+} else {
+ puts "PASSED: ishost with no arguments"
+}
+
# istarget tests
if [istarget $target_triplet] {
puts "PASSED: istarget, native"
@@ -90,6 +104,13 @@ if [istarget hppa-ibm-macos] {
puts "PASSED: istarget, native bogus config string"
}
+# test default argument for istarget
+if [string compare [istarget] $target_triplet] {
+ puts "FAILED: istarget with no arguments"
+} else {
+ puts "PASSED: istarget with no arguments"
+}
+
# native tests
if [isnative] {
puts "PASSED: isnative, native"
signature.asc
Description: PGP signature
- PATCH: fix isbuild, ishost, istarget defaults,
Ben Elliston <=