Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Update autosetup to the latest version. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
3a5c9b34f39be09bcb6e6f41ba5878fe |
| User & Date: | mistachkin 2014-06-14 20:05:31.020 |
Context
|
2014-06-14
| ||
| 20:06 | Add support for an Inno Setup project file for Fossil. ... (check-in: 3887a31812 user: mistachkin tags: trunk) | |
| 20:05 | Update autosetup to the latest version. ... (check-in: 3a5c9b34f3 user: mistachkin tags: trunk) | |
| 16:19 | Fix another memory leak in the "fossil fusefs" command. ... (check-in: 6b15019765 user: drh tags: trunk) | |
|
2014-06-12
| ||
| 20:21 | Update autosetup to the latest version. ... (Closed-Leaf check-in: 022c5c4faf user: mistachkin tags: autosetup) | |
Changes
Changes to autosetup/autosetup.
| ︙ | ︙ | |||
923 924 925 926 927 928 929 |
}
}
}
# Load module source in the global scope by executing the given command
proc automf_load {args} {
if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
| | | 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 |
}
}
}
# Load module source in the global scope by executing the given command
proc automf_load {args} {
if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
}
}
# Initial settings
set autosetup(exe) $::argv0
set autosetup(istcl) 1
set autosetup(start) [clock millis]
|
| ︙ | ︙ | |||
1704 1705 1706 1707 1708 1709 1710 1711 |
#puts "Skipping $info(file):$info(line)"
}
return $msg
}
# Given the return from [catch {...} msg opts], returns an appropriate
# error message. A nice one for Jim and a less-nice one for Tcl.
#
| > > | > | > | | | > > > > > > > > > > > > > | 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 |
#puts "Skipping $info(file):$info(line)"
}
return $msg
}
# Given the return from [catch {...} msg opts], returns an appropriate
# error message. A nice one for Jim and a less-nice one for Tcl.
# If 'fulltrace' is set, a full stack trace is provided.
# Otherwise a simple message is provided.
#
# This is designed for developer errors, e.g. in module code or auto.def code
#
#
proc error-dump {msg opts fulltrace} {
if {$::autosetup(istcl)} {
if {$fulltrace} {
return "Error: [dict get $opts -errorinfo]"
} else {
return "Error: $msg"
}
} else {
lassign $opts(-errorinfo) p f l
if {$f ne ""} {
set result "$f:$l: Error: "
}
append result "$msg\n"
if {$fulltrace} {
append result [stackdump $opts(-errorinfo)]
}
# Remove the trailing newline
string trim $result
}
}
}
# ----- module text-formatting -----
set modsource(text-formatting) {
|
| ︙ | ︙ | |||
1884 1885 1886 1887 1888 1889 1890 |
##################################################################
#
# Entry/Exit
#
if {$autosetup(debug)} {
main $argv
}
| | | | | 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 |
##################################################################
#
# Entry/Exit
#
if {$autosetup(debug)} {
main $argv
}
if {[catch {main $argv} msg opts] == 1} {
show-notices
autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
if {!$autosetup(debug)} {
puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
}
exit 1
}
|
Changes to autosetup/cc-shared.tcl.
| ︙ | ︙ | |||
92 93 94 95 96 97 98 99 100 101 102 103 |
# XXX: These haven't been tested
define SHOBJ_CFLAGS "+O3 +z"
define SHOBJ_LDFLAGS -b
define SH_CFLAGS +z
define SH_LINKFLAGS -Wl,+s
define LD_LIBRARY_PATH SHLIB_PATH
}
}
if {![is-defined SHOBJ_LDFLAGS_R]} {
define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
}
| > > > > > > > > > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# XXX: These haven't been tested
define SHOBJ_CFLAGS "+O3 +z"
define SHOBJ_LDFLAGS -b
define SH_CFLAGS +z
define SH_LINKFLAGS -Wl,+s
define LD_LIBRARY_PATH SHLIB_PATH
}
*-*-haiku {
define SHOBJ_CFLAGS ""
define SHOBJ_LDFLAGS -shared
define SH_CFLAGS ""
define SH_LDFLAGS -shared
define SH_LINKFLAGS ""
define SH_SOPREFIX ""
define LD_LIBRARY_PATH LIBRARY_PATH
}
}
if {![is-defined SHOBJ_LDFLAGS_R]} {
define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
}
|
Changes to autosetup/cc.tcl.
| ︙ | ︙ | |||
331 332 333 334 335 336 337 |
-declare {
lappend new($name) $value
}
-libs {
# Note that new libraries are added before previous libraries
set new($name) [list {*}$value {*}$new($name)]
}
| | | 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
-declare {
lappend new($name) $value
}
-libs {
# Note that new libraries are added before previous libraries
set new($name) [list {*}$value {*}$new($name)]
}
-link - -lang - -nooutput {
set new($name) $value
}
-source - -sourcefile - -code {
# XXX: These probably are only valid directly from cctest
set new($name) $value
}
default {
|
| ︙ | ︙ | |||
426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
## -declare code Code to declare before main()
## -link 1 Don't just compile, link too
## -lang c|c++ Use the C (default) or C++ compiler
## -libs liblist List of libraries to link, e.g. {-ldl -lm}
## -code code Code to compile in the body of main()
## -source code Compile a complete program. Ignore -includes, -declare and -code
## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
#
# Unless -source or -sourcefile is specified, the C program looks like:
#
## #include <firstinclude> /* same for remaining includes in the list */
##
## declare-code /* any code in -declare, verbatim */
##
| > | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
## -declare code Code to declare before main()
## -link 1 Don't just compile, link too
## -lang c|c++ Use the C (default) or C++ compiler
## -libs liblist List of libraries to link, e.g. {-ldl -lm}
## -code code Code to compile in the body of main()
## -source code Compile a complete program. Ignore -includes, -declare and -code
## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
#
# Unless -source or -sourcefile is specified, the C program looks like:
#
## #include <firstinclude> /* same for remaining includes in the list */
##
## declare-code /* any code in -declare, verbatim */
##
|
| ︙ | ︙ | |||
519 520 521 522 523 524 525 | } return $ok } writefile $src $lines\n set ok 1 | | > | 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
}
return $ok
}
writefile $src $lines\n
set ok 1
set err [catch {exec-with-stderr {*}$cmdline} result errinfo]
if {$err || ($opts(-nooutput) && [string length $result])} {
configlog "Failed: [join $cmdline]"
configlog $result
configlog "============"
configlog "The failed code was:"
configlog $lines
configlog "============"
set ok 0
|
| ︙ | ︙ | |||
669 670 671 672 673 674 675 |
if {[get-define CC] eq ""} {
user-error "Could not find a C compiler. Tried: [join $try ", "]"
}
define CCACHE [find-an-executable [get-env CCACHE ccache]]
# Initial cctest settings
| | | | | | | 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 |
if {[get-define CC] eq ""} {
user-error "Could not find a C compiler. Tried: [join $try ", "]"
}
define CCACHE [find-an-executable [get-env CCACHE ccache]]
# Initial cctest settings
cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {} -nooutput 0}
set autosetup(cc-include-deps) {}
msg-result "C compiler...[get-define CCACHE] [get-define CC] [get-define CFLAGS]"
if {[get-define CXX] ne "false"} {
msg-result "C++ compiler...[get-define CCACHE] [get-define CXX] [get-define CXXFLAGS]"
}
msg-result "Build C compiler...[get-define CC_FOR_BUILD]"
# On Darwin, we prefer to use -g0 to avoid creating .dSYM directories
# but some compilers may not support it, so test here.
switch -glob -- [get-define host] {
*-*-darwin* {
if {[cctest -cflags {-g0}]} {
define cc-default-debug -g0
}
}
}
if {![cc-check-includes stdlib.h]} {
user-error "Compiler does not work. See config.log"
}
|
Changes to autosetup/jimsh0.c.
| ︙ | ︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #define HAVE_VFORK #define HAVE_WAITPID #define HAVE_ISATTY #define HAVE_SYS_TIME_H #define HAVE_DIRENT_H #define HAVE_UNISTD_H #endif #ifndef JIM_WIN32COMPAT_H #define JIM_WIN32COMPAT_H #if defined(_WIN32) || defined(WIN32) | > | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #define HAVE_VFORK #define HAVE_WAITPID #define HAVE_ISATTY #define HAVE_SYS_TIME_H #define HAVE_DIRENT_H #define HAVE_UNISTD_H #endif #define JIM_VERSION 75 #ifndef JIM_WIN32COMPAT_H #define JIM_WIN32COMPAT_H #if defined(_WIN32) || defined(WIN32) |
| ︙ | ︙ | |||
183 184 185 186 187 188 189 | # define strtoull strtoul # endif #endif #define UCHAR(c) ((unsigned char)(c)) | < < | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | # define strtoull strtoul # endif #endif #define UCHAR(c) ((unsigned char)(c)) #define JIM_OK 0 #define JIM_ERR 1 #define JIM_RETURN 2 #define JIM_BREAK 3 #define JIM_CONTINUE 4 #define JIM_SIGNAL 5 #define JIM_EXIT 6 |
| ︙ | ︙ | |||
830 831 832 833 834 835 836 |
JIM_EXPORT int Jim_GetDouble(Jim_Interp *interp, Jim_Obj *objPtr,
double *doublePtr);
JIM_EXPORT void Jim_SetDouble(Jim_Interp *interp, Jim_Obj *objPtr,
double doubleValue);
JIM_EXPORT Jim_Obj * Jim_NewDoubleObj(Jim_Interp *interp, double doubleValue);
| < < < < < < | 829 830 831 832 833 834 835 836 837 838 839 840 841 842 |
JIM_EXPORT int Jim_GetDouble(Jim_Interp *interp, Jim_Obj *objPtr,
double *doublePtr);
JIM_EXPORT void Jim_SetDouble(Jim_Interp *interp, Jim_Obj *objPtr,
double doubleValue);
JIM_EXPORT Jim_Obj * Jim_NewDoubleObj(Jim_Interp *interp, double doubleValue);
JIM_EXPORT void Jim_WrongNumArgs (Jim_Interp *interp, int argc,
Jim_Obj *const *argv, const char *msg);
JIM_EXPORT int Jim_GetEnum (Jim_Interp *interp, Jim_Obj *objPtr,
const char * const *tablePtr, int *indexPtr, const char *name, int flags);
JIM_EXPORT int Jim_ScriptIsComplete (const char *s, int len,
char *stateCharPtr);
|
| ︙ | ︙ | |||
873 874 875 876 877 878 879 | JIM_EXPORT char *Jim_HistoryGetline(const char *prompt); JIM_EXPORT void Jim_HistoryAdd(const char *line); JIM_EXPORT void Jim_HistoryShow(void); JIM_EXPORT int Jim_InitStaticExtensions(Jim_Interp *interp); JIM_EXPORT int Jim_StringToWide(const char *str, jim_wide *widePtr, int base); | | | 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 | JIM_EXPORT char *Jim_HistoryGetline(const char *prompt); JIM_EXPORT void Jim_HistoryAdd(const char *line); JIM_EXPORT void Jim_HistoryShow(void); JIM_EXPORT int Jim_InitStaticExtensions(Jim_Interp *interp); JIM_EXPORT int Jim_StringToWide(const char *str, jim_wide *widePtr, int base); JIM_EXPORT int Jim_IsBigEndian(void); #define Jim_CheckSignal(i) ((i)->signal_level && (i)->sigmask) JIM_EXPORT int Jim_LoadLibrary(Jim_Interp *interp, const char *pathName); JIM_EXPORT void Jim_FreeLoadHandles(Jim_Interp *interp); |
| ︙ | ︙ | |||
1773 1774 1775 1776 1777 1778 1779 |
fclose(af->fp);
}
Jim_DecrRefCount(interp, af->filename);
#ifdef jim_ext_eventloop
| < | < < < < < < < | 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 |
fclose(af->fp);
}
Jim_DecrRefCount(interp, af->filename);
#ifdef jim_ext_eventloop
Jim_DeleteFileHandler(interp, af->fp, JIM_EVENT_READABLE | JIM_EVENT_WRITABLE | JIM_EVENT_EXCEPTION);
#endif
Jim_Free(af);
}
static int JimCheckStreamError(Jim_Interp *interp, AioFile *af)
{
if (!ferror(af->fp)) {
|
| ︙ | ︙ | |||
2145 2146 2147 2148 2149 2150 2151 |
}
return JIM_OK;
}
#ifdef jim_ext_eventloop
static void JimAioFileEventFinalizer(Jim_Interp *interp, void *clientData)
{
| | | > | | < < | < < | | | 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 |
}
return JIM_OK;
}
#ifdef jim_ext_eventloop
static void JimAioFileEventFinalizer(Jim_Interp *interp, void *clientData)
{
Jim_Obj **objPtrPtr = clientData;
Jim_DecrRefCount(interp, *objPtrPtr);
*objPtrPtr = NULL;
}
static int JimAioFileEventHandler(Jim_Interp *interp, void *clientData, int mask)
{
Jim_Obj **objPtrPtr = clientData;
return Jim_EvalObjBackground(interp, *objPtrPtr);
}
static int aio_eventinfo(Jim_Interp *interp, AioFile * af, unsigned mask, Jim_Obj **scriptHandlerObj,
int argc, Jim_Obj * const *argv)
{
if (argc == 0) {
if (*scriptHandlerObj) {
Jim_SetResult(interp, *scriptHandlerObj);
}
return JIM_OK;
}
if (*scriptHandlerObj) {
Jim_DeleteFileHandler(interp, af->fp, mask);
}
if (Jim_Length(argv[0]) == 0) {
return JIM_OK;
}
Jim_IncrRefCount(argv[0]);
*scriptHandlerObj = argv[0];
Jim_CreateFileHandler(interp, af->fp, mask,
JimAioFileEventHandler, scriptHandlerObj, JimAioFileEventFinalizer);
return JIM_OK;
}
static int aio_cmd_readable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
|
| ︙ | ︙ | |||
4003 4004 4005 4006 4007 4008 4009 |
static const char *JimStrError(void);
static char **JimSaveEnv(char **env);
static void JimRestoreEnv(char **env);
static int JimCreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv,
pidtype **pidArrayPtr, fdtype *inPipePtr, fdtype *outPipePtr, fdtype *errFilePtr);
static void JimDetachPids(Jim_Interp *interp, int numPids, const pidtype *pidPtr);
static int JimCleanupChildren(Jim_Interp *interp, int numPids, pidtype *pidPtr, fdtype errorId);
| | | 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 |
static const char *JimStrError(void);
static char **JimSaveEnv(char **env);
static void JimRestoreEnv(char **env);
static int JimCreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv,
pidtype **pidArrayPtr, fdtype *inPipePtr, fdtype *outPipePtr, fdtype *errFilePtr);
static void JimDetachPids(Jim_Interp *interp, int numPids, const pidtype *pidPtr);
static int JimCleanupChildren(Jim_Interp *interp, int numPids, pidtype *pidPtr, fdtype errorId);
static fdtype JimCreateTemp(Jim_Interp *interp, const char *contents, int len);
static fdtype JimOpenForWrite(const char *filename, int append);
static int JimRewindFd(fdtype fd);
static void Jim_SetResultErrno(Jim_Interp *interp, const char *msg)
{
Jim_SetResultFormatted(interp, "%s: %s", msg, JimStrError());
}
|
| ︙ | ︙ | |||
4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 |
int numPids = 0; /* Actual number of processes that exist
* at *pidPtr right now. */
int cmdCount; /* Count of number of distinct commands
* found in argc/argv. */
const char *input = NULL; /* Describes input for pipeline, depending
* on "inputFile". NULL means take input
* from stdin/pipe. */
#define FILE_NAME 0
#define FILE_APPEND 1
#define FILE_HANDLE 2
#define FILE_TEXT 3
int inputFile = FILE_NAME; /* 1 means input is name of input file.
| > | 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 |
int numPids = 0; /* Actual number of processes that exist
* at *pidPtr right now. */
int cmdCount; /* Count of number of distinct commands
* found in argc/argv. */
const char *input = NULL; /* Describes input for pipeline, depending
* on "inputFile". NULL means take input
* from stdin/pipe. */
int input_len = 0;
#define FILE_NAME 0
#define FILE_APPEND 1
#define FILE_HANDLE 2
#define FILE_TEXT 3
int inputFile = FILE_NAME; /* 1 means input is name of input file.
|
| ︙ | ︙ | |||
4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 |
const char *arg = Jim_String(argv[i]);
if (arg[0] == '<') {
inputFile = FILE_NAME;
input = arg + 1;
if (*input == '<') {
inputFile = FILE_TEXT;
input++;
}
else if (*input == '@') {
inputFile = FILE_HANDLE;
input++;
}
if (!*input && ++i < argc) {
| > | | 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 |
const char *arg = Jim_String(argv[i]);
if (arg[0] == '<') {
inputFile = FILE_NAME;
input = arg + 1;
if (*input == '<') {
inputFile = FILE_TEXT;
input_len = Jim_Length(argv[i]) - 2;
input++;
}
else if (*input == '@') {
inputFile = FILE_HANDLE;
input++;
}
if (!*input && ++i < argc) {
input = Jim_GetString(argv[i], &input_len);
}
}
else if (arg[0] == '>') {
int dup_error = 0;
outputFile = FILE_NAME;
|
| ︙ | ︙ | |||
4496 4497 4498 4499 4500 4501 4502 |
}
save_environ = JimSaveEnv(JimBuildEnv(interp));
if (input != NULL) {
if (inputFile == FILE_TEXT) {
| | | 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 |
}
save_environ = JimSaveEnv(JimBuildEnv(interp));
if (input != NULL) {
if (inputFile == FILE_TEXT) {
inputId = JimCreateTemp(interp, input, input_len);
if (inputId == JIM_BAD_FD) {
goto error;
}
}
else if (inputFile == FILE_HANDLE) {
FILE *fh = JimGetAioFilehandle(interp, input);
|
| ︙ | ︙ | |||
4585 4586 4587 4588 4589 4590 4591 |
if (errorId == JIM_BAD_FD) {
Jim_SetResultFormatted(interp, "couldn't write file \"%s\": %s", error, JimStrError());
goto error;
}
}
}
else if (errFilePtr != NULL) {
| | | 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 |
if (errorId == JIM_BAD_FD) {
Jim_SetResultFormatted(interp, "couldn't write file \"%s\": %s", error, JimStrError());
goto error;
}
}
}
else if (errFilePtr != NULL) {
errorId = JimCreateTemp(interp, NULL, 0);
if (errorId == JIM_BAD_FD) {
goto error;
}
*errFilePtr = JimDupFd(errorId);
}
|
| ︙ | ︙ | |||
4951 4952 4953 4954 4955 4956 4957 |
}
GetExitCodeProcess(pid, &ret);
*status = ret;
CloseHandle(pid);
return pid;
}
| | | 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 |
}
GetExitCodeProcess(pid, &ret);
*status = ret;
CloseHandle(pid);
return pid;
}
static HANDLE JimCreateTemp(Jim_Interp *interp, const char *contents, int len)
{
char name[MAX_PATH];
HANDLE handle;
if (!GetTempPath(MAX_PATH, name) || !GetTempFileName(name, "JIM", 0, name)) {
return JIM_BAD_FD;
}
|
| ︙ | ︙ | |||
4975 4976 4977 4978 4979 4980 4981 |
if (contents != NULL) {
FILE *fh = JimFdOpenForWrite(JimDupFd(handle));
if (fh == NULL) {
goto error;
}
| | | 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 |
if (contents != NULL) {
FILE *fh = JimFdOpenForWrite(JimDupFd(handle));
if (fh == NULL) {
goto error;
}
if (fwrite(contents, len, 1, fh) != 1) {
fclose(fh);
goto error;
}
fseek(fh, 0, SEEK_SET);
fclose(fh);
}
return handle;
|
| ︙ | ︙ | |||
5194 5195 5196 5197 5198 5199 5200 |
}
static int JimRewindFd(int fd)
{
return lseek(fd, 0L, SEEK_SET);
}
| | < | | 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 |
}
static int JimRewindFd(int fd)
{
return lseek(fd, 0L, SEEK_SET);
}
static int JimCreateTemp(Jim_Interp *interp, const char *contents, int len)
{
char inName[] = "/tmp/tcl.tmp.XXXXXX";
int fd = mkstemp(inName);
if (fd == JIM_BAD_FD) {
Jim_SetResultErrno(interp, "couldn't create temp file");
return -1;
}
unlink(inName);
if (contents) {
if (write(fd, contents, len) != len) {
Jim_SetResultErrno(interp, "couldn't write temp file");
close(fd);
return -1;
}
lseek(fd, 0L, SEEK_SET);
}
return fd;
|
| ︙ | ︙ | |||
5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 | #ifdef JIM_MAINTAINER #define JIM_DEBUG_COMMAND #define JIM_DEBUG_PANIC #endif #define JIM_INTEGER_SPACE 24 const char *jim_tt_name(int type); #ifdef JIM_DEBUG_PANIC static void JimPanicDump(int panic_condition, const char *fmt, ...); | > | 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 | #ifdef JIM_MAINTAINER #define JIM_DEBUG_COMMAND #define JIM_DEBUG_PANIC #endif #define JIM_INTEGER_SPACE 24 const char *jim_tt_name(int type); #ifdef JIM_DEBUG_PANIC static void JimPanicDump(int panic_condition, const char *fmt, ...); |
| ︙ | ︙ | |||
6027 6028 6029 6030 6031 6032 6033 |
i += 2;
if (str[i] != '-' && str[i] != '+' && !isspace(UCHAR(str[i]))) {
return i;
}
| > | | 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 |
i += 2;
if (str[i] != '-' && str[i] != '+' && !isspace(UCHAR(str[i]))) {
return i;
}
*base = 10;
return 0;
}
static long jim_strtol(const char *str, char **endptr)
{
int sign;
int base;
int i = JimNumberBase(str, &base, &sign);
|
| ︙ | ︙ | |||
6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 |
}
#endif
return len;
}
if (buf[i] == 'i' || buf[i] == 'I' || buf[i] == 'n' || buf[i] == 'N') {
buf[i] = toupper(UCHAR(buf[i]));
buf[i + 3] = 0;
return i + 3;
}
}
buf[i++] = '.';
buf[i++] = '0';
| > > | 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 |
}
#endif
return len;
}
if (buf[i] == 'i' || buf[i] == 'I' || buf[i] == 'n' || buf[i] == 'N') {
buf[i] = toupper(UCHAR(buf[i]));
if (buf[i] == 'n' || buf[i] == 'N')
buf[i+2] = toupper(UCHAR(buf[i+2]));
buf[i + 3] = 0;
return i + 3;
}
}
buf[i++] = '.';
buf[i++] = '0';
|
| ︙ | ︙ | |||
7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 |
if (objPtr->prevObjPtr)
objPtr->prevObjPtr->nextObjPtr = objPtr->nextObjPtr;
if (objPtr->nextObjPtr)
objPtr->nextObjPtr->prevObjPtr = objPtr->prevObjPtr;
if (interp->liveList == objPtr)
interp->liveList = objPtr->nextObjPtr;
objPtr->prevObjPtr = NULL;
objPtr->nextObjPtr = interp->freeList;
if (interp->freeList)
interp->freeList->prevObjPtr = objPtr;
interp->freeList = objPtr;
objPtr->refCount = -1;
}
void Jim_InvalidateStringRep(Jim_Obj *objPtr)
{
if (objPtr->bytes != NULL) {
if (objPtr->bytes != JimEmptyStringRep)
| > > > > | 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 |
if (objPtr->prevObjPtr)
objPtr->prevObjPtr->nextObjPtr = objPtr->nextObjPtr;
if (objPtr->nextObjPtr)
objPtr->nextObjPtr->prevObjPtr = objPtr->prevObjPtr;
if (interp->liveList == objPtr)
interp->liveList = objPtr->nextObjPtr;
#ifdef JIM_DISABLE_OBJECT_POOL
Jim_Free(objPtr);
#else
objPtr->prevObjPtr = NULL;
objPtr->nextObjPtr = interp->freeList;
if (interp->freeList)
interp->freeList->prevObjPtr = objPtr;
interp->freeList = objPtr;
objPtr->refCount = -1;
#endif
}
void Jim_InvalidateStringRep(Jim_Obj *objPtr)
{
if (objPtr->bytes != NULL) {
if (objPtr->bytes != JimEmptyStringRep)
|
| ︙ | ︙ | |||
8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 |
Jim_IncrRefCount(objPtr);
Jim_DecrRefCount(interp, objPtr);
}
return strObjPtr;
}
static int JimStringIs(Jim_Interp *interp, Jim_Obj *strObjPtr, Jim_Obj *strClass, int strict)
{
static const char * const strclassnames[] = {
"integer", "alpha", "alnum", "ascii", "digit",
"double", "lower", "upper", "space", "xdigit",
"control", "print", "graph", "punct",
| > > > > > > > > > | 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 |
Jim_IncrRefCount(objPtr);
Jim_DecrRefCount(interp, objPtr);
}
return strObjPtr;
}
#ifdef HAVE_ISASCII
#define jim_isascii isascii
#else
static int jim_isascii(int c)
{
return !(c & ~0x7f);
}
#endif
static int JimStringIs(Jim_Interp *interp, Jim_Obj *strObjPtr, Jim_Obj *strClass, int strict)
{
static const char * const strclassnames[] = {
"integer", "alpha", "alnum", "ascii", "digit",
"double", "lower", "upper", "space", "xdigit",
"control", "print", "graph", "punct",
|
| ︙ | ︙ | |||
8289 8290 8291 8292 8293 8294 8295 |
double d;
Jim_SetResultInt(interp, Jim_GetDouble(interp, strObjPtr, &d) == JIM_OK && errno != ERANGE);
return JIM_OK;
}
case STR_IS_ALPHA: isclassfunc = isalpha; break;
case STR_IS_ALNUM: isclassfunc = isalnum; break;
| | | 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 |
double d;
Jim_SetResultInt(interp, Jim_GetDouble(interp, strObjPtr, &d) == JIM_OK && errno != ERANGE);
return JIM_OK;
}
case STR_IS_ALPHA: isclassfunc = isalpha; break;
case STR_IS_ALNUM: isclassfunc = isalnum; break;
case STR_IS_ASCII: isclassfunc = jim_isascii; break;
case STR_IS_DIGIT: isclassfunc = isdigit; break;
case STR_IS_LOWER: isclassfunc = islower; break;
case STR_IS_UPPER: isclassfunc = isupper; break;
case STR_IS_SPACE: isclassfunc = isspace; break;
case STR_IS_XDIGIT: isclassfunc = isxdigit; break;
case STR_IS_CONTROL: isclassfunc = iscntrl; break;
case STR_IS_PRINT: isclassfunc = isprint; break;
|
| ︙ | ︙ | |||
10211 10212 10213 10214 10215 10216 10217 |
if (elapsedId > JIM_COLLECT_ID_PERIOD || elapsedTime > JIM_COLLECT_TIME_PERIOD) {
Jim_Collect(interp);
}
}
#endif
| | | 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 |
if (elapsedId > JIM_COLLECT_ID_PERIOD || elapsedTime > JIM_COLLECT_TIME_PERIOD) {
Jim_Collect(interp);
}
}
#endif
int Jim_IsBigEndian(void)
{
union {
unsigned short s;
unsigned char c[2];
} uval = {0x0102};
return uval.c[0] == 1;
|
| ︙ | ︙ | |||
10267 10268 10269 10270 10271 10272 10273 |
Jim_SetVariableStrWithStr(i, JIM_LIBPATH, TCL_LIBRARY);
Jim_SetVariableStrWithStr(i, JIM_INTERACTIVE, "0");
Jim_SetVariableStrWithStr(i, "tcl_platform(os)", TCL_PLATFORM_OS);
Jim_SetVariableStrWithStr(i, "tcl_platform(platform)", TCL_PLATFORM_PLATFORM);
Jim_SetVariableStrWithStr(i, "tcl_platform(pathSeparator)", TCL_PLATFORM_PATH_SEPARATOR);
| | | 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 |
Jim_SetVariableStrWithStr(i, JIM_LIBPATH, TCL_LIBRARY);
Jim_SetVariableStrWithStr(i, JIM_INTERACTIVE, "0");
Jim_SetVariableStrWithStr(i, "tcl_platform(os)", TCL_PLATFORM_OS);
Jim_SetVariableStrWithStr(i, "tcl_platform(platform)", TCL_PLATFORM_PLATFORM);
Jim_SetVariableStrWithStr(i, "tcl_platform(pathSeparator)", TCL_PLATFORM_PATH_SEPARATOR);
Jim_SetVariableStrWithStr(i, "tcl_platform(byteOrder)", Jim_IsBigEndian() ? "bigEndian" : "littleEndian");
Jim_SetVariableStrWithStr(i, "tcl_platform(threaded)", "0");
Jim_SetVariableStr(i, "tcl_platform(pointerSize)", Jim_NewIntObj(i, sizeof(void *)));
Jim_SetVariableStr(i, "tcl_platform(wordSize)", Jim_NewIntObj(i, sizeof(jim_wide)));
return i;
}
|
| ︙ | ︙ | |||
10447 10448 10449 10450 10451 10452 10453 |
Jim_IncrRefCount(stackTraceObj);
Jim_DecrRefCount(interp, interp->stackTrace);
interp->stackTrace = stackTraceObj;
interp->errorFlag = 1;
len = Jim_ListLength(interp, interp->stackTrace);
if (len >= 3) {
| < < | < < < < | 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 |
Jim_IncrRefCount(stackTraceObj);
Jim_DecrRefCount(interp, interp->stackTrace);
interp->stackTrace = stackTraceObj;
interp->errorFlag = 1;
len = Jim_ListLength(interp, interp->stackTrace);
if (len >= 3) {
if (Jim_Length(Jim_ListGetIndex(interp, interp->stackTrace, len - 2)) == 0) {
interp->addStackTrace = 1;
}
}
}
static void JimAppendStackTrace(Jim_Interp *interp, const char *procname,
|
| ︙ | ︙ | |||
10483 10484 10485 10486 10487 10488 10489 |
if (!*procname && Jim_Length(fileNameObj)) {
int len = Jim_ListLength(interp, interp->stackTrace);
if (len >= 3) {
| | | | > | 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 |
if (!*procname && Jim_Length(fileNameObj)) {
int len = Jim_ListLength(interp, interp->stackTrace);
if (len >= 3) {
Jim_Obj *objPtr = Jim_ListGetIndex(interp, interp->stackTrace, len - 3);
if (Jim_Length(objPtr)) {
objPtr = Jim_ListGetIndex(interp, interp->stackTrace, len - 2);
if (Jim_Length(objPtr) == 0) {
ListSetIndex(interp, interp->stackTrace, len - 2, fileNameObj, 0);
ListSetIndex(interp, interp->stackTrace, len - 1, Jim_NewIntObj(interp, linenr), 0);
return;
}
}
}
|
| ︙ | ︙ | |||
17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 |
}
static int Jim_LocalCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int retcode;
interp->local++;
retcode = Jim_EvalObjVector(interp, argc - 1, argv + 1);
interp->local--;
| > > > > > | 17152 17153 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 |
}
static int Jim_LocalCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int retcode;
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv, "cmd ?args ...?");
return JIM_ERR;
}
interp->local++;
retcode = Jim_EvalObjVector(interp, argc - 1, argv + 1);
interp->local--;
|
| ︙ | ︙ | |||
19550 19551 19552 19553 19554 19555 19556 |
Jim_Obj *resultPtr;
char *num_buffer = NULL;
int num_buffer_size = 0;
span = format = Jim_GetString(fmtObjPtr, &formatLen);
formatEnd = format + formatLen;
| | | 19550 19551 19552 19553 19554 19555 19556 19557 19558 19559 19560 19561 19562 19563 19564 |
Jim_Obj *resultPtr;
char *num_buffer = NULL;
int num_buffer_size = 0;
span = format = Jim_GetString(fmtObjPtr, &formatLen);
formatEnd = format + formatLen;
resultPtr = Jim_NewEmptyStringObj(interp);
while (format != formatEnd) {
char *end;
int gotMinus, sawFlag;
int gotPrecision, useShort;
long width, precision;
int newXpg;
|
| ︙ | ︙ |
Changes to autosetup/local.tcl.
| ︙ | ︙ | |||
24 25 26 27 28 29 30 |
if {[regexp {^(TCL_[^=]*)=(.*)$} $line -> name value]} {
set value [regsub -all {\$\{.*\}} $value ""]
set tclconfig($name) [string trim $value ']
}
}
return [array get tclconfig]
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
if {[regexp {^(TCL_[^=]*)=(.*)$} $line -> name value]} {
set value [regsub -all {\$\{.*\}} $value ""]
set tclconfig($name) [string trim $value ']
}
}
return [array get tclconfig]
}
# The complex extension checking is done here.
global withinfo
global extdb
# Final determination of module status
dict set extdb status {}
# Returns 1 if the extension has the attribute
proc ext-has {ext attr} {
expr {$attr in [dict get $::extdb attrs $ext]}
}
# Returns an entry from the extension 'info' table, or $default otherwise
proc ext-get {ext key {default {}}} {
if {[dict exists $::extdb info $ext $key]} {
return [dict get $::extdb info $ext $key]
} else {
return $default
}
}
# Set the status of the extension to the given value, and returns the value
proc ext-set-status {ext value} {
dict set ::extdb status $ext $value
return $value
}
# Returns the status of the extension, or ? if unknown
proc ext-get-status {ext} {
if {[dict exists $::extdb status $ext]} {
return [dict get $::extdb status $ext]
}
return ?
}
proc check-extension-status {ext required} {
global withinfo
set status [ext-get-status $ext]
if {$ext in $withinfo(without)} {
# Disabled without further ado
msg-result "Extension $ext...disabled"
return [ext-set-status $ext n]
}
if {$status in {m y n}} {
return $status
}
# required is "required" if this extension *must* be enabled
# required is "wanted" if it is not fatal for this extension
# not to be enabled
array set depinfo {m 0 y 0 n 0}
# Check direct dependencies
if [ext-get $ext check 1] {
# "check" conditions are met
} else {
# not met
incr depinfo(n)
}
if {$depinfo(n) == 0} {
# Now extension dependencies
foreach i [ext-get $ext dep] {
set status [check-extension-status $i $required]
#puts "$ext: dep $i $required => $status"
incr depinfo($status)
if {$depinfo(n)} {
break
}
}
}
#parray depinfo
if {$depinfo(n)} {
msg-checking "Extension $ext..."
if {$required eq "required"} {
user-error "dependencies not met"
}
msg-result "disabled (dependencies)"
return [ext-set-status $ext n]
}
# Selected as a module?
if {$ext in $withinfo(mod)} {
if {[ext-has $ext tcl]} {
# Easy, a Tcl module
msg-result "Extension $ext...tcl"
} elseif {[ext-has $ext static]} {
user-error "Extension $ext can't be a module"
} else {
msg-result "Extension $ext...module"
foreach i [ext-get $ext libdep] {
define-append LDLIBS_$ext [get-define $i ""]
}
}
return [ext-set-status $ext m]
}
# Selected as a static extension?
if {[ext-has $ext shared]} {
user-error "Extension $ext can only be selected as a module"
} elseif {$ext in $withinfo(ext) || $required eq "$required"} {
msg-result "Extension $ext...enabled"
} elseif {$ext in $withinfo(maybe)} {
msg-result "Extension $ext...enabled (default)"
} else {
# Could be selected, but isn't (yet)
return [ext-set-status $ext x]
}
foreach i [ext-get $ext libdep] {
define-append LDLIBS [get-define $i ""]
}
return [ext-set-status $ext y]
}
# Examines the user options (the $withinfo array)
# and the extension database ($extdb) to determine
# what is selected, and in what way.
#
# The results are available via ext-get-status
# And a dictionary is returned containing four keys:
# static-c extensions which are static C
# static-tcl extensions which are static Tcl
# module-c extensions which are C modules
# module-tcl extensions which are Tcl modules
proc check-extensions {} {
global extdb withinfo
# Check valid extension names
foreach i [concat $withinfo(ext) $withinfo(mod)] {
if {![dict exists $extdb attrs $i]} {
user-error "Unknown extension: $i"
}
}
set extlist [lsort [dict keys [dict get $extdb attrs]]]
set withinfo(maybe) {}
# Now work out the default status. We have.
# normal case, include !optional if possible
# --without=default, don't include optional
if {$withinfo(nodefault)} {
lappend withinfo(maybe) stdlib
} else {
foreach i $extlist {
if {![ext-has $i optional]} {
lappend withinfo(maybe) $i
}
}
}
foreach i $extlist {
define LDLIBS_$i ""
}
foreach i [concat $withinfo(ext) $withinfo(mod)] {
check-extension-status $i required
}
foreach i $withinfo(maybe) {
check-extension-status $i wanted
}
array set extinfo {static-c {} static-tcl {} module-c {} module-tcl {}}
foreach i $extlist {
set status [ext-get-status $i]
set tcl [ext-has $i tcl]
switch $status,$tcl {
y,1 {
define jim_ext_$i
lappend extinfo(static-tcl) $i
}
y,0 {
define jim_ext_$i
lappend extinfo(static-c) $i
# If there are any static C++ extensions, jimsh must be linked using
# the C++ compiler
if {[ext-has $i cpp]} {
define HAVE_CXX_EXTENSIONS
}
}
m,1 { lappend extinfo(module-tcl) $i }
m,0 { lappend extinfo(module-c) $i }
}
}
return [array get extinfo]
}
|