Fossil SCM

Update autosetup to the latest version.

mistachkin 2014-06-12 20:21 trunk
Commit 022c5c4faf6aeea0c28bd73d790beb5b692348e7
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -925,11 +925,11 @@
925925
}
926926
927927
# Load module source in the global scope by executing the given command
928928
proc automf_load {args} {
929929
if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
930
- autosetup-full-error [error-dump $msg $opts]
930
+ autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
931931
}
932932
}
933933
934934
# Initial settings
935935
set autosetup(exe) $::argv0
@@ -1706,18 +1706,35 @@
17061706
return $msg
17071707
}
17081708
17091709
# Given the return from [catch {...} msg opts], returns an appropriate
17101710
# error message. A nice one for Jim and a less-nice one for Tcl.
1711
+# If 'fulltrace' is set, a full stack trace is provided.
1712
+# Otherwise a simple message is provided.
17111713
#
1712
-# This is designed for developer errors, e.g. in module code
1714
+# This is designed for developer errors, e.g. in module code or auto.def code
1715
+#
17131716
#
1714
-proc error-dump {msg opts} {
1717
+proc error-dump {msg opts fulltrace} {
17151718
if {$::autosetup(istcl)} {
1716
- return "Error: [dict get $opts -errorinfo]"
1719
+ if {$fulltrace} {
1720
+ return "Error: [dict get $opts -errorinfo]"
1721
+ } else {
1722
+ return "Error: $msg"
1723
+ }
17171724
} else {
1718
- return "Error: $msg\n[stackdump $opts(-errorinfo)]"
1725
+ lassign $opts(-errorinfo) p f l
1726
+ if {$f ne ""} {
1727
+ set result "$f:$l: Error: "
1728
+ }
1729
+ append result "$msg\n"
1730
+ if {$fulltrace} {
1731
+ append result [stackdump $opts(-errorinfo)]
1732
+ }
1733
+
1734
+ # Remove the trailing newline
1735
+ string trim $result
17191736
}
17201737
}
17211738
}
17221739
17231740
# ----- module text-formatting -----
@@ -1886,13 +1903,13 @@
18861903
# Entry/Exit
18871904
#
18881905
if {$autosetup(debug)} {
18891906
main $argv
18901907
}
1891
-if {[catch {main $argv} msg] == 1} {
1908
+if {[catch {main $argv} msg opts] == 1} {
18921909
show-notices
1893
- puts stderr [error-stacktrace $msg]
1894
- if {!$autosetup(debug) && !$autosetup(istcl)} {
1910
+ autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
1911
+ if {!$autosetup(debug)} {
18951912
puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
18961913
}
18971914
exit 1
18981915
}
18991916
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -925,11 +925,11 @@
925 }
926
927 # Load module source in the global scope by executing the given command
928 proc automf_load {args} {
929 if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
930 autosetup-full-error [error-dump $msg $opts]
931 }
932 }
933
934 # Initial settings
935 set autosetup(exe) $::argv0
@@ -1706,18 +1706,35 @@
1706 return $msg
1707 }
1708
1709 # Given the return from [catch {...} msg opts], returns an appropriate
1710 # error message. A nice one for Jim and a less-nice one for Tcl.
 
 
1711 #
1712 # This is designed for developer errors, e.g. in module code
 
1713 #
1714 proc error-dump {msg opts} {
1715 if {$::autosetup(istcl)} {
1716 return "Error: [dict get $opts -errorinfo]"
 
 
 
 
1717 } else {
1718 return "Error: $msg\n[stackdump $opts(-errorinfo)]"
 
 
 
 
 
 
 
 
 
 
1719 }
1720 }
1721 }
1722
1723 # ----- module text-formatting -----
@@ -1886,13 +1903,13 @@
1886 # Entry/Exit
1887 #
1888 if {$autosetup(debug)} {
1889 main $argv
1890 }
1891 if {[catch {main $argv} msg] == 1} {
1892 show-notices
1893 puts stderr [error-stacktrace $msg]
1894 if {!$autosetup(debug) && !$autosetup(istcl)} {
1895 puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
1896 }
1897 exit 1
1898 }
1899
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -925,11 +925,11 @@
925 }
926
927 # Load module source in the global scope by executing the given command
928 proc automf_load {args} {
929 if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
930 autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
931 }
932 }
933
934 # Initial settings
935 set autosetup(exe) $::argv0
@@ -1706,18 +1706,35 @@
1706 return $msg
1707 }
1708
1709 # Given the return from [catch {...} msg opts], returns an appropriate
1710 # error message. A nice one for Jim and a less-nice one for Tcl.
1711 # If 'fulltrace' is set, a full stack trace is provided.
1712 # Otherwise a simple message is provided.
1713 #
1714 # This is designed for developer errors, e.g. in module code or auto.def code
1715 #
1716 #
1717 proc error-dump {msg opts fulltrace} {
1718 if {$::autosetup(istcl)} {
1719 if {$fulltrace} {
1720 return "Error: [dict get $opts -errorinfo]"
1721 } else {
1722 return "Error: $msg"
1723 }
1724 } else {
1725 lassign $opts(-errorinfo) p f l
1726 if {$f ne ""} {
1727 set result "$f:$l: Error: "
1728 }
1729 append result "$msg\n"
1730 if {$fulltrace} {
1731 append result [stackdump $opts(-errorinfo)]
1732 }
1733
1734 # Remove the trailing newline
1735 string trim $result
1736 }
1737 }
1738 }
1739
1740 # ----- module text-formatting -----
@@ -1886,13 +1903,13 @@
1903 # Entry/Exit
1904 #
1905 if {$autosetup(debug)} {
1906 main $argv
1907 }
1908 if {[catch {main $argv} msg opts] == 1} {
1909 show-notices
1910 autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
1911 if {!$autosetup(debug)} {
1912 puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
1913 }
1914 exit 1
1915 }
1916
--- autosetup/cc-shared.tcl
+++ autosetup/cc-shared.tcl
@@ -94,10 +94,19 @@
9494
define SHOBJ_LDFLAGS -b
9595
define SH_CFLAGS +z
9696
define SH_LINKFLAGS -Wl,+s
9797
define LD_LIBRARY_PATH SHLIB_PATH
9898
}
99
+ *-*-haiku {
100
+ define SHOBJ_CFLAGS ""
101
+ define SHOBJ_LDFLAGS -shared
102
+ define SH_CFLAGS ""
103
+ define SH_LDFLAGS -shared
104
+ define SH_LINKFLAGS ""
105
+ define SH_SOPREFIX ""
106
+ define LD_LIBRARY_PATH LIBRARY_PATH
107
+ }
99108
}
100109
101110
if {![is-defined SHOBJ_LDFLAGS_R]} {
102111
define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
103112
}
104113
--- autosetup/cc-shared.tcl
+++ autosetup/cc-shared.tcl
@@ -94,10 +94,19 @@
94 define SHOBJ_LDFLAGS -b
95 define SH_CFLAGS +z
96 define SH_LINKFLAGS -Wl,+s
97 define LD_LIBRARY_PATH SHLIB_PATH
98 }
 
 
 
 
 
 
 
 
 
99 }
100
101 if {![is-defined SHOBJ_LDFLAGS_R]} {
102 define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
103 }
104
--- autosetup/cc-shared.tcl
+++ autosetup/cc-shared.tcl
@@ -94,10 +94,19 @@
94 define SHOBJ_LDFLAGS -b
95 define SH_CFLAGS +z
96 define SH_LINKFLAGS -Wl,+s
97 define LD_LIBRARY_PATH SHLIB_PATH
98 }
99 *-*-haiku {
100 define SHOBJ_CFLAGS ""
101 define SHOBJ_LDFLAGS -shared
102 define SH_CFLAGS ""
103 define SH_LDFLAGS -shared
104 define SH_LINKFLAGS ""
105 define SH_SOPREFIX ""
106 define LD_LIBRARY_PATH LIBRARY_PATH
107 }
108 }
109
110 if {![is-defined SHOBJ_LDFLAGS_R]} {
111 define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
112 }
113
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -333,11 +333,11 @@
333333
}
334334
-libs {
335335
# Note that new libraries are added before previous libraries
336336
set new($name) [list {*}$value {*}$new($name)]
337337
}
338
- -link - -lang {
338
+ -link - -lang - -nooutput {
339339
set new($name) $value
340340
}
341341
-source - -sourcefile - -code {
342342
# XXX: These probably are only valid directly from cctest
343343
set new($name) $value
@@ -428,10 +428,11 @@
428428
## -lang c|c++ Use the C (default) or C++ compiler
429429
## -libs liblist List of libraries to link, e.g. {-ldl -lm}
430430
## -code code Code to compile in the body of main()
431431
## -source code Compile a complete program. Ignore -includes, -declare and -code
432432
## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
433
+## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
433434
#
434435
# Unless -source or -sourcefile is specified, the C program looks like:
435436
#
436437
## #include <firstinclude> /* same for remaining includes in the list */
437438
##
@@ -521,11 +522,12 @@
521522
}
522523
523524
writefile $src $lines\n
524525
525526
set ok 1
526
- if {[catch {exec-with-stderr {*}$cmdline} result errinfo]} {
527
+ set err [catch {exec-with-stderr {*}$cmdline} result errinfo]
528
+ if {$err || ($opts(-nooutput) && [string length $result])} {
527529
configlog "Failed: [join $cmdline]"
528530
configlog $result
529531
configlog "============"
530532
configlog "The failed code was:"
531533
configlog $lines
@@ -671,27 +673,27 @@
671673
}
672674
673675
define CCACHE [find-an-executable [get-env CCACHE ccache]]
674676
675677
# Initial cctest settings
676
-cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {}}
678
+cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {} -nooutput 0}
677679
set autosetup(cc-include-deps) {}
678680
679681
msg-result "C compiler...[get-define CCACHE] [get-define CC] [get-define CFLAGS]"
680682
if {[get-define CXX] ne "false"} {
681683
msg-result "C++ compiler...[get-define CCACHE] [get-define CXX] [get-define CXXFLAGS]"
682684
}
683685
msg-result "Build C compiler...[get-define CC_FOR_BUILD]"
684686
685
-# On Darwin, we prefer to use -gstabs to avoid creating .dSYM directories
686
-# but some compilers don't support -gstabs, so test for it here.
687
+# On Darwin, we prefer to use -g0 to avoid creating .dSYM directories
688
+# but some compilers may not support it, so test here.
687689
switch -glob -- [get-define host] {
688690
*-*-darwin* {
689
- if {[cctest -cflags {-gstabs}]} {
690
- define cc-default-debug -gstabs
691
+ if {[cctest -cflags {-g0}]} {
692
+ define cc-default-debug -g0
691693
}
692694
}
693695
}
694696
695697
if {![cc-check-includes stdlib.h]} {
696698
user-error "Compiler does not work. See config.log"
697699
}
698700
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -333,11 +333,11 @@
333 }
334 -libs {
335 # Note that new libraries are added before previous libraries
336 set new($name) [list {*}$value {*}$new($name)]
337 }
338 -link - -lang {
339 set new($name) $value
340 }
341 -source - -sourcefile - -code {
342 # XXX: These probably are only valid directly from cctest
343 set new($name) $value
@@ -428,10 +428,11 @@
428 ## -lang c|c++ Use the C (default) or C++ compiler
429 ## -libs liblist List of libraries to link, e.g. {-ldl -lm}
430 ## -code code Code to compile in the body of main()
431 ## -source code Compile a complete program. Ignore -includes, -declare and -code
432 ## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
 
433 #
434 # Unless -source or -sourcefile is specified, the C program looks like:
435 #
436 ## #include <firstinclude> /* same for remaining includes in the list */
437 ##
@@ -521,11 +522,12 @@
521 }
522
523 writefile $src $lines\n
524
525 set ok 1
526 if {[catch {exec-with-stderr {*}$cmdline} result errinfo]} {
 
527 configlog "Failed: [join $cmdline]"
528 configlog $result
529 configlog "============"
530 configlog "The failed code was:"
531 configlog $lines
@@ -671,27 +673,27 @@
671 }
672
673 define CCACHE [find-an-executable [get-env CCACHE ccache]]
674
675 # Initial cctest settings
676 cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {}}
677 set autosetup(cc-include-deps) {}
678
679 msg-result "C compiler...[get-define CCACHE] [get-define CC] [get-define CFLAGS]"
680 if {[get-define CXX] ne "false"} {
681 msg-result "C++ compiler...[get-define CCACHE] [get-define CXX] [get-define CXXFLAGS]"
682 }
683 msg-result "Build C compiler...[get-define CC_FOR_BUILD]"
684
685 # On Darwin, we prefer to use -gstabs to avoid creating .dSYM directories
686 # but some compilers don't support -gstabs, so test for it here.
687 switch -glob -- [get-define host] {
688 *-*-darwin* {
689 if {[cctest -cflags {-gstabs}]} {
690 define cc-default-debug -gstabs
691 }
692 }
693 }
694
695 if {![cc-check-includes stdlib.h]} {
696 user-error "Compiler does not work. See config.log"
697 }
698
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -333,11 +333,11 @@
333 }
334 -libs {
335 # Note that new libraries are added before previous libraries
336 set new($name) [list {*}$value {*}$new($name)]
337 }
338 -link - -lang - -nooutput {
339 set new($name) $value
340 }
341 -source - -sourcefile - -code {
342 # XXX: These probably are only valid directly from cctest
343 set new($name) $value
@@ -428,10 +428,11 @@
428 ## -lang c|c++ Use the C (default) or C++ compiler
429 ## -libs liblist List of libraries to link, e.g. {-ldl -lm}
430 ## -code code Code to compile in the body of main()
431 ## -source code Compile a complete program. Ignore -includes, -declare and -code
432 ## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
433 ## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
434 #
435 # Unless -source or -sourcefile is specified, the C program looks like:
436 #
437 ## #include <firstinclude> /* same for remaining includes in the list */
438 ##
@@ -521,11 +522,12 @@
522 }
523
524 writefile $src $lines\n
525
526 set ok 1
527 set err [catch {exec-with-stderr {*}$cmdline} result errinfo]
528 if {$err || ($opts(-nooutput) && [string length $result])} {
529 configlog "Failed: [join $cmdline]"
530 configlog $result
531 configlog "============"
532 configlog "The failed code was:"
533 configlog $lines
@@ -671,27 +673,27 @@
673 }
674
675 define CCACHE [find-an-executable [get-env CCACHE ccache]]
676
677 # Initial cctest settings
678 cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {} -nooutput 0}
679 set autosetup(cc-include-deps) {}
680
681 msg-result "C compiler...[get-define CCACHE] [get-define CC] [get-define CFLAGS]"
682 if {[get-define CXX] ne "false"} {
683 msg-result "C++ compiler...[get-define CCACHE] [get-define CXX] [get-define CXXFLAGS]"
684 }
685 msg-result "Build C compiler...[get-define CC_FOR_BUILD]"
686
687 # On Darwin, we prefer to use -g0 to avoid creating .dSYM directories
688 # but some compilers may not support it, so test here.
689 switch -glob -- [get-define host] {
690 *-*-darwin* {
691 if {[cctest -cflags {-g0}]} {
692 define cc-default-debug -g0
693 }
694 }
695 }
696
697 if {![cc-check-includes stdlib.h]} {
698 user-error "Compiler does not work. See config.log"
699 }
700
+53 -53
--- autosetup/jimsh0.c
+++ autosetup/jimsh0.c
@@ -42,10 +42,11 @@
4242
#define HAVE_ISATTY
4343
#define HAVE_SYS_TIME_H
4444
#define HAVE_DIRENT_H
4545
#define HAVE_UNISTD_H
4646
#endif
47
+#define JIM_VERSION 75
4748
#ifndef JIM_WIN32COMPAT_H
4849
#define JIM_WIN32COMPAT_H
4950
5051
5152
@@ -185,12 +186,10 @@
185186
#endif
186187
187188
#define UCHAR(c) ((unsigned char)(c))
188189
189190
190
-#define JIM_VERSION 74
191
-
192191
#define JIM_OK 0
193192
#define JIM_ERR 1
194193
#define JIM_RETURN 2
195194
#define JIM_BREAK 3
196195
#define JIM_CONTINUE 4
@@ -832,16 +831,10 @@
832831
double *doublePtr);
833832
JIM_EXPORT void Jim_SetDouble(Jim_Interp *interp, Jim_Obj *objPtr,
834833
double doubleValue);
835834
JIM_EXPORT Jim_Obj * Jim_NewDoubleObj(Jim_Interp *interp, double doubleValue);
836835
837
-
838
-JIM_EXPORT const char * Jim_GetSharedString (Jim_Interp *interp,
839
- const char *str);
840
-JIM_EXPORT void Jim_ReleaseSharedString (Jim_Interp *interp,
841
- const char *str);
842
-
843836
844837
JIM_EXPORT void Jim_WrongNumArgs (Jim_Interp *interp, int argc,
845838
Jim_Obj *const *argv, const char *msg);
846839
JIM_EXPORT int Jim_GetEnum (Jim_Interp *interp, Jim_Obj *objPtr,
847840
const char * const *tablePtr, int *indexPtr, const char *name, int flags);
@@ -875,11 +868,11 @@
875868
JIM_EXPORT void Jim_HistoryShow(void);
876869
877870
878871
JIM_EXPORT int Jim_InitStaticExtensions(Jim_Interp *interp);
879872
JIM_EXPORT int Jim_StringToWide(const char *str, jim_wide *widePtr, int base);
880
-JIM_EXPORT int Jim_CheckSignal(Jim_Interp *interp);
873
+JIM_EXPORT int Jim_IsBigEndian(void);
881874
#define Jim_CheckSignal(i) ((i)->signal_level && (i)->sigmask)
882875
883876
884877
JIM_EXPORT int Jim_LoadLibrary(Jim_Interp *interp, const char *pathName);
885878
JIM_EXPORT void Jim_FreeLoadHandles(Jim_Interp *interp);
@@ -1775,19 +1768,11 @@
17751768
17761769
Jim_DecrRefCount(interp, af->filename);
17771770
17781771
#ifdef jim_ext_eventloop
17791772
1780
- if (af->rEvent) {
1781
- Jim_DeleteFileHandler(interp, af->fp);
1782
- }
1783
- if (af->wEvent) {
1784
- Jim_DeleteFileHandler(interp, af->fp);
1785
- }
1786
- if (af->eEvent) {
1787
- Jim_DeleteFileHandler(interp, af->fp);
1788
- }
1773
+ Jim_DeleteFileHandler(interp, af->fp, JIM_EVENT_READABLE | JIM_EVENT_WRITABLE | JIM_EVENT_EXCEPTION);
17891774
#endif
17901775
Jim_Free(af);
17911776
}
17921777
17931778
static int JimCheckStreamError(Jim_Interp *interp, AioFile *af)
@@ -2147,27 +2132,26 @@
21472132
}
21482133
21492134
#ifdef jim_ext_eventloop
21502135
static void JimAioFileEventFinalizer(Jim_Interp *interp, void *clientData)
21512136
{
2152
- Jim_Obj *objPtr = clientData;
2137
+ Jim_Obj **objPtrPtr = clientData;
21532138
2154
- Jim_DecrRefCount(interp, objPtr);
2139
+ Jim_DecrRefCount(interp, *objPtrPtr);
2140
+ *objPtrPtr = NULL;
21552141
}
21562142
21572143
static int JimAioFileEventHandler(Jim_Interp *interp, void *clientData, int mask)
21582144
{
2159
- Jim_Obj *objPtr = clientData;
2145
+ Jim_Obj **objPtrPtr = clientData;
21602146
2161
- return Jim_EvalObjBackground(interp, objPtr);
2147
+ return Jim_EvalObjBackground(interp, *objPtrPtr);
21622148
}
21632149
21642150
static int aio_eventinfo(Jim_Interp *interp, AioFile * af, unsigned mask, Jim_Obj **scriptHandlerObj,
21652151
int argc, Jim_Obj * const *argv)
21662152
{
2167
- int scriptlen = 0;
2168
-
21692153
if (argc == 0) {
21702154
21712155
if (*scriptHandlerObj) {
21722156
Jim_SetResult(interp, *scriptHandlerObj);
21732157
}
@@ -2174,27 +2158,25 @@
21742158
return JIM_OK;
21752159
}
21762160
21772161
if (*scriptHandlerObj) {
21782162
2179
- Jim_DeleteFileHandler(interp, af->fp);
2180
- *scriptHandlerObj = NULL;
2163
+ Jim_DeleteFileHandler(interp, af->fp, mask);
21812164
}
21822165
21832166
2184
- Jim_GetString(argv[0], &scriptlen);
2185
- if (scriptlen == 0) {
2167
+ if (Jim_Length(argv[0]) == 0) {
21862168
21872169
return JIM_OK;
21882170
}
21892171
21902172
21912173
Jim_IncrRefCount(argv[0]);
21922174
*scriptHandlerObj = argv[0];
21932175
21942176
Jim_CreateFileHandler(interp, af->fp, mask,
2195
- JimAioFileEventHandler, *scriptHandlerObj, JimAioFileEventFinalizer);
2177
+ JimAioFileEventHandler, scriptHandlerObj, JimAioFileEventFinalizer);
21962178
21972179
return JIM_OK;
21982180
}
21992181
22002182
static int aio_cmd_readable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
@@ -4005,11 +3987,11 @@
40053987
static void JimRestoreEnv(char **env);
40063988
static int JimCreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv,
40073989
pidtype **pidArrayPtr, fdtype *inPipePtr, fdtype *outPipePtr, fdtype *errFilePtr);
40083990
static void JimDetachPids(Jim_Interp *interp, int numPids, const pidtype *pidPtr);
40093991
static int JimCleanupChildren(Jim_Interp *interp, int numPids, pidtype *pidPtr, fdtype errorId);
4010
-static fdtype JimCreateTemp(Jim_Interp *interp, const char *contents);
3992
+static fdtype JimCreateTemp(Jim_Interp *interp, const char *contents, int len);
40113993
static fdtype JimOpenForWrite(const char *filename, int append);
40123994
static int JimRewindFd(fdtype fd);
40133995
40143996
static void Jim_SetResultErrno(Jim_Interp *interp, const char *msg)
40153997
{
@@ -4347,10 +4329,11 @@
43474329
int cmdCount; /* Count of number of distinct commands
43484330
* found in argc/argv. */
43494331
const char *input = NULL; /* Describes input for pipeline, depending
43504332
* on "inputFile". NULL means take input
43514333
* from stdin/pipe. */
4334
+ int input_len = 0;
43524335
43534336
#define FILE_NAME 0
43544337
#define FILE_APPEND 1
43554338
#define FILE_HANDLE 2
43564339
#define FILE_TEXT 3
@@ -4412,19 +4395,20 @@
44124395
if (arg[0] == '<') {
44134396
inputFile = FILE_NAME;
44144397
input = arg + 1;
44154398
if (*input == '<') {
44164399
inputFile = FILE_TEXT;
4400
+ input_len = Jim_Length(argv[i]) - 2;
44174401
input++;
44184402
}
44194403
else if (*input == '@') {
44204404
inputFile = FILE_HANDLE;
44214405
input++;
44224406
}
44234407
44244408
if (!*input && ++i < argc) {
4425
- input = Jim_String(argv[i]);
4409
+ input = Jim_GetString(argv[i], &input_len);
44264410
}
44274411
}
44284412
else if (arg[0] == '>') {
44294413
int dup_error = 0;
44304414
@@ -4498,11 +4482,11 @@
44984482
44994483
save_environ = JimSaveEnv(JimBuildEnv(interp));
45004484
45014485
if (input != NULL) {
45024486
if (inputFile == FILE_TEXT) {
4503
- inputId = JimCreateTemp(interp, input);
4487
+ inputId = JimCreateTemp(interp, input, input_len);
45044488
if (inputId == JIM_BAD_FD) {
45054489
goto error;
45064490
}
45074491
}
45084492
else if (inputFile == FILE_HANDLE) {
@@ -4587,11 +4571,11 @@
45874571
goto error;
45884572
}
45894573
}
45904574
}
45914575
else if (errFilePtr != NULL) {
4592
- errorId = JimCreateTemp(interp, NULL);
4576
+ errorId = JimCreateTemp(interp, NULL, 0);
45934577
if (errorId == JIM_BAD_FD) {
45944578
goto error;
45954579
}
45964580
*errFilePtr = JimDupFd(errorId);
45974581
}
@@ -4953,11 +4937,11 @@
49534937
*status = ret;
49544938
CloseHandle(pid);
49554939
return pid;
49564940
}
49574941
4958
-static HANDLE JimCreateTemp(Jim_Interp *interp, const char *contents)
4942
+static HANDLE JimCreateTemp(Jim_Interp *interp, const char *contents, int len)
49594943
{
49604944
char name[MAX_PATH];
49614945
HANDLE handle;
49624946
49634947
if (!GetTempPath(MAX_PATH, name) || !GetTempFileName(name, "JIM", 0, name)) {
@@ -4977,11 +4961,11 @@
49774961
FILE *fh = JimFdOpenForWrite(JimDupFd(handle));
49784962
if (fh == NULL) {
49794963
goto error;
49804964
}
49814965
4982
- if (fwrite(contents, strlen(contents), 1, fh) != 1) {
4966
+ if (fwrite(contents, len, 1, fh) != 1) {
49834967
fclose(fh);
49844968
goto error;
49854969
}
49864970
fseek(fh, 0, SEEK_SET);
49874971
fclose(fh);
@@ -5196,11 +5180,11 @@
51965180
static int JimRewindFd(int fd)
51975181
{
51985182
return lseek(fd, 0L, SEEK_SET);
51995183
}
52005184
5201
-static int JimCreateTemp(Jim_Interp *interp, const char *contents)
5185
+static int JimCreateTemp(Jim_Interp *interp, const char *contents, int len)
52025186
{
52035187
char inName[] = "/tmp/tcl.tmp.XXXXXX";
52045188
52055189
int fd = mkstemp(inName);
52065190
if (fd == JIM_BAD_FD) {
@@ -5207,12 +5191,11 @@
52075191
Jim_SetResultErrno(interp, "couldn't create temp file");
52085192
return -1;
52095193
}
52105194
unlink(inName);
52115195
if (contents) {
5212
- int length = strlen(contents);
5213
- if (write(fd, contents, length) != length) {
5196
+ if (write(fd, contents, len) != len) {
52145197
Jim_SetResultErrno(interp, "couldn't write temp file");
52155198
close(fd);
52165199
return -1;
52175200
}
52185201
lseek(fd, 0L, SEEK_SET);
@@ -5671,10 +5654,11 @@
56715654
#ifdef JIM_MAINTAINER
56725655
#define JIM_DEBUG_COMMAND
56735656
#define JIM_DEBUG_PANIC
56745657
#endif
56755658
5659
+
56765660
56775661
#define JIM_INTEGER_SPACE 24
56785662
56795663
const char *jim_tt_name(int type);
56805664
@@ -6029,11 +6013,12 @@
60296013
if (str[i] != '-' && str[i] != '+' && !isspace(UCHAR(str[i]))) {
60306014
60316015
return i;
60326016
}
60336017
6034
- return 10;
6018
+ *base = 10;
6019
+ return 0;
60356020
}
60366021
60376022
static long jim_strtol(const char *str, char **endptr)
60386023
{
60396024
int sign;
@@ -6109,10 +6094,12 @@
61096094
return len;
61106095
}
61116096
61126097
if (buf[i] == 'i' || buf[i] == 'I' || buf[i] == 'n' || buf[i] == 'N') {
61136098
buf[i] = toupper(UCHAR(buf[i]));
6099
+ if (buf[i] == 'n' || buf[i] == 'N')
6100
+ buf[i+2] = toupper(UCHAR(buf[i+2]));
61146101
buf[i + 3] = 0;
61156102
return i + 3;
61166103
}
61176104
}
61186105
@@ -7581,17 +7568,21 @@
75817568
objPtr->prevObjPtr->nextObjPtr = objPtr->nextObjPtr;
75827569
if (objPtr->nextObjPtr)
75837570
objPtr->nextObjPtr->prevObjPtr = objPtr->prevObjPtr;
75847571
if (interp->liveList == objPtr)
75857572
interp->liveList = objPtr->nextObjPtr;
7573
+#ifdef JIM_DISABLE_OBJECT_POOL
7574
+ Jim_Free(objPtr);
7575
+#else
75867576
75877577
objPtr->prevObjPtr = NULL;
75887578
objPtr->nextObjPtr = interp->freeList;
75897579
if (interp->freeList)
75907580
interp->freeList->prevObjPtr = objPtr;
75917581
interp->freeList = objPtr;
75927582
objPtr->refCount = -1;
7583
+#endif
75937584
}
75947585
75957586
75967587
void Jim_InvalidateStringRep(Jim_Obj *objPtr)
75977588
{
@@ -8244,10 +8235,19 @@
82448235
}
82458236
82468237
return strObjPtr;
82478238
}
82488239
8240
+
8241
+#ifdef HAVE_ISASCII
8242
+#define jim_isascii isascii
8243
+#else
8244
+static int jim_isascii(int c)
8245
+{
8246
+ return !(c & ~0x7f);
8247
+}
8248
+#endif
82498249
82508250
static int JimStringIs(Jim_Interp *interp, Jim_Obj *strObjPtr, Jim_Obj *strClass, int strict)
82518251
{
82528252
static const char * const strclassnames[] = {
82538253
"integer", "alpha", "alnum", "ascii", "digit",
@@ -8291,11 +8291,11 @@
82918291
return JIM_OK;
82928292
}
82938293
82948294
case STR_IS_ALPHA: isclassfunc = isalpha; break;
82958295
case STR_IS_ALNUM: isclassfunc = isalnum; break;
8296
- case STR_IS_ASCII: isclassfunc = isascii; break;
8296
+ case STR_IS_ASCII: isclassfunc = jim_isascii; break;
82978297
case STR_IS_DIGIT: isclassfunc = isdigit; break;
82988298
case STR_IS_LOWER: isclassfunc = islower; break;
82998299
case STR_IS_UPPER: isclassfunc = isupper; break;
83008300
case STR_IS_SPACE: isclassfunc = isspace; break;
83018301
case STR_IS_XDIGIT: isclassfunc = isxdigit; break;
@@ -10213,11 +10213,11 @@
1021310213
Jim_Collect(interp);
1021410214
}
1021510215
}
1021610216
#endif
1021710217
10218
-static int JimIsBigEndian(void)
10218
+int Jim_IsBigEndian(void)
1021910219
{
1022010220
union {
1022110221
unsigned short s;
1022210222
unsigned char c[2];
1022310223
} uval = {0x0102};
@@ -10269,11 +10269,11 @@
1026910269
Jim_SetVariableStrWithStr(i, JIM_INTERACTIVE, "0");
1027010270
1027110271
Jim_SetVariableStrWithStr(i, "tcl_platform(os)", TCL_PLATFORM_OS);
1027210272
Jim_SetVariableStrWithStr(i, "tcl_platform(platform)", TCL_PLATFORM_PLATFORM);
1027310273
Jim_SetVariableStrWithStr(i, "tcl_platform(pathSeparator)", TCL_PLATFORM_PATH_SEPARATOR);
10274
- Jim_SetVariableStrWithStr(i, "tcl_platform(byteOrder)", JimIsBigEndian() ? "bigEndian" : "littleEndian");
10274
+ Jim_SetVariableStrWithStr(i, "tcl_platform(byteOrder)", Jim_IsBigEndian() ? "bigEndian" : "littleEndian");
1027510275
Jim_SetVariableStrWithStr(i, "tcl_platform(threaded)", "0");
1027610276
Jim_SetVariableStr(i, "tcl_platform(pointerSize)", Jim_NewIntObj(i, sizeof(void *)));
1027710277
Jim_SetVariableStr(i, "tcl_platform(wordSize)", Jim_NewIntObj(i, sizeof(jim_wide)));
1027810278
1027910279
return i;
@@ -10449,17 +10449,11 @@
1044910449
interp->stackTrace = stackTraceObj;
1045010450
interp->errorFlag = 1;
1045110451
1045210452
len = Jim_ListLength(interp, interp->stackTrace);
1045310453
if (len >= 3) {
10454
- Jim_Obj *filenameObj;
10455
-
10456
- Jim_ListIndex(interp, interp->stackTrace, len - 2, &filenameObj, JIM_NONE);
10457
-
10458
- Jim_GetString(filenameObj, &len);
10459
-
10460
- if (!Jim_Length(filenameObj)) {
10454
+ if (Jim_Length(Jim_ListGetIndex(interp, interp->stackTrace, len - 2)) == 0) {
1046110455
interp->addStackTrace = 1;
1046210456
}
1046310457
}
1046410458
}
1046510459
@@ -10485,14 +10479,15 @@
1048510479
if (!*procname && Jim_Length(fileNameObj)) {
1048610480
1048710481
int len = Jim_ListLength(interp, interp->stackTrace);
1048810482
1048910483
if (len >= 3) {
10490
- Jim_Obj *objPtr;
10491
- if (Jim_ListIndex(interp, interp->stackTrace, len - 3, &objPtr, JIM_NONE) == JIM_OK && Jim_Length(objPtr)) {
10484
+ Jim_Obj *objPtr = Jim_ListGetIndex(interp, interp->stackTrace, len - 3);
10485
+ if (Jim_Length(objPtr)) {
1049210486
10493
- if (Jim_ListIndex(interp, interp->stackTrace, len - 2, &objPtr, JIM_NONE) == JIM_OK && !Jim_Length(objPtr)) {
10487
+ objPtr = Jim_ListGetIndex(interp, interp->stackTrace, len - 2);
10488
+ if (Jim_Length(objPtr) == 0) {
1049410489
1049510490
ListSetIndex(interp, interp->stackTrace, len - 2, fileNameObj, 0);
1049610491
ListSetIndex(interp, interp->stackTrace, len - 1, Jim_NewIntObj(interp, linenr), 0);
1049710492
return;
1049810493
}
@@ -17159,10 +17154,15 @@
1715917154
1716017155
static int Jim_LocalCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
1716117156
{
1716217157
int retcode;
1716317158
17159
+ if (argc < 2) {
17160
+ Jim_WrongNumArgs(interp, 1, argv, "cmd ?args ...?");
17161
+ return JIM_ERR;
17162
+ }
17163
+
1716417164
1716517165
interp->local++;
1716617166
retcode = Jim_EvalObjVector(interp, argc - 1, argv + 1);
1716717167
interp->local--;
1716817168
@@ -19552,11 +19552,11 @@
1955219552
char *num_buffer = NULL;
1955319553
int num_buffer_size = 0;
1955419554
1955519555
span = format = Jim_GetString(fmtObjPtr, &formatLen);
1955619556
formatEnd = format + formatLen;
19557
- resultPtr = Jim_NewStringObj(interp, "", 0);
19557
+ resultPtr = Jim_NewEmptyStringObj(interp);
1955819558
1955919559
while (format != formatEnd) {
1956019560
char *end;
1956119561
int gotMinus, sawFlag;
1956219562
int gotPrecision, useShort;
1956319563
--- autosetup/jimsh0.c
+++ autosetup/jimsh0.c
@@ -42,10 +42,11 @@
42 #define HAVE_ISATTY
43 #define HAVE_SYS_TIME_H
44 #define HAVE_DIRENT_H
45 #define HAVE_UNISTD_H
46 #endif
 
47 #ifndef JIM_WIN32COMPAT_H
48 #define JIM_WIN32COMPAT_H
49
50
51
@@ -185,12 +186,10 @@
185 #endif
186
187 #define UCHAR(c) ((unsigned char)(c))
188
189
190 #define JIM_VERSION 74
191
192 #define JIM_OK 0
193 #define JIM_ERR 1
194 #define JIM_RETURN 2
195 #define JIM_BREAK 3
196 #define JIM_CONTINUE 4
@@ -832,16 +831,10 @@
832 double *doublePtr);
833 JIM_EXPORT void Jim_SetDouble(Jim_Interp *interp, Jim_Obj *objPtr,
834 double doubleValue);
835 JIM_EXPORT Jim_Obj * Jim_NewDoubleObj(Jim_Interp *interp, double doubleValue);
836
837
838 JIM_EXPORT const char * Jim_GetSharedString (Jim_Interp *interp,
839 const char *str);
840 JIM_EXPORT void Jim_ReleaseSharedString (Jim_Interp *interp,
841 const char *str);
842
843
844 JIM_EXPORT void Jim_WrongNumArgs (Jim_Interp *interp, int argc,
845 Jim_Obj *const *argv, const char *msg);
846 JIM_EXPORT int Jim_GetEnum (Jim_Interp *interp, Jim_Obj *objPtr,
847 const char * const *tablePtr, int *indexPtr, const char *name, int flags);
@@ -875,11 +868,11 @@
875 JIM_EXPORT void Jim_HistoryShow(void);
876
877
878 JIM_EXPORT int Jim_InitStaticExtensions(Jim_Interp *interp);
879 JIM_EXPORT int Jim_StringToWide(const char *str, jim_wide *widePtr, int base);
880 JIM_EXPORT int Jim_CheckSignal(Jim_Interp *interp);
881 #define Jim_CheckSignal(i) ((i)->signal_level && (i)->sigmask)
882
883
884 JIM_EXPORT int Jim_LoadLibrary(Jim_Interp *interp, const char *pathName);
885 JIM_EXPORT void Jim_FreeLoadHandles(Jim_Interp *interp);
@@ -1775,19 +1768,11 @@
1775
1776 Jim_DecrRefCount(interp, af->filename);
1777
1778 #ifdef jim_ext_eventloop
1779
1780 if (af->rEvent) {
1781 Jim_DeleteFileHandler(interp, af->fp);
1782 }
1783 if (af->wEvent) {
1784 Jim_DeleteFileHandler(interp, af->fp);
1785 }
1786 if (af->eEvent) {
1787 Jim_DeleteFileHandler(interp, af->fp);
1788 }
1789 #endif
1790 Jim_Free(af);
1791 }
1792
1793 static int JimCheckStreamError(Jim_Interp *interp, AioFile *af)
@@ -2147,27 +2132,26 @@
2147 }
2148
2149 #ifdef jim_ext_eventloop
2150 static void JimAioFileEventFinalizer(Jim_Interp *interp, void *clientData)
2151 {
2152 Jim_Obj *objPtr = clientData;
2153
2154 Jim_DecrRefCount(interp, objPtr);
 
2155 }
2156
2157 static int JimAioFileEventHandler(Jim_Interp *interp, void *clientData, int mask)
2158 {
2159 Jim_Obj *objPtr = clientData;
2160
2161 return Jim_EvalObjBackground(interp, objPtr);
2162 }
2163
2164 static int aio_eventinfo(Jim_Interp *interp, AioFile * af, unsigned mask, Jim_Obj **scriptHandlerObj,
2165 int argc, Jim_Obj * const *argv)
2166 {
2167 int scriptlen = 0;
2168
2169 if (argc == 0) {
2170
2171 if (*scriptHandlerObj) {
2172 Jim_SetResult(interp, *scriptHandlerObj);
2173 }
@@ -2174,27 +2158,25 @@
2174 return JIM_OK;
2175 }
2176
2177 if (*scriptHandlerObj) {
2178
2179 Jim_DeleteFileHandler(interp, af->fp);
2180 *scriptHandlerObj = NULL;
2181 }
2182
2183
2184 Jim_GetString(argv[0], &scriptlen);
2185 if (scriptlen == 0) {
2186
2187 return JIM_OK;
2188 }
2189
2190
2191 Jim_IncrRefCount(argv[0]);
2192 *scriptHandlerObj = argv[0];
2193
2194 Jim_CreateFileHandler(interp, af->fp, mask,
2195 JimAioFileEventHandler, *scriptHandlerObj, JimAioFileEventFinalizer);
2196
2197 return JIM_OK;
2198 }
2199
2200 static int aio_cmd_readable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
@@ -4005,11 +3987,11 @@
4005 static void JimRestoreEnv(char **env);
4006 static int JimCreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv,
4007 pidtype **pidArrayPtr, fdtype *inPipePtr, fdtype *outPipePtr, fdtype *errFilePtr);
4008 static void JimDetachPids(Jim_Interp *interp, int numPids, const pidtype *pidPtr);
4009 static int JimCleanupChildren(Jim_Interp *interp, int numPids, pidtype *pidPtr, fdtype errorId);
4010 static fdtype JimCreateTemp(Jim_Interp *interp, const char *contents);
4011 static fdtype JimOpenForWrite(const char *filename, int append);
4012 static int JimRewindFd(fdtype fd);
4013
4014 static void Jim_SetResultErrno(Jim_Interp *interp, const char *msg)
4015 {
@@ -4347,10 +4329,11 @@
4347 int cmdCount; /* Count of number of distinct commands
4348 * found in argc/argv. */
4349 const char *input = NULL; /* Describes input for pipeline, depending
4350 * on "inputFile". NULL means take input
4351 * from stdin/pipe. */
 
4352
4353 #define FILE_NAME 0
4354 #define FILE_APPEND 1
4355 #define FILE_HANDLE 2
4356 #define FILE_TEXT 3
@@ -4412,19 +4395,20 @@
4412 if (arg[0] == '<') {
4413 inputFile = FILE_NAME;
4414 input = arg + 1;
4415 if (*input == '<') {
4416 inputFile = FILE_TEXT;
 
4417 input++;
4418 }
4419 else if (*input == '@') {
4420 inputFile = FILE_HANDLE;
4421 input++;
4422 }
4423
4424 if (!*input && ++i < argc) {
4425 input = Jim_String(argv[i]);
4426 }
4427 }
4428 else if (arg[0] == '>') {
4429 int dup_error = 0;
4430
@@ -4498,11 +4482,11 @@
4498
4499 save_environ = JimSaveEnv(JimBuildEnv(interp));
4500
4501 if (input != NULL) {
4502 if (inputFile == FILE_TEXT) {
4503 inputId = JimCreateTemp(interp, input);
4504 if (inputId == JIM_BAD_FD) {
4505 goto error;
4506 }
4507 }
4508 else if (inputFile == FILE_HANDLE) {
@@ -4587,11 +4571,11 @@
4587 goto error;
4588 }
4589 }
4590 }
4591 else if (errFilePtr != NULL) {
4592 errorId = JimCreateTemp(interp, NULL);
4593 if (errorId == JIM_BAD_FD) {
4594 goto error;
4595 }
4596 *errFilePtr = JimDupFd(errorId);
4597 }
@@ -4953,11 +4937,11 @@
4953 *status = ret;
4954 CloseHandle(pid);
4955 return pid;
4956 }
4957
4958 static HANDLE JimCreateTemp(Jim_Interp *interp, const char *contents)
4959 {
4960 char name[MAX_PATH];
4961 HANDLE handle;
4962
4963 if (!GetTempPath(MAX_PATH, name) || !GetTempFileName(name, "JIM", 0, name)) {
@@ -4977,11 +4961,11 @@
4977 FILE *fh = JimFdOpenForWrite(JimDupFd(handle));
4978 if (fh == NULL) {
4979 goto error;
4980 }
4981
4982 if (fwrite(contents, strlen(contents), 1, fh) != 1) {
4983 fclose(fh);
4984 goto error;
4985 }
4986 fseek(fh, 0, SEEK_SET);
4987 fclose(fh);
@@ -5196,11 +5180,11 @@
5196 static int JimRewindFd(int fd)
5197 {
5198 return lseek(fd, 0L, SEEK_SET);
5199 }
5200
5201 static int JimCreateTemp(Jim_Interp *interp, const char *contents)
5202 {
5203 char inName[] = "/tmp/tcl.tmp.XXXXXX";
5204
5205 int fd = mkstemp(inName);
5206 if (fd == JIM_BAD_FD) {
@@ -5207,12 +5191,11 @@
5207 Jim_SetResultErrno(interp, "couldn't create temp file");
5208 return -1;
5209 }
5210 unlink(inName);
5211 if (contents) {
5212 int length = strlen(contents);
5213 if (write(fd, contents, length) != length) {
5214 Jim_SetResultErrno(interp, "couldn't write temp file");
5215 close(fd);
5216 return -1;
5217 }
5218 lseek(fd, 0L, SEEK_SET);
@@ -5671,10 +5654,11 @@
5671 #ifdef JIM_MAINTAINER
5672 #define JIM_DEBUG_COMMAND
5673 #define JIM_DEBUG_PANIC
5674 #endif
5675
 
5676
5677 #define JIM_INTEGER_SPACE 24
5678
5679 const char *jim_tt_name(int type);
5680
@@ -6029,11 +6013,12 @@
6029 if (str[i] != '-' && str[i] != '+' && !isspace(UCHAR(str[i]))) {
6030
6031 return i;
6032 }
6033
6034 return 10;
 
6035 }
6036
6037 static long jim_strtol(const char *str, char **endptr)
6038 {
6039 int sign;
@@ -6109,10 +6094,12 @@
6109 return len;
6110 }
6111
6112 if (buf[i] == 'i' || buf[i] == 'I' || buf[i] == 'n' || buf[i] == 'N') {
6113 buf[i] = toupper(UCHAR(buf[i]));
 
 
6114 buf[i + 3] = 0;
6115 return i + 3;
6116 }
6117 }
6118
@@ -7581,17 +7568,21 @@
7581 objPtr->prevObjPtr->nextObjPtr = objPtr->nextObjPtr;
7582 if (objPtr->nextObjPtr)
7583 objPtr->nextObjPtr->prevObjPtr = objPtr->prevObjPtr;
7584 if (interp->liveList == objPtr)
7585 interp->liveList = objPtr->nextObjPtr;
 
 
 
7586
7587 objPtr->prevObjPtr = NULL;
7588 objPtr->nextObjPtr = interp->freeList;
7589 if (interp->freeList)
7590 interp->freeList->prevObjPtr = objPtr;
7591 interp->freeList = objPtr;
7592 objPtr->refCount = -1;
 
7593 }
7594
7595
7596 void Jim_InvalidateStringRep(Jim_Obj *objPtr)
7597 {
@@ -8244,10 +8235,19 @@
8244 }
8245
8246 return strObjPtr;
8247 }
8248
 
 
 
 
 
 
 
 
 
8249
8250 static int JimStringIs(Jim_Interp *interp, Jim_Obj *strObjPtr, Jim_Obj *strClass, int strict)
8251 {
8252 static const char * const strclassnames[] = {
8253 "integer", "alpha", "alnum", "ascii", "digit",
@@ -8291,11 +8291,11 @@
8291 return JIM_OK;
8292 }
8293
8294 case STR_IS_ALPHA: isclassfunc = isalpha; break;
8295 case STR_IS_ALNUM: isclassfunc = isalnum; break;
8296 case STR_IS_ASCII: isclassfunc = isascii; break;
8297 case STR_IS_DIGIT: isclassfunc = isdigit; break;
8298 case STR_IS_LOWER: isclassfunc = islower; break;
8299 case STR_IS_UPPER: isclassfunc = isupper; break;
8300 case STR_IS_SPACE: isclassfunc = isspace; break;
8301 case STR_IS_XDIGIT: isclassfunc = isxdigit; break;
@@ -10213,11 +10213,11 @@
10213 Jim_Collect(interp);
10214 }
10215 }
10216 #endif
10217
10218 static int JimIsBigEndian(void)
10219 {
10220 union {
10221 unsigned short s;
10222 unsigned char c[2];
10223 } uval = {0x0102};
@@ -10269,11 +10269,11 @@
10269 Jim_SetVariableStrWithStr(i, JIM_INTERACTIVE, "0");
10270
10271 Jim_SetVariableStrWithStr(i, "tcl_platform(os)", TCL_PLATFORM_OS);
10272 Jim_SetVariableStrWithStr(i, "tcl_platform(platform)", TCL_PLATFORM_PLATFORM);
10273 Jim_SetVariableStrWithStr(i, "tcl_platform(pathSeparator)", TCL_PLATFORM_PATH_SEPARATOR);
10274 Jim_SetVariableStrWithStr(i, "tcl_platform(byteOrder)", JimIsBigEndian() ? "bigEndian" : "littleEndian");
10275 Jim_SetVariableStrWithStr(i, "tcl_platform(threaded)", "0");
10276 Jim_SetVariableStr(i, "tcl_platform(pointerSize)", Jim_NewIntObj(i, sizeof(void *)));
10277 Jim_SetVariableStr(i, "tcl_platform(wordSize)", Jim_NewIntObj(i, sizeof(jim_wide)));
10278
10279 return i;
@@ -10449,17 +10449,11 @@
10449 interp->stackTrace = stackTraceObj;
10450 interp->errorFlag = 1;
10451
10452 len = Jim_ListLength(interp, interp->stackTrace);
10453 if (len >= 3) {
10454 Jim_Obj *filenameObj;
10455
10456 Jim_ListIndex(interp, interp->stackTrace, len - 2, &filenameObj, JIM_NONE);
10457
10458 Jim_GetString(filenameObj, &len);
10459
10460 if (!Jim_Length(filenameObj)) {
10461 interp->addStackTrace = 1;
10462 }
10463 }
10464 }
10465
@@ -10485,14 +10479,15 @@
10485 if (!*procname && Jim_Length(fileNameObj)) {
10486
10487 int len = Jim_ListLength(interp, interp->stackTrace);
10488
10489 if (len >= 3) {
10490 Jim_Obj *objPtr;
10491 if (Jim_ListIndex(interp, interp->stackTrace, len - 3, &objPtr, JIM_NONE) == JIM_OK && Jim_Length(objPtr)) {
10492
10493 if (Jim_ListIndex(interp, interp->stackTrace, len - 2, &objPtr, JIM_NONE) == JIM_OK && !Jim_Length(objPtr)) {
 
10494
10495 ListSetIndex(interp, interp->stackTrace, len - 2, fileNameObj, 0);
10496 ListSetIndex(interp, interp->stackTrace, len - 1, Jim_NewIntObj(interp, linenr), 0);
10497 return;
10498 }
@@ -17159,10 +17154,15 @@
17159
17160 static int Jim_LocalCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
17161 {
17162 int retcode;
17163
 
 
 
 
 
17164
17165 interp->local++;
17166 retcode = Jim_EvalObjVector(interp, argc - 1, argv + 1);
17167 interp->local--;
17168
@@ -19552,11 +19552,11 @@
19552 char *num_buffer = NULL;
19553 int num_buffer_size = 0;
19554
19555 span = format = Jim_GetString(fmtObjPtr, &formatLen);
19556 formatEnd = format + formatLen;
19557 resultPtr = Jim_NewStringObj(interp, "", 0);
19558
19559 while (format != formatEnd) {
19560 char *end;
19561 int gotMinus, sawFlag;
19562 int gotPrecision, useShort;
19563
--- autosetup/jimsh0.c
+++ autosetup/jimsh0.c
@@ -42,10 +42,11 @@
42 #define HAVE_ISATTY
43 #define HAVE_SYS_TIME_H
44 #define HAVE_DIRENT_H
45 #define HAVE_UNISTD_H
46 #endif
47 #define JIM_VERSION 75
48 #ifndef JIM_WIN32COMPAT_H
49 #define JIM_WIN32COMPAT_H
50
51
52
@@ -185,12 +186,10 @@
186 #endif
187
188 #define UCHAR(c) ((unsigned char)(c))
189
190
 
 
191 #define JIM_OK 0
192 #define JIM_ERR 1
193 #define JIM_RETURN 2
194 #define JIM_BREAK 3
195 #define JIM_CONTINUE 4
@@ -832,16 +831,10 @@
831 double *doublePtr);
832 JIM_EXPORT void Jim_SetDouble(Jim_Interp *interp, Jim_Obj *objPtr,
833 double doubleValue);
834 JIM_EXPORT Jim_Obj * Jim_NewDoubleObj(Jim_Interp *interp, double doubleValue);
835
 
 
 
 
 
 
836
837 JIM_EXPORT void Jim_WrongNumArgs (Jim_Interp *interp, int argc,
838 Jim_Obj *const *argv, const char *msg);
839 JIM_EXPORT int Jim_GetEnum (Jim_Interp *interp, Jim_Obj *objPtr,
840 const char * const *tablePtr, int *indexPtr, const char *name, int flags);
@@ -875,11 +868,11 @@
868 JIM_EXPORT void Jim_HistoryShow(void);
869
870
871 JIM_EXPORT int Jim_InitStaticExtensions(Jim_Interp *interp);
872 JIM_EXPORT int Jim_StringToWide(const char *str, jim_wide *widePtr, int base);
873 JIM_EXPORT int Jim_IsBigEndian(void);
874 #define Jim_CheckSignal(i) ((i)->signal_level && (i)->sigmask)
875
876
877 JIM_EXPORT int Jim_LoadLibrary(Jim_Interp *interp, const char *pathName);
878 JIM_EXPORT void Jim_FreeLoadHandles(Jim_Interp *interp);
@@ -1775,19 +1768,11 @@
1768
1769 Jim_DecrRefCount(interp, af->filename);
1770
1771 #ifdef jim_ext_eventloop
1772
1773 Jim_DeleteFileHandler(interp, af->fp, JIM_EVENT_READABLE | JIM_EVENT_WRITABLE | JIM_EVENT_EXCEPTION);
 
 
 
 
 
 
 
 
1774 #endif
1775 Jim_Free(af);
1776 }
1777
1778 static int JimCheckStreamError(Jim_Interp *interp, AioFile *af)
@@ -2147,27 +2132,26 @@
2132 }
2133
2134 #ifdef jim_ext_eventloop
2135 static void JimAioFileEventFinalizer(Jim_Interp *interp, void *clientData)
2136 {
2137 Jim_Obj **objPtrPtr = clientData;
2138
2139 Jim_DecrRefCount(interp, *objPtrPtr);
2140 *objPtrPtr = NULL;
2141 }
2142
2143 static int JimAioFileEventHandler(Jim_Interp *interp, void *clientData, int mask)
2144 {
2145 Jim_Obj **objPtrPtr = clientData;
2146
2147 return Jim_EvalObjBackground(interp, *objPtrPtr);
2148 }
2149
2150 static int aio_eventinfo(Jim_Interp *interp, AioFile * af, unsigned mask, Jim_Obj **scriptHandlerObj,
2151 int argc, Jim_Obj * const *argv)
2152 {
 
 
2153 if (argc == 0) {
2154
2155 if (*scriptHandlerObj) {
2156 Jim_SetResult(interp, *scriptHandlerObj);
2157 }
@@ -2174,27 +2158,25 @@
2158 return JIM_OK;
2159 }
2160
2161 if (*scriptHandlerObj) {
2162
2163 Jim_DeleteFileHandler(interp, af->fp, mask);
 
2164 }
2165
2166
2167 if (Jim_Length(argv[0]) == 0) {
 
2168
2169 return JIM_OK;
2170 }
2171
2172
2173 Jim_IncrRefCount(argv[0]);
2174 *scriptHandlerObj = argv[0];
2175
2176 Jim_CreateFileHandler(interp, af->fp, mask,
2177 JimAioFileEventHandler, scriptHandlerObj, JimAioFileEventFinalizer);
2178
2179 return JIM_OK;
2180 }
2181
2182 static int aio_cmd_readable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
@@ -4005,11 +3987,11 @@
3987 static void JimRestoreEnv(char **env);
3988 static int JimCreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv,
3989 pidtype **pidArrayPtr, fdtype *inPipePtr, fdtype *outPipePtr, fdtype *errFilePtr);
3990 static void JimDetachPids(Jim_Interp *interp, int numPids, const pidtype *pidPtr);
3991 static int JimCleanupChildren(Jim_Interp *interp, int numPids, pidtype *pidPtr, fdtype errorId);
3992 static fdtype JimCreateTemp(Jim_Interp *interp, const char *contents, int len);
3993 static fdtype JimOpenForWrite(const char *filename, int append);
3994 static int JimRewindFd(fdtype fd);
3995
3996 static void Jim_SetResultErrno(Jim_Interp *interp, const char *msg)
3997 {
@@ -4347,10 +4329,11 @@
4329 int cmdCount; /* Count of number of distinct commands
4330 * found in argc/argv. */
4331 const char *input = NULL; /* Describes input for pipeline, depending
4332 * on "inputFile". NULL means take input
4333 * from stdin/pipe. */
4334 int input_len = 0;
4335
4336 #define FILE_NAME 0
4337 #define FILE_APPEND 1
4338 #define FILE_HANDLE 2
4339 #define FILE_TEXT 3
@@ -4412,19 +4395,20 @@
4395 if (arg[0] == '<') {
4396 inputFile = FILE_NAME;
4397 input = arg + 1;
4398 if (*input == '<') {
4399 inputFile = FILE_TEXT;
4400 input_len = Jim_Length(argv[i]) - 2;
4401 input++;
4402 }
4403 else if (*input == '@') {
4404 inputFile = FILE_HANDLE;
4405 input++;
4406 }
4407
4408 if (!*input && ++i < argc) {
4409 input = Jim_GetString(argv[i], &input_len);
4410 }
4411 }
4412 else if (arg[0] == '>') {
4413 int dup_error = 0;
4414
@@ -4498,11 +4482,11 @@
4482
4483 save_environ = JimSaveEnv(JimBuildEnv(interp));
4484
4485 if (input != NULL) {
4486 if (inputFile == FILE_TEXT) {
4487 inputId = JimCreateTemp(interp, input, input_len);
4488 if (inputId == JIM_BAD_FD) {
4489 goto error;
4490 }
4491 }
4492 else if (inputFile == FILE_HANDLE) {
@@ -4587,11 +4571,11 @@
4571 goto error;
4572 }
4573 }
4574 }
4575 else if (errFilePtr != NULL) {
4576 errorId = JimCreateTemp(interp, NULL, 0);
4577 if (errorId == JIM_BAD_FD) {
4578 goto error;
4579 }
4580 *errFilePtr = JimDupFd(errorId);
4581 }
@@ -4953,11 +4937,11 @@
4937 *status = ret;
4938 CloseHandle(pid);
4939 return pid;
4940 }
4941
4942 static HANDLE JimCreateTemp(Jim_Interp *interp, const char *contents, int len)
4943 {
4944 char name[MAX_PATH];
4945 HANDLE handle;
4946
4947 if (!GetTempPath(MAX_PATH, name) || !GetTempFileName(name, "JIM", 0, name)) {
@@ -4977,11 +4961,11 @@
4961 FILE *fh = JimFdOpenForWrite(JimDupFd(handle));
4962 if (fh == NULL) {
4963 goto error;
4964 }
4965
4966 if (fwrite(contents, len, 1, fh) != 1) {
4967 fclose(fh);
4968 goto error;
4969 }
4970 fseek(fh, 0, SEEK_SET);
4971 fclose(fh);
@@ -5196,11 +5180,11 @@
5180 static int JimRewindFd(int fd)
5181 {
5182 return lseek(fd, 0L, SEEK_SET);
5183 }
5184
5185 static int JimCreateTemp(Jim_Interp *interp, const char *contents, int len)
5186 {
5187 char inName[] = "/tmp/tcl.tmp.XXXXXX";
5188
5189 int fd = mkstemp(inName);
5190 if (fd == JIM_BAD_FD) {
@@ -5207,12 +5191,11 @@
5191 Jim_SetResultErrno(interp, "couldn't create temp file");
5192 return -1;
5193 }
5194 unlink(inName);
5195 if (contents) {
5196 if (write(fd, contents, len) != len) {
 
5197 Jim_SetResultErrno(interp, "couldn't write temp file");
5198 close(fd);
5199 return -1;
5200 }
5201 lseek(fd, 0L, SEEK_SET);
@@ -5671,10 +5654,11 @@
5654 #ifdef JIM_MAINTAINER
5655 #define JIM_DEBUG_COMMAND
5656 #define JIM_DEBUG_PANIC
5657 #endif
5658
5659
5660
5661 #define JIM_INTEGER_SPACE 24
5662
5663 const char *jim_tt_name(int type);
5664
@@ -6029,11 +6013,12 @@
6013 if (str[i] != '-' && str[i] != '+' && !isspace(UCHAR(str[i]))) {
6014
6015 return i;
6016 }
6017
6018 *base = 10;
6019 return 0;
6020 }
6021
6022 static long jim_strtol(const char *str, char **endptr)
6023 {
6024 int sign;
@@ -6109,10 +6094,12 @@
6094 return len;
6095 }
6096
6097 if (buf[i] == 'i' || buf[i] == 'I' || buf[i] == 'n' || buf[i] == 'N') {
6098 buf[i] = toupper(UCHAR(buf[i]));
6099 if (buf[i] == 'n' || buf[i] == 'N')
6100 buf[i+2] = toupper(UCHAR(buf[i+2]));
6101 buf[i + 3] = 0;
6102 return i + 3;
6103 }
6104 }
6105
@@ -7581,17 +7568,21 @@
7568 objPtr->prevObjPtr->nextObjPtr = objPtr->nextObjPtr;
7569 if (objPtr->nextObjPtr)
7570 objPtr->nextObjPtr->prevObjPtr = objPtr->prevObjPtr;
7571 if (interp->liveList == objPtr)
7572 interp->liveList = objPtr->nextObjPtr;
7573 #ifdef JIM_DISABLE_OBJECT_POOL
7574 Jim_Free(objPtr);
7575 #else
7576
7577 objPtr->prevObjPtr = NULL;
7578 objPtr->nextObjPtr = interp->freeList;
7579 if (interp->freeList)
7580 interp->freeList->prevObjPtr = objPtr;
7581 interp->freeList = objPtr;
7582 objPtr->refCount = -1;
7583 #endif
7584 }
7585
7586
7587 void Jim_InvalidateStringRep(Jim_Obj *objPtr)
7588 {
@@ -8244,10 +8235,19 @@
8235 }
8236
8237 return strObjPtr;
8238 }
8239
8240
8241 #ifdef HAVE_ISASCII
8242 #define jim_isascii isascii
8243 #else
8244 static int jim_isascii(int c)
8245 {
8246 return !(c & ~0x7f);
8247 }
8248 #endif
8249
8250 static int JimStringIs(Jim_Interp *interp, Jim_Obj *strObjPtr, Jim_Obj *strClass, int strict)
8251 {
8252 static const char * const strclassnames[] = {
8253 "integer", "alpha", "alnum", "ascii", "digit",
@@ -8291,11 +8291,11 @@
8291 return JIM_OK;
8292 }
8293
8294 case STR_IS_ALPHA: isclassfunc = isalpha; break;
8295 case STR_IS_ALNUM: isclassfunc = isalnum; break;
8296 case STR_IS_ASCII: isclassfunc = jim_isascii; break;
8297 case STR_IS_DIGIT: isclassfunc = isdigit; break;
8298 case STR_IS_LOWER: isclassfunc = islower; break;
8299 case STR_IS_UPPER: isclassfunc = isupper; break;
8300 case STR_IS_SPACE: isclassfunc = isspace; break;
8301 case STR_IS_XDIGIT: isclassfunc = isxdigit; break;
@@ -10213,11 +10213,11 @@
10213 Jim_Collect(interp);
10214 }
10215 }
10216 #endif
10217
10218 int Jim_IsBigEndian(void)
10219 {
10220 union {
10221 unsigned short s;
10222 unsigned char c[2];
10223 } uval = {0x0102};
@@ -10269,11 +10269,11 @@
10269 Jim_SetVariableStrWithStr(i, JIM_INTERACTIVE, "0");
10270
10271 Jim_SetVariableStrWithStr(i, "tcl_platform(os)", TCL_PLATFORM_OS);
10272 Jim_SetVariableStrWithStr(i, "tcl_platform(platform)", TCL_PLATFORM_PLATFORM);
10273 Jim_SetVariableStrWithStr(i, "tcl_platform(pathSeparator)", TCL_PLATFORM_PATH_SEPARATOR);
10274 Jim_SetVariableStrWithStr(i, "tcl_platform(byteOrder)", Jim_IsBigEndian() ? "bigEndian" : "littleEndian");
10275 Jim_SetVariableStrWithStr(i, "tcl_platform(threaded)", "0");
10276 Jim_SetVariableStr(i, "tcl_platform(pointerSize)", Jim_NewIntObj(i, sizeof(void *)));
10277 Jim_SetVariableStr(i, "tcl_platform(wordSize)", Jim_NewIntObj(i, sizeof(jim_wide)));
10278
10279 return i;
@@ -10449,17 +10449,11 @@
10449 interp->stackTrace = stackTraceObj;
10450 interp->errorFlag = 1;
10451
10452 len = Jim_ListLength(interp, interp->stackTrace);
10453 if (len >= 3) {
10454 if (Jim_Length(Jim_ListGetIndex(interp, interp->stackTrace, len - 2)) == 0) {
 
 
 
 
 
 
10455 interp->addStackTrace = 1;
10456 }
10457 }
10458 }
10459
@@ -10485,14 +10479,15 @@
10479 if (!*procname && Jim_Length(fileNameObj)) {
10480
10481 int len = Jim_ListLength(interp, interp->stackTrace);
10482
10483 if (len >= 3) {
10484 Jim_Obj *objPtr = Jim_ListGetIndex(interp, interp->stackTrace, len - 3);
10485 if (Jim_Length(objPtr)) {
10486
10487 objPtr = Jim_ListGetIndex(interp, interp->stackTrace, len - 2);
10488 if (Jim_Length(objPtr) == 0) {
10489
10490 ListSetIndex(interp, interp->stackTrace, len - 2, fileNameObj, 0);
10491 ListSetIndex(interp, interp->stackTrace, len - 1, Jim_NewIntObj(interp, linenr), 0);
10492 return;
10493 }
@@ -17159,10 +17154,15 @@
17154
17155 static int Jim_LocalCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
17156 {
17157 int retcode;
17158
17159 if (argc < 2) {
17160 Jim_WrongNumArgs(interp, 1, argv, "cmd ?args ...?");
17161 return JIM_ERR;
17162 }
17163
17164
17165 interp->local++;
17166 retcode = Jim_EvalObjVector(interp, argc - 1, argv + 1);
17167 interp->local--;
17168
@@ -19552,11 +19552,11 @@
19552 char *num_buffer = NULL;
19553 int num_buffer_size = 0;
19554
19555 span = format = Jim_GetString(fmtObjPtr, &formatLen);
19556 formatEnd = format + formatLen;
19557 resultPtr = Jim_NewEmptyStringObj(interp);
19558
19559 while (format != formatEnd) {
19560 char *end;
19561 int gotMinus, sawFlag;
19562 int gotPrecision, useShort;
19563
--- autosetup/local.tcl
+++ autosetup/local.tcl
@@ -26,5 +26,200 @@
2626
set tclconfig($name) [string trim $value ']
2727
}
2828
}
2929
return [array get tclconfig]
3030
}
31
+
32
+# The complex extension checking is done here.
33
+
34
+global withinfo
35
+global extdb
36
+
37
+# Final determination of module status
38
+dict set extdb status {}
39
+
40
+# Returns 1 if the extension has the attribute
41
+proc ext-has {ext attr} {
42
+ expr {$attr in [dict get $::extdb attrs $ext]}
43
+}
44
+
45
+# Returns an entry from the extension 'info' table, or $default otherwise
46
+proc ext-get {ext key {default {}}} {
47
+ if {[dict exists $::extdb info $ext $key]} {
48
+ return [dict get $::extdb info $ext $key]
49
+ } else {
50
+ return $default
51
+ }
52
+}
53
+
54
+# Set the status of the extension to the given value, and returns the value
55
+proc ext-set-status {ext value} {
56
+ dict set ::extdb status $ext $value
57
+ return $value
58
+}
59
+
60
+# Returns the status of the extension, or ? if unknown
61
+proc ext-get-status {ext} {
62
+ if {[dict exists $::extdb status $ext]} {
63
+ return [dict get $::extdb status $ext]
64
+ }
65
+ return ?
66
+}
67
+
68
+proc check-extension-status {ext required} {
69
+ global withinfo
70
+
71
+ set status [ext-get-status $ext]
72
+
73
+ if {$ext in $withinfo(without)} {
74
+ # Disabled without further ado
75
+ msg-result "Extension $ext...disabled"
76
+ return [ext-set-status $ext n]
77
+ }
78
+
79
+ if {$status in {m y n}} {
80
+ return $status
81
+ }
82
+
83
+ # required is "required" if this extension *must* be enabled
84
+ # required is "wanted" if it is not fatal for this extension
85
+ # not to be enabled
86
+
87
+ array set depinfo {m 0 y 0 n 0}
88
+
89
+ # Check direct dependencies
90
+ if [ext-get $ext check 1] {
91
+ # "check" conditions are met
92
+ } else {
93
+ # not met
94
+ incr depinfo(n)
95
+ }
96
+
97
+ if {$depinfo(n) == 0} {
98
+ # Now extension dependencies
99
+ foreach i [ext-get $ext dep] {
100
+ set status [check-extension-status $i $required]
101
+ #puts "$ext: dep $i $required => $status"
102
+ incr depinfo($status)
103
+ if {$depinfo(n)} {
104
+ break
105
+ }
106
+ }
107
+ }
108
+
109
+ #parray depinfo
110
+
111
+ if {$depinfo(n)} {
112
+ msg-checking "Extension $ext..."
113
+ if {$required eq "required"} {
114
+ user-error "dependencies not met"
115
+ }
116
+ msg-result "disabled (dependencies)"
117
+ return [ext-set-status $ext n]
118
+ }
119
+
120
+ # Selected as a module?
121
+ if {$ext in $withinfo(mod)} {
122
+ if {[ext-has $ext tcl]} {
123
+ # Easy, a Tcl module
124
+ msg-result "Extension $ext...tcl"
125
+ } elseif {[ext-has $ext static]} {
126
+ user-error "Extension $ext can't be a module"
127
+ } else {
128
+ msg-result "Extension $ext...module"
129
+ foreach i [ext-get $ext libdep] {
130
+ define-append LDLIBS_$ext [get-define $i ""]
131
+ }
132
+ }
133
+ return [ext-set-status $ext m]
134
+ }
135
+
136
+ # Selected as a static extension?
137
+ if {[ext-has $ext shared]} {
138
+ user-error "Extension $ext can only be selected as a module"
139
+ } elseif {$ext in $withinfo(ext) || $required eq "$required"} {
140
+ msg-result "Extension $ext...enabled"
141
+ } elseif {$ext in $withinfo(maybe)} {
142
+ msg-result "Extension $ext...enabled (default)"
143
+ } else {
144
+ # Could be selected, but isn't (yet)
145
+ return [ext-set-status $ext x]
146
+ }
147
+ foreach i [ext-get $ext libdep] {
148
+ define-append LDLIBS [get-define $i ""]
149
+ }
150
+ return [ext-set-status $ext y]
151
+}
152
+
153
+# Examines the user options (the $withinfo array)
154
+# and the extension database ($extdb) to determine
155
+# what is selected, and in what way.
156
+#
157
+# The results are available via ext-get-status
158
+# And a dictionary is returned containing four keys:
159
+# static-c extensions which are static C
160
+# static-tcl extensions which are static Tcl
161
+# module-c extensions which are C modules
162
+# module-tcl extensions which are Tcl modules
163
+proc check-extensions {} {
164
+ global extdb withinfo
165
+
166
+ # Check valid extension names
167
+ foreach i [concat $withinfo(ext) $withinfo(mod)] {
168
+ if {![dict exists $extdb attrs $i]} {
169
+ user-error "Unknown extension: $i"
170
+ }
171
+ }
172
+
173
+ set extlist [lsort [dict keys [dict get $extdb attrs]]]
174
+
175
+ set withinfo(maybe) {}
176
+
177
+ # Now work out the default status. We have.
178
+ # normal case, include !optional if possible
179
+ # --without=default, don't include optional
180
+ if {$withinfo(nodefault)} {
181
+ lappend withinfo(maybe) stdlib
182
+ } else {
183
+ foreach i $extlist {
184
+ if {![ext-has $i optional]} {
185
+ lappend withinfo(maybe) $i
186
+ }
187
+ }
188
+ }
189
+
190
+ foreach i $extlist {
191
+ define LDLIBS_$i ""
192
+ }
193
+
194
+ foreach i [concat $withinfo(ext) $withinfo(mod)] {
195
+ check-extension-status $i required
196
+ }
197
+ foreach i $withinfo(maybe) {
198
+ check-extension-status $i wanted
199
+ }
200
+
201
+ array set extinfo {static-c {} static-tcl {} module-c {} module-tcl {}}
202
+
203
+ foreach i $extlist {
204
+ set status [ext-get-status $i]
205
+ set tcl [ext-has $i tcl]
206
+ switch $status,$tcl {
207
+ y,1 {
208
+ define jim_ext_$i
209
+ lappend extinfo(static-tcl) $i
210
+ }
211
+ y,0 {
212
+ define jim_ext_$i
213
+ lappend extinfo(static-c) $i
214
+ # If there are any static C++ extensions, jimsh must be linked using
215
+ # the C++ compiler
216
+ if {[ext-has $i cpp]} {
217
+ define HAVE_CXX_EXTENSIONS
218
+ }
219
+ }
220
+ m,1 { lappend extinfo(module-tcl) $i }
221
+ m,0 { lappend extinfo(module-c) $i }
222
+ }
223
+ }
224
+ return [array get extinfo]
225
+}
31226
--- autosetup/local.tcl
+++ autosetup/local.tcl
@@ -26,5 +26,200 @@
26 set tclconfig($name) [string trim $value ']
27 }
28 }
29 return [array get tclconfig]
30 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
--- autosetup/local.tcl
+++ autosetup/local.tcl
@@ -26,5 +26,200 @@
26 set tclconfig($name) [string trim $value ']
27 }
28 }
29 return [array get tclconfig]
30 }
31
32 # The complex extension checking is done here.
33
34 global withinfo
35 global extdb
36
37 # Final determination of module status
38 dict set extdb status {}
39
40 # Returns 1 if the extension has the attribute
41 proc ext-has {ext attr} {
42 expr {$attr in [dict get $::extdb attrs $ext]}
43 }
44
45 # Returns an entry from the extension 'info' table, or $default otherwise
46 proc ext-get {ext key {default {}}} {
47 if {[dict exists $::extdb info $ext $key]} {
48 return [dict get $::extdb info $ext $key]
49 } else {
50 return $default
51 }
52 }
53
54 # Set the status of the extension to the given value, and returns the value
55 proc ext-set-status {ext value} {
56 dict set ::extdb status $ext $value
57 return $value
58 }
59
60 # Returns the status of the extension, or ? if unknown
61 proc ext-get-status {ext} {
62 if {[dict exists $::extdb status $ext]} {
63 return [dict get $::extdb status $ext]
64 }
65 return ?
66 }
67
68 proc check-extension-status {ext required} {
69 global withinfo
70
71 set status [ext-get-status $ext]
72
73 if {$ext in $withinfo(without)} {
74 # Disabled without further ado
75 msg-result "Extension $ext...disabled"
76 return [ext-set-status $ext n]
77 }
78
79 if {$status in {m y n}} {
80 return $status
81 }
82
83 # required is "required" if this extension *must* be enabled
84 # required is "wanted" if it is not fatal for this extension
85 # not to be enabled
86
87 array set depinfo {m 0 y 0 n 0}
88
89 # Check direct dependencies
90 if [ext-get $ext check 1] {
91 # "check" conditions are met
92 } else {
93 # not met
94 incr depinfo(n)
95 }
96
97 if {$depinfo(n) == 0} {
98 # Now extension dependencies
99 foreach i [ext-get $ext dep] {
100 set status [check-extension-status $i $required]
101 #puts "$ext: dep $i $required => $status"
102 incr depinfo($status)
103 if {$depinfo(n)} {
104 break
105 }
106 }
107 }
108
109 #parray depinfo
110
111 if {$depinfo(n)} {
112 msg-checking "Extension $ext..."
113 if {$required eq "required"} {
114 user-error "dependencies not met"
115 }
116 msg-result "disabled (dependencies)"
117 return [ext-set-status $ext n]
118 }
119
120 # Selected as a module?
121 if {$ext in $withinfo(mod)} {
122 if {[ext-has $ext tcl]} {
123 # Easy, a Tcl module
124 msg-result "Extension $ext...tcl"
125 } elseif {[ext-has $ext static]} {
126 user-error "Extension $ext can't be a module"
127 } else {
128 msg-result "Extension $ext...module"
129 foreach i [ext-get $ext libdep] {
130 define-append LDLIBS_$ext [get-define $i ""]
131 }
132 }
133 return [ext-set-status $ext m]
134 }
135
136 # Selected as a static extension?
137 if {[ext-has $ext shared]} {
138 user-error "Extension $ext can only be selected as a module"
139 } elseif {$ext in $withinfo(ext) || $required eq "$required"} {
140 msg-result "Extension $ext...enabled"
141 } elseif {$ext in $withinfo(maybe)} {
142 msg-result "Extension $ext...enabled (default)"
143 } else {
144 # Could be selected, but isn't (yet)
145 return [ext-set-status $ext x]
146 }
147 foreach i [ext-get $ext libdep] {
148 define-append LDLIBS [get-define $i ""]
149 }
150 return [ext-set-status $ext y]
151 }
152
153 # Examines the user options (the $withinfo array)
154 # and the extension database ($extdb) to determine
155 # what is selected, and in what way.
156 #
157 # The results are available via ext-get-status
158 # And a dictionary is returned containing four keys:
159 # static-c extensions which are static C
160 # static-tcl extensions which are static Tcl
161 # module-c extensions which are C modules
162 # module-tcl extensions which are Tcl modules
163 proc check-extensions {} {
164 global extdb withinfo
165
166 # Check valid extension names
167 foreach i [concat $withinfo(ext) $withinfo(mod)] {
168 if {![dict exists $extdb attrs $i]} {
169 user-error "Unknown extension: $i"
170 }
171 }
172
173 set extlist [lsort [dict keys [dict get $extdb attrs]]]
174
175 set withinfo(maybe) {}
176
177 # Now work out the default status. We have.
178 # normal case, include !optional if possible
179 # --without=default, don't include optional
180 if {$withinfo(nodefault)} {
181 lappend withinfo(maybe) stdlib
182 } else {
183 foreach i $extlist {
184 if {![ext-has $i optional]} {
185 lappend withinfo(maybe) $i
186 }
187 }
188 }
189
190 foreach i $extlist {
191 define LDLIBS_$i ""
192 }
193
194 foreach i [concat $withinfo(ext) $withinfo(mod)] {
195 check-extension-status $i required
196 }
197 foreach i $withinfo(maybe) {
198 check-extension-status $i wanted
199 }
200
201 array set extinfo {static-c {} static-tcl {} module-c {} module-tcl {}}
202
203 foreach i $extlist {
204 set status [ext-get-status $i]
205 set tcl [ext-has $i tcl]
206 switch $status,$tcl {
207 y,1 {
208 define jim_ext_$i
209 lappend extinfo(static-tcl) $i
210 }
211 y,0 {
212 define jim_ext_$i
213 lappend extinfo(static-c) $i
214 # If there are any static C++ extensions, jimsh must be linked using
215 # the C++ compiler
216 if {[ext-has $i cpp]} {
217 define HAVE_CXX_EXTENSIONS
218 }
219 }
220 m,1 { lappend extinfo(module-tcl) $i }
221 m,0 { lappend extinfo(module-c) $i }
222 }
223 }
224 return [array get extinfo]
225 }
226

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button