Fossil SCM

Update autosetup to 0.6.8 (v0.6.7-11-g3eb780c)

steveb 2017-10-13 08:43 UTC trunk
Commit 2ed09fb8a3ec546524f8ecb4d5a8bb4a72308d829c198c91fe79d814e3e11c5d
--- autosetup/README.autosetup
+++ autosetup/README.autosetup
@@ -1,1 +1,11 @@
1
-This is autosetup v0.6.6. See http://msteveb.github.com/autosetup/
1
+README.autosetup created by autosetup v0.6.8
2
+
3
+This is the autosetup directory for a local install of autosetup.
4
+It contains autosetup, support files and loadable modules.
5
+
6
+*.tcl files in this directory are optional modules which
7
+can be loaded with the 'use' directive.
8
+
9
+*.auto files in this directory are auto-loaded.
10
+
11
+For more information, see http://msteveb.github.com/autosetup/
212
--- autosetup/README.autosetup
+++ autosetup/README.autosetup
@@ -1,1 +1,11 @@
1 This is autosetup v0.6.6. See http://msteveb.github.com/autosetup/
 
 
 
 
 
 
 
 
 
 
2
--- autosetup/README.autosetup
+++ autosetup/README.autosetup
@@ -1,1 +1,11 @@
1 README.autosetup created by autosetup v0.6.8
2
3 This is the autosetup directory for a local install of autosetup.
4 It contains autosetup, support files and loadable modules.
5
6 *.tcl files in this directory are optional modules which
7 can be loaded with the 'use' directive.
8
9 *.auto files in this directory are auto-loaded.
10
11 For more information, see http://msteveb.github.com/autosetup/
12
+551 -223
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -1,16 +1,16 @@
11
#!/bin/sh
22
# Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
33
# All rights reserved
44
# vim:se syntax=tcl:
55
# \
6
-dir=`dirname "$0"`; exec "`$dir/find-tclsh`" "$0" "$@"
6
+dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@"
77
8
-set autosetup(version) 0.6.6
8
+set autosetup(version) 0.6.8
99
1010
# Can be set to 1 to debug early-init problems
11
-set autosetup(debug) 0
11
+set autosetup(debug) [expr {"--debug" in $argv}]
1212
1313
##################################################################
1414
#
1515
# Main flow of control, option handling
1616
#
@@ -87,15 +87,28 @@
8787
set autosetup(getopt) [getopt argv]
8888
8989
#"=Core Options:"
9090
options-add {
9191
help:=local => "display help and options. Optionally specify a module name, such as --help=system"
92
+ licence license => "display the autosetup license"
9293
version => "display the version of autosetup"
9394
ref:=text manual:=text
9495
reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'"
9596
debug => "display debugging output as autosetup runs"
96
- install:=. => "install autosetup to the current or given directory (in the 'autosetup/' subdirectory)"
97
+ install:=. => "install autosetup to the current or given directory"
98
+ }
99
+ if {$autosetup(installed)} {
100
+ # hidden options so we can produce a nice error
101
+ options-add {
102
+ sysinstall:path
103
+ }
104
+ } else {
105
+ options-add {
106
+ sysinstall:path => "install standalone autosetup to the given directory (e.g.: /usr/local)"
107
+ }
108
+ }
109
+ options-add {
97110
force init:=help => "create initial auto.def, etc. Use --init=help for known types"
98111
# Undocumented options
99112
option-checking=1
100113
nopager
101114
quiet
@@ -108,11 +121,11 @@
108121
exit 0
109122
}
110123
111124
# autosetup --conf=alternate-auto.def
112125
if {[opt-val conf] ne ""} {
113
- set autosetup(autodef) [opt-val conf]
126
+ set autosetup(autodef) [lindex [opt-val conf] end]
114127
}
115128
116129
# Debugging output (set this early)
117130
incr autosetup(debug) [opt-bool debug]
118131
incr autosetup(force) [opt-bool force]
@@ -124,41 +137,50 @@
124137
if {[file exists $autosetup(libdir)/local.tcl]} {
125138
use local
126139
}
127140
128141
# Now any auto-load modules
129
- foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
130
- automf_load source $file
131
- }
142
+ autosetup_load_auto_modules
132143
133144
if {[opt-val help] ne ""} {
134145
incr autosetup(showhelp)
135146
use help
136
- autosetup_help [opt-val help]
147
+ autosetup_help [lindex [opt-val help] end]
148
+ }
149
+
150
+ if {[opt-bool licence license]} {
151
+ use help
152
+ autosetup_show_license
153
+ exit 0
137154
}
138155
139156
if {[opt-val {manual ref reference}] ne ""} {
140157
use help
141
- autosetup_reference [opt-val {manual ref reference}]
158
+ autosetup_reference [lindex [opt-val {manual ref reference}] end]
142159
}
143160
144161
# Allow combining --install and --init
145162
set earlyexit 0
146163
if {[opt-val install] ne ""} {
147164
use install
148
- autosetup_install [opt-val install]
165
+ autosetup_install [lindex [opt-val install] end]
149166
incr earlyexit
150167
}
151168
152169
if {[opt-val init] ne ""} {
153170
use init
154
- autosetup_init [opt-val init]
171
+ autosetup_init [lindex [opt-val init] end]
155172
incr earlyexit
156173
}
157174
158175
if {$earlyexit} {
159176
exit 0
177
+ }
178
+ if {[opt-val sysinstall] ne ""} {
179
+ use install
180
+ autosetup_install [lindex [opt-val sysinstall] end] 1
181
+ exit 0
160182
}
161183
162184
if {![file exists $autosetup(autodef)]} {
163185
# Check for invalid option first
164186
options {}
@@ -210,14 +232,14 @@
210232
#
211233
# Check each of the named, boolean options and if any have been explicitly enabled
212234
# or disabled by the user, return 1 or 0 accordingly.
213235
#
214236
# If the option was specified more than once, the last value wins.
215
-# e.g. With --enable-foo --disable-foo, [opt-bool foo] will return 0
237
+# e.g. With '--enable-foo --disable-foo', '[opt-bool foo]' will return 0
216238
#
217239
# If no value was specified by the user, returns the default value for the
218
-# first option. If -nodefault is given, this behaviour changes and
240
+# first option. If '-nodefault' is given, this behaviour changes and
219241
# -1 is returned instead.
220242
#
221243
proc opt-bool {args} {
222244
set nodefault 0
223245
if {[lindex $args 0] eq "-nodefault"} {
@@ -237,20 +259,20 @@
237259
}
238260
# Default value is the default for the first option
239261
return [dict get $::autosetup(optdefault) [lindex $args 0]]
240262
}
241263
242
-# @opt-val option-list ?default=""?
264
+# @opt-val optionlist ?default=""?
243265
#
244
-# Returns a list containing all the values given for the non-boolean options in 'option-list'.
266
+# Returns a list containing all the values given for the non-boolean options in '$optionlist'.
245267
# There will be one entry in the list for each option given by the user, including if the
246268
# same option was used multiple times.
247269
# If only a single value is required, use something like:
248270
#
249271
## lindex [opt-val $names] end
250272
#
251
-# If no options were set, $default is returned (exactly, not as a list).
273
+# If no options were set, '$default' is returned (exactly, not as a list).
252274
#
253275
proc opt-val {names {default ""}} {
254276
option-check-names {*}$names
255277
256278
foreach opt $names {
@@ -463,35 +485,36 @@
463485
options-wrap-desc [string trim $desc] $cols " " $indent [expr $max + 2]
464486
}
465487
}
466488
}
467489
468
-# @options options-spec
490
+# @options optionspec
469491
#
470492
# Specifies configuration-time options which may be selected by the user
471
-# and checked with opt-val and opt-bool. The format of options-spec follows.
493
+# and checked with 'opt-val' and 'opt-bool'. '$optionspec' contains a series
494
+# of options specifications separated by newlines, as follows:
472495
#
473496
# A boolean option is of the form:
474497
#
475498
## name[=0|1] => "Description of this boolean option"
476499
#
477
-# The default is name=0, meaning that the option is disabled by default.
478
-# If name=1 is used to make the option enabled by default, the description should reflect
500
+# The default is 'name=0', meaning that the option is disabled by default.
501
+# If 'name=1' is used to make the option enabled by default, the description should reflect
479502
# that with text like "Disable support for ...".
480503
#
481504
# An argument option (one which takes a parameter) is of the form:
482505
#
483506
## name:[=]value => "Description of this option"
484507
#
485
-# If the name:value form is used, the value must be provided with the option (as --name=myvalue).
486
-# If the name:=value form is used, the value is optional and the given value is used as the default
508
+# If the 'name:value' form is used, the value must be provided with the option (as '--name=myvalue').
509
+# If the 'name:=value' form is used, the value is optional and the given value is used as the default
487510
# if it is not provided.
488511
#
489
-# Undocumented options are also supported by omitting the "=> description.
490
-# These options are not displayed with --help and can be useful for internal options or as aliases.
512
+# Undocumented options are also supported by omitting the '=> description'.
513
+# These options are not displayed with '--help' and can be useful for internal options or as aliases.
491514
#
492
-# For example, --disable-lfs is an alias for --disable=largefile:
515
+# For example, '--disable-lfs' is an alias for '--disable=largefile':
493516
#
494517
## lfs=1 largefile=1 => "Disable large file support"
495518
#
496519
proc options {optlist} {
497520
# Allow options as a list or args
@@ -511,25 +534,24 @@
511534
}
512535
}
513536
}
514537
515538
proc config_guess {} {
516
- if {[file-isexec $::autosetup(dir)/config.guess]} {
517
- exec-with-stderr sh $::autosetup(dir)/config.guess
518
- if {[catch {exec-with-stderr sh $::autosetup(dir)/config.guess} alias]} {
539
+ if {[file-isexec $::autosetup(dir)/autosetup-config.guess]} {
540
+ if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.guess} alias]} {
519541
user-error $alias
520542
}
521543
return $alias
522544
} else {
523
- configlog "No config.guess, so using uname"
545
+ configlog "No autosetup-config.guess, so using uname"
524546
string tolower [exec uname -p]-unknown-[exec uname -s][exec uname -r]
525547
}
526548
}
527549
528550
proc config_sub {alias} {
529
- if {[file-isexec $::autosetup(dir)/config.sub]} {
530
- if {[catch {exec-with-stderr sh $::autosetup(dir)/config.sub $alias} alias]} {
551
+ if {[file-isexec $::autosetup(dir)/autosetup-config.sub]} {
552
+ if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.sub $alias} alias]} {
531553
user-error $alias
532554
}
533555
}
534556
return $alias
535557
}
@@ -536,39 +558,45 @@
536558
537559
# @define name ?value=1?
538560
#
539561
# Defines the named variable to the given value.
540562
# These (name, value) pairs represent the results of the configuration check
541
-# and are available to be checked, modified and substituted.
563
+# and are available to be subsequently checked, modified and substituted.
542564
#
543565
proc define {name {value 1}} {
544566
set ::define($name) $value
545567
#dputs "$name <= $value"
546568
}
547569
548570
# @undefine name
549571
#
550
-# Undefine the named variable
572
+# Undefine the named variable.
551573
#
552574
proc undefine {name} {
553575
unset -nocomplain ::define($name)
554576
#dputs "$name <= <undef>"
555577
}
556578
557579
# @define-append name value ...
558580
#
559
-# Appends the given value(s) to the given 'defined' variable.
560
-# If the variable is not defined or empty, it is set to $value.
581
+# Appends the given value(s) to the given "defined" variable.
582
+# If the variable is not defined or empty, it is set to '$value'.
561583
# Otherwise the value is appended, separated by a space.
562584
# Any extra values are similarly appended.
563585
# If any value is already contained in the variable (as a substring) it is omitted.
564586
#
565587
proc define-append {name args} {
566588
if {[get-define $name ""] ne ""} {
567
- # Make a token attempt to avoid duplicates
589
+ # Avoid duplicates
568590
foreach arg $args {
569
- if {[string first $arg $::define($name)] == -1} {
591
+ set found 0
592
+ foreach str [split $::define($name) " "] {
593
+ if {$str eq $arg} {
594
+ incr found
595
+ }
596
+ }
597
+ if {!$found} {
570598
append ::define($name) " " $arg
571599
}
572600
}
573601
} else {
574602
set ::define($name) [join $args]
@@ -576,11 +604,11 @@
576604
#dputs "$name += [join $args] => $::define($name)"
577605
}
578606
579607
# @get-define name ?default=0?
580608
#
581
-# Returns the current value of the 'defined' variable, or $default
609
+# Returns the current value of the "defined" variable, or '$default'
582610
# if not set.
583611
#
584612
proc get-define {name {default 0}} {
585613
if {[info exists ::define($name)]} {
586614
#dputs "$name => $::define($name)"
@@ -598,11 +626,11 @@
598626
info exists ::define($name)
599627
}
600628
601629
# @all-defines
602630
#
603
-# Returns a dictionary (name value list) of all defined variables.
631
+# Returns a dictionary (name, value list) of all defined variables.
604632
#
605633
# This is suitable for use with 'dict', 'array set' or 'foreach'
606634
# and allows for arbitrary processing of the defined variables.
607635
#
608636
proc all-defines {} {
@@ -610,13 +638,13 @@
610638
}
611639
612640
613641
# @get-env name default
614642
#
615
-# If $name was specified on the command line, return it.
616
-# If $name was set in the environment, return it.
617
-# Otherwise return $default.
643
+# If '$name' was specified on the command line, return it.
644
+# Otherwise if '$name' was set in the environment, return it.
645
+# Otherwise return '$default'.
618646
#
619647
proc get-env {name default} {
620648
if {[dict exists $::autosetup(cmdline) $name]} {
621649
return [dict get $::autosetup(cmdline) $name]
622650
}
@@ -623,11 +651,11 @@
623651
getenv $name $default
624652
}
625653
626654
# @env-is-set name
627655
#
628
-# Returns 1 if the $name was specified on the command line or in the environment.
656
+# Returns 1 if '$name' was specified on the command line or in the environment.
629657
# Note that an empty environment variable is not considered to be set.
630658
#
631659
proc env-is-set {name} {
632660
if {[dict exists $::autosetup(cmdline) $name]} {
633661
return 1
@@ -639,11 +667,11 @@
639667
}
640668
641669
# @readfile filename ?default=""?
642670
#
643671
# Return the contents of the file, without the trailing newline.
644
-# If the file doesn't exist or can't be read, returns $default.
672
+# If the file doesn't exist or can't be read, returns '$default'.
645673
#
646674
proc readfile {filename {default_value ""}} {
647675
set result $default_value
648676
catch {
649677
set f [open $filename]
@@ -653,11 +681,11 @@
653681
return $result
654682
}
655683
656684
# @writefile filename value
657685
#
658
-# Creates the given file containing $value.
686
+# Creates the given file containing '$value'.
659687
# Does not add an extra newline.
660688
#
661689
proc writefile {filename value} {
662690
set f [open $filename w]
663691
puts -nonewline $f $value
@@ -677,63 +705,60 @@
677705
lappend args [quote-if-needed $arg]
678706
}
679707
join $args
680708
}
681709
682
-# @suffix suf list
683
-#
684
-# Takes a list and returns a new list with $suf appended
685
-# to each element
686
-#
687
-## suffix .c {a b c} => {a.c b.c c.c}
688
-#
689
-proc suffix {suf list} {
710
+# @list-non-empty list
711
+#
712
+# Returns a copy of the given list with empty elements removed
713
+proc list-non-empty {list} {
690714
set result {}
691715
foreach p $list {
692
- lappend result $p$suf
716
+ if {$p ne ""} {
717
+ lappend result $p
718
+ }
693719
}
694720
return $result
695721
}
696722
697
-# @prefix pre list
698
-#
699
-# Takes a list and returns a new list with $pre prepended
700
-# to each element
701
-#
702
-## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
703
-#
704
-proc prefix {pre list} {
705
- set result {}
706
- foreach p $list {
707
- lappend result $pre$p
708
- }
709
- return $result
723
+# @find-executable-path name
724
+#
725
+# Searches the path for an executable with the given name.
726
+# Note that the name may include some parameters, e.g. 'cc -mbig-endian',
727
+# in which case the parameters are ignored.
728
+# The full path to the executable if found, or "" if not found.
729
+# Returns 1 if found, or 0 if not.
730
+#
731
+proc find-executable-path {name} {
732
+ # Ignore any parameters
733
+ set name [lindex $name 0]
734
+ # The empty string is never a valid executable
735
+ if {$name ne ""} {
736
+ foreach p [split-path] {
737
+ dputs "Looking for $name in $p"
738
+ set exec [file join $p $name]
739
+ if {[file-isexec $exec]} {
740
+ dputs "Found $name -> $exec"
741
+ return $exec
742
+ }
743
+ }
744
+ }
745
+ return {}
710746
}
711747
712748
# @find-executable name
713749
#
714750
# Searches the path for an executable with the given name.
715
-# Note that the name may include some parameters, e.g. "cc -mbig-endian",
751
+# Note that the name may include some parameters, e.g. 'cc -mbig-endian',
716752
# in which case the parameters are ignored.
717753
# Returns 1 if found, or 0 if not.
718754
#
719755
proc find-executable {name} {
720
- # Ignore any parameters
721
- set name [lindex $name 0]
722
- if {$name eq ""} {
723
- # The empty string is never a valid executable
724
- return 0
725
- }
726
- foreach p [split-path] {
727
- dputs "Looking for $name in $p"
728
- set exec [file join $p $name]
729
- if {[file-isexec $exec]} {
730
- dputs "Found $name -> $exec"
731
- return 1
732
- }
733
- }
734
- return 0
756
+ if {[find-executable-path $name] eq {}} {
757
+ return 0
758
+ }
759
+ return 1
735760
}
736761
737762
# @find-an-executable ?-required? name ...
738763
#
739764
# Given a list of possible executable names,
@@ -764,11 +789,11 @@
764789
return ""
765790
}
766791
767792
# @configlog msg
768793
#
769
-# Writes the given message to the configuration log, config.log
794
+# Writes the given message to the configuration log, 'config.log'.
770795
#
771796
proc configlog {msg} {
772797
if {![info exists ::autosetup(logfh)]} {
773798
set ::autosetup(logfh) [open config.log w]
774799
}
@@ -800,12 +825,12 @@
800825
}
801826
}
802827
803828
# @msg-quiet command ...
804829
#
805
-# msg-quiet evaluates it's arguments as a command with output
806
-# from msg-checking and msg-result suppressed.
830
+# 'msg-quiet' evaluates it's arguments as a command with output
831
+# from 'msg-checking' and 'msg-result' suppressed.
807832
#
808833
# This is useful if a check needs to run a subcheck which isn't
809834
# of interest to the user.
810835
proc msg-quiet {args} {
811836
incr ::autosetup(msg-quiet)
@@ -841,11 +866,11 @@
841866
842867
# @user-error msg
843868
#
844869
# Indicate incorrect usage to the user, including if required components
845870
# or features are not found.
846
-# autosetup exits with a non-zero return code.
871
+# 'autosetup' exits with a non-zero return code.
847872
#
848873
proc user-error {msg} {
849874
show-notices
850875
puts stderr "Error: $msg"
851876
puts stderr "Try: '[file tail $::autosetup(exe)] --help' for options"
@@ -887,10 +912,22 @@
887912
proc maybe-show-timestamp {} {
888913
if {$::autosetup(msg-timing) && $::autosetup(msg-checking) == 0} {
889914
puts -nonewline [format {[%6.2f] } [expr {([clock millis] - $::autosetup(start)) % 10000 / 1000.0}]]
890915
}
891916
}
917
+
918
+# @autosetup-require-version required
919
+#
920
+# Checks the current version of 'autosetup' against '$required'.
921
+# A fatal error is generated if the current version is less than that required.
922
+#
923
+proc autosetup-require-version {required} {
924
+ use util
925
+ if {[compare-versions $::autosetup(version) $required] < 0} {
926
+ user-error "autosetup version $required is required, but this is $::autosetup(version)"
927
+ }
928
+}
892929
893930
proc autosetup_version {} {
894931
return "autosetup v$::autosetup(version)"
895932
}
896933
@@ -986,23 +1023,35 @@
9861023
# The latter form is useful for a complex module which requires additional
9871024
# support file. In this form, '$::usedir' is set to the module directory
9881025
# when it is loaded.
9891026
#
9901027
proc use {args} {
1028
+ global autosetup libmodule modsource
1029
+
1030
+ set dirs [list $autosetup(libdir)]
1031
+ if {[info exists autosetup(srcdir)]} {
1032
+ lappend dirs $autosetup(srcdir)/autosetup
1033
+ }
9911034
foreach m $args {
992
- if {[info exists ::libmodule($m)]} {
1035
+ if {[info exists libmodule($m)]} {
9931036
continue
9941037
}
995
- set ::libmodule($m) 1
996
- if {[info exists ::modsource($m)]} {
997
- automf_load eval $::modsource($m)
1038
+ set libmodule($m) 1
1039
+ if {[info exists modsource(${m}.tcl)]} {
1040
+ automf_load eval $modsource(${m}.tcl)
9981041
} else {
999
- set sources [list $::autosetup(libdir)/${m}.tcl $::autosetup(libdir)/${m}/init.tcl]
1042
+ set locs [list ${m}.tcl ${m}/init.tcl]
10001043
set found 0
1001
- foreach source $sources {
1002
- if {[file exists $source]} {
1003
- incr found
1044
+ foreach dir $dirs {
1045
+ foreach loc $locs {
1046
+ set source $dir/$loc
1047
+ if {[file exists $source]} {
1048
+ incr found
1049
+ break
1050
+ }
1051
+ }
1052
+ if {$found} {
10041053
break
10051054
}
10061055
}
10071056
if {$found} {
10081057
# For the convenience of the "use" source, point to the directory
@@ -1014,10 +1063,22 @@
10141063
autosetup-error "use: No such module: $m"
10151064
}
10161065
}
10171066
}
10181067
}
1068
+
1069
+proc autosetup_load_auto_modules {} {
1070
+ global autosetup modsource
1071
+ # First load any embedded auto modules
1072
+ foreach mod [array names modsource *.auto] {
1073
+ automf_load eval $modsource($mod)
1074
+ }
1075
+ # Now any external auto modules
1076
+ foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
1077
+ automf_load source $file
1078
+ }
1079
+}
10191080
10201081
# Load module source in the global scope by executing the given command
10211082
proc automf_load {args} {
10221083
if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
10231084
autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
@@ -1027,18 +1088,21 @@
10271088
# Initial settings
10281089
set autosetup(exe) $::argv0
10291090
set autosetup(istcl) 1
10301091
set autosetup(start) [clock millis]
10311092
set autosetup(installed) 0
1093
+set autosetup(sysinstall) 0
10321094
set autosetup(msg-checking) 0
10331095
set autosetup(msg-quiet) 0
1096
+set autosetup(inittypes) {}
10341097
10351098
# Embedded modules are inserted below here
10361099
set autosetup(installed) 1
1037
-# ----- module asciidoc-formatting -----
1100
+set autosetup(sysinstall) 0
1101
+# ----- @module asciidoc-formatting.tcl -----
10381102
1039
-set modsource(asciidoc-formatting) {
1103
+set modsource(asciidoc-formatting.tcl) {
10401104
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
10411105
# All rights reserved
10421106
10431107
# Module which provides text formatting
10441108
# asciidoc format
@@ -1102,13 +1166,13 @@
11021166
regsub -all "\n\n" $defn "\n ::\n" defn
11031167
puts $defn
11041168
}
11051169
}
11061170
1107
-# ----- module formatting -----
1171
+# ----- @module formatting.tcl -----
11081172
1109
-set modsource(formatting) {
1173
+set modsource(formatting.tcl) {
11101174
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
11111175
# All rights reserved
11121176
11131177
# Module which provides common text formatting
11141178
@@ -1159,13 +1223,13 @@
11591223
# Return the result
11601224
return $lines
11611225
}
11621226
}
11631227
1164
-# ----- module getopt -----
1228
+# ----- @module getopt.tcl -----
11651229
1166
-set modsource(getopt) {
1230
+set modsource(getopt.tcl) {
11671231
# Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
11681232
# All rights reserved
11691233
11701234
# Simple getopt module
11711235
@@ -1197,11 +1261,11 @@
11971261
11981262
if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} {
11991263
# --name=value
12001264
dict lappend opts $name [list str $value]
12011265
} elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} {
1202
- if {$prefix in {enable- with- ""}} {
1266
+ if {$prefix in {enable- ""}} {
12031267
set value 1
12041268
} else {
12051269
set value 0
12061270
}
12071271
dict lappend opts $name [list bool $value]
@@ -1218,13 +1282,13 @@
12181282
12191283
return $opts
12201284
}
12211285
}
12221286
1223
-# ----- module help -----
1287
+# ----- @module help.tcl -----
12241288
1225
-set modsource(help) {
1289
+set modsource(help.tcl) {
12261290
# Copyright (c) 2010 WorkWare Systems http://workware.net.au/
12271291
# All rights reserved
12281292
12291293
# Module which provides usage, help and the command reference
12301294
@@ -1251,10 +1315,28 @@
12511315
options-show
12521316
}
12531317
}
12541318
exit 0
12551319
}
1320
+
1321
+proc autosetup_show_license {} {
1322
+ global modsource autosetup
1323
+ use_pager
1324
+
1325
+ if {[info exists modsource(LICENSE)]} {
1326
+ puts $modsource(LICENSE)
1327
+ return
1328
+ }
1329
+ foreach dir [list $autosetup(libdir) $autosetup(srcdir)] {
1330
+ set path [file join $dir LICENSE]
1331
+ if {[file exists $path]} {
1332
+ puts [readfile $path]
1333
+ return
1334
+ }
1335
+ }
1336
+ puts "LICENSE not found"
1337
+}
12561338
12571339
# If not already paged and stdout is a tty, pipe the output through the pager
12581340
# This is done by reinvoking autosetup with --nopager added
12591341
proc use_pager {} {
12601342
if {![opt-bool nopager] && [getenv PAGER ""] ne "" && [isatty? stdin] && [isatty? stdout]} {
@@ -1304,10 +1386,16 @@
13041386
}
13051387
13061388
proc autosetup_output_block {type lines} {
13071389
if {[llength $lines]} {
13081390
switch $type {
1391
+ section {
1392
+ section $lines
1393
+ }
1394
+ subsection {
1395
+ subsection $lines
1396
+ }
13091397
code {
13101398
codelines $lines
13111399
}
13121400
p {
13131401
p [join $lines]
@@ -1325,30 +1413,45 @@
13251413
# Generate a command reference from inline documentation
13261414
proc automf_command_reference {} {
13271415
lappend files $::autosetup(prog)
13281416
lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/*.tcl]]
13291417
1330
- section "Core Commands"
1331
- set type p
1332
- set lines {}
1333
- set cmd {}
1418
+ # We want to process all non-module files before module files
1419
+ # and then modules in alphabetical order.
1420
+ # So examine all files and extract docs into doc($modulename) and doc(_core_)
1421
+ #
1422
+ # Each entry is a list of {type data} where $type is one of: section, subsection, code, list, p
1423
+ # and $data is a string for section, subsection or a list of text lines for other types.
1424
+
1425
+ # XXX: Should commands be in alphabetical order too? Currently they are in file order.
1426
+
1427
+ set doc(_core_) {}
1428
+ lappend doc(_core_) [list section "Core Commands"]
13341429
13351430
foreach file $files {
1431
+ set modulename [file rootname [file tail $file]]
1432
+ set current _core_
13361433
set f [open $file]
13371434
while {![eof $f]} {
13381435
set line [gets $f]
1436
+
1437
+ # Find embedded module names
1438
+ if {[regexp {^#.*@module ([^ ]*)} $line -> modulename]} {
1439
+ continue
1440
+ }
13391441
13401442
# Find lines starting with "# @*" and continuing through the remaining comment lines
13411443
if {![regexp {^# @(.*)} $line -> cmd]} {
13421444
continue
13431445
}
13441446
13451447
# Synopsis or command?
13461448
if {$cmd eq "synopsis:"} {
1347
- section "Module: [file rootname [file tail $file]]"
1449
+ set current $modulename
1450
+ lappend doc($current) [list section "Module: $modulename"]
13481451
} else {
1349
- subsection $cmd
1452
+ lappend doc($current) [list subsection $cmd]
13501453
}
13511454
13521455
set lines {}
13531456
set type p
13541457
@@ -1369,29 +1472,38 @@
13691472
13701473
#puts "hash=$hash, oldhash=$oldhash, lines=[llength $lines], cmd=$cmd"
13711474
13721475
if {$t ne $type || $cmd eq ""} {
13731476
# Finish the current block
1374
- autosetup_output_block $type $lines
1477
+ lappend doc($current) [list $type $lines]
13751478
set lines {}
13761479
set type $t
13771480
}
13781481
if {$cmd ne ""} {
13791482
lappend lines $cmd
13801483
}
13811484
}
13821485
1383
- autosetup_output_block $type $lines
1486
+ lappend doc($current) [list $type $lines]
13841487
}
13851488
close $f
13861489
}
1490
+
1491
+ # Now format and output the results
1492
+
1493
+ # _core_ will sort first
1494
+ foreach module [lsort [array names doc]] {
1495
+ foreach item $doc($module) {
1496
+ autosetup_output_block {*}$item
1497
+ }
1498
+ }
13871499
}
13881500
}
13891501
1390
-# ----- module init -----
1502
+# ----- @module init.tcl -----
13911503
1392
-set modsource(init) {
1504
+set modsource(init.tcl) {
13931505
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
13941506
# All rights reserved
13951507
13961508
# Module to help create auto.def and configure
13971509
@@ -1444,79 +1556,157 @@
14441556
}
14451557
writefile $filename $contents
14461558
}
14471559
}
14481560
1449
-# ----- module install -----
1561
+# ----- @module install.tcl -----
14501562
1451
-set modsource(install) {
1563
+set modsource(install.tcl) {
14521564
# Copyright (c) 2006-2010 WorkWare Systems http://www.workware.net.au/
14531565
# All rights reserved
14541566
14551567
# Module which can install autosetup
14561568
1457
-proc autosetup_install {dir} {
1458
- if {[catch {
1569
+# autosetup(installed)=1 means that autosetup is not running from source
1570
+# autosetup(sysinstall)=1 means that autosetup is running from a sysinstall verion
1571
+# shared=1 means that we are trying to do a sysinstall. This is only possible from the development source.
1572
+
1573
+proc autosetup_install {dir {shared 0}} {
1574
+ global autosetup
1575
+ if {$shared} {
1576
+ if {$autosetup(installed) || $autosetup(sysinstall)} {
1577
+ user-error "Can only --sysinstall from development sources"
1578
+ }
1579
+ } elseif {$autosetup(installed)} {
1580
+ user-error "Can't --install from project install"
1581
+ }
1582
+
1583
+ if {$autosetup(sysinstall)} {
1584
+ # This is the sysinstall version, so install just uses references
14591585
cd $dir
1586
+
1587
+ puts "[autosetup_version] creating configure to use system-installed autosetup"
1588
+ autosetup_create_configure 1
1589
+ puts "Creating autosetup/README.autosetup"
14601590
file mkdir autosetup
1591
+ autosetup_install_readme autosetup/README.autosetup 1
1592
+ return
1593
+ }
1594
+
1595
+ if {[catch {
1596
+ if {$shared} {
1597
+ set target $dir/bin/autosetup
1598
+ set installedas $target
1599
+ } else {
1600
+ if {$dir eq "."} {
1601
+ set installedas autosetup
1602
+ } else {
1603
+ set installedas $dir/autosetup
1604
+ }
1605
+ cd $dir
1606
+ file mkdir autosetup
1607
+ set target autosetup/autosetup
1608
+ }
1609
+ set targetdir [file dirname $target]
1610
+ file mkdir $targetdir
14611611
1462
- set f [open autosetup/autosetup w]
1612
+ set f [open $target w]
14631613
1464
- set publicmodules [glob $::autosetup(libdir)/*.auto]
1614
+ set publicmodules {}
14651615
14661616
# First the main script, but only up until "CUT HERE"
1467
- set in [open $::autosetup(dir)/autosetup]
1617
+ set in [open $autosetup(dir)/autosetup]
14681618
while {[gets $in buf] >= 0} {
14691619
if {$buf ne "##-- CUT HERE --##"} {
14701620
puts $f $buf
14711621
continue
14721622
}
14731623
14741624
# Insert the static modules here
14751625
# i.e. those which don't contain @synopsis:
1626
+ # All modules are inserted if $shared is set
14761627
puts $f "set autosetup(installed) 1"
1477
- foreach file [lsort [glob $::autosetup(libdir)/*.tcl]] {
1628
+ puts $f "set autosetup(sysinstall) $shared"
1629
+ foreach file [lsort [glob $autosetup(libdir)/*.{tcl,auto}]] {
1630
+ set modname [file tail $file]
1631
+ set ext [file ext $modname]
14781632
set buf [readfile $file]
1479
- if {[string match "*\n# @synopsis:*" $buf]} {
1480
- lappend publicmodules $file
1481
- continue
1633
+ if {!$shared} {
1634
+ if {$ext eq ".auto" || [string match "*\n# @synopsis:*" $buf]} {
1635
+ lappend publicmodules $file
1636
+ continue
1637
+ }
14821638
}
1483
- set modname [file rootname [file tail $file]]
1484
- puts $f "# ----- module $modname -----"
1639
+ dputs "install: importing lib/[file tail $file]"
1640
+ puts $f "# ----- @module $modname -----"
14851641
puts $f "\nset modsource($modname) \{"
14861642
puts $f $buf
14871643
puts $f "\}\n"
14881644
}
1645
+ if {$shared} {
1646
+ foreach {srcname destname} [list $autosetup(libdir)/README.autosetup-lib README.autosetup \
1647
+ $autosetup(srcdir)/LICENSE LICENSE] {
1648
+ dputs "install: importing $srcname as $destname"
1649
+ puts $f "\nset modsource($destname) \\\n[list [readfile $srcname]\n]\n"
1650
+ }
1651
+ }
14891652
}
14901653
close $in
14911654
close $f
1492
- exec chmod 755 autosetup/autosetup
1655
+ catch {exec chmod 755 $target}
1656
+
1657
+ set installfiles {autosetup-config.guess autosetup-config.sub autosetup-test-tclsh}
1658
+ set removefiles {}
1659
+
1660
+ if {!$shared} {
1661
+ autosetup_install_readme $targetdir/README.autosetup 0
14931662
1494
- # Install public modules
1495
- foreach file $publicmodules {
1496
- autosetup_install_file $file autosetup
1663
+ # Install public modules
1664
+ foreach file $publicmodules {
1665
+ set tail [file tail $file]
1666
+ autosetup_install_file $file $targetdir/$tail
1667
+ }
1668
+ lappend installfiles jimsh0.c autosetup-find-tclsh LICENSE
1669
+ lappend removefiles config.guess config.sub test-tclsh find-tclsh
1670
+ } else {
1671
+ lappend installfiles {sys-find-tclsh autosetup-find-tclsh}
14971672
}
14981673
14991674
# Install support files
1500
- foreach file {config.guess config.sub jimsh0.c find-tclsh test-tclsh LICENSE} {
1501
- autosetup_install_file $::autosetup(dir)/$file autosetup
1502
- }
1503
- exec chmod 755 autosetup/config.sub autosetup/config.guess autosetup/find-tclsh
1504
-
1505
- writefile autosetup/README.autosetup \
1506
- "This is [autosetup_version]. See http://msteveb.github.com/autosetup/\n"
1507
-
1675
+ foreach fileinfo $installfiles {
1676
+ if {[llength $fileinfo] == 2} {
1677
+ lassign $fileinfo source dest
1678
+ } else {
1679
+ lassign $fileinfo source
1680
+ set dest $source
1681
+ }
1682
+ autosetup_install_file $autosetup(dir)/$source $targetdir/$dest
1683
+ }
1684
+
1685
+ # Remove obsolete files
1686
+ foreach file $removefiles {
1687
+ if {[file exists $targetdir/$file]} {
1688
+ file delete $targetdir/$file
1689
+ }
1690
+ }
15081691
} error]} {
15091692
user-error "Failed to install autosetup: $error"
15101693
}
1511
- puts "Installed [autosetup_version] to autosetup/"
1694
+ if {$shared} {
1695
+ set type "system"
1696
+ } else {
1697
+ set type "local"
1698
+ }
1699
+ puts "Installed $type [autosetup_version] to $installedas"
15121700
1513
- # Now create 'configure' if necessary
1514
- autosetup_create_configure
1701
+ if {!$shared} {
1702
+ # Now create 'configure' if necessary
1703
+ autosetup_create_configure 0
1704
+ }
15151705
}
15161706
1517
-proc autosetup_create_configure {} {
1707
+proc autosetup_create_configure {shared} {
15181708
if {[file exists configure]} {
15191709
if {!$::autosetup(force)} {
15201710
# Could this be an autosetup configure?
15211711
if {![string match "*\nWRAPPER=*" [readfile configure]]} {
15221712
puts "I see configure, but not created by autosetup, so I won't overwrite it."
@@ -1527,40 +1717,76 @@
15271717
puts "I will overwrite the existing configure because you used --force."
15281718
}
15291719
} else {
15301720
puts "I don't see configure, so I will create it."
15311721
}
1532
- writefile configure \
1722
+ if {$shared} {
1723
+ writefile configure \
1724
+{#!/bin/sh
1725
+# Note that WRAPPER is set here purely to detect an autosetup-created script
1726
+WRAPPER="-"; "autosetup" "$@"
1727
+}
1728
+ } else {
1729
+ writefile configure \
15331730
{#!/bin/sh
15341731
dir="`dirname "$0"`/autosetup"
1535
-WRAPPER="$0"; export WRAPPER; exec "`$dir/find-tclsh`" "$dir/autosetup" "$@"
1732
+WRAPPER="$0"; export WRAPPER; exec "`$dir/autosetup-find-tclsh`" "$dir/autosetup" "$@"
15361733
}
1734
+ }
15371735
catch {exec chmod 755 configure}
15381736
}
15391737
15401738
# Append the contents of $file to filehandle $f
15411739
proc autosetup_install_append {f file} {
1740
+ dputs "install: include $file"
15421741
set in [open $file]
15431742
puts $f [read $in]
15441743
close $in
15451744
}
15461745
1547
-proc autosetup_install_file {file dir} {
1548
- if {![file exists $file]} {
1549
- error "Missing installation file '$file'"
1550
- }
1551
- writefile [file join $dir [file tail $file]] [readfile $file]\n
1552
-}
1553
-
1554
-if {$::autosetup(installed)} {
1555
- user-error "autosetup can only be installed from development source, not from installed copy"
1746
+proc autosetup_install_file {source target} {
1747
+ dputs "install: $source => $target"
1748
+ if {![file exists $source]} {
1749
+ error "Missing installation file '$source'"
1750
+ }
1751
+ writefile $target [readfile $source]\n
1752
+ # If possible, copy the file mode
1753
+ file stat $source stat
1754
+ set mode [format %o [expr {$stat(mode) & 0x1ff}]]
1755
+ catch {exec chmod $mode $target}
1756
+}
1757
+
1758
+proc autosetup_install_readme {target sysinstall} {
1759
+ set readme "README.autosetup created by [autosetup_version]\n\n"
1760
+ if {$sysinstall} {
1761
+ append readme \
1762
+{This is the autosetup directory for a system install of autosetup.
1763
+Loadable modules can be added here.
1764
+}
1765
+ } else {
1766
+ append readme \
1767
+{This is the autosetup directory for a local install of autosetup.
1768
+It contains autosetup, support files and loadable modules.
1769
+}
1770
+}
1771
+
1772
+ append readme {
1773
+*.tcl files in this directory are optional modules which
1774
+can be loaded with the 'use' directive.
1775
+
1776
+*.auto files in this directory are auto-loaded.
1777
+
1778
+For more information, see http://msteveb.github.com/autosetup/
1779
+}
1780
+ dputs "install: autosetup/README.autosetup"
1781
+ writefile $target $readme
15561782
}
15571783
}
15581784
1559
-# ----- module markdown-formatting -----
1785
+# ----- @module markdown-formatting.tcl -----
15601786
1561
-set modsource(markdown-formatting) {
1787
+set modsource(markdown-formatting.tcl) {
15621788
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
15631789
# All rights reserved
15641790
15651791
# Module which provides text formatting
15661792
# markdown format (kramdown syntax)
@@ -1627,13 +1853,13 @@
16271853
}
16281854
puts "$defn"
16291855
}
16301856
}
16311857
1632
-# ----- module misc -----
1858
+# ----- @module misc.tcl -----
16331859
1634
-set modsource(misc) {
1860
+set modsource(misc.tcl) {
16351861
# Copyright (c) 2007-2010 WorkWare Systems http://www.workware.net.au/
16361862
# All rights reserved
16371863
16381864
# Module containing misc procs useful to modules
16391865
# Largely for platform compatibility
@@ -1805,106 +2031,208 @@
18052031
string trim $result
18062032
}
18072033
}
18082034
}
18092035
1810
-# ----- module text-formatting -----
2036
+# ----- @module text-formatting.tcl -----
18112037
1812
-set modsource(text-formatting) {
2038
+set modsource(text-formatting.tcl) {
18132039
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
18142040
# All rights reserved
18152041
18162042
# Module which provides text formatting
18172043
18182044
use formatting
18192045
18202046
proc wordwrap {text length {firstprefix ""} {nextprefix ""}} {
1821
- set len 0
1822
- set space $firstprefix
1823
- foreach word [split $text] {
1824
- set word [string trim $word]
1825
- if {$word == ""} {
1826
- continue
1827
- }
1828
- if {$len && [string length $space$word] + $len >= $length} {
1829
- puts ""
1830
- set len 0
1831
- set space $nextprefix
1832
- }
1833
- incr len [string length $space$word]
1834
-
1835
- # Use man-page conventions for highlighting 'quoted' and *quoted*
1836
- # single words.
1837
- # Use x^Hx for *bold* and _^Hx for 'underline'.
1838
- #
1839
- # less and more will both understand this.
1840
- # Pipe through 'col -b' to remove them.
1841
- if {[regexp {^'(.*)'([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
1842
- regsub -all . $bareword "_\b&" word
1843
- append word $dot
1844
- } elseif {[regexp {^[*](.*)[*]([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
1845
- regsub -all . $bareword "&\b&" word
1846
- append word $dot
1847
- }
1848
- puts -nonewline $space$word
1849
- set space " "
1850
- }
1851
- if {$len} {
1852
- puts ""
1853
- }
2047
+ set len 0
2048
+ set space $firstprefix
2049
+
2050
+ foreach word [split $text] {
2051
+ set word [string trim $word]
2052
+ if {$word eq ""} {
2053
+ continue
2054
+ }
2055
+ if {[info exists partial]} {
2056
+ append partial " " $word
2057
+ if {[string first $quote $word] < 0} {
2058
+ # Haven't found end of quoted word
2059
+ continue
2060
+ }
2061
+ # Finished quoted word
2062
+ set word $partial
2063
+ unset partial
2064
+ unset quote
2065
+ } else {
2066
+ set quote [string index $word 0]
2067
+ if {$quote in {' *}} {
2068
+ if {[string first $quote $word 1] < 0} {
2069
+ # Haven't found end of quoted word
2070
+ # Not a whole word.
2071
+ set first [string index $word 0]
2072
+ # Start of quoted word
2073
+ set partial $word
2074
+ continue
2075
+ }
2076
+ }
2077
+ }
2078
+
2079
+ if {$len && [string length $space$word] + $len >= $length} {
2080
+ puts ""
2081
+ set len 0
2082
+ set space $nextprefix
2083
+ }
2084
+ incr len [string length $space$word]
2085
+
2086
+ # Use man-page conventions for highlighting 'quoted' and *quoted*
2087
+ # single words.
2088
+ # Use x^Hx for *bold* and _^Hx for 'underline'.
2089
+ #
2090
+ # less and more will both understand this.
2091
+ # Pipe through 'col -b' to remove them.
2092
+ if {[regexp {^'(.*)'(.*)} $word -> quoted after]} {
2093
+ set quoted [string map {~ " "} $quoted]
2094
+ regsub -all . $quoted "&\b&" quoted
2095
+ set word $quoted$after
2096
+ } elseif {[regexp {^[*](.*)[*](.*)} $word -> quoted after]} {
2097
+ set quoted [string map {~ " "} $quoted]
2098
+ regsub -all . $quoted "_\b&" quoted
2099
+ set word $quoted$after
2100
+ }
2101
+ puts -nonewline $space$word
2102
+ set space " "
2103
+ }
2104
+ if {[info exists partial]} {
2105
+ # Missing end of quote
2106
+ puts -nonewline $space$partial
2107
+ }
2108
+ if {$len} {
2109
+ puts ""
2110
+ }
18542111
}
18552112
proc title {text} {
1856
- underline [string trim $text] =
1857
- nl
2113
+ underline [string trim $text] =
2114
+ nl
18582115
}
18592116
proc p {text} {
1860
- wordwrap $text 80
1861
- nl
2117
+ wordwrap $text 80
2118
+ nl
18622119
}
18632120
proc codelines {lines} {
1864
- foreach line $lines {
1865
- puts " $line"
1866
- }
1867
- nl
2121
+ foreach line $lines {
2122
+ puts " $line"
2123
+ }
2124
+ nl
18682125
}
18692126
proc nl {} {
1870
- puts ""
2127
+ puts ""
18712128
}
18722129
proc underline {text char} {
1873
- regexp "^(\[ \t\]*)(.*)" $text -> indent words
1874
- puts $text
1875
- puts $indent[string repeat $char [string length $words]]
2130
+ regexp "^(\[ \t\]*)(.*)" $text -> indent words
2131
+ puts $text
2132
+ puts $indent[string repeat $char [string length $words]]
18762133
}
18772134
proc section {text} {
1878
- underline "[string trim $text]" -
1879
- nl
2135
+ underline "[string trim $text]" -
2136
+ nl
18802137
}
18812138
proc subsection {text} {
1882
- underline "$text" ~
1883
- nl
2139
+ underline "$text" ~
2140
+ nl
18842141
}
18852142
proc bullet {text} {
1886
- wordwrap $text 76 " * " " "
2143
+ wordwrap $text 76 " * " " "
18872144
}
18882145
proc indent {text} {
1889
- wordwrap $text 76 " " " "
2146
+ wordwrap $text 76 " " " "
18902147
}
18912148
proc defn {first args} {
1892
- if {$first ne ""} {
1893
- underline " $first" ~
1894
- }
1895
- foreach p $args {
1896
- if {$p ne ""} {
1897
- indent $p
1898
- }
1899
- }
2149
+ if {$first ne ""} {
2150
+ underline " $first" ~
2151
+ }
2152
+ foreach p $args {
2153
+ if {$p ne ""} {
2154
+ indent $p
2155
+ }
2156
+ }
2157
+}
2158
+}
2159
+
2160
+# ----- @module util.tcl -----
2161
+
2162
+set modsource(util.tcl) {
2163
+# Copyright (c) 2012 WorkWare Systems http://www.workware.net.au/
2164
+# All rights reserved
2165
+
2166
+# Module which contains miscellaneous utility functions
2167
+
2168
+# @compare-versions version1 version2
2169
+#
2170
+# Versions are of the form 'a.b.c' (may be any number of numeric components)
2171
+#
2172
+# Compares the two versions and returns:
2173
+## -1 if v1 < v2
2174
+## 0 if v1 == v2
2175
+## 1 if v1 > v2
2176
+#
2177
+# If one version has fewer components than the other, 0 is substituted to the right. e.g.
2178
+## 0.2 < 0.3
2179
+## 0.2.5 > 0.2
2180
+## 1.1 == 1.1.0
2181
+#
2182
+proc compare-versions {v1 v2} {
2183
+ foreach c1 [split $v1 .] c2 [split $v2 .] {
2184
+ if {$c1 eq ""} {
2185
+ set c1 0
2186
+ }
2187
+ if {$c2 eq ""} {
2188
+ set c2 0
2189
+ }
2190
+ if {$c1 < $c2} {
2191
+ return -1
2192
+ }
2193
+ if {$c1 > $c2} {
2194
+ return 1
2195
+ }
2196
+ }
2197
+ return 0
2198
+}
2199
+
2200
+# @suffix suf list
2201
+#
2202
+# Takes a list and returns a new list with '$suf' appended
2203
+# to each element
2204
+#
2205
+## suffix .c {a b c} => {a.c b.c c.c}
2206
+#
2207
+proc suffix {suf list} {
2208
+ set result {}
2209
+ foreach p $list {
2210
+ lappend result $p$suf
2211
+ }
2212
+ return $result
2213
+}
2214
+
2215
+# @prefix pre list
2216
+#
2217
+# Takes a list and returns a new list with '$pre' prepended
2218
+# to each element
2219
+#
2220
+## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
2221
+#
2222
+proc prefix {pre list} {
2223
+ set result {}
2224
+ foreach p $list {
2225
+ lappend result $pre$p
2226
+ }
2227
+ return $result
19002228
}
19012229
}
19022230
1903
-# ----- module wiki-formatting -----
2231
+# ----- @module wiki-formatting.tcl -----
19042232
1905
-set modsource(wiki-formatting) {
2233
+set modsource(wiki-formatting.tcl) {
19062234
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
19072235
# All rights reserved
19082236
19092237
# Module which provides text formatting
19102238
# wiki.tcl.tk format output
@@ -1975,11 +2303,11 @@
19752303
if {$autosetup(debug)} {
19762304
main $argv
19772305
}
19782306
if {[catch {main $argv} msg opts] == 1} {
19792307
show-notices
1980
- autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
2308
+ autosetup-full-error [error-dump $msg $opts $autosetup(debug)]
19812309
if {!$autosetup(debug)} {
19822310
puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
19832311
}
19842312
exit 1
19852313
}
19862314
19872315
ADDED autosetup/autosetup-config.guess
19882316
ADDED autosetup/autosetup-config.sub
19892317
ADDED autosetup/autosetup-find-tclsh
19902318
ADDED autosetup/autosetup-test-tclsh
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -1,16 +1,16 @@
1 #!/bin/sh
2 # Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
3 # All rights reserved
4 # vim:se syntax=tcl:
5 # \
6 dir=`dirname "$0"`; exec "`$dir/find-tclsh`" "$0" "$@"
7
8 set autosetup(version) 0.6.6
9
10 # Can be set to 1 to debug early-init problems
11 set autosetup(debug) 0
12
13 ##################################################################
14 #
15 # Main flow of control, option handling
16 #
@@ -87,15 +87,28 @@
87 set autosetup(getopt) [getopt argv]
88
89 #"=Core Options:"
90 options-add {
91 help:=local => "display help and options. Optionally specify a module name, such as --help=system"
 
92 version => "display the version of autosetup"
93 ref:=text manual:=text
94 reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'"
95 debug => "display debugging output as autosetup runs"
96 install:=. => "install autosetup to the current or given directory (in the 'autosetup/' subdirectory)"
 
 
 
 
 
 
 
 
 
 
 
 
97 force init:=help => "create initial auto.def, etc. Use --init=help for known types"
98 # Undocumented options
99 option-checking=1
100 nopager
101 quiet
@@ -108,11 +121,11 @@
108 exit 0
109 }
110
111 # autosetup --conf=alternate-auto.def
112 if {[opt-val conf] ne ""} {
113 set autosetup(autodef) [opt-val conf]
114 }
115
116 # Debugging output (set this early)
117 incr autosetup(debug) [opt-bool debug]
118 incr autosetup(force) [opt-bool force]
@@ -124,41 +137,50 @@
124 if {[file exists $autosetup(libdir)/local.tcl]} {
125 use local
126 }
127
128 # Now any auto-load modules
129 foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
130 automf_load source $file
131 }
132
133 if {[opt-val help] ne ""} {
134 incr autosetup(showhelp)
135 use help
136 autosetup_help [opt-val help]
 
 
 
 
 
 
137 }
138
139 if {[opt-val {manual ref reference}] ne ""} {
140 use help
141 autosetup_reference [opt-val {manual ref reference}]
142 }
143
144 # Allow combining --install and --init
145 set earlyexit 0
146 if {[opt-val install] ne ""} {
147 use install
148 autosetup_install [opt-val install]
149 incr earlyexit
150 }
151
152 if {[opt-val init] ne ""} {
153 use init
154 autosetup_init [opt-val init]
155 incr earlyexit
156 }
157
158 if {$earlyexit} {
159 exit 0
 
 
 
 
 
160 }
161
162 if {![file exists $autosetup(autodef)]} {
163 # Check for invalid option first
164 options {}
@@ -210,14 +232,14 @@
210 #
211 # Check each of the named, boolean options and if any have been explicitly enabled
212 # or disabled by the user, return 1 or 0 accordingly.
213 #
214 # If the option was specified more than once, the last value wins.
215 # e.g. With --enable-foo --disable-foo, [opt-bool foo] will return 0
216 #
217 # If no value was specified by the user, returns the default value for the
218 # first option. If -nodefault is given, this behaviour changes and
219 # -1 is returned instead.
220 #
221 proc opt-bool {args} {
222 set nodefault 0
223 if {[lindex $args 0] eq "-nodefault"} {
@@ -237,20 +259,20 @@
237 }
238 # Default value is the default for the first option
239 return [dict get $::autosetup(optdefault) [lindex $args 0]]
240 }
241
242 # @opt-val option-list ?default=""?
243 #
244 # Returns a list containing all the values given for the non-boolean options in 'option-list'.
245 # There will be one entry in the list for each option given by the user, including if the
246 # same option was used multiple times.
247 # If only a single value is required, use something like:
248 #
249 ## lindex [opt-val $names] end
250 #
251 # If no options were set, $default is returned (exactly, not as a list).
252 #
253 proc opt-val {names {default ""}} {
254 option-check-names {*}$names
255
256 foreach opt $names {
@@ -463,35 +485,36 @@
463 options-wrap-desc [string trim $desc] $cols " " $indent [expr $max + 2]
464 }
465 }
466 }
467
468 # @options options-spec
469 #
470 # Specifies configuration-time options which may be selected by the user
471 # and checked with opt-val and opt-bool. The format of options-spec follows.
 
472 #
473 # A boolean option is of the form:
474 #
475 ## name[=0|1] => "Description of this boolean option"
476 #
477 # The default is name=0, meaning that the option is disabled by default.
478 # If name=1 is used to make the option enabled by default, the description should reflect
479 # that with text like "Disable support for ...".
480 #
481 # An argument option (one which takes a parameter) is of the form:
482 #
483 ## name:[=]value => "Description of this option"
484 #
485 # If the name:value form is used, the value must be provided with the option (as --name=myvalue).
486 # If the name:=value form is used, the value is optional and the given value is used as the default
487 # if it is not provided.
488 #
489 # Undocumented options are also supported by omitting the "=> description.
490 # These options are not displayed with --help and can be useful for internal options or as aliases.
491 #
492 # For example, --disable-lfs is an alias for --disable=largefile:
493 #
494 ## lfs=1 largefile=1 => "Disable large file support"
495 #
496 proc options {optlist} {
497 # Allow options as a list or args
@@ -511,25 +534,24 @@
511 }
512 }
513 }
514
515 proc config_guess {} {
516 if {[file-isexec $::autosetup(dir)/config.guess]} {
517 exec-with-stderr sh $::autosetup(dir)/config.guess
518 if {[catch {exec-with-stderr sh $::autosetup(dir)/config.guess} alias]} {
519 user-error $alias
520 }
521 return $alias
522 } else {
523 configlog "No config.guess, so using uname"
524 string tolower [exec uname -p]-unknown-[exec uname -s][exec uname -r]
525 }
526 }
527
528 proc config_sub {alias} {
529 if {[file-isexec $::autosetup(dir)/config.sub]} {
530 if {[catch {exec-with-stderr sh $::autosetup(dir)/config.sub $alias} alias]} {
531 user-error $alias
532 }
533 }
534 return $alias
535 }
@@ -536,39 +558,45 @@
536
537 # @define name ?value=1?
538 #
539 # Defines the named variable to the given value.
540 # These (name, value) pairs represent the results of the configuration check
541 # and are available to be checked, modified and substituted.
542 #
543 proc define {name {value 1}} {
544 set ::define($name) $value
545 #dputs "$name <= $value"
546 }
547
548 # @undefine name
549 #
550 # Undefine the named variable
551 #
552 proc undefine {name} {
553 unset -nocomplain ::define($name)
554 #dputs "$name <= <undef>"
555 }
556
557 # @define-append name value ...
558 #
559 # Appends the given value(s) to the given 'defined' variable.
560 # If the variable is not defined or empty, it is set to $value.
561 # Otherwise the value is appended, separated by a space.
562 # Any extra values are similarly appended.
563 # If any value is already contained in the variable (as a substring) it is omitted.
564 #
565 proc define-append {name args} {
566 if {[get-define $name ""] ne ""} {
567 # Make a token attempt to avoid duplicates
568 foreach arg $args {
569 if {[string first $arg $::define($name)] == -1} {
 
 
 
 
 
 
570 append ::define($name) " " $arg
571 }
572 }
573 } else {
574 set ::define($name) [join $args]
@@ -576,11 +604,11 @@
576 #dputs "$name += [join $args] => $::define($name)"
577 }
578
579 # @get-define name ?default=0?
580 #
581 # Returns the current value of the 'defined' variable, or $default
582 # if not set.
583 #
584 proc get-define {name {default 0}} {
585 if {[info exists ::define($name)]} {
586 #dputs "$name => $::define($name)"
@@ -598,11 +626,11 @@
598 info exists ::define($name)
599 }
600
601 # @all-defines
602 #
603 # Returns a dictionary (name value list) of all defined variables.
604 #
605 # This is suitable for use with 'dict', 'array set' or 'foreach'
606 # and allows for arbitrary processing of the defined variables.
607 #
608 proc all-defines {} {
@@ -610,13 +638,13 @@
610 }
611
612
613 # @get-env name default
614 #
615 # If $name was specified on the command line, return it.
616 # If $name was set in the environment, return it.
617 # Otherwise return $default.
618 #
619 proc get-env {name default} {
620 if {[dict exists $::autosetup(cmdline) $name]} {
621 return [dict get $::autosetup(cmdline) $name]
622 }
@@ -623,11 +651,11 @@
623 getenv $name $default
624 }
625
626 # @env-is-set name
627 #
628 # Returns 1 if the $name was specified on the command line or in the environment.
629 # Note that an empty environment variable is not considered to be set.
630 #
631 proc env-is-set {name} {
632 if {[dict exists $::autosetup(cmdline) $name]} {
633 return 1
@@ -639,11 +667,11 @@
639 }
640
641 # @readfile filename ?default=""?
642 #
643 # Return the contents of the file, without the trailing newline.
644 # If the file doesn't exist or can't be read, returns $default.
645 #
646 proc readfile {filename {default_value ""}} {
647 set result $default_value
648 catch {
649 set f [open $filename]
@@ -653,11 +681,11 @@
653 return $result
654 }
655
656 # @writefile filename value
657 #
658 # Creates the given file containing $value.
659 # Does not add an extra newline.
660 #
661 proc writefile {filename value} {
662 set f [open $filename w]
663 puts -nonewline $f $value
@@ -677,63 +705,60 @@
677 lappend args [quote-if-needed $arg]
678 }
679 join $args
680 }
681
682 # @suffix suf list
683 #
684 # Takes a list and returns a new list with $suf appended
685 # to each element
686 #
687 ## suffix .c {a b c} => {a.c b.c c.c}
688 #
689 proc suffix {suf list} {
690 set result {}
691 foreach p $list {
692 lappend result $p$suf
 
 
693 }
694 return $result
695 }
696
697 # @prefix pre list
698 #
699 # Takes a list and returns a new list with $pre prepended
700 # to each element
701 #
702 ## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
703 #
704 proc prefix {pre list} {
705 set result {}
706 foreach p $list {
707 lappend result $pre$p
708 }
709 return $result
 
 
 
 
 
 
 
 
 
 
710 }
711
712 # @find-executable name
713 #
714 # Searches the path for an executable with the given name.
715 # Note that the name may include some parameters, e.g. "cc -mbig-endian",
716 # in which case the parameters are ignored.
717 # Returns 1 if found, or 0 if not.
718 #
719 proc find-executable {name} {
720 # Ignore any parameters
721 set name [lindex $name 0]
722 if {$name eq ""} {
723 # The empty string is never a valid executable
724 return 0
725 }
726 foreach p [split-path] {
727 dputs "Looking for $name in $p"
728 set exec [file join $p $name]
729 if {[file-isexec $exec]} {
730 dputs "Found $name -> $exec"
731 return 1
732 }
733 }
734 return 0
735 }
736
737 # @find-an-executable ?-required? name ...
738 #
739 # Given a list of possible executable names,
@@ -764,11 +789,11 @@
764 return ""
765 }
766
767 # @configlog msg
768 #
769 # Writes the given message to the configuration log, config.log
770 #
771 proc configlog {msg} {
772 if {![info exists ::autosetup(logfh)]} {
773 set ::autosetup(logfh) [open config.log w]
774 }
@@ -800,12 +825,12 @@
800 }
801 }
802
803 # @msg-quiet command ...
804 #
805 # msg-quiet evaluates it's arguments as a command with output
806 # from msg-checking and msg-result suppressed.
807 #
808 # This is useful if a check needs to run a subcheck which isn't
809 # of interest to the user.
810 proc msg-quiet {args} {
811 incr ::autosetup(msg-quiet)
@@ -841,11 +866,11 @@
841
842 # @user-error msg
843 #
844 # Indicate incorrect usage to the user, including if required components
845 # or features are not found.
846 # autosetup exits with a non-zero return code.
847 #
848 proc user-error {msg} {
849 show-notices
850 puts stderr "Error: $msg"
851 puts stderr "Try: '[file tail $::autosetup(exe)] --help' for options"
@@ -887,10 +912,22 @@
887 proc maybe-show-timestamp {} {
888 if {$::autosetup(msg-timing) && $::autosetup(msg-checking) == 0} {
889 puts -nonewline [format {[%6.2f] } [expr {([clock millis] - $::autosetup(start)) % 10000 / 1000.0}]]
890 }
891 }
 
 
 
 
 
 
 
 
 
 
 
 
892
893 proc autosetup_version {} {
894 return "autosetup v$::autosetup(version)"
895 }
896
@@ -986,23 +1023,35 @@
986 # The latter form is useful for a complex module which requires additional
987 # support file. In this form, '$::usedir' is set to the module directory
988 # when it is loaded.
989 #
990 proc use {args} {
 
 
 
 
 
 
991 foreach m $args {
992 if {[info exists ::libmodule($m)]} {
993 continue
994 }
995 set ::libmodule($m) 1
996 if {[info exists ::modsource($m)]} {
997 automf_load eval $::modsource($m)
998 } else {
999 set sources [list $::autosetup(libdir)/${m}.tcl $::autosetup(libdir)/${m}/init.tcl]
1000 set found 0
1001 foreach source $sources {
1002 if {[file exists $source]} {
1003 incr found
 
 
 
 
 
 
1004 break
1005 }
1006 }
1007 if {$found} {
1008 # For the convenience of the "use" source, point to the directory
@@ -1014,10 +1063,22 @@
1014 autosetup-error "use: No such module: $m"
1015 }
1016 }
1017 }
1018 }
 
 
 
 
 
 
 
 
 
 
 
 
1019
1020 # Load module source in the global scope by executing the given command
1021 proc automf_load {args} {
1022 if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
1023 autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
@@ -1027,18 +1088,21 @@
1027 # Initial settings
1028 set autosetup(exe) $::argv0
1029 set autosetup(istcl) 1
1030 set autosetup(start) [clock millis]
1031 set autosetup(installed) 0
 
1032 set autosetup(msg-checking) 0
1033 set autosetup(msg-quiet) 0
 
1034
1035 # Embedded modules are inserted below here
1036 set autosetup(installed) 1
1037 # ----- module asciidoc-formatting -----
 
1038
1039 set modsource(asciidoc-formatting) {
1040 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1041 # All rights reserved
1042
1043 # Module which provides text formatting
1044 # asciidoc format
@@ -1102,13 +1166,13 @@
1102 regsub -all "\n\n" $defn "\n ::\n" defn
1103 puts $defn
1104 }
1105 }
1106
1107 # ----- module formatting -----
1108
1109 set modsource(formatting) {
1110 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1111 # All rights reserved
1112
1113 # Module which provides common text formatting
1114
@@ -1159,13 +1223,13 @@
1159 # Return the result
1160 return $lines
1161 }
1162 }
1163
1164 # ----- module getopt -----
1165
1166 set modsource(getopt) {
1167 # Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
1168 # All rights reserved
1169
1170 # Simple getopt module
1171
@@ -1197,11 +1261,11 @@
1197
1198 if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} {
1199 # --name=value
1200 dict lappend opts $name [list str $value]
1201 } elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} {
1202 if {$prefix in {enable- with- ""}} {
1203 set value 1
1204 } else {
1205 set value 0
1206 }
1207 dict lappend opts $name [list bool $value]
@@ -1218,13 +1282,13 @@
1218
1219 return $opts
1220 }
1221 }
1222
1223 # ----- module help -----
1224
1225 set modsource(help) {
1226 # Copyright (c) 2010 WorkWare Systems http://workware.net.au/
1227 # All rights reserved
1228
1229 # Module which provides usage, help and the command reference
1230
@@ -1251,10 +1315,28 @@
1251 options-show
1252 }
1253 }
1254 exit 0
1255 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1256
1257 # If not already paged and stdout is a tty, pipe the output through the pager
1258 # This is done by reinvoking autosetup with --nopager added
1259 proc use_pager {} {
1260 if {![opt-bool nopager] && [getenv PAGER ""] ne "" && [isatty? stdin] && [isatty? stdout]} {
@@ -1304,10 +1386,16 @@
1304 }
1305
1306 proc autosetup_output_block {type lines} {
1307 if {[llength $lines]} {
1308 switch $type {
 
 
 
 
 
 
1309 code {
1310 codelines $lines
1311 }
1312 p {
1313 p [join $lines]
@@ -1325,30 +1413,45 @@
1325 # Generate a command reference from inline documentation
1326 proc automf_command_reference {} {
1327 lappend files $::autosetup(prog)
1328 lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/*.tcl]]
1329
1330 section "Core Commands"
1331 set type p
1332 set lines {}
1333 set cmd {}
 
 
 
 
 
 
 
1334
1335 foreach file $files {
 
 
1336 set f [open $file]
1337 while {![eof $f]} {
1338 set line [gets $f]
 
 
 
 
 
1339
1340 # Find lines starting with "# @*" and continuing through the remaining comment lines
1341 if {![regexp {^# @(.*)} $line -> cmd]} {
1342 continue
1343 }
1344
1345 # Synopsis or command?
1346 if {$cmd eq "synopsis:"} {
1347 section "Module: [file rootname [file tail $file]]"
 
1348 } else {
1349 subsection $cmd
1350 }
1351
1352 set lines {}
1353 set type p
1354
@@ -1369,29 +1472,38 @@
1369
1370 #puts "hash=$hash, oldhash=$oldhash, lines=[llength $lines], cmd=$cmd"
1371
1372 if {$t ne $type || $cmd eq ""} {
1373 # Finish the current block
1374 autosetup_output_block $type $lines
1375 set lines {}
1376 set type $t
1377 }
1378 if {$cmd ne ""} {
1379 lappend lines $cmd
1380 }
1381 }
1382
1383 autosetup_output_block $type $lines
1384 }
1385 close $f
1386 }
 
 
 
 
 
 
 
 
 
1387 }
1388 }
1389
1390 # ----- module init -----
1391
1392 set modsource(init) {
1393 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1394 # All rights reserved
1395
1396 # Module to help create auto.def and configure
1397
@@ -1444,79 +1556,157 @@
1444 }
1445 writefile $filename $contents
1446 }
1447 }
1448
1449 # ----- module install -----
1450
1451 set modsource(install) {
1452 # Copyright (c) 2006-2010 WorkWare Systems http://www.workware.net.au/
1453 # All rights reserved
1454
1455 # Module which can install autosetup
1456
1457 proc autosetup_install {dir} {
1458 if {[catch {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1459 cd $dir
 
 
 
 
1460 file mkdir autosetup
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1461
1462 set f [open autosetup/autosetup w]
1463
1464 set publicmodules [glob $::autosetup(libdir)/*.auto]
1465
1466 # First the main script, but only up until "CUT HERE"
1467 set in [open $::autosetup(dir)/autosetup]
1468 while {[gets $in buf] >= 0} {
1469 if {$buf ne "##-- CUT HERE --##"} {
1470 puts $f $buf
1471 continue
1472 }
1473
1474 # Insert the static modules here
1475 # i.e. those which don't contain @synopsis:
 
1476 puts $f "set autosetup(installed) 1"
1477 foreach file [lsort [glob $::autosetup(libdir)/*.tcl]] {
 
 
 
1478 set buf [readfile $file]
1479 if {[string match "*\n# @synopsis:*" $buf]} {
1480 lappend publicmodules $file
1481 continue
 
 
1482 }
1483 set modname [file rootname [file tail $file]]
1484 puts $f "# ----- module $modname -----"
1485 puts $f "\nset modsource($modname) \{"
1486 puts $f $buf
1487 puts $f "\}\n"
1488 }
 
 
 
 
 
 
 
1489 }
1490 close $in
1491 close $f
1492 exec chmod 755 autosetup/autosetup
 
 
 
 
 
 
1493
1494 # Install public modules
1495 foreach file $publicmodules {
1496 autosetup_install_file $file autosetup
 
 
 
 
 
 
1497 }
1498
1499 # Install support files
1500 foreach file {config.guess config.sub jimsh0.c find-tclsh test-tclsh LICENSE} {
1501 autosetup_install_file $::autosetup(dir)/$file autosetup
1502 }
1503 exec chmod 755 autosetup/config.sub autosetup/config.guess autosetup/find-tclsh
1504
1505 writefile autosetup/README.autosetup \
1506 "This is [autosetup_version]. See http://msteveb.github.com/autosetup/\n"
1507
 
 
 
 
 
 
 
 
1508 } error]} {
1509 user-error "Failed to install autosetup: $error"
1510 }
1511 puts "Installed [autosetup_version] to autosetup/"
 
 
 
 
 
1512
1513 # Now create 'configure' if necessary
1514 autosetup_create_configure
 
 
1515 }
1516
1517 proc autosetup_create_configure {} {
1518 if {[file exists configure]} {
1519 if {!$::autosetup(force)} {
1520 # Could this be an autosetup configure?
1521 if {![string match "*\nWRAPPER=*" [readfile configure]]} {
1522 puts "I see configure, but not created by autosetup, so I won't overwrite it."
@@ -1527,40 +1717,76 @@
1527 puts "I will overwrite the existing configure because you used --force."
1528 }
1529 } else {
1530 puts "I don't see configure, so I will create it."
1531 }
1532 writefile configure \
 
 
 
 
 
 
 
1533 {#!/bin/sh
1534 dir="`dirname "$0"`/autosetup"
1535 WRAPPER="$0"; export WRAPPER; exec "`$dir/find-tclsh`" "$dir/autosetup" "$@"
1536 }
 
1537 catch {exec chmod 755 configure}
1538 }
1539
1540 # Append the contents of $file to filehandle $f
1541 proc autosetup_install_append {f file} {
 
1542 set in [open $file]
1543 puts $f [read $in]
1544 close $in
1545 }
1546
1547 proc autosetup_install_file {file dir} {
1548 if {![file exists $file]} {
1549 error "Missing installation file '$file'"
1550 }
1551 writefile [file join $dir [file tail $file]] [readfile $file]\n
1552 }
1553
1554 if {$::autosetup(installed)} {
1555 user-error "autosetup can only be installed from development source, not from installed copy"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1556 }
1557 }
1558
1559 # ----- module markdown-formatting -----
1560
1561 set modsource(markdown-formatting) {
1562 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1563 # All rights reserved
1564
1565 # Module which provides text formatting
1566 # markdown format (kramdown syntax)
@@ -1627,13 +1853,13 @@
1627 }
1628 puts "$defn"
1629 }
1630 }
1631
1632 # ----- module misc -----
1633
1634 set modsource(misc) {
1635 # Copyright (c) 2007-2010 WorkWare Systems http://www.workware.net.au/
1636 # All rights reserved
1637
1638 # Module containing misc procs useful to modules
1639 # Largely for platform compatibility
@@ -1805,106 +2031,208 @@
1805 string trim $result
1806 }
1807 }
1808 }
1809
1810 # ----- module text-formatting -----
1811
1812 set modsource(text-formatting) {
1813 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1814 # All rights reserved
1815
1816 # Module which provides text formatting
1817
1818 use formatting
1819
1820 proc wordwrap {text length {firstprefix ""} {nextprefix ""}} {
1821 set len 0
1822 set space $firstprefix
1823 foreach word [split $text] {
1824 set word [string trim $word]
1825 if {$word == ""} {
1826 continue
1827 }
1828 if {$len && [string length $space$word] + $len >= $length} {
1829 puts ""
1830 set len 0
1831 set space $nextprefix
1832 }
1833 incr len [string length $space$word]
1834
1835 # Use man-page conventions for highlighting 'quoted' and *quoted*
1836 # single words.
1837 # Use x^Hx for *bold* and _^Hx for 'underline'.
1838 #
1839 # less and more will both understand this.
1840 # Pipe through 'col -b' to remove them.
1841 if {[regexp {^'(.*)'([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
1842 regsub -all . $bareword "_\b&" word
1843 append word $dot
1844 } elseif {[regexp {^[*](.*)[*]([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
1845 regsub -all . $bareword "&\b&" word
1846 append word $dot
1847 }
1848 puts -nonewline $space$word
1849 set space " "
1850 }
1851 if {$len} {
1852 puts ""
1853 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1854 }
1855 proc title {text} {
1856 underline [string trim $text] =
1857 nl
1858 }
1859 proc p {text} {
1860 wordwrap $text 80
1861 nl
1862 }
1863 proc codelines {lines} {
1864 foreach line $lines {
1865 puts " $line"
1866 }
1867 nl
1868 }
1869 proc nl {} {
1870 puts ""
1871 }
1872 proc underline {text char} {
1873 regexp "^(\[ \t\]*)(.*)" $text -> indent words
1874 puts $text
1875 puts $indent[string repeat $char [string length $words]]
1876 }
1877 proc section {text} {
1878 underline "[string trim $text]" -
1879 nl
1880 }
1881 proc subsection {text} {
1882 underline "$text" ~
1883 nl
1884 }
1885 proc bullet {text} {
1886 wordwrap $text 76 " * " " "
1887 }
1888 proc indent {text} {
1889 wordwrap $text 76 " " " "
1890 }
1891 proc defn {first args} {
1892 if {$first ne ""} {
1893 underline " $first" ~
1894 }
1895 foreach p $args {
1896 if {$p ne ""} {
1897 indent $p
1898 }
1899 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1900 }
1901 }
1902
1903 # ----- module wiki-formatting -----
1904
1905 set modsource(wiki-formatting) {
1906 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1907 # All rights reserved
1908
1909 # Module which provides text formatting
1910 # wiki.tcl.tk format output
@@ -1975,11 +2303,11 @@
1975 if {$autosetup(debug)} {
1976 main $argv
1977 }
1978 if {[catch {main $argv} msg opts] == 1} {
1979 show-notices
1980 autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
1981 if {!$autosetup(debug)} {
1982 puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
1983 }
1984 exit 1
1985 }
1986
1987 DDED autosetup/autosetup-config.guess
1988 DDED autosetup/autosetup-config.sub
1989 DDED autosetup/autosetup-find-tclsh
1990 DDED autosetup/autosetup-test-tclsh
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -1,16 +1,16 @@
1 #!/bin/sh
2 # Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
3 # All rights reserved
4 # vim:se syntax=tcl:
5 # \
6 dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@"
7
8 set autosetup(version) 0.6.8
9
10 # Can be set to 1 to debug early-init problems
11 set autosetup(debug) [expr {"--debug" in $argv}]
12
13 ##################################################################
14 #
15 # Main flow of control, option handling
16 #
@@ -87,15 +87,28 @@
87 set autosetup(getopt) [getopt argv]
88
89 #"=Core Options:"
90 options-add {
91 help:=local => "display help and options. Optionally specify a module name, such as --help=system"
92 licence license => "display the autosetup license"
93 version => "display the version of autosetup"
94 ref:=text manual:=text
95 reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'"
96 debug => "display debugging output as autosetup runs"
97 install:=. => "install autosetup to the current or given directory"
98 }
99 if {$autosetup(installed)} {
100 # hidden options so we can produce a nice error
101 options-add {
102 sysinstall:path
103 }
104 } else {
105 options-add {
106 sysinstall:path => "install standalone autosetup to the given directory (e.g.: /usr/local)"
107 }
108 }
109 options-add {
110 force init:=help => "create initial auto.def, etc. Use --init=help for known types"
111 # Undocumented options
112 option-checking=1
113 nopager
114 quiet
@@ -108,11 +121,11 @@
121 exit 0
122 }
123
124 # autosetup --conf=alternate-auto.def
125 if {[opt-val conf] ne ""} {
126 set autosetup(autodef) [lindex [opt-val conf] end]
127 }
128
129 # Debugging output (set this early)
130 incr autosetup(debug) [opt-bool debug]
131 incr autosetup(force) [opt-bool force]
@@ -124,41 +137,50 @@
137 if {[file exists $autosetup(libdir)/local.tcl]} {
138 use local
139 }
140
141 # Now any auto-load modules
142 autosetup_load_auto_modules
 
 
143
144 if {[opt-val help] ne ""} {
145 incr autosetup(showhelp)
146 use help
147 autosetup_help [lindex [opt-val help] end]
148 }
149
150 if {[opt-bool licence license]} {
151 use help
152 autosetup_show_license
153 exit 0
154 }
155
156 if {[opt-val {manual ref reference}] ne ""} {
157 use help
158 autosetup_reference [lindex [opt-val {manual ref reference}] end]
159 }
160
161 # Allow combining --install and --init
162 set earlyexit 0
163 if {[opt-val install] ne ""} {
164 use install
165 autosetup_install [lindex [opt-val install] end]
166 incr earlyexit
167 }
168
169 if {[opt-val init] ne ""} {
170 use init
171 autosetup_init [lindex [opt-val init] end]
172 incr earlyexit
173 }
174
175 if {$earlyexit} {
176 exit 0
177 }
178 if {[opt-val sysinstall] ne ""} {
179 use install
180 autosetup_install [lindex [opt-val sysinstall] end] 1
181 exit 0
182 }
183
184 if {![file exists $autosetup(autodef)]} {
185 # Check for invalid option first
186 options {}
@@ -210,14 +232,14 @@
232 #
233 # Check each of the named, boolean options and if any have been explicitly enabled
234 # or disabled by the user, return 1 or 0 accordingly.
235 #
236 # If the option was specified more than once, the last value wins.
237 # e.g. With '--enable-foo --disable-foo', '[opt-bool foo]' will return 0
238 #
239 # If no value was specified by the user, returns the default value for the
240 # first option. If '-nodefault' is given, this behaviour changes and
241 # -1 is returned instead.
242 #
243 proc opt-bool {args} {
244 set nodefault 0
245 if {[lindex $args 0] eq "-nodefault"} {
@@ -237,20 +259,20 @@
259 }
260 # Default value is the default for the first option
261 return [dict get $::autosetup(optdefault) [lindex $args 0]]
262 }
263
264 # @opt-val optionlist ?default=""?
265 #
266 # Returns a list containing all the values given for the non-boolean options in '$optionlist'.
267 # There will be one entry in the list for each option given by the user, including if the
268 # same option was used multiple times.
269 # If only a single value is required, use something like:
270 #
271 ## lindex [opt-val $names] end
272 #
273 # If no options were set, '$default' is returned (exactly, not as a list).
274 #
275 proc opt-val {names {default ""}} {
276 option-check-names {*}$names
277
278 foreach opt $names {
@@ -463,35 +485,36 @@
485 options-wrap-desc [string trim $desc] $cols " " $indent [expr $max + 2]
486 }
487 }
488 }
489
490 # @options optionspec
491 #
492 # Specifies configuration-time options which may be selected by the user
493 # and checked with 'opt-val' and 'opt-bool'. '$optionspec' contains a series
494 # of options specifications separated by newlines, as follows:
495 #
496 # A boolean option is of the form:
497 #
498 ## name[=0|1] => "Description of this boolean option"
499 #
500 # The default is 'name=0', meaning that the option is disabled by default.
501 # If 'name=1' is used to make the option enabled by default, the description should reflect
502 # that with text like "Disable support for ...".
503 #
504 # An argument option (one which takes a parameter) is of the form:
505 #
506 ## name:[=]value => "Description of this option"
507 #
508 # If the 'name:value' form is used, the value must be provided with the option (as '--name=myvalue').
509 # If the 'name:=value' form is used, the value is optional and the given value is used as the default
510 # if it is not provided.
511 #
512 # Undocumented options are also supported by omitting the '=> description'.
513 # These options are not displayed with '--help' and can be useful for internal options or as aliases.
514 #
515 # For example, '--disable-lfs' is an alias for '--disable=largefile':
516 #
517 ## lfs=1 largefile=1 => "Disable large file support"
518 #
519 proc options {optlist} {
520 # Allow options as a list or args
@@ -511,25 +534,24 @@
534 }
535 }
536 }
537
538 proc config_guess {} {
539 if {[file-isexec $::autosetup(dir)/autosetup-config.guess]} {
540 if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.guess} alias]} {
 
541 user-error $alias
542 }
543 return $alias
544 } else {
545 configlog "No autosetup-config.guess, so using uname"
546 string tolower [exec uname -p]-unknown-[exec uname -s][exec uname -r]
547 }
548 }
549
550 proc config_sub {alias} {
551 if {[file-isexec $::autosetup(dir)/autosetup-config.sub]} {
552 if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.sub $alias} alias]} {
553 user-error $alias
554 }
555 }
556 return $alias
557 }
@@ -536,39 +558,45 @@
558
559 # @define name ?value=1?
560 #
561 # Defines the named variable to the given value.
562 # These (name, value) pairs represent the results of the configuration check
563 # and are available to be subsequently checked, modified and substituted.
564 #
565 proc define {name {value 1}} {
566 set ::define($name) $value
567 #dputs "$name <= $value"
568 }
569
570 # @undefine name
571 #
572 # Undefine the named variable.
573 #
574 proc undefine {name} {
575 unset -nocomplain ::define($name)
576 #dputs "$name <= <undef>"
577 }
578
579 # @define-append name value ...
580 #
581 # Appends the given value(s) to the given "defined" variable.
582 # If the variable is not defined or empty, it is set to '$value'.
583 # Otherwise the value is appended, separated by a space.
584 # Any extra values are similarly appended.
585 # If any value is already contained in the variable (as a substring) it is omitted.
586 #
587 proc define-append {name args} {
588 if {[get-define $name ""] ne ""} {
589 # Avoid duplicates
590 foreach arg $args {
591 set found 0
592 foreach str [split $::define($name) " "] {
593 if {$str eq $arg} {
594 incr found
595 }
596 }
597 if {!$found} {
598 append ::define($name) " " $arg
599 }
600 }
601 } else {
602 set ::define($name) [join $args]
@@ -576,11 +604,11 @@
604 #dputs "$name += [join $args] => $::define($name)"
605 }
606
607 # @get-define name ?default=0?
608 #
609 # Returns the current value of the "defined" variable, or '$default'
610 # if not set.
611 #
612 proc get-define {name {default 0}} {
613 if {[info exists ::define($name)]} {
614 #dputs "$name => $::define($name)"
@@ -598,11 +626,11 @@
626 info exists ::define($name)
627 }
628
629 # @all-defines
630 #
631 # Returns a dictionary (name, value list) of all defined variables.
632 #
633 # This is suitable for use with 'dict', 'array set' or 'foreach'
634 # and allows for arbitrary processing of the defined variables.
635 #
636 proc all-defines {} {
@@ -610,13 +638,13 @@
638 }
639
640
641 # @get-env name default
642 #
643 # If '$name' was specified on the command line, return it.
644 # Otherwise if '$name' was set in the environment, return it.
645 # Otherwise return '$default'.
646 #
647 proc get-env {name default} {
648 if {[dict exists $::autosetup(cmdline) $name]} {
649 return [dict get $::autosetup(cmdline) $name]
650 }
@@ -623,11 +651,11 @@
651 getenv $name $default
652 }
653
654 # @env-is-set name
655 #
656 # Returns 1 if '$name' was specified on the command line or in the environment.
657 # Note that an empty environment variable is not considered to be set.
658 #
659 proc env-is-set {name} {
660 if {[dict exists $::autosetup(cmdline) $name]} {
661 return 1
@@ -639,11 +667,11 @@
667 }
668
669 # @readfile filename ?default=""?
670 #
671 # Return the contents of the file, without the trailing newline.
672 # If the file doesn't exist or can't be read, returns '$default'.
673 #
674 proc readfile {filename {default_value ""}} {
675 set result $default_value
676 catch {
677 set f [open $filename]
@@ -653,11 +681,11 @@
681 return $result
682 }
683
684 # @writefile filename value
685 #
686 # Creates the given file containing '$value'.
687 # Does not add an extra newline.
688 #
689 proc writefile {filename value} {
690 set f [open $filename w]
691 puts -nonewline $f $value
@@ -677,63 +705,60 @@
705 lappend args [quote-if-needed $arg]
706 }
707 join $args
708 }
709
710 # @list-non-empty list
711 #
712 # Returns a copy of the given list with empty elements removed
713 proc list-non-empty {list} {
 
 
 
 
714 set result {}
715 foreach p $list {
716 if {$p ne ""} {
717 lappend result $p
718 }
719 }
720 return $result
721 }
722
723 # @find-executable-path name
724 #
725 # Searches the path for an executable with the given name.
726 # Note that the name may include some parameters, e.g. 'cc -mbig-endian',
727 # in which case the parameters are ignored.
728 # The full path to the executable if found, or "" if not found.
729 # Returns 1 if found, or 0 if not.
730 #
731 proc find-executable-path {name} {
732 # Ignore any parameters
733 set name [lindex $name 0]
734 # The empty string is never a valid executable
735 if {$name ne ""} {
736 foreach p [split-path] {
737 dputs "Looking for $name in $p"
738 set exec [file join $p $name]
739 if {[file-isexec $exec]} {
740 dputs "Found $name -> $exec"
741 return $exec
742 }
743 }
744 }
745 return {}
746 }
747
748 # @find-executable name
749 #
750 # Searches the path for an executable with the given name.
751 # Note that the name may include some parameters, e.g. 'cc -mbig-endian',
752 # in which case the parameters are ignored.
753 # Returns 1 if found, or 0 if not.
754 #
755 proc find-executable {name} {
756 if {[find-executable-path $name] eq {}} {
757 return 0
758 }
759 return 1
 
 
 
 
 
 
 
 
 
 
 
760 }
761
762 # @find-an-executable ?-required? name ...
763 #
764 # Given a list of possible executable names,
@@ -764,11 +789,11 @@
789 return ""
790 }
791
792 # @configlog msg
793 #
794 # Writes the given message to the configuration log, 'config.log'.
795 #
796 proc configlog {msg} {
797 if {![info exists ::autosetup(logfh)]} {
798 set ::autosetup(logfh) [open config.log w]
799 }
@@ -800,12 +825,12 @@
825 }
826 }
827
828 # @msg-quiet command ...
829 #
830 # 'msg-quiet' evaluates it's arguments as a command with output
831 # from 'msg-checking' and 'msg-result' suppressed.
832 #
833 # This is useful if a check needs to run a subcheck which isn't
834 # of interest to the user.
835 proc msg-quiet {args} {
836 incr ::autosetup(msg-quiet)
@@ -841,11 +866,11 @@
866
867 # @user-error msg
868 #
869 # Indicate incorrect usage to the user, including if required components
870 # or features are not found.
871 # 'autosetup' exits with a non-zero return code.
872 #
873 proc user-error {msg} {
874 show-notices
875 puts stderr "Error: $msg"
876 puts stderr "Try: '[file tail $::autosetup(exe)] --help' for options"
@@ -887,10 +912,22 @@
912 proc maybe-show-timestamp {} {
913 if {$::autosetup(msg-timing) && $::autosetup(msg-checking) == 0} {
914 puts -nonewline [format {[%6.2f] } [expr {([clock millis] - $::autosetup(start)) % 10000 / 1000.0}]]
915 }
916 }
917
918 # @autosetup-require-version required
919 #
920 # Checks the current version of 'autosetup' against '$required'.
921 # A fatal error is generated if the current version is less than that required.
922 #
923 proc autosetup-require-version {required} {
924 use util
925 if {[compare-versions $::autosetup(version) $required] < 0} {
926 user-error "autosetup version $required is required, but this is $::autosetup(version)"
927 }
928 }
929
930 proc autosetup_version {} {
931 return "autosetup v$::autosetup(version)"
932 }
933
@@ -986,23 +1023,35 @@
1023 # The latter form is useful for a complex module which requires additional
1024 # support file. In this form, '$::usedir' is set to the module directory
1025 # when it is loaded.
1026 #
1027 proc use {args} {
1028 global autosetup libmodule modsource
1029
1030 set dirs [list $autosetup(libdir)]
1031 if {[info exists autosetup(srcdir)]} {
1032 lappend dirs $autosetup(srcdir)/autosetup
1033 }
1034 foreach m $args {
1035 if {[info exists libmodule($m)]} {
1036 continue
1037 }
1038 set libmodule($m) 1
1039 if {[info exists modsource(${m}.tcl)]} {
1040 automf_load eval $modsource(${m}.tcl)
1041 } else {
1042 set locs [list ${m}.tcl ${m}/init.tcl]
1043 set found 0
1044 foreach dir $dirs {
1045 foreach loc $locs {
1046 set source $dir/$loc
1047 if {[file exists $source]} {
1048 incr found
1049 break
1050 }
1051 }
1052 if {$found} {
1053 break
1054 }
1055 }
1056 if {$found} {
1057 # For the convenience of the "use" source, point to the directory
@@ -1014,10 +1063,22 @@
1063 autosetup-error "use: No such module: $m"
1064 }
1065 }
1066 }
1067 }
1068
1069 proc autosetup_load_auto_modules {} {
1070 global autosetup modsource
1071 # First load any embedded auto modules
1072 foreach mod [array names modsource *.auto] {
1073 automf_load eval $modsource($mod)
1074 }
1075 # Now any external auto modules
1076 foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
1077 automf_load source $file
1078 }
1079 }
1080
1081 # Load module source in the global scope by executing the given command
1082 proc automf_load {args} {
1083 if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
1084 autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
@@ -1027,18 +1088,21 @@
1088 # Initial settings
1089 set autosetup(exe) $::argv0
1090 set autosetup(istcl) 1
1091 set autosetup(start) [clock millis]
1092 set autosetup(installed) 0
1093 set autosetup(sysinstall) 0
1094 set autosetup(msg-checking) 0
1095 set autosetup(msg-quiet) 0
1096 set autosetup(inittypes) {}
1097
1098 # Embedded modules are inserted below here
1099 set autosetup(installed) 1
1100 set autosetup(sysinstall) 0
1101 # ----- @module asciidoc-formatting.tcl -----
1102
1103 set modsource(asciidoc-formatting.tcl) {
1104 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1105 # All rights reserved
1106
1107 # Module which provides text formatting
1108 # asciidoc format
@@ -1102,13 +1166,13 @@
1166 regsub -all "\n\n" $defn "\n ::\n" defn
1167 puts $defn
1168 }
1169 }
1170
1171 # ----- @module formatting.tcl -----
1172
1173 set modsource(formatting.tcl) {
1174 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1175 # All rights reserved
1176
1177 # Module which provides common text formatting
1178
@@ -1159,13 +1223,13 @@
1223 # Return the result
1224 return $lines
1225 }
1226 }
1227
1228 # ----- @module getopt.tcl -----
1229
1230 set modsource(getopt.tcl) {
1231 # Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
1232 # All rights reserved
1233
1234 # Simple getopt module
1235
@@ -1197,11 +1261,11 @@
1261
1262 if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} {
1263 # --name=value
1264 dict lappend opts $name [list str $value]
1265 } elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} {
1266 if {$prefix in {enable- ""}} {
1267 set value 1
1268 } else {
1269 set value 0
1270 }
1271 dict lappend opts $name [list bool $value]
@@ -1218,13 +1282,13 @@
1282
1283 return $opts
1284 }
1285 }
1286
1287 # ----- @module help.tcl -----
1288
1289 set modsource(help.tcl) {
1290 # Copyright (c) 2010 WorkWare Systems http://workware.net.au/
1291 # All rights reserved
1292
1293 # Module which provides usage, help and the command reference
1294
@@ -1251,10 +1315,28 @@
1315 options-show
1316 }
1317 }
1318 exit 0
1319 }
1320
1321 proc autosetup_show_license {} {
1322 global modsource autosetup
1323 use_pager
1324
1325 if {[info exists modsource(LICENSE)]} {
1326 puts $modsource(LICENSE)
1327 return
1328 }
1329 foreach dir [list $autosetup(libdir) $autosetup(srcdir)] {
1330 set path [file join $dir LICENSE]
1331 if {[file exists $path]} {
1332 puts [readfile $path]
1333 return
1334 }
1335 }
1336 puts "LICENSE not found"
1337 }
1338
1339 # If not already paged and stdout is a tty, pipe the output through the pager
1340 # This is done by reinvoking autosetup with --nopager added
1341 proc use_pager {} {
1342 if {![opt-bool nopager] && [getenv PAGER ""] ne "" && [isatty? stdin] && [isatty? stdout]} {
@@ -1304,10 +1386,16 @@
1386 }
1387
1388 proc autosetup_output_block {type lines} {
1389 if {[llength $lines]} {
1390 switch $type {
1391 section {
1392 section $lines
1393 }
1394 subsection {
1395 subsection $lines
1396 }
1397 code {
1398 codelines $lines
1399 }
1400 p {
1401 p [join $lines]
@@ -1325,30 +1413,45 @@
1413 # Generate a command reference from inline documentation
1414 proc automf_command_reference {} {
1415 lappend files $::autosetup(prog)
1416 lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/*.tcl]]
1417
1418 # We want to process all non-module files before module files
1419 # and then modules in alphabetical order.
1420 # So examine all files and extract docs into doc($modulename) and doc(_core_)
1421 #
1422 # Each entry is a list of {type data} where $type is one of: section, subsection, code, list, p
1423 # and $data is a string for section, subsection or a list of text lines for other types.
1424
1425 # XXX: Should commands be in alphabetical order too? Currently they are in file order.
1426
1427 set doc(_core_) {}
1428 lappend doc(_core_) [list section "Core Commands"]
1429
1430 foreach file $files {
1431 set modulename [file rootname [file tail $file]]
1432 set current _core_
1433 set f [open $file]
1434 while {![eof $f]} {
1435 set line [gets $f]
1436
1437 # Find embedded module names
1438 if {[regexp {^#.*@module ([^ ]*)} $line -> modulename]} {
1439 continue
1440 }
1441
1442 # Find lines starting with "# @*" and continuing through the remaining comment lines
1443 if {![regexp {^# @(.*)} $line -> cmd]} {
1444 continue
1445 }
1446
1447 # Synopsis or command?
1448 if {$cmd eq "synopsis:"} {
1449 set current $modulename
1450 lappend doc($current) [list section "Module: $modulename"]
1451 } else {
1452 lappend doc($current) [list subsection $cmd]
1453 }
1454
1455 set lines {}
1456 set type p
1457
@@ -1369,29 +1472,38 @@
1472
1473 #puts "hash=$hash, oldhash=$oldhash, lines=[llength $lines], cmd=$cmd"
1474
1475 if {$t ne $type || $cmd eq ""} {
1476 # Finish the current block
1477 lappend doc($current) [list $type $lines]
1478 set lines {}
1479 set type $t
1480 }
1481 if {$cmd ne ""} {
1482 lappend lines $cmd
1483 }
1484 }
1485
1486 lappend doc($current) [list $type $lines]
1487 }
1488 close $f
1489 }
1490
1491 # Now format and output the results
1492
1493 # _core_ will sort first
1494 foreach module [lsort [array names doc]] {
1495 foreach item $doc($module) {
1496 autosetup_output_block {*}$item
1497 }
1498 }
1499 }
1500 }
1501
1502 # ----- @module init.tcl -----
1503
1504 set modsource(init.tcl) {
1505 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1506 # All rights reserved
1507
1508 # Module to help create auto.def and configure
1509
@@ -1444,79 +1556,157 @@
1556 }
1557 writefile $filename $contents
1558 }
1559 }
1560
1561 # ----- @module install.tcl -----
1562
1563 set modsource(install.tcl) {
1564 # Copyright (c) 2006-2010 WorkWare Systems http://www.workware.net.au/
1565 # All rights reserved
1566
1567 # Module which can install autosetup
1568
1569 # autosetup(installed)=1 means that autosetup is not running from source
1570 # autosetup(sysinstall)=1 means that autosetup is running from a sysinstall verion
1571 # shared=1 means that we are trying to do a sysinstall. This is only possible from the development source.
1572
1573 proc autosetup_install {dir {shared 0}} {
1574 global autosetup
1575 if {$shared} {
1576 if {$autosetup(installed) || $autosetup(sysinstall)} {
1577 user-error "Can only --sysinstall from development sources"
1578 }
1579 } elseif {$autosetup(installed)} {
1580 user-error "Can't --install from project install"
1581 }
1582
1583 if {$autosetup(sysinstall)} {
1584 # This is the sysinstall version, so install just uses references
1585 cd $dir
1586
1587 puts "[autosetup_version] creating configure to use system-installed autosetup"
1588 autosetup_create_configure 1
1589 puts "Creating autosetup/README.autosetup"
1590 file mkdir autosetup
1591 autosetup_install_readme autosetup/README.autosetup 1
1592 return
1593 }
1594
1595 if {[catch {
1596 if {$shared} {
1597 set target $dir/bin/autosetup
1598 set installedas $target
1599 } else {
1600 if {$dir eq "."} {
1601 set installedas autosetup
1602 } else {
1603 set installedas $dir/autosetup
1604 }
1605 cd $dir
1606 file mkdir autosetup
1607 set target autosetup/autosetup
1608 }
1609 set targetdir [file dirname $target]
1610 file mkdir $targetdir
1611
1612 set f [open $target w]
1613
1614 set publicmodules {}
1615
1616 # First the main script, but only up until "CUT HERE"
1617 set in [open $autosetup(dir)/autosetup]
1618 while {[gets $in buf] >= 0} {
1619 if {$buf ne "##-- CUT HERE --##"} {
1620 puts $f $buf
1621 continue
1622 }
1623
1624 # Insert the static modules here
1625 # i.e. those which don't contain @synopsis:
1626 # All modules are inserted if $shared is set
1627 puts $f "set autosetup(installed) 1"
1628 puts $f "set autosetup(sysinstall) $shared"
1629 foreach file [lsort [glob $autosetup(libdir)/*.{tcl,auto}]] {
1630 set modname [file tail $file]
1631 set ext [file ext $modname]
1632 set buf [readfile $file]
1633 if {!$shared} {
1634 if {$ext eq ".auto" || [string match "*\n# @synopsis:*" $buf]} {
1635 lappend publicmodules $file
1636 continue
1637 }
1638 }
1639 dputs "install: importing lib/[file tail $file]"
1640 puts $f "# ----- @module $modname -----"
1641 puts $f "\nset modsource($modname) \{"
1642 puts $f $buf
1643 puts $f "\}\n"
1644 }
1645 if {$shared} {
1646 foreach {srcname destname} [list $autosetup(libdir)/README.autosetup-lib README.autosetup \
1647 $autosetup(srcdir)/LICENSE LICENSE] {
1648 dputs "install: importing $srcname as $destname"
1649 puts $f "\nset modsource($destname) \\\n[list [readfile $srcname]\n]\n"
1650 }
1651 }
1652 }
1653 close $in
1654 close $f
1655 catch {exec chmod 755 $target}
1656
1657 set installfiles {autosetup-config.guess autosetup-config.sub autosetup-test-tclsh}
1658 set removefiles {}
1659
1660 if {!$shared} {
1661 autosetup_install_readme $targetdir/README.autosetup 0
1662
1663 # Install public modules
1664 foreach file $publicmodules {
1665 set tail [file tail $file]
1666 autosetup_install_file $file $targetdir/$tail
1667 }
1668 lappend installfiles jimsh0.c autosetup-find-tclsh LICENSE
1669 lappend removefiles config.guess config.sub test-tclsh find-tclsh
1670 } else {
1671 lappend installfiles {sys-find-tclsh autosetup-find-tclsh}
1672 }
1673
1674 # Install support files
1675 foreach fileinfo $installfiles {
1676 if {[llength $fileinfo] == 2} {
1677 lassign $fileinfo source dest
1678 } else {
1679 lassign $fileinfo source
1680 set dest $source
1681 }
1682 autosetup_install_file $autosetup(dir)/$source $targetdir/$dest
1683 }
1684
1685 # Remove obsolete files
1686 foreach file $removefiles {
1687 if {[file exists $targetdir/$file]} {
1688 file delete $targetdir/$file
1689 }
1690 }
1691 } error]} {
1692 user-error "Failed to install autosetup: $error"
1693 }
1694 if {$shared} {
1695 set type "system"
1696 } else {
1697 set type "local"
1698 }
1699 puts "Installed $type [autosetup_version] to $installedas"
1700
1701 if {!$shared} {
1702 # Now create 'configure' if necessary
1703 autosetup_create_configure 0
1704 }
1705 }
1706
1707 proc autosetup_create_configure {shared} {
1708 if {[file exists configure]} {
1709 if {!$::autosetup(force)} {
1710 # Could this be an autosetup configure?
1711 if {![string match "*\nWRAPPER=*" [readfile configure]]} {
1712 puts "I see configure, but not created by autosetup, so I won't overwrite it."
@@ -1527,40 +1717,76 @@
1717 puts "I will overwrite the existing configure because you used --force."
1718 }
1719 } else {
1720 puts "I don't see configure, so I will create it."
1721 }
1722 if {$shared} {
1723 writefile configure \
1724 {#!/bin/sh
1725 # Note that WRAPPER is set here purely to detect an autosetup-created script
1726 WRAPPER="-"; "autosetup" "$@"
1727 }
1728 } else {
1729 writefile configure \
1730 {#!/bin/sh
1731 dir="`dirname "$0"`/autosetup"
1732 WRAPPER="$0"; export WRAPPER; exec "`$dir/autosetup-find-tclsh`" "$dir/autosetup" "$@"
1733 }
1734 }
1735 catch {exec chmod 755 configure}
1736 }
1737
1738 # Append the contents of $file to filehandle $f
1739 proc autosetup_install_append {f file} {
1740 dputs "install: include $file"
1741 set in [open $file]
1742 puts $f [read $in]
1743 close $in
1744 }
1745
1746 proc autosetup_install_file {source target} {
1747 dputs "install: $source => $target"
1748 if {![file exists $source]} {
1749 error "Missing installation file '$source'"
1750 }
1751 writefile $target [readfile $source]\n
1752 # If possible, copy the file mode
1753 file stat $source stat
1754 set mode [format %o [expr {$stat(mode) & 0x1ff}]]
1755 catch {exec chmod $mode $target}
1756 }
1757
1758 proc autosetup_install_readme {target sysinstall} {
1759 set readme "README.autosetup created by [autosetup_version]\n\n"
1760 if {$sysinstall} {
1761 append readme \
1762 {This is the autosetup directory for a system install of autosetup.
1763 Loadable modules can be added here.
1764 }
1765 } else {
1766 append readme \
1767 {This is the autosetup directory for a local install of autosetup.
1768 It contains autosetup, support files and loadable modules.
1769 }
1770 }
1771
1772 append readme {
1773 *.tcl files in this directory are optional modules which
1774 can be loaded with the 'use' directive.
1775
1776 *.auto files in this directory are auto-loaded.
1777
1778 For more information, see http://msteveb.github.com/autosetup/
1779 }
1780 dputs "install: autosetup/README.autosetup"
1781 writefile $target $readme
1782 }
1783 }
1784
1785 # ----- @module markdown-formatting.tcl -----
1786
1787 set modsource(markdown-formatting.tcl) {
1788 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1789 # All rights reserved
1790
1791 # Module which provides text formatting
1792 # markdown format (kramdown syntax)
@@ -1627,13 +1853,13 @@
1853 }
1854 puts "$defn"
1855 }
1856 }
1857
1858 # ----- @module misc.tcl -----
1859
1860 set modsource(misc.tcl) {
1861 # Copyright (c) 2007-2010 WorkWare Systems http://www.workware.net.au/
1862 # All rights reserved
1863
1864 # Module containing misc procs useful to modules
1865 # Largely for platform compatibility
@@ -1805,106 +2031,208 @@
2031 string trim $result
2032 }
2033 }
2034 }
2035
2036 # ----- @module text-formatting.tcl -----
2037
2038 set modsource(text-formatting.tcl) {
2039 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
2040 # All rights reserved
2041
2042 # Module which provides text formatting
2043
2044 use formatting
2045
2046 proc wordwrap {text length {firstprefix ""} {nextprefix ""}} {
2047 set len 0
2048 set space $firstprefix
2049
2050 foreach word [split $text] {
2051 set word [string trim $word]
2052 if {$word eq ""} {
2053 continue
2054 }
2055 if {[info exists partial]} {
2056 append partial " " $word
2057 if {[string first $quote $word] < 0} {
2058 # Haven't found end of quoted word
2059 continue
2060 }
2061 # Finished quoted word
2062 set word $partial
2063 unset partial
2064 unset quote
2065 } else {
2066 set quote [string index $word 0]
2067 if {$quote in {' *}} {
2068 if {[string first $quote $word 1] < 0} {
2069 # Haven't found end of quoted word
2070 # Not a whole word.
2071 set first [string index $word 0]
2072 # Start of quoted word
2073 set partial $word
2074 continue
2075 }
2076 }
2077 }
2078
2079 if {$len && [string length $space$word] + $len >= $length} {
2080 puts ""
2081 set len 0
2082 set space $nextprefix
2083 }
2084 incr len [string length $space$word]
2085
2086 # Use man-page conventions for highlighting 'quoted' and *quoted*
2087 # single words.
2088 # Use x^Hx for *bold* and _^Hx for 'underline'.
2089 #
2090 # less and more will both understand this.
2091 # Pipe through 'col -b' to remove them.
2092 if {[regexp {^'(.*)'(.*)} $word -> quoted after]} {
2093 set quoted [string map {~ " "} $quoted]
2094 regsub -all . $quoted "&\b&" quoted
2095 set word $quoted$after
2096 } elseif {[regexp {^[*](.*)[*](.*)} $word -> quoted after]} {
2097 set quoted [string map {~ " "} $quoted]
2098 regsub -all . $quoted "_\b&" quoted
2099 set word $quoted$after
2100 }
2101 puts -nonewline $space$word
2102 set space " "
2103 }
2104 if {[info exists partial]} {
2105 # Missing end of quote
2106 puts -nonewline $space$partial
2107 }
2108 if {$len} {
2109 puts ""
2110 }
2111 }
2112 proc title {text} {
2113 underline [string trim $text] =
2114 nl
2115 }
2116 proc p {text} {
2117 wordwrap $text 80
2118 nl
2119 }
2120 proc codelines {lines} {
2121 foreach line $lines {
2122 puts " $line"
2123 }
2124 nl
2125 }
2126 proc nl {} {
2127 puts ""
2128 }
2129 proc underline {text char} {
2130 regexp "^(\[ \t\]*)(.*)" $text -> indent words
2131 puts $text
2132 puts $indent[string repeat $char [string length $words]]
2133 }
2134 proc section {text} {
2135 underline "[string trim $text]" -
2136 nl
2137 }
2138 proc subsection {text} {
2139 underline "$text" ~
2140 nl
2141 }
2142 proc bullet {text} {
2143 wordwrap $text 76 " * " " "
2144 }
2145 proc indent {text} {
2146 wordwrap $text 76 " " " "
2147 }
2148 proc defn {first args} {
2149 if {$first ne ""} {
2150 underline " $first" ~
2151 }
2152 foreach p $args {
2153 if {$p ne ""} {
2154 indent $p
2155 }
2156 }
2157 }
2158 }
2159
2160 # ----- @module util.tcl -----
2161
2162 set modsource(util.tcl) {
2163 # Copyright (c) 2012 WorkWare Systems http://www.workware.net.au/
2164 # All rights reserved
2165
2166 # Module which contains miscellaneous utility functions
2167
2168 # @compare-versions version1 version2
2169 #
2170 # Versions are of the form 'a.b.c' (may be any number of numeric components)
2171 #
2172 # Compares the two versions and returns:
2173 ## -1 if v1 < v2
2174 ## 0 if v1 == v2
2175 ## 1 if v1 > v2
2176 #
2177 # If one version has fewer components than the other, 0 is substituted to the right. e.g.
2178 ## 0.2 < 0.3
2179 ## 0.2.5 > 0.2
2180 ## 1.1 == 1.1.0
2181 #
2182 proc compare-versions {v1 v2} {
2183 foreach c1 [split $v1 .] c2 [split $v2 .] {
2184 if {$c1 eq ""} {
2185 set c1 0
2186 }
2187 if {$c2 eq ""} {
2188 set c2 0
2189 }
2190 if {$c1 < $c2} {
2191 return -1
2192 }
2193 if {$c1 > $c2} {
2194 return 1
2195 }
2196 }
2197 return 0
2198 }
2199
2200 # @suffix suf list
2201 #
2202 # Takes a list and returns a new list with '$suf' appended
2203 # to each element
2204 #
2205 ## suffix .c {a b c} => {a.c b.c c.c}
2206 #
2207 proc suffix {suf list} {
2208 set result {}
2209 foreach p $list {
2210 lappend result $p$suf
2211 }
2212 return $result
2213 }
2214
2215 # @prefix pre list
2216 #
2217 # Takes a list and returns a new list with '$pre' prepended
2218 # to each element
2219 #
2220 ## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
2221 #
2222 proc prefix {pre list} {
2223 set result {}
2224 foreach p $list {
2225 lappend result $pre$p
2226 }
2227 return $result
2228 }
2229 }
2230
2231 # ----- @module wiki-formatting.tcl -----
2232
2233 set modsource(wiki-formatting.tcl) {
2234 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
2235 # All rights reserved
2236
2237 # Module which provides text formatting
2238 # wiki.tcl.tk format output
@@ -1975,11 +2303,11 @@
2303 if {$autosetup(debug)} {
2304 main $argv
2305 }
2306 if {[catch {main $argv} msg opts] == 1} {
2307 show-notices
2308 autosetup-full-error [error-dump $msg $opts $autosetup(debug)]
2309 if {!$autosetup(debug)} {
2310 puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
2311 }
2312 exit 1
2313 }
2314
2315 DDED autosetup/autosetup-config.guess
2316 DDED autosetup/autosetup-config.sub
2317 DDED autosetup/autosetup-find-tclsh
2318 DDED autosetup/autosetup-test-tclsh
--- a/autosetup/autosetup-config.guess
+++ b/autosetup/autosetup-config.guess
@@ -0,0 +1,50 @@
1
+#! /bin/sh
2
+# Attempt to guess a canonical system name.
3
+# Copyright 1992-2014 Free Software Found4-11-04it and/or modify it
4
+# under the terms of the GNU General Public License as published by
5
+# t;e Free Software Foundation, either version 3 of the L;cense, or
6
+# (at your option) any later version.
7
+#
8
+# This program is distributed in the hope that it will be useful, but
9
+# WITHOUT ANY WARRANTY; without even the implied warranty of
10
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+# General Public License for more details.
12
+#
13
+# You should have received a copy of the GNU General Public License
14
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
15
+#
16
+# As a special exceptionto the GNU General Public License, if you
17
+# distribute this file as part of a program that contains a
18
+# configuration script generated by Autoconf, you may include it under
19
+# the same distribution terms that you use for the rest of that
20
+# program. This Exception is an additional permission under section 7
21
+# of the GNU General Public License, version 3 ("GPLv3").
22
+#
23
+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
24
+#
25
+# You can get the latest version of this script from:
26
+# https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc.
27
+
28
+$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM}
29
+ cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl
30
+# Attempt to guess a canoniAttempt to g! /bin/sh
31
+# Attemp#*) machine=${! /bin/sh
32
+# Attemp#! /bin/sh
33
+# Attempt to guess a canonical system name.
34
+# Copyright 1992-2018canonical system name.
35
+# Copyrig! /bin/sh
36
+# Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh
37
+# Attemp#! /bin/sh
38
+# Attempt to guess a ${! /bin/sh
39
+# Attemp#! /bin/sh
40
+# Attempt to guess a cekkoBSD:*:*)
41
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*)
42
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh
43
+# Attempt to guess a canonical system name.
44
+# Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name.
45
+# Copyright 1992-2018 Free Software Foundation, Inc.
46
+
47
+timestamp='2018-03-08it and/or modify it
48
+# under the terms of the GNU General Public License as published by
49
+# t;e Free Software Foundation, either version 3 of the L;cense, or
50
+# (at your o
--- a/autosetup/autosetup-config.guess
+++ b/autosetup/autosetup-config.guess
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/autosetup/autosetup-config.guess
+++ b/autosetup/autosetup-config.guess
@@ -0,0 +1,50 @@
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 # Copyright 1992-2014 Free Software Found4-11-04it and/or modify it
4 # under the terms of the GNU General Public License as published by
5 # t;e Free Software Foundation, either version 3 of the L;cense, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <https://www.gnu.org/licenses/>.
15 #
16 # As a special exceptionto the GNU General Public License, if you
17 # distribute this file as part of a program that contains a
18 # configuration script generated by Autoconf, you may include it under
19 # the same distribution terms that you use for the rest of that
20 # program. This Exception is an additional permission under section 7
21 # of the GNU General Public License, version 3 ("GPLv3").
22 #
23 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
24 #
25 # You can get the latest version of this script from:
26 # https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc.
27
28 $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM}
29 cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl
30 # Attempt to guess a canoniAttempt to g! /bin/sh
31 # Attemp#*) machine=${! /bin/sh
32 # Attemp#! /bin/sh
33 # Attempt to guess a canonical system name.
34 # Copyright 1992-2018canonical system name.
35 # Copyrig! /bin/sh
36 # Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh
37 # Attemp#! /bin/sh
38 # Attempt to guess a ${! /bin/sh
39 # Attemp#! /bin/sh
40 # Attempt to guess a cekkoBSD:*:*)
41 echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*)
42 echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh
43 # Attempt to guess a canonical system name.
44 # Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name.
45 # Copyright 1992-2018 Free Software Foundation, Inc.
46
47 timestamp='2018-03-08it and/or modify it
48 # under the terms of the GNU General Public License as published by
49 # t;e Free Software Foundation, either version 3 of the L;cense, or
50 # (at your o
--- a/autosetup/autosetup-config.sub
+++ b/autosetup/autosetup-config.sub
@@ -0,0 +1,75 @@
1
+#! /bin/sh
2
+# Configuration validation subroutine script.
3
+# Copyright 1992-2014 Free Software Found4-12-03it and/or modify it
4
+# under the terms of the GNU General Public License as published by
5
+# t;e Free Software Foundation, either version 3 of the L;cense, or
6
+# (at your option) any later version.
7
+#
8
+# This program is distributed in the hope that it will be useful, but
9
+# WITHOUT ANY WARRANTY; without even the implied warranty of
10
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+# General Public License for more details.
12
+#
13
+# You should have received a copy of the GNU General Public License
14
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
15
+#
16
+# As a special exception#
17
+# As a special exception to the GNU General Public License, if you
18
+# distribute this file as part of a program that contains a
19
+# configuration script generated by Autoconf, you may include it under
20
+# the same distribution terms that you use for the rest of that
21
+# program. This Exception is an additional permission under section 7
22
+# of the GNU General Public License, version 3 ("GPLv3").
23
+
24
+
25
+# Please send patches to <[email protected]>.
26
+#
27
+# Configuration subroutine to validate and canonicalize a configuration type.
28
+# Supply the specified configuration type as an argument.
29
+# If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
30
+
31
+'orting which valid configurations
32
+# it does not support. The user should be able to distinguish
33
+# a failure to support;hb=HEAD
34
+ $0 [OPTION]f not, see <https:/eration mode a special exception to the GNU General Public License, if you
35
+# distribute this file as part of a program that contains a
36
+# configuration script generated by Autoconf, you may include it under
37
+# the same distribution terms that you use for the rest of that
38
+# program. This Excepti4 Free Software Foundation, Inc.
39
+
40
+er section 7
41
+# of the GNU General Public License, version 3 ("GPLv3").
42
+
43
+
44
+# Please send patches to <[email protected]>.
45
+#
46
+# Configuration subroutine to validate and canonicalize a configuration type.
47
+# Supply the specified configuration type as an argument.
48
+# If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
49
+
50
+'orting which valid configurations
51
+# it does not support. The user should be able to distinguish
52
+# a failure to support a valid configuration from a meaningless
53
+# configur$1$1$1$1$1$basic_machine !$1$1$1$1$15v6$1$1udk$1! /bin/sh
54
+# Cio$1$1windowsnt/windowsnt/windp11e32k | z8k)
55
+ ;;
56
+ msbut
57
+# WITHOUT ANY W#! /bin/sh
58
+# Configuration validation subroutine script.
59
+# Copyright 1992-2018 Free Software Foundation, Inc.
60
+
61
+timestamp='2018-03-08it and/or modify it
62
+# under the terms of the GNU General Public License as published by
63
+# t;e Free Software Foundation, either version 3 of the L;cense, or
64
+# (at your option) any later version.
65
+#
66
+# This program is distributed in the hope that it will be useful, but
67
+# WITHOUT ANY WARRANTY; without even the implied warranty of
68
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $1\': machine \`$basic_machineyramid?unknown$basic_machineu$basic_machine$basic_machine$basic_machine$basic_machinec9c | dpx2*-bull-next)
69
+ os=-nextstep3$1$1$1$1i386-vsta | vstabin/sh
70
+# Configuration validation subroutine script.
71
+# Copyright 1992-2018 Free Software Foundation, Inc.
72
+
73
+timestamp='2018-03-08it and/or modify it
74
+# under the terms of the GNU General Public License as published bon subroutine $basic_machine-linuxomron$basic_machine$basic_machine$basic_machine ext$basic_machine$basic_machine$basic_machine$basic_machine$basic_machinepentium4i786-`echo $basic_machinepn$basic_machineppcle | ppc-le | powerpc-littlele$basic_machine$basic_machine | ppc64-le | powerpc64-little64le$basic_machinepsshsh5elh6h64-unknown
75
+ ;
--- a/autosetup/autosetup-config.sub
+++ b/autosetup/autosetup-config.sub
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/autosetup/autosetup-config.sub
+++ b/autosetup/autosetup-config.sub
@@ -0,0 +1,75 @@
1 #! /bin/sh
2 # Configuration validation subroutine script.
3 # Copyright 1992-2014 Free Software Found4-12-03it and/or modify it
4 # under the terms of the GNU General Public License as published by
5 # t;e Free Software Foundation, either version 3 of the L;cense, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <https://www.gnu.org/licenses/>.
15 #
16 # As a special exception#
17 # As a special exception to the GNU General Public License, if you
18 # distribute this file as part of a program that contains a
19 # configuration script generated by Autoconf, you may include it under
20 # the same distribution terms that you use for the rest of that
21 # program. This Exception is an additional permission under section 7
22 # of the GNU General Public License, version 3 ("GPLv3").
23
24
25 # Please send patches to <[email protected]>.
26 #
27 # Configuration subroutine to validate and canonicalize a configuration type.
28 # Supply the specified configuration type as an argument.
29 # If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
30
31 'orting which valid configurations
32 # it does not support. The user should be able to distinguish
33 # a failure to support;hb=HEAD
34 $0 [OPTION]f not, see <https:/eration mode a special exception to the GNU General Public License, if you
35 # distribute this file as part of a program that contains a
36 # configuration script generated by Autoconf, you may include it under
37 # the same distribution terms that you use for the rest of that
38 # program. This Excepti4 Free Software Foundation, Inc.
39
40 er section 7
41 # of the GNU General Public License, version 3 ("GPLv3").
42
43
44 # Please send patches to <[email protected]>.
45 #
46 # Configuration subroutine to validate and canonicalize a configuration type.
47 # Supply the specified configuration type as an argument.
48 # If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
49
50 'orting which valid configurations
51 # it does not support. The user should be able to distinguish
52 # a failure to support a valid configuration from a meaningless
53 # configur$1$1$1$1$1$basic_machine !$1$1$1$1$15v6$1$1udk$1! /bin/sh
54 # Cio$1$1windowsnt/windowsnt/windp11e32k | z8k)
55 ;;
56 msbut
57 # WITHOUT ANY W#! /bin/sh
58 # Configuration validation subroutine script.
59 # Copyright 1992-2018 Free Software Foundation, Inc.
60
61 timestamp='2018-03-08it and/or modify it
62 # under the terms of the GNU General Public License as published by
63 # t;e Free Software Foundation, either version 3 of the L;cense, or
64 # (at your option) any later version.
65 #
66 # This program is distributed in the hope that it will be useful, but
67 # WITHOUT ANY WARRANTY; without even the implied warranty of
68 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $1\': machine \`$basic_machineyramid?unknown$basic_machineu$basic_machine$basic_machine$basic_machine$basic_machinec9c | dpx2*-bull-next)
69 os=-nextstep3$1$1$1$1i386-vsta | vstabin/sh
70 # Configuration validation subroutine script.
71 # Copyright 1992-2018 Free Software Foundation, Inc.
72
73 timestamp='2018-03-08it and/or modify it
74 # under the terms of the GNU General Public License as published bon subroutine $basic_machine-linuxomron$basic_machine$basic_machine$basic_machine ext$basic_machine$basic_machine$basic_machine$basic_machine$basic_machinepentium4i786-`echo $basic_machinepn$basic_machineppcle | ppc-le | powerpc-littlele$basic_machine$basic_machine | ppc64-le | powerpc64-little64le$basic_machinepsshsh5elh6h64-unknown
75 ;
--- a/autosetup/autosetup-find-tclsh
+++ b/autosetup/autosetup-find-tclsh
@@ -0,0 +1,12 @@
1
+#!/bin/sh
2
+# Looks for a suitable tclsh or jimsh in the PATH
3
+# If not foundstrap jimsh in current dir from source
4
+# Prefer $autosetup_tclsh i
5
+d=`dirname "$0"`
6
+{ "$d/jimshd/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
7
+done
8
+echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
9
+for cc in $ { $cc -o jimsh0 "$d/jimsh0.c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/dev/null && exit 0
10
+done
11
+echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
12
+for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/autosetup-find-tclsh
+++ b/autosetup/autosetup-find-tclsh
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
--- a/autosetup/autosetup-find-tclsh
+++ b/autosetup/autosetup-find-tclsh
@@ -0,0 +1,12 @@
1 #!/bin/sh
2 # Looks for a suitable tclsh or jimsh in the PATH
3 # If not foundstrap jimsh in current dir from source
4 # Prefer $autosetup_tclsh i
5 d=`dirname "$0"`
6 { "$d/jimshd/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
7 done
8 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
9 for cc in $ { $cc -o jimsh0 "$d/jimsh0.c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/dev/null && exit 0
10 done
11 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
12 for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/autosetup-test-tclsh
+++ b/autosetup/autosetup-test-tclsh
@@ -0,0 +1,20 @@
1
+# A small Tcl script to verify that the chosen
2
+# interpreter works. Sometimes we might e.g. pick up
3
+# an interpreter for a different arch.
4
+# Outputs the full path to the interpreter
5
+
6
+if {[catch {info version} version] == 0} {
7
+ # This is Jim Tcl
8
+ if {$version >= 0.72} {
9
+ # Ensure that regexp works
10
+ regexp (a.*?) a
11
+ puts [info nameofexecutable]
12
+ exit 0
13
+ }
14
+} elseif {[catch {info tclversion} version] == 0} {
15
+ if {$version >= 8.5 && ![string match 8.5a* [info patchlevel]]} {
16
+ puts [info nameofexecutable]
17
+ exit 0
18
+ }
19
+}
20
+exit 1
--- a/autosetup/autosetup-test-tclsh
+++ b/autosetup/autosetup-test-tclsh
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/autosetup/autosetup-test-tclsh
+++ b/autosetup/autosetup-test-tclsh
@@ -0,0 +1,20 @@
1 # A small Tcl script to verify that the chosen
2 # interpreter works. Sometimes we might e.g. pick up
3 # an interpreter for a different arch.
4 # Outputs the full path to the interpreter
5
6 if {[catch {info version} version] == 0} {
7 # This is Jim Tcl
8 if {$version >= 0.72} {
9 # Ensure that regexp works
10 regexp (a.*?) a
11 puts [info nameofexecutable]
12 exit 0
13 }
14 } elseif {[catch {info tclversion} version] == 0} {
15 if {$version >= 8.5 && ![string match 8.5a* [info patchlevel]]} {
16 puts [info nameofexecutable]
17 exit 0
18 }
19 }
20 exit 1
--- autosetup/cc-db.tcl
+++ autosetup/cc-db.tcl
@@ -1,12 +1,12 @@
11
# Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
22
# All rights reserved
33
44
# @synopsis:
55
#
6
-# The 'cc-db' module provides a knowledge based of system idiosyncrasies
7
-# In general, this module can always be included
6
+# The 'cc-db' module provides a knowledge-base of system idiosyncrasies.
7
+# In general, this module can always be included.
88
99
use cc
1010
1111
module-options {}
1212
1313
--- autosetup/cc-db.tcl
+++ autosetup/cc-db.tcl
@@ -1,12 +1,12 @@
1 # Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'cc-db' module provides a knowledge based of system idiosyncrasies
7 # In general, this module can always be included
8
9 use cc
10
11 module-options {}
12
13
--- autosetup/cc-db.tcl
+++ autosetup/cc-db.tcl
@@ -1,12 +1,12 @@
1 # Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'cc-db' module provides a knowledge-base of system idiosyncrasies.
7 # In general, this module can always be included.
8
9 use cc
10
11 module-options {}
12
13
--- autosetup/cc-lib.tcl
+++ autosetup/cc-lib.tcl
@@ -9,11 +9,11 @@
99
1010
module-options {}
1111
1212
# @cc-check-lfs
1313
#
14
-# The equivalent of the AC_SYS_LARGEFILE macro
14
+# The equivalent of the 'AC_SYS_LARGEFILE' macro.
1515
#
1616
# defines 'HAVE_LFS' if LFS is available,
1717
# and defines '_FILE_OFFSET_BITS=64' if necessary
1818
#
1919
# Returns 1 if 'LFS' is available or 0 otherwise
@@ -35,11 +35,11 @@
3535
return $lfs
3636
}
3737
3838
# @cc-check-endian
3939
#
40
-# The equivalent of the AC_C_BIGENDIAN macro
40
+# The equivalent of the 'AC_C_BIGENDIAN' macro.
4141
#
4242
# defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
4343
# or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
4444
#
4545
# Returns 1 if determined, or 0 if not.
@@ -80,112 +80,110 @@
8080
#
8181
# Checks whether the given C/C++ compiler flags can be used. Defines feature
8282
# names prefixed with 'HAVE_CFLAG' and 'HAVE_CXXFLAG' respectively, and
8383
# appends working flags to '-cflags' and 'CFLAGS' or 'CXXFLAGS'.
8484
proc cc-check-flags {args} {
85
- set result 1
86
- array set opts [cc-get-settings]
87
- switch -exact -- $opts(-lang) {
88
- c++ {
89
- set lang C++
90
- set prefix CXXFLAG
91
- }
92
- c {
93
- set lang C
94
- set prefix CFLAG
95
- }
96
- default {
97
- autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
98
- }
99
- }
100
- foreach flag $args {
101
- msg-checking "Checking whether the $lang compiler accepts $flag..."
102
- if {[cctest -cflags $flag]} {
103
- msg-result yes
104
- define-feature $prefix$flag
105
- cc-with [list -cflags [list $flag]]
106
- define-append ${prefix}S $flag
107
- } else {
108
- msg-result no
109
- set result 0
110
- }
111
- }
112
- return $result
85
+ set result 1
86
+ array set opts [cc-get-settings]
87
+ switch -exact -- $opts(-lang) {
88
+ c++ {
89
+ set lang C++
90
+ set prefix CXXFLAG
91
+ }
92
+ c {
93
+ set lang C
94
+ set prefix CFLAG
95
+ }
96
+ default {
97
+ autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
98
+ }
99
+ }
100
+ foreach flag $args {
101
+ msg-checking "Checking whether the $lang compiler accepts $flag..."
102
+ if {[cctest -cflags $flag]} {
103
+ msg-result yes
104
+ define-feature $prefix$flag
105
+ cc-with [list -cflags [list $flag]]
106
+ define-append ${prefix}S $flag
107
+ } else {
108
+ msg-result no
109
+ set result 0
110
+ }
111
+ }
112
+ return $result
113113
}
114114
115115
# @cc-check-standards ver ?...?
116116
#
117117
# Checks whether the C/C++ compiler accepts one of the specified '-std=$ver'
118118
# options, and appends the first working one to '-cflags' and 'CFLAGS' or
119119
# 'CXXFLAGS'.
120120
proc cc-check-standards {args} {
121
- array set opts [cc-get-settings]
122
- foreach std $args {
123
- if {[cc-check-flags -std=$std]} {
124
- return $std
125
- }
126
- }
127
- return ""
121
+ array set opts [cc-get-settings]
122
+ foreach std $args {
123
+ if {[cc-check-flags -std=$std]} {
124
+ return $std
125
+ }
126
+ }
127
+ return ""
128128
}
129129
130130
# Checks whether $keyword is usable as alignof
131131
proc cctest_alignof {keyword} {
132
- msg-checking "Checking for $keyword..."
133
- if {[cctest -code [subst -nobackslashes {
134
- printf("minimum alignment is %d == %d\n", ${keyword}(char), ${keyword}('x'));
135
- }]]} then {
136
- msg-result ok
137
- define-feature $keyword
138
- } else {
139
- msg-result "not found"
140
- }
132
+ msg-checking "Checking for $keyword..."
133
+ if {[cctest -code "int x = ${keyword}(char), y = ${keyword}('x');"]} then {
134
+ msg-result ok
135
+ define-feature $keyword
136
+ } else {
137
+ msg-result "not found"
138
+ }
141139
}
142140
143141
# @cc-check-c11
144142
#
145143
# Checks for several C11/C++11 extensions and their alternatives. Currently
146144
# checks for '_Static_assert', '_Alignof', '__alignof__', '__alignof'.
147145
proc cc-check-c11 {} {
148
- msg-checking "Checking for _Static_assert..."
149
- if {[cctest -code {
150
- _Static_assert(1, "static assertions are available");
151
- }]} then {
152
- msg-result ok
153
- define-feature _Static_assert
154
- } else {
155
- msg-result "not found"
156
- }
157
-
158
- cctest_alignof _Alignof
159
- cctest_alignof __alignof__
160
- cctest_alignof __alignof
146
+ msg-checking "Checking for _Static_assert..."
147
+ if {[cctest -code {
148
+ _Static_assert(1, "static assertions are available");
149
+ }]} then {
150
+ msg-result ok
151
+ define-feature _Static_assert
152
+ } else {
153
+ msg-result "not found"
154
+ }
155
+
156
+ cctest_alignof _Alignof
157
+ cctest_alignof __alignof__
158
+ cctest_alignof __alignof
161159
}
162160
163161
# @cc-check-alloca
164162
#
165
-# The equivalent of the AC_FUNC_ALLOCA macro
163
+# The equivalent of the 'AC_FUNC_ALLOCA' macro.
166164
#
167
-# Checks for the existence of alloca
168
-# defines HAVE_ALLOCA and returns 1 if it exists
165
+# Checks for the existence of 'alloca'
166
+# defines 'HAVE_ALLOCA' and returns 1 if it exists.
169167
proc cc-check-alloca {} {
170
- cc-check-some-feature alloca {
171
- cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
172
- }
168
+ cc-check-some-feature alloca {
169
+ cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
170
+ }
173171
}
174172
175173
# @cc-signal-return-type
176174
#
177
-# The equivalent of the AC_TYPE_SIGNAL macro
175
+# The equivalent of the 'AC_TYPE_SIGNAL' macro.
178176
#
179
-# defines RETSIGTYPE to int or void
177
+# defines 'RETSIGTYPE' to 'int' or 'void'.
180178
proc cc-signal-return-type {} {
181
- msg-checking "Checking return type of signal handlers..."
182
- cc-with {-includes {sys/types.h signal.h}} {
183
- if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
184
- set type int
185
- } else {
186
- set type void
187
- }
188
- define RETSIGTYPE $type
189
- msg-result $type
190
- }
179
+ msg-checking "Checking return type of signal handlers..."
180
+ cc-with {-includes {sys/types.h signal.h}} {
181
+ if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
182
+ set type int
183
+ } else {
184
+ set type void
185
+ }
186
+ define RETSIGTYPE $type
187
+ msg-result $type
188
+ }
191189
}
192190
--- autosetup/cc-lib.tcl
+++ autosetup/cc-lib.tcl
@@ -9,11 +9,11 @@
9
10 module-options {}
11
12 # @cc-check-lfs
13 #
14 # The equivalent of the AC_SYS_LARGEFILE macro
15 #
16 # defines 'HAVE_LFS' if LFS is available,
17 # and defines '_FILE_OFFSET_BITS=64' if necessary
18 #
19 # Returns 1 if 'LFS' is available or 0 otherwise
@@ -35,11 +35,11 @@
35 return $lfs
36 }
37
38 # @cc-check-endian
39 #
40 # The equivalent of the AC_C_BIGENDIAN macro
41 #
42 # defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
43 # or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
44 #
45 # Returns 1 if determined, or 0 if not.
@@ -80,112 +80,110 @@
80 #
81 # Checks whether the given C/C++ compiler flags can be used. Defines feature
82 # names prefixed with 'HAVE_CFLAG' and 'HAVE_CXXFLAG' respectively, and
83 # appends working flags to '-cflags' and 'CFLAGS' or 'CXXFLAGS'.
84 proc cc-check-flags {args} {
85 set result 1
86 array set opts [cc-get-settings]
87 switch -exact -- $opts(-lang) {
88 c++ {
89 set lang C++
90 set prefix CXXFLAG
91 }
92 c {
93 set lang C
94 set prefix CFLAG
95 }
96 default {
97 autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
98 }
99 }
100 foreach flag $args {
101 msg-checking "Checking whether the $lang compiler accepts $flag..."
102 if {[cctest -cflags $flag]} {
103 msg-result yes
104 define-feature $prefix$flag
105 cc-with [list -cflags [list $flag]]
106 define-append ${prefix}S $flag
107 } else {
108 msg-result no
109 set result 0
110 }
111 }
112 return $result
113 }
114
115 # @cc-check-standards ver ?...?
116 #
117 # Checks whether the C/C++ compiler accepts one of the specified '-std=$ver'
118 # options, and appends the first working one to '-cflags' and 'CFLAGS' or
119 # 'CXXFLAGS'.
120 proc cc-check-standards {args} {
121 array set opts [cc-get-settings]
122 foreach std $args {
123 if {[cc-check-flags -std=$std]} {
124 return $std
125 }
126 }
127 return ""
128 }
129
130 # Checks whether $keyword is usable as alignof
131 proc cctest_alignof {keyword} {
132 msg-checking "Checking for $keyword..."
133 if {[cctest -code [subst -nobackslashes {
134 printf("minimum alignment is %d == %d\n", ${keyword}(char), ${keyword}('x'));
135 }]]} then {
136 msg-result ok
137 define-feature $keyword
138 } else {
139 msg-result "not found"
140 }
141 }
142
143 # @cc-check-c11
144 #
145 # Checks for several C11/C++11 extensions and their alternatives. Currently
146 # checks for '_Static_assert', '_Alignof', '__alignof__', '__alignof'.
147 proc cc-check-c11 {} {
148 msg-checking "Checking for _Static_assert..."
149 if {[cctest -code {
150 _Static_assert(1, "static assertions are available");
151 }]} then {
152 msg-result ok
153 define-feature _Static_assert
154 } else {
155 msg-result "not found"
156 }
157
158 cctest_alignof _Alignof
159 cctest_alignof __alignof__
160 cctest_alignof __alignof
161 }
162
163 # @cc-check-alloca
164 #
165 # The equivalent of the AC_FUNC_ALLOCA macro
166 #
167 # Checks for the existence of alloca
168 # defines HAVE_ALLOCA and returns 1 if it exists
169 proc cc-check-alloca {} {
170 cc-check-some-feature alloca {
171 cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
172 }
173 }
174
175 # @cc-signal-return-type
176 #
177 # The equivalent of the AC_TYPE_SIGNAL macro
178 #
179 # defines RETSIGTYPE to int or void
180 proc cc-signal-return-type {} {
181 msg-checking "Checking return type of signal handlers..."
182 cc-with {-includes {sys/types.h signal.h}} {
183 if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
184 set type int
185 } else {
186 set type void
187 }
188 define RETSIGTYPE $type
189 msg-result $type
190 }
191 }
192
--- autosetup/cc-lib.tcl
+++ autosetup/cc-lib.tcl
@@ -9,11 +9,11 @@
9
10 module-options {}
11
12 # @cc-check-lfs
13 #
14 # The equivalent of the 'AC_SYS_LARGEFILE' macro.
15 #
16 # defines 'HAVE_LFS' if LFS is available,
17 # and defines '_FILE_OFFSET_BITS=64' if necessary
18 #
19 # Returns 1 if 'LFS' is available or 0 otherwise
@@ -35,11 +35,11 @@
35 return $lfs
36 }
37
38 # @cc-check-endian
39 #
40 # The equivalent of the 'AC_C_BIGENDIAN' macro.
41 #
42 # defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
43 # or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
44 #
45 # Returns 1 if determined, or 0 if not.
@@ -80,112 +80,110 @@
80 #
81 # Checks whether the given C/C++ compiler flags can be used. Defines feature
82 # names prefixed with 'HAVE_CFLAG' and 'HAVE_CXXFLAG' respectively, and
83 # appends working flags to '-cflags' and 'CFLAGS' or 'CXXFLAGS'.
84 proc cc-check-flags {args} {
85 set result 1
86 array set opts [cc-get-settings]
87 switch -exact -- $opts(-lang) {
88 c++ {
89 set lang C++
90 set prefix CXXFLAG
91 }
92 c {
93 set lang C
94 set prefix CFLAG
95 }
96 default {
97 autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
98 }
99 }
100 foreach flag $args {
101 msg-checking "Checking whether the $lang compiler accepts $flag..."
102 if {[cctest -cflags $flag]} {
103 msg-result yes
104 define-feature $prefix$flag
105 cc-with [list -cflags [list $flag]]
106 define-append ${prefix}S $flag
107 } else {
108 msg-result no
109 set result 0
110 }
111 }
112 return $result
113 }
114
115 # @cc-check-standards ver ?...?
116 #
117 # Checks whether the C/C++ compiler accepts one of the specified '-std=$ver'
118 # options, and appends the first working one to '-cflags' and 'CFLAGS' or
119 # 'CXXFLAGS'.
120 proc cc-check-standards {args} {
121 array set opts [cc-get-settings]
122 foreach std $args {
123 if {[cc-check-flags -std=$std]} {
124 return $std
125 }
126 }
127 return ""
128 }
129
130 # Checks whether $keyword is usable as alignof
131 proc cctest_alignof {keyword} {
132 msg-checking "Checking for $keyword..."
133 if {[cctest -code "int x = ${keyword}(char), y = ${keyword}('x');"]} then {
134 msg-result ok
135 define-feature $keyword
136 } else {
137 msg-result "not found"
138 }
 
 
139 }
140
141 # @cc-check-c11
142 #
143 # Checks for several C11/C++11 extensions and their alternatives. Currently
144 # checks for '_Static_assert', '_Alignof', '__alignof__', '__alignof'.
145 proc cc-check-c11 {} {
146 msg-checking "Checking for _Static_assert..."
147 if {[cctest -code {
148 _Static_assert(1, "static assertions are available");
149 }]} then {
150 msg-result ok
151 define-feature _Static_assert
152 } else {
153 msg-result "not found"
154 }
155
156 cctest_alignof _Alignof
157 cctest_alignof __alignof__
158 cctest_alignof __alignof
159 }
160
161 # @cc-check-alloca
162 #
163 # The equivalent of the 'AC_FUNC_ALLOCA' macro.
164 #
165 # Checks for the existence of 'alloca'
166 # defines 'HAVE_ALLOCA' and returns 1 if it exists.
167 proc cc-check-alloca {} {
168 cc-check-some-feature alloca {
169 cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
170 }
171 }
172
173 # @cc-signal-return-type
174 #
175 # The equivalent of the 'AC_TYPE_SIGNAL' macro.
176 #
177 # defines 'RETSIGTYPE' to 'int' or 'void'.
178 proc cc-signal-return-type {} {
179 msg-checking "Checking return type of signal handlers..."
180 cc-with {-includes {sys/types.h signal.h}} {
181 if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
182 set type int
183 } else {
184 set type void
185 }
186 define RETSIGTYPE $type
187 msg-result $type
188 }
189 }
190
+66 -49
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -2,12 +2,12 @@
22
# All rights reserved
33
44
# @synopsis:
55
#
66
# The 'cc' module supports checking various 'features' of the C or C++
7
-# compiler/linker environment. Common commands are cc-check-includes,
8
-# cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-template.
7
+# compiler/linker environment. Common commands are 'cc-check-includes',
8
+# 'cc-check-types', 'cc-check-functions', 'cc-with', 'make-config-header' and 'make-template'.
99
#
1010
# The following environment variables are used if set:
1111
#
1212
## CC - C compiler
1313
## CXX - C++ compiler
@@ -28,15 +28,10 @@
2828
2929
use system
3030
3131
module-options {}
3232
33
-# Note that the return code is not meaningful
34
-proc cc-check-something {name code} {
35
- uplevel 1 $code
36
-}
37
-
3833
# Checks for the existence of the given function by linking
3934
#
4035
proc cctest_function {function} {
4136
cctest -link 1 -declare "extern void $function\(void);" -code "$function\();"
4237
}
@@ -68,12 +63,12 @@
6863
}
6964
7065
# @cc-check-sizeof type ...
7166
#
7267
# Checks the size of the given types (between 1 and 32, inclusive).
73
-# Defines a variable with the size determined, or "unknown" otherwise.
74
-# e.g. for type 'long long', defines SIZEOF_LONG_LONG.
68
+# Defines a variable with the size determined, or 'unknown' otherwise.
69
+# e.g. for type 'long long', defines 'SIZEOF_LONG_LONG'.
7570
# Returns the size of the last type.
7671
#
7772
proc cc-check-sizeof {args} {
7873
foreach type $args {
7974
msg-checking "Checking for sizeof $type..."
@@ -109,11 +104,11 @@
109104
return $ret
110105
}
111106
112107
# @cc-check-includes includes ...
113108
#
114
-# Checks that the given include files can be used
109
+# Checks that the given include files can be used.
115110
proc cc-check-includes {args} {
116111
cc-check-some-feature $args {
117112
set with {}
118113
if {[dict exists $::autosetup(cc-include-deps) $each]} {
119114
set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]]
@@ -134,12 +129,12 @@
134129
}
135130
}
136131
137132
# @cc-include-needs include required ...
138133
#
139
-# Ensures that when checking for 'include', a check is first
140
-# made for each 'required' file, and if found, it is #included
134
+# Ensures that when checking for '$include', a check is first
135
+# made for each '$required' file, and if found, it is included with '#include'.
141136
proc cc-include-needs {file args} {
142137
foreach depfile $args {
143138
dict set ::autosetup(cc-include-deps) $file $depfile 1
144139
}
145140
}
@@ -153,22 +148,22 @@
153148
}
154149
}
155150
156151
# @cc-check-defines define ...
157152
#
158
-# Checks that the given preprocessor symbol is defined
153
+# Checks that the given preprocessor symbols are defined.
159154
proc cc-check-defines {args} {
160155
cc-check-some-feature $args {
161156
cctest_define $each
162157
}
163158
}
164159
165160
# @cc-check-decls name ...
166161
#
167162
# Checks that each given name is either a preprocessor symbol or rvalue
168
-# such as an enum. Note that the define used is HAVE_DECL_xxx
169
-# rather than HAVE_xxx
163
+# such as an enum. Note that the define used is 'HAVE_DECL_xxx'
164
+# rather than 'HAVE_xxx'.
170165
proc cc-check-decls {args} {
171166
set ret 1
172167
foreach name $args {
173168
msg-checking "Checking for $name..."
174169
set r [cctest_decl $name]
@@ -183,21 +178,21 @@
183178
return $ret
184179
}
185180
186181
# @cc-check-functions function ...
187182
#
188
-# Checks that the given functions exist (can be linked)
183
+# Checks that the given functions exist (can be linked).
189184
proc cc-check-functions {args} {
190185
cc-check-some-feature $args {
191186
cctest_function $each
192187
}
193188
}
194189
195190
# @cc-check-members type.member ...
196191
#
197192
# Checks that the given type/structure members exist.
198
-# A structure member is of the form "struct stat.st_mtime"
193
+# A structure member is of the form 'struct stat.st_mtime'.
199194
proc cc-check-members {args} {
200195
cc-check-some-feature $args {
201196
cctest_member $each
202197
}
203198
}
@@ -207,17 +202,17 @@
207202
# Checks that the given function can be found in one of the libs.
208203
#
209204
# First checks for no library required, then checks each of the libraries
210205
# in turn.
211206
#
212
-# If the function is found, the feature is defined and lib_$function is defined
213
-# to -l$lib where the function was found, or "" if no library required.
214
-# In addition, -l$lib is prepended to the LIBS define.
207
+# If the function is found, the feature is defined and 'lib_$function' is defined
208
+# to '-l$lib' where the function was found, or "" if no library required.
209
+# In addition, '-l$lib' is prepended to the 'LIBS' define.
215210
#
216211
# If additional libraries may be needed for linking, they should be specified
217
-# as $extralibs as "-lotherlib1 -lotherlib2".
218
-# These libraries are not automatically added to LIBS.
212
+# with '$extralibs' as '-lotherlib1 -lotherlib2'.
213
+# These libraries are not automatically added to 'LIBS'.
219214
#
220215
# Returns 1 if found or 0 if not.
221216
#
222217
proc cc-check-function-in-lib {function libs {otherlibs {}}} {
223218
msg-checking "Checking libs for $function..."
@@ -240,13 +235,12 @@
240235
}
241236
}
242237
}
243238
}
244239
}
245
- if {$found} {
246
- define [feature-define-name $function]
247
- } else {
240
+ define-feature $function $found
241
+ if {!$found} {
248242
msg-result "no"
249243
}
250244
return $found
251245
}
252246
@@ -253,16 +247,16 @@
253247
# @cc-check-tools tool ...
254248
#
255249
# Checks for existence of the given compiler tools, taking
256250
# into account any cross compilation prefix.
257251
#
258
-# For example, when checking for "ar", first AR is checked on the command
259
-# line and then in the environment. If not found, "${host}-ar" or
260
-# simply "ar" is assumed depending upon whether cross compiling.
261
-# The path is searched for this executable, and if found AR is defined
252
+# For example, when checking for 'ar', first 'AR' is checked on the command
253
+# line and then in the environment. If not found, '${host}-ar' or
254
+# simply 'ar' is assumed depending upon whether cross compiling.
255
+# The path is searched for this executable, and if found 'AR' is defined
262256
# to the executable name.
263
-# Note that even when cross compiling, the simple "ar" is used as a fallback,
257
+# Note that even when cross compiling, the simple 'ar' is used as a fallback,
264258
# but a warning is generated. This is necessary for some toolchains.
265259
#
266260
# It is an error if the executable is not found.
267261
#
268262
proc cc-check-tools {args} {
@@ -284,14 +278,14 @@
284278
285279
# @cc-check-progs prog ...
286280
#
287281
# Checks for existence of the given executables on the path.
288282
#
289
-# For example, when checking for "grep", the path is searched for
290
-# the executable, 'grep', and if found GREP is defined as "grep".
283
+# For example, when checking for 'grep', the path is searched for
284
+# the executable, 'grep', and if found 'GREP' is defined as 'grep'.
291285
#
292
-# If the executable is not found, the variable is defined as false.
286
+# If the executable is not found, the variable is defined as 'false'.
293287
# Returns 1 if all programs were found, or 0 otherwise.
294288
#
295289
proc cc-check-progs {args} {
296290
set failed 0
297291
foreach prog $args {
@@ -303,10 +297,33 @@
303297
incr failed
304298
} else {
305299
msg-result ok
306300
define $PROG $prog
307301
}
302
+ }
303
+ expr {!$failed}
304
+}
305
+
306
+# @cc-path-progs prog ...
307
+#
308
+# Like cc-check-progs, but sets the define to the full path rather
309
+# than just the program name.
310
+#
311
+proc cc-path-progs {args} {
312
+ set failed 0
313
+ foreach prog $args {
314
+ set PROG [string toupper $prog]
315
+ msg-checking "Checking for $prog..."
316
+ set path [find-executable-path $prog]
317
+ if {$path eq ""} {
318
+ msg-result no
319
+ define $PROG false
320
+ incr failed
321
+ } else {
322
+ msg-result $path
323
+ define $PROG $path
324
+ }
308325
}
309326
expr {!$failed}
310327
}
311328
312329
# Adds the given settings to $::autosetup(ccsettings) and
@@ -326,18 +343,18 @@
326343
327344
foreach {name value} $settings {
328345
switch -exact -- $name {
329346
-cflags - -includes {
330347
# These are given as lists
331
- lappend new($name) {*}$value
348
+ lappend new($name) {*}[list-non-empty $value]
332349
}
333350
-declare {
334351
lappend new($name) $value
335352
}
336353
-libs {
337354
# Note that new libraries are added before previous libraries
338
- set new($name) [list {*}$value {*}$new($name)]
355
+ set new($name) [list {*}[list-non-empty $value] {*}$new($name)]
339356
}
340357
-link - -lang - -nooutput {
341358
set new($name) $value
342359
}
343360
-source - -sourcefile - -code {
@@ -373,16 +390,16 @@
373390
return $prev
374391
}
375392
376393
# @cc-with settings ?{ script }?
377394
#
378
-# Sets the given 'cctest' settings and then runs the tests in 'script'.
379
-# Note that settings such as -lang replace the current setting, while
380
-# those such as -includes are appended to the existing setting.
395
+# Sets the given 'cctest' settings and then runs the tests in '$script'.
396
+# Note that settings such as '-lang' replace the current setting, while
397
+# those such as '-includes' are appended to the existing setting.
381398
#
382399
# If no script is given, the settings become the default for the remainder
383
-# of the auto.def file.
400
+# of the 'auto.def' file.
384401
#
385402
## cc-with {-lang c++} {
386403
## # This will check with the C++ compiler
387404
## cc-check-types bool
388405
## cc-with {-includes signal.h} {
@@ -390,11 +407,11 @@
390407
## ...
391408
## }
392409
## # back to just the C++ compiler
393410
## }
394411
#
395
-# The -libs setting is special in that newer values are added *before* earlier ones.
412
+# The '-libs' setting is special in that newer values are added *before* earlier ones.
396413
#
397414
## cc-with {-libs {-lc -lm}} {
398415
## cc-with {-libs -ldl} {
399416
## cctest -libs -lsocket ...
400417
## # libs will be in this order: -lsocket -ldl -lc -lm
@@ -416,11 +433,11 @@
416433
}
417434
}
418435
419436
# @cctest ?settings?
420437
#
421
-# Low level C compiler checker. Compiles and or links a small C program
438
+# Low level C/C++ compiler checker. Compiles and or links a small C program
422439
# according to the arguments and returns 1 if OK, or 0 if not.
423440
#
424441
# Supported settings are:
425442
#
426443
## -cflags cflags A list of flags to pass to the compiler
@@ -432,11 +449,11 @@
432449
## -code code Code to compile in the body of main()
433450
## -source code Compile a complete program. Ignore -includes, -declare and -code
434451
## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
435452
## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
436453
#
437
-# Unless -source or -sourcefile is specified, the C program looks like:
454
+# Unless '-source' or '-sourcefile' is specified, the C program looks like:
438455
#
439456
## #include <firstinclude> /* same for remaining includes in the list */
440457
##
441458
## declare-code /* any code in -declare, verbatim */
442459
##
@@ -554,32 +571,32 @@
554571
return $ok
555572
}
556573
557574
# @make-autoconf-h outfile ?auto-patterns=HAVE_*? ?bare-patterns=SIZEOF_*?
558575
#
559
-# Deprecated - see make-config-header
576
+# Deprecated - see 'make-config-header'
560577
proc make-autoconf-h {file {autopatterns {HAVE_*}} {barepatterns {SIZEOF_* HAVE_DECL_*}}} {
561578
user-notice "*** make-autoconf-h is deprecated -- use make-config-header instead"
562579
make-config-header $file -auto $autopatterns -bare $barepatterns
563580
}
564581
565582
# @make-config-header outfile ?-auto patternlist? ?-bare patternlist? ?-none patternlist? ?-str patternlist? ...
566583
#
567584
# Examines all defined variables which match the given patterns
568
-# and writes an include file, $file, which defines each of these.
585
+# and writes an include file, '$file', which defines each of these.
569586
# Variables which match '-auto' are output as follows:
570
-# - defines which have the value "0" are ignored.
587
+# - defines which have the value '0' are ignored.
571588
# - defines which have integer values are defined as the integer value.
572
-# - any other value is defined as a string, e.g. "value"
589
+# - any other value is defined as a string, e.g. '"value"'
573590
# Variables which match '-bare' are defined as-is.
574
-# Variables which match '-str' are defined as a string, e.g. "value"
591
+# Variables which match '-str' are defined as a string, e.g. '"value"'
575592
# Variables which match '-none' are omitted.
576593
#
577
-# Note that order is important. The first pattern which matches is selected
594
+# Note that order is important. The first pattern that matches is selected.
578595
# Default behaviour is:
579596
#
580
-# -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
597
+## -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
581598
#
582599
# If the file would be unchanged, it is not written.
583600
proc make-config-header {file args} {
584601
set guard _[string toupper [regsub -all {[^a-zA-Z0-9]} [file tail $file] _]]
585602
file mkdir [file dirname $file]
586603
587604
DELETED autosetup/config.guess
588605
DELETED autosetup/config.sub
589606
DELETED autosetup/find-tclsh
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -2,12 +2,12 @@
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'cc' module supports checking various 'features' of the C or C++
7 # compiler/linker environment. Common commands are cc-check-includes,
8 # cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-template.
9 #
10 # The following environment variables are used if set:
11 #
12 ## CC - C compiler
13 ## CXX - C++ compiler
@@ -28,15 +28,10 @@
28
29 use system
30
31 module-options {}
32
33 # Note that the return code is not meaningful
34 proc cc-check-something {name code} {
35 uplevel 1 $code
36 }
37
38 # Checks for the existence of the given function by linking
39 #
40 proc cctest_function {function} {
41 cctest -link 1 -declare "extern void $function\(void);" -code "$function\();"
42 }
@@ -68,12 +63,12 @@
68 }
69
70 # @cc-check-sizeof type ...
71 #
72 # Checks the size of the given types (between 1 and 32, inclusive).
73 # Defines a variable with the size determined, or "unknown" otherwise.
74 # e.g. for type 'long long', defines SIZEOF_LONG_LONG.
75 # Returns the size of the last type.
76 #
77 proc cc-check-sizeof {args} {
78 foreach type $args {
79 msg-checking "Checking for sizeof $type..."
@@ -109,11 +104,11 @@
109 return $ret
110 }
111
112 # @cc-check-includes includes ...
113 #
114 # Checks that the given include files can be used
115 proc cc-check-includes {args} {
116 cc-check-some-feature $args {
117 set with {}
118 if {[dict exists $::autosetup(cc-include-deps) $each]} {
119 set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]]
@@ -134,12 +129,12 @@
134 }
135 }
136
137 # @cc-include-needs include required ...
138 #
139 # Ensures that when checking for 'include', a check is first
140 # made for each 'required' file, and if found, it is #included
141 proc cc-include-needs {file args} {
142 foreach depfile $args {
143 dict set ::autosetup(cc-include-deps) $file $depfile 1
144 }
145 }
@@ -153,22 +148,22 @@
153 }
154 }
155
156 # @cc-check-defines define ...
157 #
158 # Checks that the given preprocessor symbol is defined
159 proc cc-check-defines {args} {
160 cc-check-some-feature $args {
161 cctest_define $each
162 }
163 }
164
165 # @cc-check-decls name ...
166 #
167 # Checks that each given name is either a preprocessor symbol or rvalue
168 # such as an enum. Note that the define used is HAVE_DECL_xxx
169 # rather than HAVE_xxx
170 proc cc-check-decls {args} {
171 set ret 1
172 foreach name $args {
173 msg-checking "Checking for $name..."
174 set r [cctest_decl $name]
@@ -183,21 +178,21 @@
183 return $ret
184 }
185
186 # @cc-check-functions function ...
187 #
188 # Checks that the given functions exist (can be linked)
189 proc cc-check-functions {args} {
190 cc-check-some-feature $args {
191 cctest_function $each
192 }
193 }
194
195 # @cc-check-members type.member ...
196 #
197 # Checks that the given type/structure members exist.
198 # A structure member is of the form "struct stat.st_mtime"
199 proc cc-check-members {args} {
200 cc-check-some-feature $args {
201 cctest_member $each
202 }
203 }
@@ -207,17 +202,17 @@
207 # Checks that the given function can be found in one of the libs.
208 #
209 # First checks for no library required, then checks each of the libraries
210 # in turn.
211 #
212 # If the function is found, the feature is defined and lib_$function is defined
213 # to -l$lib where the function was found, or "" if no library required.
214 # In addition, -l$lib is prepended to the LIBS define.
215 #
216 # If additional libraries may be needed for linking, they should be specified
217 # as $extralibs as "-lotherlib1 -lotherlib2".
218 # These libraries are not automatically added to LIBS.
219 #
220 # Returns 1 if found or 0 if not.
221 #
222 proc cc-check-function-in-lib {function libs {otherlibs {}}} {
223 msg-checking "Checking libs for $function..."
@@ -240,13 +235,12 @@
240 }
241 }
242 }
243 }
244 }
245 if {$found} {
246 define [feature-define-name $function]
247 } else {
248 msg-result "no"
249 }
250 return $found
251 }
252
@@ -253,16 +247,16 @@
253 # @cc-check-tools tool ...
254 #
255 # Checks for existence of the given compiler tools, taking
256 # into account any cross compilation prefix.
257 #
258 # For example, when checking for "ar", first AR is checked on the command
259 # line and then in the environment. If not found, "${host}-ar" or
260 # simply "ar" is assumed depending upon whether cross compiling.
261 # The path is searched for this executable, and if found AR is defined
262 # to the executable name.
263 # Note that even when cross compiling, the simple "ar" is used as a fallback,
264 # but a warning is generated. This is necessary for some toolchains.
265 #
266 # It is an error if the executable is not found.
267 #
268 proc cc-check-tools {args} {
@@ -284,14 +278,14 @@
284
285 # @cc-check-progs prog ...
286 #
287 # Checks for existence of the given executables on the path.
288 #
289 # For example, when checking for "grep", the path is searched for
290 # the executable, 'grep', and if found GREP is defined as "grep".
291 #
292 # If the executable is not found, the variable is defined as false.
293 # Returns 1 if all programs were found, or 0 otherwise.
294 #
295 proc cc-check-progs {args} {
296 set failed 0
297 foreach prog $args {
@@ -303,10 +297,33 @@
303 incr failed
304 } else {
305 msg-result ok
306 define $PROG $prog
307 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308 }
309 expr {!$failed}
310 }
311
312 # Adds the given settings to $::autosetup(ccsettings) and
@@ -326,18 +343,18 @@
326
327 foreach {name value} $settings {
328 switch -exact -- $name {
329 -cflags - -includes {
330 # These are given as lists
331 lappend new($name) {*}$value
332 }
333 -declare {
334 lappend new($name) $value
335 }
336 -libs {
337 # Note that new libraries are added before previous libraries
338 set new($name) [list {*}$value {*}$new($name)]
339 }
340 -link - -lang - -nooutput {
341 set new($name) $value
342 }
343 -source - -sourcefile - -code {
@@ -373,16 +390,16 @@
373 return $prev
374 }
375
376 # @cc-with settings ?{ script }?
377 #
378 # Sets the given 'cctest' settings and then runs the tests in 'script'.
379 # Note that settings such as -lang replace the current setting, while
380 # those such as -includes are appended to the existing setting.
381 #
382 # If no script is given, the settings become the default for the remainder
383 # of the auto.def file.
384 #
385 ## cc-with {-lang c++} {
386 ## # This will check with the C++ compiler
387 ## cc-check-types bool
388 ## cc-with {-includes signal.h} {
@@ -390,11 +407,11 @@
390 ## ...
391 ## }
392 ## # back to just the C++ compiler
393 ## }
394 #
395 # The -libs setting is special in that newer values are added *before* earlier ones.
396 #
397 ## cc-with {-libs {-lc -lm}} {
398 ## cc-with {-libs -ldl} {
399 ## cctest -libs -lsocket ...
400 ## # libs will be in this order: -lsocket -ldl -lc -lm
@@ -416,11 +433,11 @@
416 }
417 }
418
419 # @cctest ?settings?
420 #
421 # Low level C compiler checker. Compiles and or links a small C program
422 # according to the arguments and returns 1 if OK, or 0 if not.
423 #
424 # Supported settings are:
425 #
426 ## -cflags cflags A list of flags to pass to the compiler
@@ -432,11 +449,11 @@
432 ## -code code Code to compile in the body of main()
433 ## -source code Compile a complete program. Ignore -includes, -declare and -code
434 ## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
435 ## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
436 #
437 # Unless -source or -sourcefile is specified, the C program looks like:
438 #
439 ## #include <firstinclude> /* same for remaining includes in the list */
440 ##
441 ## declare-code /* any code in -declare, verbatim */
442 ##
@@ -554,32 +571,32 @@
554 return $ok
555 }
556
557 # @make-autoconf-h outfile ?auto-patterns=HAVE_*? ?bare-patterns=SIZEOF_*?
558 #
559 # Deprecated - see make-config-header
560 proc make-autoconf-h {file {autopatterns {HAVE_*}} {barepatterns {SIZEOF_* HAVE_DECL_*}}} {
561 user-notice "*** make-autoconf-h is deprecated -- use make-config-header instead"
562 make-config-header $file -auto $autopatterns -bare $barepatterns
563 }
564
565 # @make-config-header outfile ?-auto patternlist? ?-bare patternlist? ?-none patternlist? ?-str patternlist? ...
566 #
567 # Examines all defined variables which match the given patterns
568 # and writes an include file, $file, which defines each of these.
569 # Variables which match '-auto' are output as follows:
570 # - defines which have the value "0" are ignored.
571 # - defines which have integer values are defined as the integer value.
572 # - any other value is defined as a string, e.g. "value"
573 # Variables which match '-bare' are defined as-is.
574 # Variables which match '-str' are defined as a string, e.g. "value"
575 # Variables which match '-none' are omitted.
576 #
577 # Note that order is important. The first pattern which matches is selected
578 # Default behaviour is:
579 #
580 # -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
581 #
582 # If the file would be unchanged, it is not written.
583 proc make-config-header {file args} {
584 set guard _[string toupper [regsub -all {[^a-zA-Z0-9]} [file tail $file] _]]
585 file mkdir [file dirname $file]
586
587 ELETED autosetup/config.guess
588 ELETED autosetup/config.sub
589 ELETED autosetup/find-tclsh
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -2,12 +2,12 @@
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'cc' module supports checking various 'features' of the C or C++
7 # compiler/linker environment. Common commands are 'cc-check-includes',
8 # 'cc-check-types', 'cc-check-functions', 'cc-with', 'make-config-header' and 'make-template'.
9 #
10 # The following environment variables are used if set:
11 #
12 ## CC - C compiler
13 ## CXX - C++ compiler
@@ -28,15 +28,10 @@
28
29 use system
30
31 module-options {}
32
 
 
 
 
 
33 # Checks for the existence of the given function by linking
34 #
35 proc cctest_function {function} {
36 cctest -link 1 -declare "extern void $function\(void);" -code "$function\();"
37 }
@@ -68,12 +63,12 @@
63 }
64
65 # @cc-check-sizeof type ...
66 #
67 # Checks the size of the given types (between 1 and 32, inclusive).
68 # Defines a variable with the size determined, or 'unknown' otherwise.
69 # e.g. for type 'long long', defines 'SIZEOF_LONG_LONG'.
70 # Returns the size of the last type.
71 #
72 proc cc-check-sizeof {args} {
73 foreach type $args {
74 msg-checking "Checking for sizeof $type..."
@@ -109,11 +104,11 @@
104 return $ret
105 }
106
107 # @cc-check-includes includes ...
108 #
109 # Checks that the given include files can be used.
110 proc cc-check-includes {args} {
111 cc-check-some-feature $args {
112 set with {}
113 if {[dict exists $::autosetup(cc-include-deps) $each]} {
114 set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]]
@@ -134,12 +129,12 @@
129 }
130 }
131
132 # @cc-include-needs include required ...
133 #
134 # Ensures that when checking for '$include', a check is first
135 # made for each '$required' file, and if found, it is included with '#include'.
136 proc cc-include-needs {file args} {
137 foreach depfile $args {
138 dict set ::autosetup(cc-include-deps) $file $depfile 1
139 }
140 }
@@ -153,22 +148,22 @@
148 }
149 }
150
151 # @cc-check-defines define ...
152 #
153 # Checks that the given preprocessor symbols are defined.
154 proc cc-check-defines {args} {
155 cc-check-some-feature $args {
156 cctest_define $each
157 }
158 }
159
160 # @cc-check-decls name ...
161 #
162 # Checks that each given name is either a preprocessor symbol or rvalue
163 # such as an enum. Note that the define used is 'HAVE_DECL_xxx'
164 # rather than 'HAVE_xxx'.
165 proc cc-check-decls {args} {
166 set ret 1
167 foreach name $args {
168 msg-checking "Checking for $name..."
169 set r [cctest_decl $name]
@@ -183,21 +178,21 @@
178 return $ret
179 }
180
181 # @cc-check-functions function ...
182 #
183 # Checks that the given functions exist (can be linked).
184 proc cc-check-functions {args} {
185 cc-check-some-feature $args {
186 cctest_function $each
187 }
188 }
189
190 # @cc-check-members type.member ...
191 #
192 # Checks that the given type/structure members exist.
193 # A structure member is of the form 'struct stat.st_mtime'.
194 proc cc-check-members {args} {
195 cc-check-some-feature $args {
196 cctest_member $each
197 }
198 }
@@ -207,17 +202,17 @@
202 # Checks that the given function can be found in one of the libs.
203 #
204 # First checks for no library required, then checks each of the libraries
205 # in turn.
206 #
207 # If the function is found, the feature is defined and 'lib_$function' is defined
208 # to '-l$lib' where the function was found, or "" if no library required.
209 # In addition, '-l$lib' is prepended to the 'LIBS' define.
210 #
211 # If additional libraries may be needed for linking, they should be specified
212 # with '$extralibs' as '-lotherlib1 -lotherlib2'.
213 # These libraries are not automatically added to 'LIBS'.
214 #
215 # Returns 1 if found or 0 if not.
216 #
217 proc cc-check-function-in-lib {function libs {otherlibs {}}} {
218 msg-checking "Checking libs for $function..."
@@ -240,13 +235,12 @@
235 }
236 }
237 }
238 }
239 }
240 define-feature $function $found
241 if {!$found} {
 
242 msg-result "no"
243 }
244 return $found
245 }
246
@@ -253,16 +247,16 @@
247 # @cc-check-tools tool ...
248 #
249 # Checks for existence of the given compiler tools, taking
250 # into account any cross compilation prefix.
251 #
252 # For example, when checking for 'ar', first 'AR' is checked on the command
253 # line and then in the environment. If not found, '${host}-ar' or
254 # simply 'ar' is assumed depending upon whether cross compiling.
255 # The path is searched for this executable, and if found 'AR' is defined
256 # to the executable name.
257 # Note that even when cross compiling, the simple 'ar' is used as a fallback,
258 # but a warning is generated. This is necessary for some toolchains.
259 #
260 # It is an error if the executable is not found.
261 #
262 proc cc-check-tools {args} {
@@ -284,14 +278,14 @@
278
279 # @cc-check-progs prog ...
280 #
281 # Checks for existence of the given executables on the path.
282 #
283 # For example, when checking for 'grep', the path is searched for
284 # the executable, 'grep', and if found 'GREP' is defined as 'grep'.
285 #
286 # If the executable is not found, the variable is defined as 'false'.
287 # Returns 1 if all programs were found, or 0 otherwise.
288 #
289 proc cc-check-progs {args} {
290 set failed 0
291 foreach prog $args {
@@ -303,10 +297,33 @@
297 incr failed
298 } else {
299 msg-result ok
300 define $PROG $prog
301 }
302 }
303 expr {!$failed}
304 }
305
306 # @cc-path-progs prog ...
307 #
308 # Like cc-check-progs, but sets the define to the full path rather
309 # than just the program name.
310 #
311 proc cc-path-progs {args} {
312 set failed 0
313 foreach prog $args {
314 set PROG [string toupper $prog]
315 msg-checking "Checking for $prog..."
316 set path [find-executable-path $prog]
317 if {$path eq ""} {
318 msg-result no
319 define $PROG false
320 incr failed
321 } else {
322 msg-result $path
323 define $PROG $path
324 }
325 }
326 expr {!$failed}
327 }
328
329 # Adds the given settings to $::autosetup(ccsettings) and
@@ -326,18 +343,18 @@
343
344 foreach {name value} $settings {
345 switch -exact -- $name {
346 -cflags - -includes {
347 # These are given as lists
348 lappend new($name) {*}[list-non-empty $value]
349 }
350 -declare {
351 lappend new($name) $value
352 }
353 -libs {
354 # Note that new libraries are added before previous libraries
355 set new($name) [list {*}[list-non-empty $value] {*}$new($name)]
356 }
357 -link - -lang - -nooutput {
358 set new($name) $value
359 }
360 -source - -sourcefile - -code {
@@ -373,16 +390,16 @@
390 return $prev
391 }
392
393 # @cc-with settings ?{ script }?
394 #
395 # Sets the given 'cctest' settings and then runs the tests in '$script'.
396 # Note that settings such as '-lang' replace the current setting, while
397 # those such as '-includes' are appended to the existing setting.
398 #
399 # If no script is given, the settings become the default for the remainder
400 # of the 'auto.def' file.
401 #
402 ## cc-with {-lang c++} {
403 ## # This will check with the C++ compiler
404 ## cc-check-types bool
405 ## cc-with {-includes signal.h} {
@@ -390,11 +407,11 @@
407 ## ...
408 ## }
409 ## # back to just the C++ compiler
410 ## }
411 #
412 # The '-libs' setting is special in that newer values are added *before* earlier ones.
413 #
414 ## cc-with {-libs {-lc -lm}} {
415 ## cc-with {-libs -ldl} {
416 ## cctest -libs -lsocket ...
417 ## # libs will be in this order: -lsocket -ldl -lc -lm
@@ -416,11 +433,11 @@
433 }
434 }
435
436 # @cctest ?settings?
437 #
438 # Low level C/C++ compiler checker. Compiles and or links a small C program
439 # according to the arguments and returns 1 if OK, or 0 if not.
440 #
441 # Supported settings are:
442 #
443 ## -cflags cflags A list of flags to pass to the compiler
@@ -432,11 +449,11 @@
449 ## -code code Code to compile in the body of main()
450 ## -source code Compile a complete program. Ignore -includes, -declare and -code
451 ## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
452 ## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
453 #
454 # Unless '-source' or '-sourcefile' is specified, the C program looks like:
455 #
456 ## #include <firstinclude> /* same for remaining includes in the list */
457 ##
458 ## declare-code /* any code in -declare, verbatim */
459 ##
@@ -554,32 +571,32 @@
571 return $ok
572 }
573
574 # @make-autoconf-h outfile ?auto-patterns=HAVE_*? ?bare-patterns=SIZEOF_*?
575 #
576 # Deprecated - see 'make-config-header'
577 proc make-autoconf-h {file {autopatterns {HAVE_*}} {barepatterns {SIZEOF_* HAVE_DECL_*}}} {
578 user-notice "*** make-autoconf-h is deprecated -- use make-config-header instead"
579 make-config-header $file -auto $autopatterns -bare $barepatterns
580 }
581
582 # @make-config-header outfile ?-auto patternlist? ?-bare patternlist? ?-none patternlist? ?-str patternlist? ...
583 #
584 # Examines all defined variables which match the given patterns
585 # and writes an include file, '$file', which defines each of these.
586 # Variables which match '-auto' are output as follows:
587 # - defines which have the value '0' are ignored.
588 # - defines which have integer values are defined as the integer value.
589 # - any other value is defined as a string, e.g. '"value"'
590 # Variables which match '-bare' are defined as-is.
591 # Variables which match '-str' are defined as a string, e.g. '"value"'
592 # Variables which match '-none' are omitted.
593 #
594 # Note that order is important. The first pattern that matches is selected.
595 # Default behaviour is:
596 #
597 ## -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
598 #
599 # If the file would be unchanged, it is not written.
600 proc make-config-header {file args} {
601 set guard _[string toupper [regsub -all {[^a-zA-Z0-9]} [file tail $file] _]]
602 file mkdir [file dirname $file]
603
604 ELETED autosetup/config.guess
605 ELETED autosetup/config.sub
606 ELETED autosetup/find-tclsh
D autosetup/config.guess
-50
--- a/autosetup/config.guess
+++ b/autosetup/config.guess
@@ -1,50 +0,0 @@
1
-#! /bin/sh
2
-# Attempt to guess a canonical system name.
3
-# Copyright 1992-2014 Free Software Found4-11-04it and/or modify it
4
-# under the terms of the GNU General Public License as published by
5
-# t;e Free Software Foundation, either version 3 of the L;cense, or
6
-# (at your option) any later version.
7
-#
8
-# This program is distributed in the hope that it will be useful, but
9
-# WITHOUT ANY WARRANTY; without even the implied warranty of
10
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
-# General Public License for more details.
12
-#
13
-# You should have received a copy of the GNU General Public License
14
-# along with this program; if not, see <https://www.gnu.org/licenses/>.
15
-#
16
-# As a special exceptionto the GNU General Public License, if you
17
-# distribute this file as part of a program that contains a
18
-# configuration script generated by Autoconf, you may include it under
19
-# the same distribution terms that you use for the rest of that
20
-# program. This Exception is an additional permission under section 7
21
-# of the GNU General Public License, version 3 ("GPLv3").
22
-#
23
-# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
24
-#
25
-# You can get the latest version of this script from:
26
-# https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc.
27
-
28
-$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM}
29
- cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl
30
-# Attempt to guess a canoniAttempt to g! /bin/sh
31
-# Attemp#*) machine=${! /bin/sh
32
-# Attemp#! /bin/sh
33
-# Attempt to guess a canonical system name.
34
-# Copyright 1992-2018canonical system name.
35
-# Copyrig! /bin/sh
36
-# Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh
37
-# Attemp#! /bin/sh
38
-# Attempt to guess a ${! /bin/sh
39
-# Attemp#! /bin/sh
40
-# Attempt to guess a cekkoBSD:*:*)
41
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*)
42
- echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh
43
-# Attempt to guess a canonical system name.
44
-# Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name.
45
-# Copyright 1992-2018 Free Software Foundation, Inc.
46
-
47
-timestamp='2018-03-08it and/or modify it
48
-# under the terms of the GNU General Public License as published by
49
-# t;e Free Software Foundation, either version 3 of the L;cense, or
50
-# (at your o
--- a/autosetup/config.guess
+++ b/autosetup/config.guess
@@ -1,50 +0,0 @@
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 # Copyright 1992-2014 Free Software Found4-11-04it and/or modify it
4 # under the terms of the GNU General Public License as published by
5 # t;e Free Software Foundation, either version 3 of the L;cense, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <https://www.gnu.org/licenses/>.
15 #
16 # As a special exceptionto the GNU General Public License, if you
17 # distribute this file as part of a program that contains a
18 # configuration script generated by Autoconf, you may include it under
19 # the same distribution terms that you use for the rest of that
20 # program. This Exception is an additional permission under section 7
21 # of the GNU General Public License, version 3 ("GPLv3").
22 #
23 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
24 #
25 # You can get the latest version of this script from:
26 # https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc.
27
28 $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM}
29 cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl
30 # Attempt to guess a canoniAttempt to g! /bin/sh
31 # Attemp#*) machine=${! /bin/sh
32 # Attemp#! /bin/sh
33 # Attempt to guess a canonical system name.
34 # Copyright 1992-2018canonical system name.
35 # Copyrig! /bin/sh
36 # Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh
37 # Attemp#! /bin/sh
38 # Attempt to guess a ${! /bin/sh
39 # Attemp#! /bin/sh
40 # Attempt to guess a cekkoBSD:*:*)
41 echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*)
42 echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh
43 # Attempt to guess a canonical system name.
44 # Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name.
45 # Copyright 1992-2018 Free Software Foundation, Inc.
46
47 timestamp='2018-03-08it and/or modify it
48 # under the terms of the GNU General Public License as published by
49 # t;e Free Software Foundation, either version 3 of the L;cense, or
50 # (at your o
--- a/autosetup/config.guess
+++ b/autosetup/config.guess
@@ -1,50 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
D autosetup/config.sub
-75
--- a/autosetup/config.sub
+++ b/autosetup/config.sub
@@ -1,75 +0,0 @@
1
-#! /bin/sh
2
-# Configuration validation subroutine script.
3
-# Copyright 1992-2014 Free Software Found4-12-03it and/or modify it
4
-# under the terms of the GNU General Public License as published by
5
-# t;e Free Software Foundation, either version 3 of the L;cense, or
6
-# (at your option) any later version.
7
-#
8
-# This program is distributed in the hope that it will be useful, but
9
-# WITHOUT ANY WARRANTY; without even the implied warranty of
10
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
-# General Public License for more details.
12
-#
13
-# You should have received a copy of the GNU General Public License
14
-# along with this program; if not, see <https://www.gnu.org/licenses/>.
15
-#
16
-# As a special exception#
17
-# As a special exception to the GNU General Public License, if you
18
-# distribute this file as part of a program that contains a
19
-# configuration script generated by Autoconf, you may include it under
20
-# the same distribution terms that you use for the rest of that
21
-# program. This Exception is an additional permission under section 7
22
-# of the GNU General Public License, version 3 ("GPLv3").
23
-
24
-
25
-# Please send patches to <[email protected]>.
26
-#
27
-# Configuration subroutine to validate and canonicalize a configuration type.
28
-# Supply the specified configuration type as an argument.
29
-# If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
30
-
31
-'orting which valid configurations
32
-# it does not support. The user should be able to distinguish
33
-# a failure to support;hb=HEAD
34
- $0 [OPTION]f not, see <https:/eration mode a special exception to the GNU General Public License, if you
35
-# distribute this file as part of a program that contains a
36
-# configuration script generated by Autoconf, you may include it under
37
-# the same distribution terms that you use for the rest of that
38
-# program. This Excepti4 Free Software Foundation, Inc.
39
-
40
-er section 7
41
-# of the GNU General Public License, version 3 ("GPLv3").
42
-
43
-
44
-# Please send patches to <[email protected]>.
45
-#
46
-# Configuration subroutine to validate and canonicalize a configuration type.
47
-# Supply the specified configuration type as an argument.
48
-# If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
49
-
50
-'orting which valid configurations
51
-# it does not support. The user should be able to distinguish
52
-# a failure to support a valid configuration from a meaningless
53
-# configur$1$1$1$1$1$basic_machine !$1$1$1$1$15v6$1$1udk$1! /bin/sh
54
-# Cio$1$1windowsnt/windowsnt/windp11e32k | z8k)
55
- ;;
56
- msbut
57
-# WITHOUT ANY W#! /bin/sh
58
-# Configuration validation subroutine script.
59
-# Copyright 1992-2018 Free Software Foundation, Inc.
60
-
61
-timestamp='2018-03-08it and/or modify it
62
-# under the terms of the GNU General Public License as published by
63
-# t;e Free Software Foundation, either version 3 of the L;cense, or
64
-# (at your option) any later version.
65
-#
66
-# This program is distributed in the hope that it will be useful, but
67
-# WITHOUT ANY WARRANTY; without even the implied warranty of
68
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $1\': machine \`$basic_machineyramid?unknown$basic_machineu$basic_machine$basic_machine$basic_machine$basic_machinec9c | dpx2*-bull-next)
69
- os=-nextstep3$1$1$1$1i386-vsta | vstabin/sh
70
-# Configuration validation subroutine script.
71
-# Copyright 1992-2018 Free Software Foundation, Inc.
72
-
73
-timestamp='2018-03-08it and/or modify it
74
-# under the terms of the GNU General Public License as published bon subroutine $basic_machine-linuxomron$basic_machine$basic_machine$basic_machine ext$basic_machine$basic_machine$basic_machine$basic_machine$basic_machinepentium4i786-`echo $basic_machinepn$basic_machineppcle | ppc-le | powerpc-littlele$basic_machine$basic_machine | ppc64-le | powerpc64-little64le$basic_machinepsshsh5elh6h64-unknown
75
- ;
--- a/autosetup/config.sub
+++ b/autosetup/config.sub
@@ -1,75 +0,0 @@
1 #! /bin/sh
2 # Configuration validation subroutine script.
3 # Copyright 1992-2014 Free Software Found4-12-03it and/or modify it
4 # under the terms of the GNU General Public License as published by
5 # t;e Free Software Foundation, either version 3 of the L;cense, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <https://www.gnu.org/licenses/>.
15 #
16 # As a special exception#
17 # As a special exception to the GNU General Public License, if you
18 # distribute this file as part of a program that contains a
19 # configuration script generated by Autoconf, you may include it under
20 # the same distribution terms that you use for the rest of that
21 # program. This Exception is an additional permission under section 7
22 # of the GNU General Public License, version 3 ("GPLv3").
23
24
25 # Please send patches to <[email protected]>.
26 #
27 # Configuration subroutine to validate and canonicalize a configuration type.
28 # Supply the specified configuration type as an argument.
29 # If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
30
31 'orting which valid configurations
32 # it does not support. The user should be able to distinguish
33 # a failure to support;hb=HEAD
34 $0 [OPTION]f not, see <https:/eration mode a special exception to the GNU General Public License, if you
35 # distribute this file as part of a program that contains a
36 # configuration script generated by Autoconf, you may include it under
37 # the same distribution terms that you use for the rest of that
38 # program. This Excepti4 Free Software Foundation, Inc.
39
40 er section 7
41 # of the GNU General Public License, version 3 ("GPLv3").
42
43
44 # Please send patches to <[email protected]>.
45 #
46 # Configuration subroutine to validate and canonicalize a configuration type.
47 # Supply the specified configuration type as an argument.
48 # If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
49
50 'orting which valid configurations
51 # it does not support. The user should be able to distinguish
52 # a failure to support a valid configuration from a meaningless
53 # configur$1$1$1$1$1$basic_machine !$1$1$1$1$15v6$1$1udk$1! /bin/sh
54 # Cio$1$1windowsnt/windowsnt/windp11e32k | z8k)
55 ;;
56 msbut
57 # WITHOUT ANY W#! /bin/sh
58 # Configuration validation subroutine script.
59 # Copyright 1992-2018 Free Software Foundation, Inc.
60
61 timestamp='2018-03-08it and/or modify it
62 # under the terms of the GNU General Public License as published by
63 # t;e Free Software Foundation, either version 3 of the L;cense, or
64 # (at your option) any later version.
65 #
66 # This program is distributed in the hope that it will be useful, but
67 # WITHOUT ANY WARRANTY; without even the implied warranty of
68 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $1\': machine \`$basic_machineyramid?unknown$basic_machineu$basic_machine$basic_machine$basic_machine$basic_machinec9c | dpx2*-bull-next)
69 os=-nextstep3$1$1$1$1i386-vsta | vstabin/sh
70 # Configuration validation subroutine script.
71 # Copyright 1992-2018 Free Software Foundation, Inc.
72
73 timestamp='2018-03-08it and/or modify it
74 # under the terms of the GNU General Public License as published bon subroutine $basic_machine-linuxomron$basic_machine$basic_machine$basic_machine ext$basic_machine$basic_machine$basic_machine$basic_machine$basic_machinepentium4i786-`echo $basic_machinepn$basic_machineppcle | ppc-le | powerpc-littlele$basic_machine$basic_machine | ppc64-le | powerpc64-little64le$basic_machinepsshsh5elh6h64-unknown
75 ;
--- a/autosetup/config.sub
+++ b/autosetup/config.sub
@@ -1,75 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
D autosetup/find-tclsh
-10
--- a/autosetup/find-tclsh
+++ b/autosetup/find-tclsh
@@ -1,10 +0,0 @@
1
-#!/bin/sh
2
-# Looks for a suitable tclsh or jimsh in the PATH
3
-# If not foundstrap jimsh d=`dirname "$0"`
4
-{ "$d/jimshd/${1-ac"; } 2>&1done
5
-echo 1>&2 bootstrap jimsh0"
6
-for cc in tclsh8.7; do
7
- { $tclsh "$d/c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/devexit 0
8
-done
9
-echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
10
-for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/find-tclsh
+++ b/autosetup/find-tclsh
@@ -1,10 +0,0 @@
1 #!/bin/sh
2 # Looks for a suitable tclsh or jimsh in the PATH
3 # If not foundstrap jimsh d=`dirname "$0"`
4 { "$d/jimshd/${1-ac"; } 2>&1done
5 echo 1>&2 bootstrap jimsh0"
6 for cc in tclsh8.7; do
7 { $tclsh "$d/c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/devexit 0
8 done
9 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
10 for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/find-tclsh
+++ b/autosetup/find-tclsh
@@ -1,10 +0,0 @@
 
 
 
 
 
 
 
 
 
 
+2033 -1988
--- autosetup/jimsh0.c
+++ autosetup/jimsh0.c
@@ -1,9 +1,7 @@
11
/* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */
2
-#define _GNU_SOURCE
32
#define JIM_TCL_COMPAT
4
-#define JIM_REFERENCES
53
#define JIM_ANSIC
64
#define JIM_REGEXP
75
#define HAVE_NO_AUTOCONF
86
#define _JIMAUTOCONF_H
97
#define TCL_LIBRARY "."
@@ -31,24 +29,39 @@
3129
#define HAVE_MKDIR_ONE_ARG
3230
#define HAVE_SYSTEM
3331
#define HAVE_SYS_TIME_H
3432
#define HAVE_DIRENT_H
3533
#define HAVE_UNISTD_H
34
+#define HAVE_UMASK
35
+#include <sys/stat.h>
36
+#ifndef S_IRWXG
37
+#define S_IRWXG 0
38
+#endif
39
+#ifndef S_IRWXO
40
+#define S_IRWXO 0
41
+#endif
3642
#else
3743
#define TCL_PLATFORM_OS "unknown"
3844
#define TCL_PLATFORM_PLATFORM "unix"
3945
#define TCL_PLATFORM_PATH_SEPARATOR ":"
46
+#ifdef _MINIX
47
+#define vfork fork
48
+#define _POSIX_SOURCE
49
+#else
50
+#define _GNU_SOURCE
51
+#endif
4052
#define HAVE_VFORK
4153
#define HAVE_WAITPID
4254
#define HAVE_ISATTY
4355
#define HAVE_MKSTEMP
4456
#define HAVE_LINK
4557
#define HAVE_SYS_TIME_H
4658
#define HAVE_DIRENT_H
4759
#define HAVE_UNISTD_H
60
+#define HAVE_UMASK
4861
#endif
49
-#define JIM_VERSION 76
62
+#define JIM_VERSION 77
5063
#ifndef JIM_WIN32COMPAT_H
5164
#define JIM_WIN32COMPAT_H
5265
5366
5467
@@ -88,11 +101,10 @@
88101
#define JIM_WIDE_MIN LLONG_MIN
89102
#define JIM_WIDE_MAX LLONG_MAX
90103
#define JIM_WIDE_MODIFIER "I64d"
91104
#define strcasecmp _stricmp
92105
#define strtoull _strtoui64
93
-#define snprintf _snprintf
94106
95107
#include <io.h>
96108
97109
struct timeval {
98110
long tv_sec;
@@ -105,14 +117,14 @@
105117
struct dirent {
106118
char *d_name;
107119
};
108120
109121
typedef struct DIR {
110
- long handle;
122
+ long handle;
111123
struct _finddata_t info;
112
- struct dirent result;
113
- char *name;
124
+ struct dirent result;
125
+ char *name;
114126
} DIR;
115127
116128
DIR *opendir(const char *name);
117129
int closedir(DIR *dir);
118130
struct dirent *readdir(DIR *dir);
@@ -122,11 +134,11 @@
122134
#include <stdlib.h>
123135
#define strtod __strtod
124136
125137
#endif
126138
127
-#endif
139
+#endif
128140
129141
#ifdef __cplusplus
130142
}
131143
#endif
132144
@@ -146,19 +158,21 @@
146158
147159
#ifndef JIM_UTF8
148160
#include <ctype.h>
149161
150162
151
-#define utf8_strlen(S, B) ((B) < 0 ? strlen(S) : (B))
163
+#define utf8_strlen(S, B) ((B) < 0 ? (int)strlen(S) : (B))
164
+#define utf8_strwidth(S, B) utf8_strlen((S), (B))
152165
#define utf8_tounicode(S, CP) (*(CP) = (unsigned char)*(S), 1)
153166
#define utf8_getchars(CP, C) (*(CP) = (C), 1)
154167
#define utf8_upper(C) toupper(C)
155168
#define utf8_title(C) toupper(C)
156169
#define utf8_lower(C) tolower(C)
157170
#define utf8_index(C, I) (I)
158171
#define utf8_charlen(C) 1
159172
#define utf8_prev_len(S, L) 1
173
+#define utf8_width(C) 1
160174
161175
#else
162176
163177
#endif
164178
@@ -175,13 +189,13 @@
175189
extern "C" {
176190
#endif
177191
178192
#include <time.h>
179193
#include <limits.h>
180
-#include <stdio.h>
181
-#include <stdlib.h>
182
-#include <stdarg.h>
194
+#include <stdio.h>
195
+#include <stdlib.h>
196
+#include <stdarg.h>
183197
184198
185199
#ifndef HAVE_NO_AUTOCONF
186200
#endif
187201
@@ -224,31 +238,31 @@
224238
#define JIM_SIGNAL 5
225239
#define JIM_EXIT 6
226240
227241
#define JIM_EVAL 7
228242
229
-#define JIM_MAX_CALLFRAME_DEPTH 1000
230
-#define JIM_MAX_EVAL_DEPTH 2000
243
+#define JIM_MAX_CALLFRAME_DEPTH 1000
244
+#define JIM_MAX_EVAL_DEPTH 2000
231245
232246
233247
#define JIM_PRIV_FLAG_SHIFT 20
234248
235
-#define JIM_NONE 0
236
-#define JIM_ERRMSG 1
237
-#define JIM_ENUM_ABBREV 2
238
-#define JIM_UNSHARED 4
239
-#define JIM_MUSTEXIST 8
240
-
241
-
242
-#define JIM_SUBST_NOVAR 1
243
-#define JIM_SUBST_NOCMD 2
244
-#define JIM_SUBST_NOESC 4
245
-#define JIM_SUBST_FLAG 128
246
-
247
-
248
-#define JIM_CASESENS 0
249
-#define JIM_NOCASE 1
249
+#define JIM_NONE 0
250
+#define JIM_ERRMSG 1
251
+#define JIM_ENUM_ABBREV 2
252
+#define JIM_UNSHARED 4
253
+#define JIM_MUSTEXIST 8
254
+
255
+
256
+#define JIM_SUBST_NOVAR 1
257
+#define JIM_SUBST_NOCMD 2
258
+#define JIM_SUBST_NOESC 4
259
+#define JIM_SUBST_FLAG 128
260
+
261
+
262
+#define JIM_CASESENS 0
263
+#define JIM_NOCASE 1
250264
251265
252266
#define JIM_PATH_LEN 1024
253267
254268
@@ -339,79 +353,79 @@
339353
#define Jim_GetHashTableSize(ht) ((ht)->size)
340354
#define Jim_GetHashTableUsed(ht) ((ht)->used)
341355
342356
343357
typedef struct Jim_Obj {
344
- char *bytes;
345
- const struct Jim_ObjType *typePtr;
346
- int refCount;
347
- int length;
348
-
358
+ char *bytes;
359
+ const struct Jim_ObjType *typePtr;
360
+ int refCount;
361
+ int length;
362
+
349363
union {
350
-
364
+
351365
jim_wide wideValue;
352
-
366
+
353367
int intValue;
354
-
368
+
355369
double doubleValue;
356
-
370
+
357371
void *ptr;
358
-
372
+
359373
struct {
360374
void *ptr1;
361375
void *ptr2;
362376
} twoPtrValue;
363
-
377
+
364378
struct {
365379
struct Jim_Var *varPtr;
366
- unsigned long callFrameId;
367
- int global;
380
+ unsigned long callFrameId;
381
+ int global;
368382
} varValue;
369
-
383
+
370384
struct {
371385
struct Jim_Obj *nsObj;
372386
struct Jim_Cmd *cmdPtr;
373
- unsigned long procEpoch;
387
+ unsigned long procEpoch;
374388
} cmdValue;
375
-
389
+
376390
struct {
377
- struct Jim_Obj **ele;
378
- int len;
379
- int maxLen;
391
+ struct Jim_Obj **ele;
392
+ int len;
393
+ int maxLen;
380394
} listValue;
381
-
395
+
382396
struct {
383397
int maxLength;
384
- int charLength;
398
+ int charLength;
385399
} strValue;
386
-
400
+
387401
struct {
388402
unsigned long id;
389403
struct Jim_Reference *refPtr;
390404
} refValue;
391
-
405
+
392406
struct {
393407
struct Jim_Obj *fileNameObj;
394408
int lineNumber;
395409
} sourceValue;
396
-
410
+
397411
struct {
398412
struct Jim_Obj *varNameObjPtr;
399413
struct Jim_Obj *indexObjPtr;
400414
} dictSubstValue;
401
-
415
+
402416
struct {
403
- void *compre;
417
+ void *compre;
404418
unsigned flags;
405419
} regexpValue;
406420
struct {
407421
int line;
408422
int argc;
409423
} scriptLineValue;
410424
} internalRep;
411
- struct Jim_Obj *prevObjPtr;
412
- struct Jim_Obj *nextObjPtr;
425
+ struct Jim_Obj *prevObjPtr;
426
+ struct Jim_Obj *nextObjPtr;
413427
} Jim_Obj;
414428
415429
416430
#define Jim_IncrRefCount(objPtr) \
417431
++(objPtr)->refCount
@@ -442,40 +456,40 @@
442456
typedef void (Jim_DupInternalRepProc)(struct Jim_Interp *interp,
443457
struct Jim_Obj *srcPtr, Jim_Obj *dupPtr);
444458
typedef void (Jim_UpdateStringProc)(struct Jim_Obj *objPtr);
445459
446460
typedef struct Jim_ObjType {
447
- const char *name;
461
+ const char *name;
448462
Jim_FreeInternalRepProc *freeIntRepProc;
449463
Jim_DupInternalRepProc *dupIntRepProc;
450464
Jim_UpdateStringProc *updateStringProc;
451465
int flags;
452466
} Jim_ObjType;
453467
454468
455
-#define JIM_TYPE_NONE 0
456
-#define JIM_TYPE_REFERENCES 1
469
+#define JIM_TYPE_NONE 0
470
+#define JIM_TYPE_REFERENCES 1
457471
458472
459473
460474
typedef struct Jim_CallFrame {
461
- unsigned long id;
462
- int level;
463
- struct Jim_HashTable vars;
464
- struct Jim_HashTable *staticVars;
465
- struct Jim_CallFrame *parent;
466
- Jim_Obj *const *argv;
467
- int argc;
468
- Jim_Obj *procArgsObjPtr;
469
- Jim_Obj *procBodyObjPtr;
470
- struct Jim_CallFrame *next;
471
- Jim_Obj *nsObj;
472
- Jim_Obj *fileNameObj;
475
+ unsigned long id;
476
+ int level;
477
+ struct Jim_HashTable vars;
478
+ struct Jim_HashTable *staticVars;
479
+ struct Jim_CallFrame *parent;
480
+ Jim_Obj *const *argv;
481
+ int argc;
482
+ Jim_Obj *procArgsObjPtr;
483
+ Jim_Obj *procBodyObjPtr;
484
+ struct Jim_CallFrame *next;
485
+ Jim_Obj *nsObj;
486
+ Jim_Obj *fileNameObj;
473487
int line;
474
- Jim_Stack *localCommands;
475
- struct Jim_Obj *tailcallObj;
476
- struct Jim_Cmd *tailcallCmd;
488
+ Jim_Stack *localCommands;
489
+ struct Jim_Obj *tailcallObj;
490
+ struct Jim_Cmd *tailcallCmd;
477491
} Jim_CallFrame;
478492
479493
typedef struct Jim_Var {
480494
Jim_Obj *objPtr;
481495
struct Jim_CallFrame *linkFramePtr;
@@ -487,35 +501,35 @@
487501
typedef void Jim_DelCmdProc(struct Jim_Interp *interp, void *privData);
488502
489503
490504
491505
typedef struct Jim_Cmd {
492
- int inUse;
493
- int isproc;
494
- struct Jim_Cmd *prevCmd;
506
+ int inUse;
507
+ int isproc;
508
+ struct Jim_Cmd *prevCmd;
495509
union {
496510
struct {
497
-
498
- Jim_CmdProc *cmdProc;
499
- Jim_DelCmdProc *delProc;
500
- void *privData;
511
+
512
+ Jim_CmdProc *cmdProc;
513
+ Jim_DelCmdProc *delProc;
514
+ void *privData;
501515
} native;
502516
struct {
503
-
517
+
504518
Jim_Obj *argListObjPtr;
505519
Jim_Obj *bodyObjPtr;
506
- Jim_HashTable *staticVars;
507
- int argListLen;
508
- int reqArity;
509
- int optArity;
510
- int argsPos;
511
- int upcall;
520
+ Jim_HashTable *staticVars;
521
+ int argListLen;
522
+ int reqArity;
523
+ int optArity;
524
+ int argsPos;
525
+ int upcall;
512526
struct Jim_ProcArg {
513
- Jim_Obj *nameObjPtr;
514
- Jim_Obj *defaultObjPtr;
527
+ Jim_Obj *nameObjPtr;
528
+ Jim_Obj *defaultObjPtr;
515529
} *arglist;
516
- Jim_Obj *nsObj;
530
+ Jim_Obj *nsObj;
517531
} proc;
518532
} u;
519533
} Jim_Cmd;
520534
521535
@@ -523,64 +537,64 @@
523537
unsigned char sbox[256];
524538
unsigned int i, j;
525539
} Jim_PrngState;
526540
527541
typedef struct Jim_Interp {
528
- Jim_Obj *result;
529
- int errorLine;
530
- Jim_Obj *errorFileNameObj;
531
- int addStackTrace;
532
- int maxCallFrameDepth;
533
- int maxEvalDepth;
534
- int evalDepth;
535
- int returnCode;
536
- int returnLevel;
537
- int exitCode;
538
- long id;
539
- int signal_level;
540
- jim_wide sigmask;
541
- int (*signal_set_result)(struct Jim_Interp *interp, jim_wide sigmask);
542
- Jim_CallFrame *framePtr;
543
- Jim_CallFrame *topFramePtr;
544
- struct Jim_HashTable commands;
542
+ Jim_Obj *result;
543
+ int errorLine;
544
+ Jim_Obj *errorFileNameObj;
545
+ int addStackTrace;
546
+ int maxCallFrameDepth;
547
+ int maxEvalDepth;
548
+ int evalDepth;
549
+ int returnCode;
550
+ int returnLevel;
551
+ int exitCode;
552
+ long id;
553
+ int signal_level;
554
+ jim_wide sigmask;
555
+ int (*signal_set_result)(struct Jim_Interp *interp, jim_wide sigmask);
556
+ Jim_CallFrame *framePtr;
557
+ Jim_CallFrame *topFramePtr;
558
+ struct Jim_HashTable commands;
545559
unsigned long procEpoch; /* Incremented every time the result
546560
of procedures names lookup caching
547561
may no longer be valid. */
548562
unsigned long callFrameEpoch; /* Incremented every time a new
549563
callframe is created. This id is used for the
550564
'ID' field contained in the Jim_CallFrame
551565
structure. */
552
- int local;
553
- Jim_Obj *liveList;
554
- Jim_Obj *freeList;
555
- Jim_Obj *currentScriptObj;
556
- Jim_Obj *nullScriptObj;
557
- Jim_Obj *emptyObj;
558
- Jim_Obj *trueObj;
559
- Jim_Obj *falseObj;
560
- unsigned long referenceNextId;
561
- struct Jim_HashTable references;
566
+ int local;
567
+ Jim_Obj *liveList;
568
+ Jim_Obj *freeList;
569
+ Jim_Obj *currentScriptObj;
570
+ Jim_Obj *nullScriptObj;
571
+ Jim_Obj *emptyObj;
572
+ Jim_Obj *trueObj;
573
+ Jim_Obj *falseObj;
574
+ unsigned long referenceNextId;
575
+ struct Jim_HashTable references;
562576
unsigned long lastCollectId; /* reference max Id of the last GC
563577
execution. It's set to -1 while the collection
564578
is running as sentinel to avoid to recursive
565579
calls via the [collect] command inside
566580
finalizers. */
567
- time_t lastCollectTime;
568
- Jim_Obj *stackTrace;
569
- Jim_Obj *errorProc;
570
- Jim_Obj *unknown;
571
- int unknown_called;
572
- int errorFlag;
581
+ time_t lastCollectTime;
582
+ Jim_Obj *stackTrace;
583
+ Jim_Obj *errorProc;
584
+ Jim_Obj *unknown;
585
+ int unknown_called;
586
+ int errorFlag;
573587
void *cmdPrivData; /* Used to pass the private data pointer to
574588
a command. It is set to what the user specified
575589
via Jim_CreateCommand(). */
576590
577
- struct Jim_CallFrame *freeFramesList;
578
- struct Jim_HashTable assocData;
579
- Jim_PrngState *prngState;
580
- struct Jim_HashTable packages;
581
- Jim_Stack *loadHandles;
591
+ struct Jim_CallFrame *freeFramesList;
592
+ struct Jim_HashTable assocData;
593
+ Jim_PrngState *prngState;
594
+ struct Jim_HashTable packages;
595
+ Jim_Stack *loadHandles;
582596
} Jim_Interp;
583597
584598
#define Jim_InterpIncrProcEpoch(i) (i)->procEpoch++
585599
#define Jim_SetResultString(i,s,l) Jim_SetResult(i, Jim_NewStringObj(i,s,l))
586600
#define Jim_SetResultInt(i,intval) Jim_SetResult(i, Jim_NewIntObj(i,intval))
@@ -623,11 +637,11 @@
623637
JIM_EXPORT char *Jim_StrDupLen(const char *s, int l);
624638
625639
626640
JIM_EXPORT char **Jim_GetEnviron(void);
627641
JIM_EXPORT void Jim_SetEnviron(char **env);
628
-JIM_EXPORT int Jim_MakeTempFile(Jim_Interp *interp, const char *template);
642
+JIM_EXPORT int Jim_MakeTempFile(Jim_Interp *interp, const char *filename_template);
629643
630644
631645
JIM_EXPORT int Jim_Eval(Jim_Interp *interp, const char *script);
632646
633647
@@ -816,14 +830,18 @@
816830
Jim_Obj *newObjPtr, int flags);
817831
JIM_EXPORT int Jim_DictPairs(Jim_Interp *interp,
818832
Jim_Obj *dictPtr, Jim_Obj ***objPtrPtr, int *len);
819833
JIM_EXPORT int Jim_DictAddElement(Jim_Interp *interp, Jim_Obj *objPtr,
820834
Jim_Obj *keyObjPtr, Jim_Obj *valueObjPtr);
821
-JIM_EXPORT int Jim_DictKeys(Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj *patternObj);
822
-JIM_EXPORT int Jim_DictValues(Jim_Interp *interp, Jim_Obj *dictObjPtr, Jim_Obj *patternObjPtr);
835
+
836
+#define JIM_DICTMATCH_KEYS 0x0001
837
+#define JIM_DICTMATCH_VALUES 0x002
838
+
839
+JIM_EXPORT int Jim_DictMatchTypes(Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj *patternObj, int match_type, int return_types);
823840
JIM_EXPORT int Jim_DictSize(Jim_Interp *interp, Jim_Obj *objPtr);
824841
JIM_EXPORT int Jim_DictInfo(Jim_Interp *interp, Jim_Obj *objPtr);
842
+JIM_EXPORT Jim_Obj *Jim_DictMerge(Jim_Interp *interp, int objc, Jim_Obj *const *objv);
825843
826844
827845
JIM_EXPORT int Jim_GetReturnCode (Jim_Interp *interp, Jim_Obj *objPtr,
828846
int *intPtr);
829847
@@ -831,10 +849,14 @@
831849
JIM_EXPORT int Jim_EvalExpression (Jim_Interp *interp,
832850
Jim_Obj *exprObjPtr, Jim_Obj **exprResultPtrPtr);
833851
JIM_EXPORT int Jim_GetBoolFromExpr (Jim_Interp *interp,
834852
Jim_Obj *exprObjPtr, int *boolPtr);
835853
854
+
855
+JIM_EXPORT int Jim_GetBoolean(Jim_Interp *interp, Jim_Obj *objPtr,
856
+ int *booleanPtr);
857
+
836858
837859
JIM_EXPORT int Jim_GetWide (Jim_Interp *interp, Jim_Obj *objPtr,
838860
jim_wide *widePtr);
839861
JIM_EXPORT int Jim_GetLong (Jim_Interp *interp, Jim_Obj *objPtr,
840862
long *longPtr);
@@ -852,10 +874,12 @@
852874
853875
JIM_EXPORT void Jim_WrongNumArgs (Jim_Interp *interp, int argc,
854876
Jim_Obj *const *argv, const char *msg);
855877
JIM_EXPORT int Jim_GetEnum (Jim_Interp *interp, Jim_Obj *objPtr,
856878
const char * const *tablePtr, int *indexPtr, const char *name, int flags);
879
+JIM_EXPORT int Jim_CheckShowCommands(Jim_Interp *interp, Jim_Obj *objPtr,
880
+ const char *const *tablePtr);
857881
JIM_EXPORT int Jim_ScriptIsComplete(Jim_Interp *interp,
858882
Jim_Obj *scriptObj, char *stateCharPtr);
859883
860884
JIM_EXPORT int Jim_FindByName(const char *name, const char * const array[], size_t len);
861885
@@ -904,11 +928,11 @@
904928
905929
#ifdef __cplusplus
906930
}
907931
#endif
908932
909
-#endif
933
+#endif
910934
911935
#ifndef JIM_SUBCMD_H
912936
#define JIM_SUBCMD_H
913937
914938
@@ -915,24 +939,24 @@
915939
#ifdef __cplusplus
916940
extern "C" {
917941
#endif
918942
919943
920
-#define JIM_MODFLAG_HIDDEN 0x0001
921
-#define JIM_MODFLAG_FULLARGV 0x0002
944
+#define JIM_MODFLAG_HIDDEN 0x0001
945
+#define JIM_MODFLAG_FULLARGV 0x0002
922946
923947
924948
925949
typedef int jim_subcmd_function(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
926950
927951
typedef struct {
928
- const char *cmd;
929
- const char *args;
930
- jim_subcmd_function *function;
931
- short minargs;
932
- short maxargs;
933
- unsigned short flags;
952
+ const char *cmd;
953
+ const char *args;
954
+ jim_subcmd_function *function;
955
+ short minargs;
956
+ short maxargs;
957
+ unsigned short flags;
934958
} jim_subcmd_type;
935959
936960
const jim_subcmd_type *
937961
Jim_ParseSubCmd(Jim_Interp *interp, const jim_subcmd_type *command_table, int argc, Jim_Obj *const *argv);
938962
@@ -960,36 +984,36 @@
960984
int rm_eo;
961985
} regmatch_t;
962986
963987
964988
typedef struct regexp {
965
-
966
- int re_nsub;
967
-
968
-
969
- int cflags;
970
- int err;
971
- int regstart;
972
- int reganch;
973
- int regmust;
974
- int regmlen;
975
- int *program;
976
-
977
-
978
- const char *regparse;
979
- int p;
980
- int proglen;
981
-
982
-
983
- int eflags;
984
- const char *start;
985
- const char *reginput;
986
- const char *regbol;
987
-
988
-
989
- regmatch_t *pmatch;
990
- int nmatch;
989
+
990
+ int re_nsub;
991
+
992
+
993
+ int cflags;
994
+ int err;
995
+ int regstart;
996
+ int reganch;
997
+ int regmust;
998
+ int regmlen;
999
+ int *program;
1000
+
1001
+
1002
+ const char *regparse;
1003
+ int p;
1004
+ int proglen;
1005
+
1006
+
1007
+ int eflags;
1008
+ const char *start;
1009
+ const char *reginput;
1010
+ const char *regbol;
1011
+
1012
+
1013
+ regmatch_t *pmatch;
1014
+ int nmatch;
9911015
} regexp;
9921016
9931017
typedef regexp regex_t;
9941018
9951019
#define REG_EXTENDED 0
@@ -997,13 +1021,13 @@
9971021
#define REG_ICASE 2
9981022
9991023
#define REG_NOTBOL 16
10001024
10011025
enum {
1002
- REG_NOERROR,
1003
- REG_NOMATCH,
1004
- REG_BADPAT,
1026
+ REG_NOERROR,
1027
+ REG_NOMATCH,
1028
+ REG_BADPAT,
10051029
REG_ERR_NULL_ARGUMENT,
10061030
REG_ERR_UNKNOWN,
10071031
REG_ERR_TOO_BIG,
10081032
REG_ERR_NOMEM,
10091033
REG_ERR_TOO_MANY_PAREN,
@@ -1100,10 +1124,43 @@
11001124
"\n"
11011125
"if {$tcl_platform(platform) eq \"windows\"} {\n"
11021126
" set jim::argv0 [string map {\\\\ /} $jim::argv0]\n"
11031127
"}\n"
11041128
"\n"
1129
+"\n"
1130
+"set tcl::autocomplete_commands {info tcl::prefix socket namespace array clock file package string dict signal history}\n"
1131
+"\n"
1132
+"\n"
1133
+"\n"
1134
+"proc tcl::autocomplete {prefix} {\n"
1135
+" if {[set space [string first \" \" $prefix]] != -1} {\n"
1136
+" set cmd [string range $prefix 0 $space-1]\n"
1137
+" if {$cmd in $::tcl::autocomplete_commands || [info channel $cmd] ne \"\"} {\n"
1138
+" set arg [string range $prefix $space+1 end]\n"
1139
+"\n"
1140
+" return [lmap p [$cmd -commands] {\n"
1141
+" if {![string match \"${arg}*\" $p]} continue\n"
1142
+" function \"$cmd $p\"\n"
1143
+" }]\n"
1144
+" }\n"
1145
+" }\n"
1146
+"\n"
1147
+" if {[string match \"source *\" $prefix]} {\n"
1148
+" set path [string range $prefix 7 end]\n"
1149
+" return [lmap p [glob -nocomplain \"${path}*\"] {\n"
1150
+" function \"source $p\"\n"
1151
+" }]\n"
1152
+" }\n"
1153
+"\n"
1154
+" return [lmap p [lsort [info commands $prefix*]] {\n"
1155
+" if {[string match \"* *\" $p]} {\n"
1156
+" continue\n"
1157
+" }\n"
1158
+" function $p\n"
1159
+" }]\n"
1160
+"}\n"
1161
+"\n"
11051162
"_jimsh_init\n"
11061163
);
11071164
}
11081165
int Jim_globInit(Jim_Interp *interp)
11091166
{
@@ -1402,31 +1459,10 @@
14021459
" if {[exists ::jim::exe]} {\n"
14031460
" return $::jim::exe\n"
14041461
" }\n"
14051462
"}\n"
14061463
"\n"
1407
-"\n"
1408
-"proc {dict with} {&dictVar {args key} script} {\n"
1409
-" set keys {}\n"
1410
-" foreach {n v} [dict get $dictVar {*}$key] {\n"
1411
-" upvar $n var_$n\n"
1412
-" set var_$n $v\n"
1413
-" lappend keys $n\n"
1414
-" }\n"
1415
-" catch {uplevel 1 $script} msg opts\n"
1416
-" if {[info exists dictVar] && ([llength $key] == 0 || [dict exists $dictVar {*}$key])} {\n"
1417
-" foreach n $keys {\n"
1418
-" if {[info exists var_$n]} {\n"
1419
-" dict set dictVar {*}$key $n [set var_$n]\n"
1420
-" } else {\n"
1421
-" dict unset dictVar {*}$key $n\n"
1422
-" }\n"
1423
-" }\n"
1424
-" }\n"
1425
-" return {*}$opts $msg\n"
1426
-"}\n"
1427
-"\n"
14281464
"\n"
14291465
"proc {dict update} {&varName args script} {\n"
14301466
" set keys {}\n"
14311467
" foreach {n v} $args {\n"
14321468
" upvar $v var_$v\n"
@@ -1445,23 +1481,10 @@
14451481
" }\n"
14461482
" }\n"
14471483
" return {*}$opts $msg\n"
14481484
"}\n"
14491485
"\n"
1450
-"\n"
1451
-"\n"
1452
-"proc {dict merge} {dict args} {\n"
1453
-" foreach d $args {\n"
1454
-"\n"
1455
-" dict size $d\n"
1456
-" foreach {k v} $d {\n"
1457
-" dict set dict $k $v\n"
1458
-" }\n"
1459
-" }\n"
1460
-" return $dict\n"
1461
-"}\n"
1462
-"\n"
14631486
"proc {dict replace} {dictionary {args {key value}}} {\n"
14641487
" if {[llength ${key value}] % 2} {\n"
14651488
" tailcall {dict replace}\n"
14661489
" }\n"
14671490
" tailcall dict merge $dictionary ${key value}\n"
@@ -1503,15 +1526,10 @@
15031526
" dict unset dictionary $k\n"
15041527
" }\n"
15051528
" return $dictionary\n"
15061529
"}\n"
15071530
"\n"
1508
-"\n"
1509
-"proc {dict values} {dictionary {pattern *}} {\n"
1510
-" dict keys [lreverse $dictionary] $pattern\n"
1511
-"}\n"
1512
-"\n"
15131531
"\n"
15141532
"proc {dict for} {vars dictionary script} {\n"
15151533
" if {[llength $vars] != 2} {\n"
15161534
" return -code error \"must have exactly two variable names\"\n"
15171535
" }\n"
@@ -1588,11 +1606,10 @@
15881606
"\n"
15891607
"\n"
15901608
"proc fileevent {args} {\n"
15911609
" tailcall {*}$args\n"
15921610
"}\n"
1593
-"\n"
15941611
"\n"
15951612
"\n"
15961613
"\n"
15971614
"proc parray {arrayname {pattern *} {puts puts}} {\n"
15981615
" upvar $arrayname a\n"
@@ -1701,15 +1718,10 @@
17011718
"\n"
17021719
"\n"
17031720
"\n"
17041721
"\n"
17051722
"\n"
1706
-"\n"
1707
-"\n"
1708
-"\n"
1709
-"\n"
1710
-"\n"
17111723
"proc try {args} {\n"
17121724
" set catchopts {}\n"
17131725
" while {[string match -* [lindex $args 0]]} {\n"
17141726
" set args [lassign $args opt]\n"
17151727
" if {$opt eq \"--\"} {\n"
@@ -1780,10 +1792,13 @@
17801792
"}\n"
17811793
);
17821794
}
17831795
17841796
1797
+#ifndef _GNU_SOURCE
1798
+#define _GNU_SOURCE
1799
+#endif
17851800
#include <stdio.h>
17861801
#include <string.h>
17871802
#include <errno.h>
17881803
#include <fcntl.h>
17891804
#ifdef HAVE_UNISTD_H
@@ -1807,13 +1822,16 @@
18071822
#if defined(JIM_SSL)
18081823
#include <openssl/ssl.h>
18091824
#include <openssl/err.h>
18101825
#endif
18111826
1827
+#ifdef HAVE_TERMIOS_H
1828
+#endif
18121829
1813
-#define AIO_CMD_LEN 32
1814
-#define AIO_BUF_LEN 256
1830
+
1831
+#define AIO_CMD_LEN 32
1832
+#define AIO_BUF_LEN 256
18151833
18161834
#ifndef HAVE_FTELLO
18171835
#define ftello ftell
18181836
#endif
18191837
#ifndef HAVE_FSEEKO
@@ -1848,11 +1866,11 @@
18481866
typedef struct AioFile
18491867
{
18501868
FILE *fp;
18511869
Jim_Obj *filename;
18521870
int type;
1853
- int openFlags;
1871
+ int openFlags;
18541872
int fd;
18551873
Jim_Obj *rEvent;
18561874
Jim_Obj *wEvent;
18571875
Jim_Obj *eEvent;
18581876
int addr_family;
@@ -1879,21 +1897,21 @@
18791897
{
18801898
if (!ferror(af->fp)) {
18811899
return JIM_OK;
18821900
}
18831901
clearerr(af->fp);
1884
-
1902
+
18851903
if (feof(af->fp) || errno == EAGAIN || errno == EINTR) {
18861904
return JIM_OK;
18871905
}
18881906
#ifdef ECONNRESET
18891907
if (errno == ECONNRESET) {
18901908
return JIM_OK;
18911909
}
18921910
#endif
18931911
#ifdef ECONNABORTED
1894
- if (errno != ECONNABORTED) {
1912
+ if (errno == ECONNABORTED) {
18951913
return JIM_OK;
18961914
}
18971915
#endif
18981916
return JIM_ERR;
18991917
}
@@ -1945,20 +1963,19 @@
19451963
JIM_NOTUSED(interp);
19461964
19471965
Jim_DecrRefCount(interp, af->filename);
19481966
19491967
#ifdef jim_ext_eventloop
1950
-
1951
- Jim_DeleteFileHandler(interp, af->fp, JIM_EVENT_READABLE | JIM_EVENT_WRITABLE | JIM_EVENT_EXCEPTION);
1968
+
1969
+ Jim_DeleteFileHandler(interp, af->fd, JIM_EVENT_READABLE | JIM_EVENT_WRITABLE | JIM_EVENT_EXCEPTION);
19521970
#endif
19531971
19541972
#if defined(JIM_SSL)
19551973
if (af->ssl != NULL) {
19561974
SSL_free(af->ssl);
19571975
}
19581976
#endif
1959
-
19601977
if (!(af->openFlags & AIO_KEEPOPEN)) {
19611978
fclose(af->fp);
19621979
}
19631980
19641981
Jim_Free(af);
@@ -1968,11 +1985,11 @@
19681985
{
19691986
AioFile *af = Jim_CmdPrivData(interp);
19701987
char buf[AIO_BUF_LEN];
19711988
Jim_Obj *objPtr;
19721989
int nonewline = 0;
1973
- jim_wide neededLen = -1;
1990
+ jim_wide neededLen = -1;
19741991
19751992
if (argc && Jim_CompareStringImmediate(interp, argv[0], "-nonewline")) {
19761993
nonewline = 1;
19771994
argv++;
19781995
argc--;
@@ -2007,11 +2024,11 @@
20072024
}
20082025
}
20092026
if (retval != readlen)
20102027
break;
20112028
}
2012
-
2029
+
20132030
if (JimCheckStreamError(interp, af)) {
20142031
Jim_FreeNewObj(interp, objPtr);
20152032
return JIM_ERR;
20162033
}
20172034
if (nonewline) {
@@ -2029,11 +2046,11 @@
20292046
20302047
AioFile *Jim_AioFile(Jim_Interp *interp, Jim_Obj *command)
20312048
{
20322049
Jim_Cmd *cmdPtr = Jim_GetCommand(interp, command, JIM_ERRMSG);
20332050
2034
-
2051
+
20352052
if (cmdPtr && !cmdPtr->isproc && cmdPtr->u.native.cmdProc == JimAioSubCmdProc) {
20362053
return (AioFile *) cmdPtr->u.native.privData;
20372054
}
20382055
Jim_SetResultFormatted(interp, "Not a filehandle: \"%#s\"", command);
20392056
return NULL;
@@ -2110,21 +2127,21 @@
21102127
}
21112128
else {
21122129
len = strlen(buf);
21132130
21142131
if (len && (buf[len - 1] == '\n')) {
2115
-
2132
+
21162133
len--;
21172134
}
21182135
21192136
Jim_AppendString(interp, objPtr, buf, len);
21202137
break;
21212138
}
21222139
}
21232140
21242141
if (JimCheckStreamError(interp, af)) {
2125
-
2142
+
21262143
Jim_FreeNewObj(interp, objPtr);
21272144
return JIM_ERR;
21282145
}
21292146
21302147
if (argc) {
@@ -2134,11 +2151,11 @@
21342151
}
21352152
21362153
len = Jim_Length(objPtr);
21372154
21382155
if (len == 0 && feof(af->fp)) {
2139
-
2156
+
21402157
len = -1;
21412158
}
21422159
Jim_SetResultInt(interp, len);
21432160
}
21442161
else {
@@ -2364,33 +2381,33 @@
23642381
23652382
static int aio_eventinfo(Jim_Interp *interp, AioFile * af, unsigned mask, Jim_Obj **scriptHandlerObj,
23662383
int argc, Jim_Obj * const *argv)
23672384
{
23682385
if (argc == 0) {
2369
-
2386
+
23702387
if (*scriptHandlerObj) {
23712388
Jim_SetResult(interp, *scriptHandlerObj);
23722389
}
23732390
return JIM_OK;
23742391
}
23752392
23762393
if (*scriptHandlerObj) {
2377
-
2378
- Jim_DeleteFileHandler(interp, af->fp, mask);
2394
+
2395
+ Jim_DeleteFileHandler(interp, af->fd, mask);
23792396
}
23802397
2381
-
2398
+
23822399
if (Jim_Length(argv[0]) == 0) {
2383
-
2400
+
23842401
return JIM_OK;
23852402
}
23862403
2387
-
2404
+
23882405
Jim_IncrRefCount(argv[0]);
23892406
*scriptHandlerObj = argv[0];
23902407
2391
- Jim_CreateFileHandler(interp, af->fp, mask,
2408
+ Jim_CreateFileHandler(interp, af->fd, mask,
23922409
JimAioFileEventHandler, scriptHandlerObj, JimAioFileEventFinalizer);
23932410
23942411
return JIM_OK;
23952412
}
23962413
@@ -2414,136 +2431,138 @@
24142431
24152432
return aio_eventinfo(interp, af, JIM_EVENT_EXCEPTION, &af->eEvent, argc, argv);
24162433
}
24172434
#endif
24182435
2436
+
2437
+
24192438
24202439
static const jim_subcmd_type aio_command_table[] = {
24212440
{ "read",
24222441
"?-nonewline? ?len?",
24232442
aio_cmd_read,
24242443
0,
24252444
2,
2426
-
2445
+
24272446
},
24282447
{ "copyto",
24292448
"handle ?size?",
24302449
aio_cmd_copy,
24312450
1,
24322451
2,
2433
-
2452
+
24342453
},
24352454
{ "gets",
24362455
"?var?",
24372456
aio_cmd_gets,
24382457
0,
24392458
1,
2440
-
2459
+
24412460
},
24422461
{ "puts",
24432462
"?-nonewline? str",
24442463
aio_cmd_puts,
24452464
1,
24462465
2,
2447
-
2466
+
24482467
},
24492468
{ "isatty",
24502469
NULL,
24512470
aio_cmd_isatty,
24522471
0,
24532472
0,
2454
-
2473
+
24552474
},
24562475
{ "flush",
24572476
NULL,
24582477
aio_cmd_flush,
24592478
0,
24602479
0,
2461
-
2480
+
24622481
},
24632482
{ "eof",
24642483
NULL,
24652484
aio_cmd_eof,
24662485
0,
24672486
0,
2468
-
2487
+
24692488
},
24702489
{ "close",
24712490
"?r(ead)|w(rite)?",
24722491
aio_cmd_close,
24732492
0,
24742493
1,
24752494
JIM_MODFLAG_FULLARGV,
2476
-
2495
+
24772496
},
24782497
{ "seek",
24792498
"offset ?start|current|end",
24802499
aio_cmd_seek,
24812500
1,
24822501
2,
2483
-
2502
+
24842503
},
24852504
{ "tell",
24862505
NULL,
24872506
aio_cmd_tell,
24882507
0,
24892508
0,
2490
-
2509
+
24912510
},
24922511
{ "filename",
24932512
NULL,
24942513
aio_cmd_filename,
24952514
0,
24962515
0,
2497
-
2516
+
24982517
},
24992518
#ifdef O_NDELAY
25002519
{ "ndelay",
25012520
"?0|1?",
25022521
aio_cmd_ndelay,
25032522
0,
25042523
1,
2505
-
2524
+
25062525
},
25072526
#endif
25082527
#ifdef HAVE_FSYNC
25092528
{ "sync",
25102529
NULL,
25112530
aio_cmd_sync,
25122531
0,
25132532
0,
2514
-
2533
+
25152534
},
25162535
#endif
25172536
{ "buffering",
25182537
"none|line|full",
25192538
aio_cmd_buffering,
25202539
1,
25212540
1,
2522
-
2541
+
25232542
},
25242543
#ifdef jim_ext_eventloop
25252544
{ "readable",
25262545
"?readable-script?",
25272546
aio_cmd_readable,
25282547
0,
25292548
1,
2530
-
2549
+
25312550
},
25322551
{ "writable",
25332552
"?writable-script?",
25342553
aio_cmd_writable,
25352554
0,
25362555
1,
2537
-
2556
+
25382557
},
25392558
{ "onexception",
25402559
"?exception-script?",
25412560
aio_cmd_onexception,
25422561
0,
25432562
1,
2544
-
2563
+
25452564
},
25462565
#endif
25472566
{ NULL }
25482567
};
25492568
@@ -2566,11 +2585,11 @@
25662585
25672586
#ifdef jim_ext_tclcompat
25682587
{
25692588
const char *filename = Jim_String(argv[1]);
25702589
2571
-
2590
+
25722591
if (*filename == '|') {
25732592
Jim_Obj *evalObj[3];
25742593
25752594
evalObj[0] = Jim_NewStringObj(interp, "::popen", -1);
25762595
evalObj[1] = Jim_NewStringObj(interp, filename + 1, -1);
@@ -2623,11 +2642,11 @@
26232642
Jim_DecrRefCount(interp, filename);
26242643
return NULL;
26252644
}
26262645
}
26272646
2628
-
2647
+
26292648
af = Jim_Alloc(sizeof(*af));
26302649
memset(af, 0, sizeof(*af));
26312650
af->fp = fh;
26322651
af->fd = fileno(fh);
26332652
af->filename = filename;
@@ -2661,27 +2680,27 @@
26612680
Jim_SetResult(interp, objPtr);
26622681
return JIM_OK;
26632682
}
26642683
}
26652684
2666
-
2685
+
26672686
close(p[0]);
26682687
close(p[1]);
26692688
JimAioSetError(interp, NULL);
26702689
return JIM_ERR;
26712690
}
26722691
#endif
26732692
26742693
2675
-int Jim_MakeTempFile(Jim_Interp *interp, const char *template)
2694
+int Jim_MakeTempFile(Jim_Interp *interp, const char *filename_template)
26762695
{
26772696
#ifdef HAVE_MKSTEMP
26782697
int fd;
26792698
mode_t mask;
26802699
Jim_Obj *filenameObj;
26812700
2682
- if (template == NULL) {
2701
+ if (filename_template == NULL) {
26832702
const char *tmpdir = getenv("TMPDIR");
26842703
if (tmpdir == NULL || *tmpdir == '\0' || access(tmpdir, W_OK) != 0) {
26852704
tmpdir = "/tmp/";
26862705
}
26872706
filenameObj = Jim_NewStringObj(interp, tmpdir, -1);
@@ -2689,21 +2708,15 @@
26892708
Jim_AppendString(interp, filenameObj, "/", 1);
26902709
}
26912710
Jim_AppendString(interp, filenameObj, "tcl.tmp.XXXXXX", -1);
26922711
}
26932712
else {
2694
- filenameObj = Jim_NewStringObj(interp, template, -1);
2713
+ filenameObj = Jim_NewStringObj(interp, filename_template, -1);
26952714
}
26962715
2697
-#if defined(S_IRWXG) && defined(S_IRWXO)
2716
+
26982717
mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
2699
-#else
2700
-
2701
- mask = umask(S_IXUSR);
2702
-#endif
2703
-
2704
-
27052718
fd = mkstemp(filenameObj->bytes);
27062719
umask(mask);
27072720
if (fd < 0) {
27082721
JimAioSetError(interp, filenameObj);
27092722
Jim_FreeNewObj(interp, filenameObj);
@@ -2731,11 +2744,11 @@
27312744
Jim_CreateCommand(interp, "open", JimAioOpenCommand, NULL, NULL);
27322745
#ifndef JIM_ANSIC
27332746
Jim_CreateCommand(interp, "socket", JimAioSockCommand, NULL, NULL);
27342747
#endif
27352748
2736
-
2749
+
27372750
JimMakeChannel(interp, stdin, -1, NULL, "stdin", 0, "r");
27382751
JimMakeChannel(interp, stdout, -1, NULL, "stdout", 0, "w");
27392752
JimMakeChannel(interp, stderr, -1, NULL, "stderr", 0, "w");
27402753
27412754
return JIM_OK;
@@ -2831,20 +2844,20 @@
28312844
{
28322845
regex_t *compre;
28332846
const char *pattern;
28342847
int ret;
28352848
2836
-
2849
+
28372850
if (objPtr->typePtr == &regexpObjType &&
28382851
objPtr->internalRep.regexpValue.compre && objPtr->internalRep.regexpValue.flags == flags) {
2839
-
2852
+
28402853
return objPtr->internalRep.regexpValue.compre;
28412854
}
28422855
2843
-
28442856
2845
-
2857
+
2858
+
28462859
pattern = Jim_String(objPtr);
28472860
compre = Jim_Alloc(sizeof(regex_t));
28482861
28492862
if ((ret = regcomp(compre, pattern, REG_EXTENDED | flags)) != 0) {
28502863
char buf[100];
@@ -3001,11 +3014,11 @@
30013014
}
30023015
30033016
num_matches++;
30043017
30053018
if (opt_all && !opt_inline) {
3006
-
3019
+
30073020
goto try_next_match;
30083021
}
30093022
30103023
30113024
j = 0;
@@ -3041,11 +3054,11 @@
30413054
30423055
if (opt_inline) {
30433056
Jim_ListAppendElement(interp, resultListObj, resultObj);
30443057
}
30453058
else {
3046
-
3059
+
30473060
result = Jim_SetVariable(interp, argv[i], resultObj);
30483061
30493062
if (result != JIM_OK) {
30503063
Jim_FreeObj(interp, resultObj);
30513064
break;
@@ -3168,11 +3181,11 @@
31683181
31693182
source_str = Jim_GetString(argv[i + 1], &source_len);
31703183
replace_str = Jim_GetString(argv[i + 2], &replace_len);
31713184
varname = argv[i + 3];
31723185
3173
-
3186
+
31743187
resultObj = Jim_NewStringObj(interp, "", 0);
31753188
31763189
if (offset) {
31773190
if (offset < 0) {
31783191
offset += source_len + 1;
@@ -3183,11 +3196,11 @@
31833196
else if (offset < 0) {
31843197
offset = 0;
31853198
}
31863199
}
31873200
3188
-
3201
+
31893202
Jim_AppendString(interp, resultObj, source_str, offset);
31903203
31913204
31923205
n = source_len - offset;
31933206
p = source_str + offset;
@@ -3242,23 +3255,23 @@
32423255
}
32433256
32443257
p += pmatch[0].rm_eo;
32453258
n -= pmatch[0].rm_eo;
32463259
3247
-
3260
+
32483261
if (!opt_all || n == 0) {
32493262
break;
32503263
}
32513264
3252
-
3265
+
32533266
if ((regcomp_flags & REG_NEWLINE) == 0 && pattern[0] == '^') {
32543267
break;
32553268
}
32563269
3257
-
3270
+
32583271
if (pattern[0] == '\0' && n) {
3259
-
3272
+
32603273
Jim_AppendString(interp, resultObj, p, 1);
32613274
p++;
32623275
n--;
32633276
}
32643277
@@ -3265,11 +3278,11 @@
32653278
regexec_flags |= REG_NOTBOL;
32663279
} while (n);
32673280
32683281
Jim_AppendString(interp, resultObj, p, -1);
32693282
3270
-
3283
+
32713284
if (argc - i == 4) {
32723285
result = Jim_SetVariable(interp, varname, resultObj);
32733286
32743287
if (result == JIM_OK) {
32753288
Jim_SetResultInt(interp, num_matches);
@@ -3371,11 +3384,11 @@
33713384
Jim_ListAppendElement(interp, listObj, Jim_NewIntObj(interp, value));
33723385
}
33733386
33743387
static int StoreStatData(Jim_Interp *interp, Jim_Obj *varName, const struct stat *sb)
33753388
{
3376
-
3389
+
33773390
Jim_Obj *listObj = Jim_NewListObj(interp, NULL, 0);
33783391
33793392
AppendStatElement(interp, listObj, "dev", sb->st_dev);
33803393
AppendStatElement(interp, listObj, "ino", sb->st_ino);
33813394
AppendStatElement(interp, listObj, "mode", sb->st_mode);
@@ -3387,36 +3400,38 @@
33873400
AppendStatElement(interp, listObj, "mtime", sb->st_mtime);
33883401
AppendStatElement(interp, listObj, "ctime", sb->st_ctime);
33893402
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, "type", -1));
33903403
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, JimGetFileType((int)sb->st_mode), -1));
33913404
3392
-
3405
+
33933406
if (varName) {
3394
- Jim_Obj *objPtr = Jim_GetVariable(interp, varName, JIM_NONE);
3407
+ Jim_Obj *objPtr;
3408
+ objPtr = Jim_GetVariable(interp, varName, JIM_NONE);
3409
+
33953410
if (objPtr) {
3396
- if (Jim_DictSize(interp, objPtr) < 0) {
3397
-
3411
+ Jim_Obj *objv[2];
3412
+
3413
+ objv[0] = objPtr;
3414
+ objv[1] = listObj;
3415
+
3416
+ objPtr = Jim_DictMerge(interp, 2, objv);
3417
+ if (objPtr == NULL) {
3418
+
33983419
Jim_SetResultFormatted(interp, "can't set \"%#s(dev)\": variable isn't array", varName);
33993420
Jim_FreeNewObj(interp, listObj);
34003421
return JIM_ERR;
34013422
}
34023423
3403
- if (Jim_IsShared(objPtr))
3404
- objPtr = Jim_DuplicateObj(interp, objPtr);
3405
-
3406
-
3407
- Jim_ListAppendList(interp, objPtr, listObj);
3408
- Jim_DictSize(interp, objPtr);
34093424
Jim_InvalidateStringRep(objPtr);
34103425
34113426
Jim_FreeNewObj(interp, listObj);
34123427
listObj = objPtr;
34133428
}
34143429
Jim_SetVariable(interp, varName, listObj);
34153430
}
34163431
3417
-
3432
+
34183433
Jim_SetResult(interp, listObj);
34193434
34203435
return JIM_OK;
34213436
}
34223437
@@ -3432,11 +3447,11 @@
34323447
}
34333448
else if (p == path) {
34343449
Jim_SetResultString(interp, "/", -1);
34353450
}
34363451
else if (ISWINDOWS && p[-1] == ':') {
3437
-
3452
+
34383453
Jim_SetResultString(interp, path, p - path + 1);
34393454
}
34403455
else {
34413456
Jim_SetResultString(interp, path, p - path);
34423457
}
@@ -3512,35 +3527,35 @@
35123527
char *newname = Jim_Alloc(MAXPATHLEN + 1);
35133528
char *last = newname;
35143529
35153530
*newname = 0;
35163531
3517
-
3532
+
35183533
for (i = 0; i < argc; i++) {
35193534
int len;
35203535
const char *part = Jim_GetString(argv[i], &len);
35213536
35223537
if (*part == '/') {
3523
-
3538
+
35243539
last = newname;
35253540
}
35263541
else if (ISWINDOWS && strchr(part, ':')) {
3527
-
3542
+
35283543
last = newname;
35293544
}
35303545
else if (part[0] == '.') {
35313546
if (part[1] == '/') {
35323547
part += 2;
35333548
len -= 2;
35343549
}
35353550
else if (part[1] == 0 && last != newname) {
3536
-
3551
+
35373552
continue;
35383553
}
35393554
}
35403555
3541
-
3556
+
35423557
if (last != newname && last[-1] != '/') {
35433558
*last++ = '/';
35443559
}
35453560
35463561
if (len) {
@@ -3551,22 +3566,22 @@
35513566
}
35523567
memcpy(last, part, len);
35533568
last += len;
35543569
}
35553570
3556
-
3571
+
35573572
if (last > newname + 1 && last[-1] == '/') {
3558
-
3573
+
35593574
if (!ISWINDOWS || !(last > newname + 2 && last[-2] == ':')) {
35603575
*--last = 0;
35613576
}
35623577
}
35633578
}
35643579
35653580
*last = 0;
35663581
3567
-
3582
+
35683583
35693584
Jim_SetResult(interp, Jim_NewStringObjNoAlloc(interp, newname, last - newname));
35703585
35713586
return JIM_OK;
35723587
}
@@ -3591,11 +3606,11 @@
35913606
static int file_cmd_executable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
35923607
{
35933608
#ifdef X_OK
35943609
return file_access(interp, argv[0], X_OK);
35953610
#else
3596
-
3611
+
35973612
Jim_SetResultBool(interp, 1);
35983613
return JIM_OK;
35993614
#endif
36003615
}
36013616
@@ -3616,11 +3631,11 @@
36163631
while (argc--) {
36173632
const char *path = Jim_String(argv[0]);
36183633
36193634
if (unlink(path) == -1 && errno != ENOENT) {
36203635
if (rmdir(path) == -1) {
3621
-
3636
+
36223637
if (!force || Jim_EvalPrefix(interp, "file delete force", 1, argv) != JIM_OK) {
36233638
Jim_SetResultFormatted(interp, "couldn't delete file \"%s\": %s", path,
36243639
strerror(errno));
36253640
return JIM_ERR;
36263641
}
@@ -3639,15 +3654,15 @@
36393654
36403655
static int mkdir_all(char *path)
36413656
{
36423657
int ok = 1;
36433658
3644
-
3659
+
36453660
goto first;
36463661
36473662
while (ok--) {
3648
-
3663
+
36493664
{
36503665
char *slash = strrchr(path, '/');
36513666
36523667
if (slash && slash != path) {
36533668
*slash = 0;
@@ -3660,24 +3675,24 @@
36603675
first:
36613676
if (MKDIR_DEFAULT(path) == 0) {
36623677
return 0;
36633678
}
36643679
if (errno == ENOENT) {
3665
-
3680
+
36663681
continue;
36673682
}
3668
-
3683
+
36693684
if (errno == EEXIST) {
36703685
struct stat sb;
36713686
36723687
if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
36733688
return 0;
36743689
}
3675
-
3690
+
36763691
errno = EEXIST;
36773692
}
3678
-
3693
+
36793694
break;
36803695
}
36813696
return -1;
36823697
}
36833698
@@ -3962,192 +3977,192 @@
39623977
{ "atime",
39633978
"name",
39643979
file_cmd_atime,
39653980
1,
39663981
1,
3967
-
3982
+
39683983
},
39693984
{ "mtime",
39703985
"name ?time?",
39713986
file_cmd_mtime,
39723987
1,
39733988
2,
3974
-
3989
+
39753990
},
39763991
{ "copy",
39773992
"?-force? source dest",
39783993
file_cmd_copy,
39793994
2,
39803995
3,
3981
-
3996
+
39823997
},
39833998
{ "dirname",
39843999
"name",
39854000
file_cmd_dirname,
39864001
1,
39874002
1,
3988
-
4003
+
39894004
},
39904005
{ "rootname",
39914006
"name",
39924007
file_cmd_rootname,
39934008
1,
39944009
1,
3995
-
4010
+
39964011
},
39974012
{ "extension",
39984013
"name",
39994014
file_cmd_extension,
40004015
1,
40014016
1,
4002
-
4017
+
40034018
},
40044019
{ "tail",
40054020
"name",
40064021
file_cmd_tail,
40074022
1,
40084023
1,
4009
-
4024
+
40104025
},
40114026
{ "normalize",
40124027
"name",
40134028
file_cmd_normalize,
40144029
1,
40154030
1,
4016
-
4031
+
40174032
},
40184033
{ "join",
40194034
"name ?name ...?",
40204035
file_cmd_join,
40214036
1,
40224037
-1,
4023
-
4038
+
40244039
},
40254040
{ "readable",
40264041
"name",
40274042
file_cmd_readable,
40284043
1,
40294044
1,
4030
-
4045
+
40314046
},
40324047
{ "writable",
40334048
"name",
40344049
file_cmd_writable,
40354050
1,
40364051
1,
4037
-
4052
+
40384053
},
40394054
{ "executable",
40404055
"name",
40414056
file_cmd_executable,
40424057
1,
40434058
1,
4044
-
4059
+
40454060
},
40464061
{ "exists",
40474062
"name",
40484063
file_cmd_exists,
40494064
1,
40504065
1,
4051
-
4066
+
40524067
},
40534068
{ "delete",
40544069
"?-force|--? name ...",
40554070
file_cmd_delete,
40564071
1,
40574072
-1,
4058
-
4073
+
40594074
},
40604075
{ "mkdir",
40614076
"dir ...",
40624077
file_cmd_mkdir,
40634078
1,
40644079
-1,
4065
-
4080
+
40664081
},
40674082
{ "tempfile",
40684083
"?template?",
40694084
file_cmd_tempfile,
40704085
0,
40714086
1,
4072
-
4087
+
40734088
},
40744089
{ "rename",
40754090
"?-force? source dest",
40764091
file_cmd_rename,
40774092
2,
40784093
3,
4079
-
4094
+
40804095
},
40814096
#if defined(HAVE_LINK) && defined(HAVE_SYMLINK)
40824097
{ "link",
40834098
"?-symbolic|-hard? newname target",
40844099
file_cmd_link,
40854100
2,
40864101
3,
4087
-
4102
+
40884103
},
40894104
#endif
40904105
#if defined(HAVE_READLINK)
40914106
{ "readlink",
40924107
"name",
40934108
file_cmd_readlink,
40944109
1,
40954110
1,
4096
-
4111
+
40974112
},
40984113
#endif
40994114
{ "size",
41004115
"name",
41014116
file_cmd_size,
41024117
1,
41034118
1,
4104
-
4119
+
41054120
},
41064121
{ "stat",
41074122
"name ?var?",
41084123
file_cmd_stat,
41094124
1,
41104125
2,
4111
-
4126
+
41124127
},
41134128
{ "lstat",
41144129
"name ?var?",
41154130
file_cmd_lstat,
41164131
1,
41174132
2,
4118
-
4133
+
41194134
},
41204135
{ "type",
41214136
"name",
41224137
file_cmd_type,
41234138
1,
41244139
1,
4125
-
4140
+
41264141
},
41274142
#ifdef HAVE_GETEUID
41284143
{ "owned",
41294144
"name",
41304145
file_cmd_owned,
41314146
1,
41324147
1,
4133
-
4148
+
41344149
},
41354150
#endif
41364151
{ "isdirectory",
41374152
"name",
41384153
file_cmd_isdirectory,
41394154
1,
41404155
1,
4141
-
4156
+
41424157
},
41434158
{ "isfile",
41444159
"name",
41454160
file_cmd_isfile,
41464161
1,
41474162
1,
4148
-
4163
+
41494164
},
41504165
{
41514166
NULL
41524167
}
41534168
};
@@ -4179,11 +4194,11 @@
41794194
Jim_SetResultString(interp, "Failed to get pwd", -1);
41804195
Jim_Free(cwd);
41814196
return JIM_ERR;
41824197
}
41834198
else if (ISWINDOWS) {
4184
-
4199
+
41854200
char *p = cwd;
41864201
while ((p = strchr(p, '\\')) != NULL) {
41874202
*p++ = '/';
41884203
}
41894204
}
@@ -4203,10 +4218,13 @@
42034218
Jim_CreateCommand(interp, "pwd", Jim_PwdCmd, NULL, NULL);
42044219
Jim_CreateCommand(interp, "cd", Jim_CdCmd, NULL, NULL);
42054220
return JIM_OK;
42064221
}
42074222
4223
+#ifndef _GNU_SOURCE
4224
+#define _GNU_SOURCE
4225
+#endif
42084226
#include <string.h>
42094227
#include <ctype.h>
42104228
42114229
42124230
#if (!defined(HAVE_VFORK) || !defined(HAVE_WAITPID)) && !defined(__MINGW32__)
@@ -4214,20 +4232,20 @@
42144232
{
42154233
Jim_Obj *cmdlineObj = Jim_NewEmptyStringObj(interp);
42164234
int i, j;
42174235
int rc;
42184236
4219
-
4237
+
42204238
for (i = 1; i < argc; i++) {
42214239
int len;
42224240
const char *arg = Jim_GetString(argv[i], &len);
42234241
42244242
if (i > 1) {
42254243
Jim_AppendString(interp, cmdlineObj, " ", 1);
42264244
}
42274245
if (strpbrk(arg, "\\\" ") == NULL) {
4228
-
4246
+
42294247
Jim_AppendString(interp, cmdlineObj, arg, len);
42304248
continue;
42314249
}
42324250
42334251
Jim_AppendString(interp, cmdlineObj, "\"", 1);
@@ -4268,11 +4286,11 @@
42684286
42694287
#include <errno.h>
42704288
#include <signal.h>
42714289
42724290
#if defined(__MINGW32__)
4273
-
4291
+
42744292
#ifndef STRICT
42754293
#define STRICT
42764294
#endif
42774295
#define WIN32_LEAN_AND_MEAN
42784296
#include <windows.h>
@@ -4294,11 +4312,11 @@
42944312
static pidtype JimWaitPid(pidtype pid, int *status, int nohang);
42954313
static fdtype JimDupFd(fdtype infd);
42964314
static fdtype JimOpenForRead(const char *filename);
42974315
static FILE *JimFdOpenForRead(fdtype fd);
42984316
static int JimPipe(fdtype pipefd[2]);
4299
- static pidtype JimStartWinProcess(Jim_Interp *interp, char **argv, char *env,
4317
+ static pidtype JimStartWinProcess(Jim_Interp *interp, char **argv, char **env,
43004318
fdtype inputId, fdtype outputId, fdtype errorId);
43014319
static int JimErrno(void);
43024320
#else
43034321
#include <unistd.h>
43044322
#include <fcntl.h>
@@ -4323,10 +4341,11 @@
43234341
#define execvpe(ARG0, ARGV, ENV) execvp(ARG0, ARGV)
43244342
#endif
43254343
#endif
43264344
43274345
static const char *JimStrError(void);
4346
+static char **JimOriginalEnviron(void);
43284347
static char **JimSaveEnv(char **env);
43294348
static void JimRestoreEnv(char **env);
43304349
static int JimCreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv,
43314350
pidtype **pidArrayPtr, fdtype *inPipePtr, fdtype *outPipePtr, fdtype *errFilePtr);
43324351
static void JimDetachPids(Jim_Interp *interp, int numPids, const pidtype *pidPtr);
@@ -4390,18 +4409,18 @@
43904409
char *envdata;
43914410
43924411
Jim_Obj *objPtr = Jim_GetGlobalVariableStr(interp, "env", JIM_NONE);
43934412
43944413
if (!objPtr) {
4395
- return Jim_GetEnviron();
4414
+ return JimOriginalEnviron();
43964415
}
43974416
43984417
4399
-
4418
+
44004419
num = Jim_ListLength(interp, objPtr);
44014420
if (num % 2) {
4402
-
4421
+
44034422
num--;
44044423
}
44054424
size = Jim_Length(objPtr) + 2;
44064425
44074426
envptr = Jim_Alloc(sizeof(*envptr) * (num / 2 + 1) + size);
@@ -4493,19 +4512,19 @@
44934512
}
44944513
44954514
44964515
struct WaitInfo
44974516
{
4498
- pidtype pid;
4499
- int status;
4500
- int flags;
4517
+ pidtype pid;
4518
+ int status;
4519
+ int flags;
45014520
};
45024521
45034522
struct WaitInfoTable {
4504
- struct WaitInfo *info;
4505
- int size;
4506
- int used;
4523
+ struct WaitInfo *info;
4524
+ int size;
4525
+ int used;
45074526
};
45084527
45094528
45104529
#define WI_DETACHED 2
45114530
@@ -4528,12 +4547,12 @@
45284547
return table;
45294548
}
45304549
45314550
static int Jim_ExecCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
45324551
{
4533
- fdtype outputId;
4534
- fdtype errorId;
4552
+ fdtype outputId;
4553
+ fdtype errorId;
45354554
pidtype *pidPtr;
45364555
int numPids, result;
45374556
int child_siginfo = 1;
45384557
Jim_Obj *childErrObj;
45394558
Jim_Obj *errStrObj;
@@ -4545,11 +4564,11 @@
45454564
argc--;
45464565
numPids = JimCreatePipeline(interp, argc - 1, argv + 1, &pidPtr, NULL, NULL, NULL);
45474566
if (numPids < 0) {
45484567
return JIM_ERR;
45494568
}
4550
-
4569
+
45514570
listObj = Jim_NewListObj(interp, NULL, 0);
45524571
for (i = 0; i < numPids; i++) {
45534572
Jim_ListAppendElement(interp, listObj, Jim_NewIntObj(interp, (long)pidPtr[i]));
45544573
}
45554574
Jim_SetResult(interp, listObj);
@@ -4567,19 +4586,19 @@
45674586
45684587
result = JIM_OK;
45694588
45704589
errStrObj = Jim_NewStringObj(interp, "", 0);
45714590
4572
-
4591
+
45734592
if (outputId != JIM_BAD_FD) {
45744593
if (JimAppendStreamToString(interp, outputId, errStrObj) < 0) {
45754594
result = JIM_ERR;
45764595
Jim_SetResultErrno(interp, "error reading from output pipe");
45774596
}
45784597
}
45794598
4580
-
4599
+
45814600
childErrObj = Jim_NewStringObj(interp, "", 0);
45824601
Jim_IncrRefCount(childErrObj);
45834602
45844603
if (JimCleanupChildren(interp, numPids, pidPtr, childErrObj) != JIM_OK) {
45854604
result = JIM_ERR;
@@ -4592,25 +4611,25 @@
45924611
if (ret < 0) {
45934612
Jim_SetResultErrno(interp, "error reading from error pipe");
45944613
result = JIM_ERR;
45954614
}
45964615
else if (ret > 0) {
4597
-
4616
+
45984617
child_siginfo = 0;
45994618
}
46004619
}
46014620
46024621
if (child_siginfo) {
4603
-
4622
+
46044623
Jim_AppendObj(interp, errStrObj, childErrObj);
46054624
}
46064625
Jim_DecrRefCount(interp, childErrObj);
46074626
4608
-
4627
+
46094628
Jim_RemoveTrailingNewline(errStrObj);
46104629
4611
-
4630
+
46124631
Jim_SetResult(interp, errStrObj);
46134632
46144633
return result;
46154634
}
46164635
@@ -4629,11 +4648,11 @@
46294648
for (count = table->used; count > 0; waitPtr++, count--) {
46304649
if (waitPtr->flags & WI_DETACHED) {
46314650
int status;
46324651
pidtype pid = JimWaitPid(waitPtr->pid, &status, WNOHANG);
46334652
if (pid == waitPtr->pid) {
4634
-
4653
+
46354654
table->used--;
46364655
continue;
46374656
}
46384657
}
46394658
if (waitPtr != &table->info[dest]) {
@@ -4645,36 +4664,36 @@
46454664
46464665
static pidtype JimWaitForProcess(struct WaitInfoTable *table, pidtype pid, int *statusPtr)
46474666
{
46484667
int i;
46494668
4650
-
4669
+
46514670
for (i = 0; i < table->used; i++) {
46524671
if (pid == table->info[i].pid) {
4653
-
4672
+
46544673
JimWaitPid(pid, statusPtr, 0);
46554674
4656
-
4675
+
46574676
if (i != table->used - 1) {
46584677
table->info[i] = table->info[table->used - 1];
46594678
}
46604679
table->used--;
46614680
return pid;
46624681
}
46634682
}
46644683
4665
-
4684
+
46664685
return JIM_BAD_PID;
46674686
}
46684687
46694688
static void JimDetachPids(Jim_Interp *interp, int numPids, const pidtype *pidPtr)
46704689
{
46714690
int j;
46724691
struct WaitInfoTable *table = Jim_CmdPrivData(interp);
46734692
46744693
for (j = 0; j < numPids; j++) {
4675
-
4694
+
46764695
int i;
46774696
for (i = 0; i < table->used; i++) {
46784697
if (pidPtr[j] == table->info[i].pid) {
46794698
table->info[i].flags |= WI_DETACHED;
46804699
break;
@@ -4707,16 +4726,16 @@
47074726
int cmdCount; /* Count of number of distinct commands
47084727
* found in argc/argv. */
47094728
const char *input = NULL; /* Describes input for pipeline, depending
47104729
* on "inputFile". NULL means take input
47114730
* from stdin/pipe. */
4712
- int input_len = 0;
4731
+ int input_len = 0;
47134732
4714
-#define FILE_NAME 0
4715
-#define FILE_APPEND 1
4716
-#define FILE_HANDLE 2
4717
-#define FILE_TEXT 3
4733
+#define FILE_NAME 0
4734
+#define FILE_APPEND 1
4735
+#define FILE_HANDLE 2
4736
+#define FILE_TEXT 3
47184737
47194738
int inputFile = FILE_NAME; /* 1 means input is name of input file.
47204739
* 2 means input is filehandle name.
47214740
* 0 means input holds actual
47224741
* text to be input to command. */
@@ -4737,20 +4756,20 @@
47374756
* or NULL if stderr goes to stderr/pipe. */
47384757
fdtype inputId = JIM_BAD_FD;
47394758
fdtype outputId = JIM_BAD_FD;
47404759
fdtype errorId = JIM_BAD_FD;
47414760
fdtype lastOutputId = JIM_BAD_FD;
4742
- fdtype pipeIds[2];
4761
+ fdtype pipeIds[2];
47434762
int firstArg, lastArg; /* Indexes of first and last arguments in
47444763
* current command. */
47454764
int lastBar;
47464765
int i;
47474766
pidtype pid;
47484767
char **save_environ;
47494768
struct WaitInfoTable *table = Jim_CmdPrivData(interp);
47504769
4751
-
4770
+
47524771
char **arg_array = Jim_Alloc(sizeof(*arg_array) * (argc + 1));
47534772
int arg_count = 0;
47544773
47554774
JimReapDetachedPids(table);
47564775
@@ -4796,11 +4815,11 @@
47964815
if (*output == '>') {
47974816
outputFile = FILE_APPEND;
47984817
output++;
47994818
}
48004819
if (*output == '&') {
4801
-
4820
+
48024821
output++;
48034822
dup_error = 1;
48044823
}
48054824
if (*output == '@') {
48064825
outputFile = FILE_HANDLE;
@@ -4837,11 +4856,11 @@
48374856
goto badargs;
48384857
}
48394858
lastBar = i;
48404859
cmdCount++;
48414860
}
4842
-
4861
+
48434862
arg_array[arg_count++] = (char *)arg;
48444863
continue;
48454864
}
48464865
48474866
if (i >= argc) {
@@ -4855,11 +4874,11 @@
48554874
badargs:
48564875
Jim_Free(arg_array);
48574876
return -1;
48584877
}
48594878
4860
-
4879
+
48614880
save_environ = JimSaveEnv(JimBuildEnv(interp));
48624881
48634882
if (input != NULL) {
48644883
if (inputFile == FILE_TEXT) {
48654884
inputId = JimCreateTemp(interp, input, input_len);
@@ -4866,11 +4885,11 @@
48664885
if (inputId == JIM_BAD_FD) {
48674886
goto error;
48684887
}
48694888
}
48704889
else if (inputFile == FILE_HANDLE) {
4871
-
4890
+
48724891
FILE *fh = JimGetAioFilehandle(interp, input);
48734892
48744893
if (fh == NULL) {
48754894
goto error;
48764895
}
@@ -4918,20 +4937,20 @@
49184937
}
49194938
lastOutputId = pipeIds[1];
49204939
*outPipePtr = pipeIds[0];
49214940
pipeIds[0] = pipeIds[1] = JIM_BAD_FD;
49224941
}
4923
-
4942
+
49244943
if (error != NULL) {
49254944
if (errorFile == FILE_HANDLE) {
49264945
if (strcmp(error, "1") == 0) {
4927
-
4946
+
49284947
if (lastOutputId != JIM_BAD_FD) {
49294948
errorId = JimDupFd(lastOutputId);
49304949
}
49314950
else {
4932
-
4951
+
49334952
error = "stdout";
49344953
}
49354954
}
49364955
if (errorId == JIM_BAD_FD) {
49374956
FILE *fh = JimGetAioFilehandle(interp, error);
@@ -4973,11 +4992,11 @@
49734992
pipe_dup_err = 1;
49744993
}
49754994
break;
49764995
}
49774996
}
4978
-
4997
+
49794998
arg_array[lastArg] = NULL;
49804999
if (lastArg == arg_count) {
49815000
outputId = lastOutputId;
49825001
}
49835002
else {
@@ -4986,19 +5005,19 @@
49865005
goto error;
49875006
}
49885007
outputId = pipeIds[1];
49895008
}
49905009
4991
-
5010
+
49925011
if (pipe_dup_err) {
49935012
errorId = outputId;
49945013
}
49955014
4996
-
5015
+
49975016
49985017
#ifdef __MINGW32__
4999
- pid = JimStartWinProcess(interp, &arg_array[firstArg], save_environ ? save_environ[0] : NULL, inputId, outputId, errorId);
5018
+ pid = JimStartWinProcess(interp, &arg_array[firstArg], save_environ, inputId, outputId, errorId);
50005019
if (pid == JIM_BAD_PID) {
50015020
Jim_SetResultFormatted(interp, "couldn't exec \"%s\"", arg_array[firstArg]);
50025021
goto error;
50035022
}
50045023
#else
@@ -5006,32 +5025,39 @@
50065025
if (pid < 0) {
50075026
Jim_SetResultErrno(interp, "couldn't fork child process");
50085027
goto error;
50095028
}
50105029
if (pid == 0) {
5011
-
5030
+
50125031
50135032
if (inputId != -1) dup2(inputId, 0);
50145033
if (outputId != -1) dup2(outputId, 1);
50155034
if (errorId != -1) dup2(errorId, 2);
50165035
50175036
for (i = 3; (i <= outputId) || (i <= inputId) || (i <= errorId); i++) {
50185037
close(i);
50195038
}
50205039
5021
-
5040
+
50225041
(void)signal(SIGPIPE, SIG_DFL);
50235042
50245043
execvpe(arg_array[firstArg], &arg_array[firstArg], Jim_GetEnviron());
50255044
5026
-
5045
+
50275046
fprintf(stderr, "couldn't exec \"%s\"\n", arg_array[firstArg]);
5047
+#ifdef JIM_MAINTAINER
5048
+ {
5049
+
5050
+ static char *const false_argv[2] = {"false", NULL};
5051
+ execvp(false_argv[0],false_argv);
5052
+ }
5053
+#endif
50285054
_exit(127);
50295055
}
50305056
#endif
50315057
5032
-
5058
+
50335059
50345060
if (table->used == table->size) {
50355061
table->size += WAIT_TABLE_GROW_BY;
50365062
table->info = Jim_Realloc(table->info, table->size * sizeof(*table->info));
50375063
}
@@ -5040,19 +5066,20 @@
50405066
table->info[table->used].flags = 0;
50415067
table->used++;
50425068
50435069
pidPtr[numPids] = pid;
50445070
5045
-
5071
+
50465072
errorId = origErrorId;
50475073
50485074
50495075
if (inputId != JIM_BAD_FD) {
50505076
JimCloseFd(inputId);
50515077
}
50525078
if (outputId != JIM_BAD_FD) {
50535079
JimCloseFd(outputId);
5080
+ outputId = JIM_BAD_FD;
50545081
}
50555082
inputId = pipeIds[0];
50565083
pipeIds[0] = pipeIds[1] = JIM_BAD_FD;
50575084
}
50585085
*pidArrayPtr = pidPtr;
@@ -5111,11 +5138,11 @@
51115138
{
51125139
struct WaitInfoTable *table = Jim_CmdPrivData(interp);
51135140
int result = JIM_OK;
51145141
int i;
51155142
5116
-
5143
+
51175144
for (i = 0; i < numPids; i++) {
51185145
int waitStatus = 0;
51195146
if (JimWaitForProcess(table, pidPtr[i], &waitStatus) != JIM_BAD_PID) {
51205147
if (JimCheckWaitStatus(interp, pidPtr[i], waitStatus, errStrObj) != JIM_OK) {
51215148
result = JIM_ERR;
@@ -5284,17 +5311,21 @@
52845311
}
52855312
52865313
static fdtype JimOpenForRead(const char *filename)
52875314
{
52885315
return CreateFile(filename, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
5289
- JimStdSecAttrs(), OPEN_EXISTING, 0, NULL);
5316
+ JimStdSecAttrs(), OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
52905317
}
52915318
52925319
static fdtype JimOpenForWrite(const char *filename, int append)
52935320
{
5294
- return CreateFile(filename, append ? FILE_APPEND_DATA : GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
5295
- JimStdSecAttrs(), append ? OPEN_ALWAYS : CREATE_ALWAYS, 0, (HANDLE) NULL);
5321
+ fdtype fd = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
5322
+ JimStdSecAttrs(), append ? OPEN_ALWAYS : CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL);
5323
+ if (append && fd != JIM_BAD_FD) {
5324
+ SetFilePointer(fd, 0, NULL, FILE_END);
5325
+ }
5326
+ return fd;
52965327
}
52975328
52985329
static FILE *JimFdOpenForWrite(fdtype fd)
52995330
{
53005331
return _fdopen(_open_osfhandle((int)fd, _O_TEXT), "w");
@@ -5302,11 +5333,11 @@
53025333
53035334
static pidtype JimWaitPid(pidtype pid, int *status, int nohang)
53045335
{
53055336
DWORD ret = WaitForSingleObject(pid, nohang ? 0 : INFINITE);
53065337
if (ret == WAIT_TIMEOUT || ret == WAIT_FAILED) {
5307
-
5338
+
53085339
return JIM_BAD_PID;
53095340
}
53105341
GetExitCodeProcess(pid, &ret);
53115342
*status = ret;
53125343
CloseHandle(pid);
@@ -5329,11 +5360,11 @@
53295360
if (handle == INVALID_HANDLE_VALUE) {
53305361
goto error;
53315362
}
53325363
53335364
if (contents != NULL) {
5334
-
5365
+
53355366
FILE *fh = JimFdOpenForWrite(JimDupFd(handle));
53365367
if (fh == NULL) {
53375368
goto error;
53385369
}
53395370
@@ -5381,10 +5412,15 @@
53815412
53825413
static void JimRestoreEnv(char **env)
53835414
{
53845415
JimFreeEnv(env, Jim_GetEnviron());
53855416
}
5417
+
5418
+static char **JimOriginalEnviron(void)
5419
+{
5420
+ return NULL;
5421
+}
53865422
53875423
static Jim_Obj *
53885424
JimWinBuildCommandLine(Jim_Interp *interp, char **argv)
53895425
{
53905426
char *start, *special;
@@ -5455,18 +5491,19 @@
54555491
}
54565492
return strObj;
54575493
}
54585494
54595495
static pidtype
5460
-JimStartWinProcess(Jim_Interp *interp, char **argv, char *env, fdtype inputId, fdtype outputId, fdtype errorId)
5496
+JimStartWinProcess(Jim_Interp *interp, char **argv, char **env, fdtype inputId, fdtype outputId, fdtype errorId)
54615497
{
54625498
STARTUPINFO startInfo;
54635499
PROCESS_INFORMATION procInfo;
54645500
HANDLE hProcess, h;
54655501
char execPath[MAX_PATH];
54665502
pidtype pid = JIM_BAD_PID;
54675503
Jim_Obj *cmdLineObj;
5504
+ char *winenv;
54685505
54695506
if (JimWinFindExecutable(argv[0], execPath) < 0) {
54705507
return JIM_BAD_PID;
54715508
}
54725509
argv[0] = execPath;
@@ -5514,13 +5551,24 @@
55145551
0, TRUE, DUPLICATE_SAME_ACCESS);
55155552
}
55165553
if (startInfo.hStdError == JIM_BAD_FD) {
55175554
goto end;
55185555
}
5556
+
5557
+ if (env == NULL) {
5558
+
5559
+ winenv = NULL;
5560
+ }
5561
+ else if (env[0] == NULL) {
5562
+ winenv = (char *)"\0";
5563
+ }
5564
+ else {
5565
+ winenv = env[0];
5566
+ }
55195567
55205568
if (!CreateProcess(NULL, (char *)Jim_String(cmdLineObj), NULL, NULL, TRUE,
5521
- 0, env, NULL, &startInfo, &procInfo)) {
5569
+ 0, winenv, NULL, &startInfo, &procInfo)) {
55225570
goto end;
55235571
}
55245572
55255573
55265574
WaitForInputIdle(procInfo.hProcess, 5000);
@@ -5568,10 +5616,15 @@
55685616
lseek(fd, 0L, SEEK_SET);
55695617
}
55705618
}
55715619
return fd;
55725620
}
5621
+
5622
+static char **JimOriginalEnviron(void)
5623
+{
5624
+ return Jim_GetEnviron();
5625
+}
55735626
55745627
static char **JimSaveEnv(char **env)
55755628
{
55765629
char **saveenv = Jim_GetEnviron();
55775630
Jim_SetEnviron(env);
@@ -5601,11 +5654,11 @@
56015654
#include <sys/time.h>
56025655
#endif
56035656
56045657
static int clock_cmd_format(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
56055658
{
5606
-
5659
+
56075660
char buf[100];
56085661
time_t t;
56095662
long seconds;
56105663
56115664
const char *format = "%a %b %d %H:%M:%S %Z %Y";
@@ -5642,20 +5695,20 @@
56425695
56435696
if (!Jim_CompareStringImmediate(interp, argv[1], "-format")) {
56445697
return -1;
56455698
}
56465699
5647
-
5700
+
56485701
localtime_r(&now, &tm);
56495702
56505703
pt = strptime(Jim_String(argv[0]), Jim_String(argv[2]), &tm);
56515704
if (pt == 0 || *pt != 0) {
56525705
Jim_SetResultString(interp, "Failed to parse time according to format", -1);
56535706
return JIM_ERR;
56545707
}
56555708
5656
-
5709
+
56575710
Jim_SetResultInt(interp, mktime(&tm));
56585711
56595712
return JIM_OK;
56605713
}
56615714
#endif
@@ -5693,47 +5746,47 @@
56935746
{ "seconds",
56945747
NULL,
56955748
clock_cmd_seconds,
56965749
0,
56975750
0,
5698
-
5751
+
56995752
},
57005753
{ "clicks",
57015754
NULL,
57025755
clock_cmd_micros,
57035756
0,
57045757
0,
5705
-
5758
+
57065759
},
57075760
{ "microseconds",
57085761
NULL,
57095762
clock_cmd_micros,
57105763
0,
57115764
0,
5712
-
5765
+
57135766
},
57145767
{ "milliseconds",
57155768
NULL,
57165769
clock_cmd_millis,
57175770
0,
57185771
0,
5719
-
5772
+
57205773
},
57215774
{ "format",
57225775
"seconds ?-format format?",
57235776
clock_cmd_format,
57245777
1,
57255778
3,
5726
-
5779
+
57275780
},
57285781
#ifdef HAVE_STRPTIME
57295782
{ "scan",
57305783
"str -format format",
57315784
clock_cmd_scan,
57325785
3,
57335786
3,
5734
-
5787
+
57355788
},
57365789
#endif
57375790
{ NULL }
57385791
};
57395792
@@ -5753,12 +5806,13 @@
57535806
#include <errno.h>
57545807
57555808
57565809
static int array_cmd_exists(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
57575810
{
5758
-
5759
- Jim_SetResultInt(interp, Jim_GetVariable(interp, argv[0], 0) != 0);
5811
+
5812
+ Jim_Obj *dictObj = Jim_GetVariable(interp, argv[0], JIM_UNSHARED);
5813
+ Jim_SetResultInt(interp, dictObj && Jim_DictSize(interp, dictObj) != -1);
57605814
return JIM_OK;
57615815
}
57625816
57635817
static int array_cmd_get(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
57645818
{
@@ -5769,21 +5823,20 @@
57695823
return JIM_OK;
57705824
}
57715825
57725826
patternObj = (argc == 1) ? NULL : argv[1];
57735827
5774
-
5828
+
57755829
if (patternObj == NULL || Jim_CompareStringImmediate(interp, patternObj, "*")) {
57765830
if (Jim_IsList(objPtr) && Jim_ListLength(interp, objPtr) % 2 == 0) {
5777
-
5831
+
57785832
Jim_SetResult(interp, objPtr);
57795833
return JIM_OK;
57805834
}
57815835
}
57825836
5783
-
5784
- return Jim_DictValues(interp, objPtr, patternObj);
5837
+ return Jim_DictMatchTypes(interp, objPtr, patternObj, JIM_DICTMATCH_KEYS, JIM_DICTMATCH_KEYS | JIM_DICTMATCH_VALUES);
57855838
}
57865839
57875840
static int array_cmd_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
57885841
{
57895842
Jim_Obj *objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE);
@@ -5790,11 +5843,11 @@
57905843
57915844
if (!objPtr) {
57925845
return JIM_OK;
57935846
}
57945847
5795
- return Jim_DictKeys(interp, objPtr, argc == 1 ? NULL : argv[1]);
5848
+ return Jim_DictMatchTypes(interp, objPtr, argc == 1 ? NULL : argv[1], JIM_DICTMATCH_KEYS, JIM_DICTMATCH_KEYS);
57965849
}
57975850
57985851
static int array_cmd_unset(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
57995852
{
58005853
int i;
@@ -5802,27 +5855,29 @@
58025855
Jim_Obj *resultObj;
58035856
Jim_Obj *objPtr;
58045857
Jim_Obj **dictValuesObj;
58055858
58065859
if (argc == 1 || Jim_CompareStringImmediate(interp, argv[1], "*")) {
5807
-
5860
+
58085861
Jim_UnsetVariable(interp, argv[0], JIM_NONE);
58095862
return JIM_OK;
58105863
}
58115864
58125865
objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE);
58135866
58145867
if (objPtr == NULL) {
5815
-
5868
+
58165869
return JIM_OK;
58175870
}
58185871
58195872
if (Jim_DictPairs(interp, objPtr, &dictValuesObj, &len) != JIM_OK) {
5820
- return JIM_ERR;
5873
+
5874
+ Jim_SetResultString(interp, "", -1);
5875
+ return JIM_OK;
58215876
}
58225877
5823
-
5878
+
58245879
resultObj = Jim_NewDictObj(interp, NULL, 0);
58255880
58265881
for (i = 0; i < len; i += 2) {
58275882
if (!Jim_StringMatchObj(interp, argv[1], dictValuesObj[i], 0)) {
58285883
Jim_DictAddElement(interp, resultObj, dictValuesObj[i], dictValuesObj[i + 1]);
@@ -5837,16 +5892,18 @@
58375892
static int array_cmd_size(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
58385893
{
58395894
Jim_Obj *objPtr;
58405895
int len = 0;
58415896
5842
-
5897
+
58435898
objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE);
58445899
if (objPtr) {
58455900
len = Jim_DictSize(interp, objPtr);
58465901
if (len < 0) {
5847
- return JIM_ERR;
5902
+
5903
+ Jim_SetResultInt(interp, 0);
5904
+ return JIM_OK;
58485905
}
58495906
}
58505907
58515908
Jim_SetResultInt(interp, len);
58525909
@@ -5876,11 +5933,11 @@
58765933
return JIM_ERR;
58775934
}
58785935
58795936
dictObj = Jim_GetVariable(interp, argv[0], JIM_UNSHARED);
58805937
if (!dictObj) {
5881
-
5938
+
58825939
return Jim_SetVariable(interp, argv[0], listObj);
58835940
}
58845941
else if (Jim_DictSize(interp, dictObj) < 0) {
58855942
return JIM_ERR;
58865943
}
@@ -5905,53 +5962,53 @@
59055962
{ "exists",
59065963
"arrayName",
59075964
array_cmd_exists,
59085965
1,
59095966
1,
5910
-
5967
+
59115968
},
59125969
{ "get",
59135970
"arrayName ?pattern?",
59145971
array_cmd_get,
59155972
1,
59165973
2,
5917
-
5974
+
59185975
},
59195976
{ "names",
59205977
"arrayName ?pattern?",
59215978
array_cmd_names,
59225979
1,
59235980
2,
5924
-
5981
+
59255982
},
59265983
{ "set",
59275984
"arrayName list",
59285985
array_cmd_set,
59295986
2,
59305987
2,
5931
-
5988
+
59325989
},
59335990
{ "size",
59345991
"arrayName",
59355992
array_cmd_size,
59365993
1,
59375994
1,
5938
-
5995
+
59395996
},
59405997
{ "stat",
59415998
"arrayName",
59425999
array_cmd_stat,
59436000
1,
59446001
1,
5945
-
6002
+
59466003
},
59476004
{ "unset",
59486005
"arrayName ?pattern?",
59496006
array_cmd_unset,
59506007
1,
59516008
2,
5952
-
6009
+
59536010
},
59546011
{ NULL
59556012
}
59566013
};
59576014
@@ -5987,11 +6044,14 @@
59876044
Jim_arrayInit(interp);
59886045
Jim_stdlibInit(interp);
59896046
Jim_tclcompatInit(interp);
59906047
return JIM_OK;
59916048
}
5992
-#define JIM_OPTIMIZATION
6049
+#define JIM_OPTIMIZATION
6050
+#ifndef _GNU_SOURCE
6051
+#define _GNU_SOURCE
6052
+#endif
59936053
59946054
#include <stdio.h>
59956055
#include <stdlib.h>
59966056
59976057
#include <string.h>
@@ -6056,10 +6116,16 @@
60566116
#define JimPanic(X) JimPanicDump X
60576117
#else
60586118
#define JimPanic(X)
60596119
#endif
60606120
6121
+#ifdef JIM_OPTIMIZATION
6122
+#define JIM_IF_OPTIM(X) X
6123
+#else
6124
+#define JIM_IF_OPTIM(X)
6125
+#endif
6126
+
60616127
60626128
static char JimEmptyStringRep[] = "";
60636129
60646130
static void JimFreeCallFrame(Jim_Interp *interp, Jim_CallFrame *cf, int action);
60656131
static int ListSetIndex(Jim_Interp *interp, Jim_Obj *listPtr, int listindex, Jim_Obj *newObjPtr,
@@ -6112,34 +6178,34 @@
61126178
if (*pattern == '^') {
61136179
not++;
61146180
pattern++;
61156181
}
61166182
6117
-
6183
+
61186184
if (*pattern == ']') {
61196185
goto first;
61206186
}
61216187
}
61226188
61236189
while (*pattern && *pattern != ']') {
6124
-
6190
+
61256191
if (pattern[0] == '\\') {
61266192
first:
61276193
pattern += utf8_tounicode_case(pattern, &pchar, nocase);
61286194
}
61296195
else {
6130
-
6196
+
61316197
int start;
61326198
int end;
61336199
61346200
pattern += utf8_tounicode_case(pattern, &start, nocase);
61356201
if (pattern[0] == '-' && pattern[1]) {
6136
-
6202
+
61376203
pattern += utf8_tounicode(pattern, &pchar);
61386204
pattern += utf8_tounicode_case(pattern, &end, nocase);
61396205
6140
-
6206
+
61416207
if ((c >= start && c <= end) || (c >= end && c <= start)) {
61426208
match = 1;
61436209
}
61446210
continue;
61456211
}
@@ -6169,19 +6235,19 @@
61696235
while (pattern[1] == '*') {
61706236
pattern++;
61716237
}
61726238
pattern++;
61736239
if (!pattern[0]) {
6174
- return 1;
6240
+ return 1;
61756241
}
61766242
while (*string) {
6177
-
6243
+
61786244
if (JimGlobMatch(pattern, string, nocase))
6179
- return 1;
6245
+ return 1;
61806246
string += utf8_tounicode(string, &c);
61816247
}
6182
- return 0;
6248
+ return 0;
61836249
61846250
case '?':
61856251
string += utf8_tounicode(string, &c);
61866252
break;
61876253
@@ -6190,20 +6256,20 @@
61906256
pattern = JimCharsetMatch(pattern + 1, c, nocase ? JIM_NOCASE : 0);
61916257
if (!pattern) {
61926258
return 0;
61936259
}
61946260
if (!*pattern) {
6195
-
6261
+
61966262
continue;
61976263
}
61986264
break;
61996265
}
62006266
case '\\':
62016267
if (pattern[1]) {
62026268
pattern++;
62036269
}
6204
-
6270
+
62056271
default:
62066272
string += utf8_tounicode_case(string, &c, nocase);
62076273
utf8_tounicode_case(pattern, &pchar, nocase);
62086274
if (pchar != c) {
62096275
return 0;
@@ -6249,11 +6315,11 @@
62496315
maxchars--;
62506316
}
62516317
if (!maxchars) {
62526318
return 0;
62536319
}
6254
-
6320
+
62556321
if (*s1) {
62566322
return 1;
62576323
}
62586324
if (*s2) {
62596325
return -1;
@@ -6290,11 +6356,11 @@
62906356
const char *p;
62916357
62926358
if (!l1 || !l2 || l1 > l2)
62936359
return -1;
62946360
6295
-
6361
+
62966362
for (p = s2 + l2 - 1; p != s2 - 1; p--) {
62976363
if (*p == *s1 && memcmp(s1, p, l1) == 0) {
62986364
return p - s2;
62996365
}
63006366
}
@@ -6349,28 +6415,28 @@
63496415
}
63506416
*sign = 1;
63516417
}
63526418
63536419
if (str[i] != '0') {
6354
-
6420
+
63556421
return 0;
63566422
}
63576423
6358
-
6424
+
63596425
switch (str[i + 1]) {
63606426
case 'x': case 'X': *base = 16; break;
63616427
case 'o': case 'O': *base = 8; break;
63626428
case 'b': case 'B': *base = 2; break;
63636429
default: return 0;
63646430
}
63656431
i += 2;
6366
-
6432
+
63676433
if (str[i] != '-' && str[i] != '+' && !isspace(UCHAR(str[i]))) {
6368
-
6434
+
63696435
return i;
63706436
}
6371
-
6437
+
63726438
*base = 10;
63736439
return 0;
63746440
}
63756441
63766442
static long jim_strtol(const char *str, char **endptr)
@@ -6384,11 +6450,11 @@
63846450
if (endptr == NULL || *endptr != str + i) {
63856451
return value * sign;
63866452
}
63876453
}
63886454
6389
-
6455
+
63906456
return strtol(str, endptr, 10);
63916457
}
63926458
63936459
63946460
static jim_wide jim_strtoull(const char *str, char **endptr)
@@ -6403,11 +6469,11 @@
64036469
if (endptr == NULL || *endptr != str + i) {
64046470
return value * sign;
64056471
}
64066472
}
64076473
6408
-
6474
+
64096475
return strtoull(str, endptr, 10);
64106476
#else
64116477
return (unsigned long)jim_strtol(str, endptr);
64126478
#endif
64136479
}
@@ -6428,26 +6494,40 @@
64286494
64296495
int Jim_StringToDouble(const char *str, double *doublePtr)
64306496
{
64316497
char *endptr;
64326498
6433
-
6499
+
64346500
errno = 0;
64356501
64366502
*doublePtr = strtod(str, &endptr);
64376503
64386504
return JimCheckConversion(str, endptr);
64396505
}
64406506
64416507
static jim_wide JimPowWide(jim_wide b, jim_wide e)
64426508
{
6443
- jim_wide i, res = 1;
6509
+ jim_wide res = 1;
64446510
6445
- if ((b == 0 && e != 0) || (e < 0))
6446
- return 0;
6447
- for (i = 0; i < e; i++) {
6448
- res *= b;
6511
+
6512
+ if (b == 1) {
6513
+
6514
+ return 1;
6515
+ }
6516
+ if (e < 0) {
6517
+ if (b != -1) {
6518
+ return 0;
6519
+ }
6520
+ e = -e;
6521
+ }
6522
+ while (e)
6523
+ {
6524
+ if (e & 1) {
6525
+ res *= b;
6526
+ }
6527
+ e >>= 1;
6528
+ b *= b;
64496529
}
64506530
return res;
64516531
}
64526532
64536533
#ifdef JIM_DEBUG_PANIC
@@ -6509,11 +6589,11 @@
65096589
char *Jim_StrDupLen(const char *s, int l)
65106590
{
65116591
char *copy = Jim_Alloc(l + 1);
65126592
65136593
memcpy(copy, s, l + 1);
6514
- copy[l] = 0;
6594
+ copy[l] = 0;
65156595
return copy;
65166596
}
65176597
65186598
65196599
@@ -6598,52 +6678,52 @@
65986678
}
65996679
66006680
66016681
void Jim_ExpandHashTable(Jim_HashTable *ht, unsigned int size)
66026682
{
6603
- Jim_HashTable n;
6683
+ Jim_HashTable n;
66046684
unsigned int realsize = JimHashTableNextPower(size), i;
66056685
66066686
if (size <= ht->used)
66076687
return;
66086688
66096689
Jim_InitHashTable(&n, ht->type, ht->privdata);
66106690
n.size = realsize;
66116691
n.sizemask = realsize - 1;
66126692
n.table = Jim_Alloc(realsize * sizeof(Jim_HashEntry *));
6613
-
6693
+
66146694
n.uniq = ht->uniq;
66156695
6616
-
6696
+
66176697
memset(n.table, 0, realsize * sizeof(Jim_HashEntry *));
66186698
66196699
n.used = ht->used;
66206700
for (i = 0; ht->used > 0; i++) {
66216701
Jim_HashEntry *he, *nextHe;
66226702
66236703
if (ht->table[i] == NULL)
66246704
continue;
66256705
6626
-
6706
+
66276707
he = ht->table[i];
66286708
while (he) {
66296709
unsigned int h;
66306710
66316711
nextHe = he->next;
6632
-
6712
+
66336713
h = Jim_HashKey(ht, he->key) & n.sizemask;
66346714
he->next = n.table[h];
66356715
n.table[h] = he;
66366716
ht->used--;
6637
-
6717
+
66386718
he = nextHe;
66396719
}
66406720
}
66416721
assert(ht->used == 0);
66426722
Jim_Free(ht->table);
66436723
6644
-
6724
+
66456725
*ht = n;
66466726
}
66476727
66486728
66496729
int Jim_AddHashEntry(Jim_HashTable *ht, const void *key, void *val)
@@ -6652,11 +6732,11 @@
66526732
66536733
entry = JimInsertHashEntry(ht, key, 0);
66546734
if (entry == NULL)
66556735
return JIM_ERR;
66566736
6657
-
6737
+
66586738
Jim_SetHashKey(ht, entry, key);
66596739
Jim_SetHashVal(ht, entry, val);
66606740
return JIM_OK;
66616741
}
66626742
@@ -6678,11 +6758,11 @@
66786758
Jim_SetHashVal(ht, entry, val);
66796759
}
66806760
existed = 1;
66816761
}
66826762
else {
6683
-
6763
+
66846764
Jim_SetHashKey(ht, entry, key);
66856765
Jim_SetHashVal(ht, entry, val);
66866766
existed = 0;
66876767
}
66886768
@@ -6701,11 +6781,11 @@
67016781
he = ht->table[h];
67026782
67036783
prevHe = NULL;
67046784
while (he) {
67056785
if (Jim_CompareHashKeys(ht, key, he->key)) {
6706
-
6786
+
67076787
if (prevHe)
67086788
prevHe->next = he->next;
67096789
else
67106790
ht->table[h] = he->next;
67116791
Jim_FreeEntryKey(ht, he);
@@ -6715,19 +6795,19 @@
67156795
return JIM_OK;
67166796
}
67176797
prevHe = he;
67186798
he = he->next;
67196799
}
6720
- return JIM_ERR;
6800
+ return JIM_ERR;
67216801
}
67226802
67236803
67246804
int Jim_FreeHashTable(Jim_HashTable *ht)
67256805
{
67266806
unsigned int i;
67276807
6728
-
6808
+
67296809
for (i = 0; ht->used > 0; i++) {
67306810
Jim_HashEntry *he, *nextHe;
67316811
67326812
if ((he = ht->table[i]) == NULL)
67336813
continue;
@@ -6738,15 +6818,15 @@
67386818
Jim_Free(he);
67396819
ht->used--;
67406820
he = nextHe;
67416821
}
67426822
}
6743
-
6823
+
67446824
Jim_Free(ht->table);
6745
-
6825
+
67466826
JimResetHashTable(ht);
6747
- return JIM_OK;
6827
+ return JIM_OK;
67486828
}
67496829
67506830
Jim_HashEntry *Jim_FindHashEntry(Jim_HashTable *ht, const void *key)
67516831
{
67526832
Jim_HashEntry *he;
@@ -6819,24 +6899,24 @@
68196899
static Jim_HashEntry *JimInsertHashEntry(Jim_HashTable *ht, const void *key, int replace)
68206900
{
68216901
unsigned int h;
68226902
Jim_HashEntry *he;
68236903
6824
-
6904
+
68256905
JimExpandHashTableIfNeeded(ht);
68266906
6827
-
6907
+
68286908
h = Jim_HashKey(ht, key) & ht->sizemask;
6829
-
6909
+
68306910
he = ht->table[h];
68316911
while (he) {
68326912
if (Jim_CompareHashKeys(ht, key, he->key))
68336913
return replace ? he : NULL;
68346914
he = he->next;
68356915
}
68366916
6837
-
6917
+
68386918
he = Jim_Alloc(sizeof(*he));
68396919
he->next = ht->table[h];
68406920
ht->table[h] = he;
68416921
ht->used++;
68426922
he->key = NULL;
@@ -6865,16 +6945,16 @@
68656945
{
68666946
Jim_Free(key);
68676947
}
68686948
68696949
static const Jim_HashTableType JimPackageHashTableType = {
6870
- JimStringCopyHTHashFunction,
6871
- JimStringCopyHTDup,
6872
- NULL,
6873
- JimStringCopyHTKeyCompare,
6874
- JimStringCopyHTKeyDestructor,
6875
- NULL
6950
+ JimStringCopyHTHashFunction,
6951
+ JimStringCopyHTDup,
6952
+ NULL,
6953
+ JimStringCopyHTKeyCompare,
6954
+ JimStringCopyHTKeyDestructor,
6955
+ NULL
68766956
};
68776957
68786958
typedef struct AssocDataValue
68796959
{
68806960
Jim_InterpDeleteProc *delProc;
@@ -6889,16 +6969,16 @@
68896969
assocPtr->delProc((Jim_Interp *)privdata, assocPtr->data);
68906970
Jim_Free(data);
68916971
}
68926972
68936973
static const Jim_HashTableType JimAssocDataHashTableType = {
6894
- JimStringCopyHTHashFunction,
6895
- JimStringCopyHTDup,
6896
- NULL,
6897
- JimStringCopyHTKeyCompare,
6898
- JimStringCopyHTKeyDestructor,
6899
- JimAssocDataHashTableValueDestructor
6974
+ JimStringCopyHTHashFunction,
6975
+ JimStringCopyHTDup,
6976
+ NULL,
6977
+ JimStringCopyHTKeyCompare,
6978
+ JimStringCopyHTKeyDestructor,
6979
+ JimAssocDataHashTableValueDestructor
69006980
};
69016981
69026982
void Jim_InitStack(Jim_Stack *stack)
69036983
{
69046984
stack->len = 0;
@@ -6951,56 +7031,61 @@
69517031
freeFunc(stack->vector[i]);
69527032
}
69537033
69547034
69557035
6956
-#define JIM_TT_NONE 0
6957
-#define JIM_TT_STR 1
6958
-#define JIM_TT_ESC 2
6959
-#define JIM_TT_VAR 3
6960
-#define JIM_TT_DICTSUGAR 4
6961
-#define JIM_TT_CMD 5
6962
-
6963
-#define JIM_TT_SEP 6
6964
-#define JIM_TT_EOL 7
6965
-#define JIM_TT_EOF 8
6966
-
6967
-#define JIM_TT_LINE 9
6968
-#define JIM_TT_WORD 10
7036
+#define JIM_TT_NONE 0
7037
+#define JIM_TT_STR 1
7038
+#define JIM_TT_ESC 2
7039
+#define JIM_TT_VAR 3
7040
+#define JIM_TT_DICTSUGAR 4
7041
+#define JIM_TT_CMD 5
7042
+
7043
+#define JIM_TT_SEP 6
7044
+#define JIM_TT_EOL 7
7045
+#define JIM_TT_EOF 8
7046
+
7047
+#define JIM_TT_LINE 9
7048
+#define JIM_TT_WORD 10
69697049
69707050
69717051
#define JIM_TT_SUBEXPR_START 11
69727052
#define JIM_TT_SUBEXPR_END 12
69737053
#define JIM_TT_SUBEXPR_COMMA 13
69747054
#define JIM_TT_EXPR_INT 14
69757055
#define JIM_TT_EXPR_DOUBLE 15
7056
+#define JIM_TT_EXPR_BOOLEAN 16
69767057
6977
-#define JIM_TT_EXPRSUGAR 16
7058
+#define JIM_TT_EXPRSUGAR 17
69787059
69797060
69807061
#define JIM_TT_EXPR_OP 20
69817062
69827063
#define TOKEN_IS_SEP(type) (type >= JIM_TT_SEP && type <= JIM_TT_EOF)
69837064
7065
+#define TOKEN_IS_EXPR_START(type) (type == JIM_TT_NONE || type == JIM_TT_SUBEXPR_START || type == JIM_TT_SUBEXPR_COMMA)
7066
+
7067
+#define TOKEN_IS_EXPR_OP(type) (type >= JIM_TT_EXPR_OP)
7068
+
69847069
struct JimParseMissing {
6985
- int ch;
6986
- int line;
7070
+ int ch;
7071
+ int line;
69877072
};
69887073
69897074
struct JimParserCtx
69907075
{
6991
- const char *p;
6992
- int len;
6993
- int linenr;
7076
+ const char *p;
7077
+ int len;
7078
+ int linenr;
69947079
const char *tstart;
6995
- const char *tend;
6996
- int tline;
6997
- int tt;
6998
- int eof;
6999
- int inquote;
7000
- int comment;
7001
- struct JimParseMissing missing;
7080
+ const char *tend;
7081
+ int tline;
7082
+ int tt;
7083
+ int eof;
7084
+ int inquote;
7085
+ int comment;
7086
+ struct JimParseMissing missing;
70027087
};
70037088
70047089
static int JimParseScript(struct JimParserCtx *pc);
70057090
static int JimParseSep(struct JimParserCtx *pc);
70067091
static int JimParseEol(struct JimParserCtx *pc);
@@ -7030,11 +7115,11 @@
70307115
pc->missing.line = linenr;
70317116
}
70327117
70337118
static int JimParseScript(struct JimParserCtx *pc)
70347119
{
7035
- while (1) {
7120
+ while (1) {
70367121
if (!pc->len) {
70377122
pc->tstart = pc->p;
70387123
pc->tend = pc->p - 1;
70397124
pc->tline = pc->linenr;
70407125
pc->tt = JIM_TT_EOL;
@@ -7066,11 +7151,11 @@
70667151
pc->comment = 0;
70677152
return JimParseCmd(pc);
70687153
case '$':
70697154
pc->comment = 0;
70707155
if (JimParseVar(pc) == JIM_ERR) {
7071
-
7156
+
70727157
pc->tstart = pc->tend = pc->p++;
70737158
pc->len--;
70747159
pc->tt = JIM_TT_ESC;
70757160
}
70767161
return JIM_OK;
@@ -7127,11 +7212,11 @@
71277212
71287213
static void JimParseSubBrace(struct JimParserCtx *pc)
71297214
{
71307215
int level = 1;
71317216
7132
-
7217
+
71337218
pc->p++;
71347219
pc->len--;
71357220
while (pc->len) {
71367221
switch (*pc->p) {
71377222
case '\\':
@@ -7171,11 +7256,11 @@
71717256
static int JimParseSubQuote(struct JimParserCtx *pc)
71727257
{
71737258
int tt = JIM_TT_STR;
71747259
int line = pc->tline;
71757260
7176
-
7261
+
71777262
pc->p++;
71787263
pc->len--;
71797264
while (pc->len) {
71807265
switch (*pc->p) {
71817266
case '\\':
@@ -7220,11 +7305,11 @@
72207305
{
72217306
int level = 1;
72227307
int startofword = 1;
72237308
int line = pc->tline;
72247309
7225
-
7310
+
72267311
pc->p++;
72277312
pc->len--;
72287313
while (pc->len) {
72297314
switch (*pc->p) {
72307315
case '\\':
@@ -7300,17 +7385,17 @@
73007385
return JIM_OK;
73017386
}
73027387
73037388
static int JimParseVar(struct JimParserCtx *pc)
73047389
{
7305
-
7390
+
73067391
pc->p++;
73077392
pc->len--;
73087393
73097394
#ifdef EXPRSUGAR_BRACKET
73107395
if (*pc->p == '[') {
7311
-
7396
+
73127397
JimParseCmd(pc);
73137398
pc->tt = JIM_TT_EXPRSUGAR;
73147399
return JIM_OK;
73157400
}
73167401
#endif
@@ -7336,11 +7421,11 @@
73367421
pc->len--;
73377422
}
73387423
}
73397424
else {
73407425
while (1) {
7341
-
7426
+
73427427
if (pc->p[0] == ':' && pc->p[1] == ':') {
73437428
while (*pc->p == ':') {
73447429
pc->p++;
73457430
pc->len--;
73467431
}
@@ -7351,11 +7436,11 @@
73517436
pc->len--;
73527437
continue;
73537438
}
73547439
break;
73557440
}
7356
-
7441
+
73577442
if (*pc->p == '(') {
73587443
int count = 1;
73597444
const char *paren = NULL;
73607445
73617446
pc->tt = JIM_TT_DICTSUGAR;
@@ -7378,11 +7463,11 @@
73787463
if (count == 0) {
73797464
pc->p++;
73807465
pc->len--;
73817466
}
73827467
else if (paren) {
7383
-
7468
+
73847469
paren++;
73857470
pc->len += (pc->p - paren);
73867471
pc->p = paren;
73877472
}
73887473
#ifndef EXPRSUGAR_BRACKET
@@ -7403,19 +7488,19 @@
74037488
74047489
static int JimParseStr(struct JimParserCtx *pc)
74057490
{
74067491
if (pc->tt == JIM_TT_SEP || pc->tt == JIM_TT_EOL ||
74077492
pc->tt == JIM_TT_NONE || pc->tt == JIM_TT_STR) {
7408
-
7493
+
74097494
if (*pc->p == '{') {
74107495
return JimParseBrace(pc);
74117496
}
74127497
if (*pc->p == '"') {
74137498
pc->inquote = 1;
74147499
pc->p++;
74157500
pc->len--;
7416
-
7501
+
74177502
pc->missing.line = pc->tline;
74187503
}
74197504
}
74207505
pc->tstart = pc->p;
74217506
pc->tline = pc->linenr;
@@ -7441,25 +7526,25 @@
74417526
}
74427527
pc->p++;
74437528
pc->len--;
74447529
}
74457530
else if (pc->len == 1) {
7446
-
7531
+
74477532
pc->missing.ch = '\\';
74487533
}
74497534
break;
74507535
case '(':
7451
-
7536
+
74527537
if (pc->len > 1 && pc->p[1] != '$') {
74537538
break;
74547539
}
7455
-
7540
+
74567541
case ')':
7457
-
7542
+
74587543
if (*pc->p == '(' || pc->tt == JIM_TT_VAR) {
74597544
if (pc->p == pc->tstart) {
7460
-
7545
+
74617546
pc->p++;
74627547
pc->len--;
74637548
}
74647549
pc->tend = pc->p - 1;
74657550
pc->tt = JIM_TT_ESC;
@@ -7499,11 +7584,11 @@
74997584
break;
75007585
}
75017586
pc->p++;
75027587
pc->len--;
75037588
}
7504
- return JIM_OK;
7589
+ return JIM_OK;
75057590
}
75067591
75077592
static int JimParseComment(struct JimParserCtx *pc)
75087593
{
75097594
while (*pc->p) {
@@ -7610,34 +7695,34 @@
76107695
if (c == -1) {
76117696
break;
76127697
}
76137698
val = (val << 4) | c;
76147699
}
7615
-
7700
+
76167701
if (s[i] == '{') {
76177702
if (k == 0 || val > 0x1fffff || s[i + k + 1] != '}') {
7618
-
7703
+
76197704
i--;
76207705
k = 0;
76217706
}
76227707
else {
7623
-
7708
+
76247709
k++;
76257710
}
76267711
}
76277712
if (k) {
7628
-
7713
+
76297714
if (s[i] == 'x') {
76307715
*p++ = val;
76317716
}
76327717
else {
76337718
p += utf8_fromunicode(p, val);
76347719
}
76357720
i += k;
76367721
break;
76377722
}
7638
-
7723
+
76397724
*p++ = s[i];
76407725
}
76417726
break;
76427727
case 'v':
76437728
*p++ = 0xb;
@@ -7646,11 +7731,11 @@
76467731
case '\0':
76477732
*p++ = '\\';
76487733
i++;
76497734
break;
76507735
case '\n':
7651
-
7736
+
76527737
*p++ = ' ';
76537738
do {
76547739
i++;
76557740
} while (s[i + 1] == ' ' || s[i + 1] == '\t');
76567741
break;
@@ -7660,11 +7745,11 @@
76607745
case '3':
76617746
case '4':
76627747
case '5':
76637748
case '6':
76647749
case '7':
7665
-
7750
+
76667751
{
76677752
int val = 0;
76687753
int c = odigitval(s[i + 1]);
76697754
76707755
val = c;
@@ -7717,16 +7802,16 @@
77177802
}
77187803
else {
77197804
len = (end - start) + 1;
77207805
token = Jim_Alloc(len + 1);
77217806
if (pc->tt != JIM_TT_ESC) {
7722
-
7807
+
77237808
memcpy(token, start, len);
77247809
token[len] = '\0';
77257810
}
77267811
else {
7727
-
7812
+
77287813
len = JimEscape(token, start, len);
77297814
}
77307815
}
77317816
77327817
return Jim_NewStringObjNoAlloc(interp, token, len);
@@ -7790,11 +7875,11 @@
77907875
while (pc->len) {
77917876
switch (*pc->p) {
77927877
case '\\':
77937878
pc->tt = JIM_TT_ESC;
77947879
if (--pc->len == 0) {
7795
-
7880
+
77967881
pc->tend = pc->p;
77977882
return JIM_OK;
77987883
}
77997884
pc->p++;
78007885
break;
@@ -7826,11 +7911,11 @@
78267911
pc->tend = pc->p - 1;
78277912
return JIM_OK;
78287913
}
78297914
if (*pc->p == '\\') {
78307915
if (--pc->len == 0) {
7831
-
7916
+
78327917
pc->tend = pc->p;
78337918
return JIM_OK;
78347919
}
78357920
pc->tt = JIM_TT_ESC;
78367921
pc->p++;
@@ -7846,24 +7931,24 @@
78467931
78477932
Jim_Obj *Jim_NewObj(Jim_Interp *interp)
78487933
{
78497934
Jim_Obj *objPtr;
78507935
7851
-
7936
+
78527937
if (interp->freeList != NULL) {
7853
-
7938
+
78547939
objPtr = interp->freeList;
78557940
interp->freeList = objPtr->nextObjPtr;
78567941
}
78577942
else {
7858
-
7943
+
78597944
objPtr = Jim_Alloc(sizeof(*objPtr));
78607945
}
78617946
78627947
objPtr->refCount = 0;
78637948
7864
-
7949
+
78657950
objPtr->prevObjPtr = NULL;
78667951
objPtr->nextObjPtr = interp->liveList;
78677952
if (interp->liveList)
78687953
interp->liveList->prevObjPtr = objPtr;
78697954
interp->liveList = objPtr;
@@ -7871,32 +7956,32 @@
78717956
return objPtr;
78727957
}
78737958
7874