Skip to content

Commit 2ed5bf0

Browse files
committed
Teaish internal API tweaks and ensure that -encoding utf-8 is used when source'ing test scripts.
1 parent 297f5d1 commit 2ed5bf0

File tree

3 files changed

+34
-29
lines changed

3 files changed

+34
-29
lines changed

autoconf/tea/autosetup/core.tcl

+29-24
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ proc teaish-configure-core {} {
177177

178178
# TEA has --with-tclinclude but it appears to only be useful for
179179
# building an extension against an uninstalled copy of TCL's own
180-
# source tree. Either we get that info from tclConfig.sh or we
181-
# give up.
180+
# source tree. The policy here is that either we get that info
181+
# from tclConfig.sh or we give up.
182182
#
183183
# with-tclinclude:DIR
184184
# => {Specify the directory which contains the tcl.h. This should not
@@ -188,24 +188,27 @@ proc teaish-configure-core {} {
188188
# extensions, and thus use a teaish-... prefix on most flags. However,
189189
# --teaish-extension-dir is frequently needed, so...
190190
#
191-
# As of this spontaneous moment, we'll formalize using using
192-
# --t-X-Y to abbreviate teaish flags when doing so is
191+
# As of this spontaneous moment, we'll settle on using --t-A-X to
192+
# abbreviate --teaish-A...-X... flags when doing so is
193193
# unambiguous...
194194
ted: t-e-d:
195195
teaish-extension-dir:DIR
196-
=> {Looks for an extension in the given directory instead of the current dir.}
196+
=> {Looks for an extension in the given directory instead of the current
197+
dir.}
197198

198199
t-c-e:
199200
teaish-create-extension:TARGET_DIRECTORY
200201
=> {Writes stub files for creating an extension. Will refuse to overwrite
201-
existing files without --force.}
202+
existing files without --teaish-force.}
202203

203204
t-f
204205
teaish-force
205-
=> {Has a context-dependent meaning (autosetup defines --force for its own use)}
206+
=> {Has a context-dependent meaning (autosetup defines --force for its
207+
own use).}
206208

207209
t-d-d
208-
teaish-dump-defines => {Dump all configure-defined vars to config.defines.txt}
210+
teaish-dump-defines
211+
=> {Dump all configure-defined vars to config.defines.txt}
209212

210213
t-v
211214
teaish-verbose=0
@@ -813,7 +816,7 @@ proc teaish__find_extension {} {
813816
if {$dirExt ne $dirSrc} {
814817
lappend flist $dirSrc/teaish.tcl
815818
}
816-
if {![proj-first-file-found $flist extT]} {
819+
if {![proj-first-file-found extT $flist]} {
817820
if {$gotHelpArg} {
818821
# Tell teaish-configure-core that the lack of extension is not
819822
# an error when --help is used.
@@ -859,9 +862,8 @@ If you are attempting an out-of-tree build, use
859862
# We use the first one of teaish.make.in or teaish.make we find in
860863
# $dirExt.
861864
#
862-
if {[proj-first-file-found \
863-
[list $dirExt/teaish.make.in $dirExt/teaish.make] \
864-
extM]} {
865+
if {[proj-first-file-found extM \
866+
[list $dirExt/teaish.make.in $dirExt/teaish.make]]} {
865867
if {[string match *.in $extM]} {
866868
define TEAISH_MAKEFILE_IN $extM
867869
define TEAISH_MAKEFILE [file rootname [file tail $extM]]
@@ -878,9 +880,8 @@ If you are attempting an out-of-tree build, use
878880
}
879881

880882
# Look for teaish.pkginit.tcl[.in]
881-
if {[proj-first-file-found \
882-
[list $dirExt/teaish.pkginit.tcl.in $dirExt/teaish.pkginit.tcl] \
883-
extI]} {
883+
if {[proj-first-file-found extI \
884+
[list $dirExt/teaish.pkginit.tcl.in $dirExt/teaish.pkginit.tcl]]} {
884885
if {[string match *.in $extI]} {
885886
proj-dot-ins-append $extI
886887
define TEAISH_PKGINIT_TCL_IN $extI
@@ -897,19 +898,19 @@ If you are attempting an out-of-tree build, use
897898

898899
# Look for pkgIndex.tcl[.in]...
899900
set piPolicy 0
900-
if {[proj-first-file-found $dirExt/pkgIndex.tcl.in extPI]} {
901+
if {[proj-first-file-found extPI $dirExt/pkgIndex.tcl.in]} {
901902
# Generate ./pkgIndex.tcl from it.
902903
define TEAISH_PKGINDEX_TCL_IN $extPI
903904
define TEAISH_PKGINDEX_TCL [file rootname [file tail $extPI]]
904905
apply $addDist $extPI
905906
set piPolicy 0x01
906907
} elseif {$dirExt ne $dirSrc
907-
&& [proj-first-file-found $dirSrc/pkgIndex.tcl.in extPI]} {
908+
&& [proj-first-file-found extPI $dirSrc/pkgIndex.tcl.in]} {
908909
# Generate ./pkgIndex.tcl from it.
909910
define TEAISH_PKGINDEX_TCL_IN $extPI
910911
define TEAISH_PKGINDEX_TCL [file rootname [file tail $extPI]]
911912
set piPolicy 0x02
912-
} elseif {[proj-first-file-found $dirExt/pkgIndex.tcl extPI]} {
913+
} elseif {[proj-first-file-found extPI $dirExt/pkgIndex.tcl]} {
913914
# Assume it's a static file and use it.
914915
define TEAISH_PKGINDEX_TCL_IN ""
915916
define TEAISH_PKGINDEX_TCL $extPI
@@ -924,7 +925,7 @@ If you are attempting an out-of-tree build, use
924925
# Look for teaish.test.tcl[.in]
925926
proj-assert {"" ne $dirExt}
926927
set flist [list $dirExt/teaish.test.tcl.in $dirExt/teaish.test.tcl]
927-
if {[proj-first-file-found $flist ttt]} {
928+
if {[proj-first-file-found ttt $flist]} {
928929
if {[string match *.in $ttt]} {
929930
# Generate teaish.test.tcl from $ttt
930931
set xt [file rootname [file tail $ttt]]
@@ -944,7 +945,7 @@ If you are attempting an out-of-tree build, use
944945

945946
# Look for teaish.tester.tcl[.in]
946947
set flist [list $dirExt/teaish.tester.tcl.in $dirSrc/teaish.tester.tcl.in]
947-
if {[proj-first-file-found $flist ttt]} {
948+
if {[proj-first-file-found ttt $flist]} {
948949
# Generate teaish.test.tcl from $ttt
949950
set xt [file rootname [file tail $ttt]]
950951
file delete -force -- $xt; # ensure no stale copy is used
@@ -1408,10 +1409,14 @@ proc teaish__pragma {args} {
14081409
# teaish-pkginfo-set ?-vars|-subst? {-name foo -version 0.1.2}
14091410
#
14101411
# The latter may be easier to write for a multi-line invocation.
1411-
# Passing the -vars flag tells it to perform a [subst] of (only)
1412-
# variables in the {...} part from the calling scope. The -subst flag
1413-
# will cause is to [subst] the {...} with command substitution as well
1414-
# (but no backslash substitution).
1412+
#
1413+
# For the second call form, passing the -vars flag tells it to perform
1414+
# a [subst] of (only) variables in the {...} part from the calling
1415+
# scope. The -subst flag will cause it to [subst] the {...} with
1416+
# command substitution as well (but no backslash substitution). When
1417+
# using -subst for string concatenation, e.g. with -libDir
1418+
# foo[get-version-number], be sure to wrap the value in braces:
1419+
# -libDir {foo[get-version-number]}.
14151420
#
14161421
# Each pkginfo flag corresponds to one piece of extension package
14171422
# info. Teaish provides usable default values for all of these flags,

autoconf/tea/teaish.tester.tcl.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
if {[llength [lindex $::argv 0]] > 0} {
2020
load [lindex $::argv 0] [lindex $::argv 1];
2121
}
22-
source [lindex $::argv 2]; # teaish/tester.tcl
22+
source -encoding utf-8 [lindex $::argv 2]; # teaish/tester.tcl
2323
@if TEAISH_PKGINIT_TCL
2424
apply {{file} {
2525
set dir [file dirname $::argv0]
26-
source $file
26+
source -encoding utf-8 $file
2727
}} [join {@TEAISH_PKGINIT_TCL@}]
2828
@endif
2929
@if TEAISH_TEST_TCL
@@ -32,7 +32,7 @@ apply {{file} {
3232
array set ::teaish__BuildFlags @TEAISH__DEFINES_MAP@
3333
set dir [file normalize [file dirname $file]]
3434
#test-fail "Just testing"
35-
source $file
35+
source -encoding utf-8 $file
3636
}} [join {@TEAISH_TEST_TCL@}]
3737
@else # TEAISH_TEST_TCL
3838
# No $TEAISH_TEST_TCL provided, so here's a default test which simply

autosetup/proj.tcl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1760,13 +1760,13 @@ proc proj-validate-no-unresolved-ats {args} {
17601760
}
17611761

17621762
#
1763-
# @proj-first-found fileList tgtVar
1763+
# @proj-first-found tgtVar fileList
17641764
#
17651765
# Searches $fileList for an existing file. If one is found, its name is
17661766
# assigned to tgtVar and 1 is returned, else tgtVar is not modified
17671767
# and 0 is returned.
17681768
#
1769-
proc proj-first-file-found {fileList tgtVar} {
1769+
proc proj-first-file-found {tgtVar fileList} {
17701770
upvar $tgtVar tgt
17711771
foreach f $fileList {
17721772
if {[file exists $f]} {

0 commit comments

Comments
 (0)