Fossil SCM

Update Jim Tcl to build with MSVC

steveb 2011-11-07 05:51 jimtcl
Commit b6270d665be938f8b9643b68b883a6387194a700
+752 -612
--- autosetup/jimsh0.c
+++ autosetup/jimsh0.c
@@ -16,24 +16,99 @@
1616
#define jim_ext_exec
1717
#define jim_ext_clock
1818
#define jim_ext_array
1919
#define jim_ext_stdlib
2020
#define jim_ext_tclcompat
21
-#if defined(__MINGW32__)
21
+#if defined(_MSC_VER)
22
+#define TCL_PLATFORM_OS "windows"
23
+#define TCL_PLATFORM_PLATFORM "windows"
24
+#define TCL_PLATFORM_PATH_SEPARATOR ";"
25
+#define HAVE_MKDIR_ONE_ARG
26
+#define HAVE_SYSTEM
27
+#elif defined(__MINGW32__)
2228
#define TCL_PLATFORM_OS "mingw"
2329
#define TCL_PLATFORM_PLATFORM "windows"
2430
#define TCL_PLATFORM_PATH_SEPARATOR ";"
2531
#define HAVE_MKDIR_ONE_ARG
2632
#define HAVE_SYSTEM
27
-#define WIN32_LEAN_AND_MEAN
28
-#include <windows.h>
33
+#define HAVE_SYS_TIME_H
34
+#define HAVE_DIRENT_H
35
+#define HAVE_UNISTD_H
2936
#else
3037
#define TCL_PLATFORM_OS "unknown"
3138
#define TCL_PLATFORM_PLATFORM "unix"
3239
#define TCL_PLATFORM_PATH_SEPARATOR ":"
3340
#define HAVE_VFORK
3441
#define HAVE_WAITPID
42
+#define HAVE_SYS_TIME_H
43
+#define HAVE_DIRENT_H
44
+#define HAVE_UNISTD_H
45
+#endif
46
+#ifndef JIM_WIN32COMPAT_H
47
+#define JIM_WIN32COMPAT_H
48
+
49
+
50
+
51
+
52
+#if defined(_WIN32) || defined(WIN32)
53
+
54
+#define HAVE_DLOPEN
55
+void *dlopen(const char *path, int mode);
56
+int dlclose(void *handle);
57
+void *dlsym(void *handle, const char *symbol);
58
+char *dlerror(void);
59
+
60
+#ifdef _MSC_VER
61
+
62
+
63
+#if _MSC_VER >= 1000
64
+ #pragma warning(disable:4146)
65
+#endif
66
+
67
+#include <limits.h>
68
+#define jim_wide _int64
69
+#ifndef LLONG_MAX
70
+ #define LLONG_MAX 9223372036854775807I64
71
+#endif
72
+#ifndef LLONG_MIN
73
+ #define LLONG_MIN (-LLONG_MAX - 1I64)
74
+#endif
75
+#define JIM_WIDE_MIN LLONG_MIN
76
+#define JIM_WIDE_MAX LLONG_MAX
77
+#define JIM_WIDE_MODIFIER "I64d"
78
+#define strcasecmp _stricmp
79
+#define strtoull _strtoui64
80
+#define snprintf _snprintf
81
+
82
+#include <io.h>
83
+
84
+struct timeval {
85
+ long tv_sec;
86
+ long tv_usec;
87
+};
88
+
89
+int gettimeofday(struct timeval *tv, void *unused);
90
+
91
+#define HAVE_OPENDIR
92
+struct dirent {
93
+ char *d_name;
94
+};
95
+
96
+typedef struct DIR {
97
+ long handle;
98
+ struct _finddata_t info;
99
+ struct dirent result;
100
+ char *name;
101
+} DIR;
102
+
103
+DIR *opendir(const char *name);
104
+int closedir(DIR *dir);
105
+struct dirent *readdir(DIR *dir);
106
+#endif
107
+
108
+#endif
109
+
35110
#endif
36111
#ifndef UTF8_UTIL_H
37112
#define UTF8_UTIL_H
38113
39114
int utf8_fromunicode(char *p, unsigned short uc);
@@ -102,11 +177,11 @@
102177
#endif
103178
104179
#define UCHAR(c) ((unsigned char)(c))
105180
106181
107
-#define JIM_VERSION 72
182
+#define JIM_VERSION 73
108183
109184
#define JIM_OK 0
110185
#define JIM_ERR 1
111186
#define JIM_RETURN 2
112187
#define JIM_BREAK 3
@@ -816,24 +891,20 @@
816891
const char *cmd;
817892
const char *args;
818893
tclmod_cmd_function *function;
819894
short minargs;
820895
short maxargs;
821
- unsigned flags;
822
- const char *description;
896
+ unsigned short flags;
823897
} jim_subcmd_type;
824898
825899
const jim_subcmd_type *
826900
Jim_ParseSubCmd(Jim_Interp *interp, const jim_subcmd_type *command_table, int argc, Jim_Obj *const *argv);
827901
828902
int Jim_SubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
829903
830904
int Jim_CallSubCmd(Jim_Interp *interp, const jim_subcmd_type *ct, int argc, Jim_Obj *const *argv);
831905
832
-int
833
-Jim_CheckCmdUsage(Jim_Interp *interp, const jim_subcmd_type *command_table, int argc, Jim_Obj *const *argv);
834
-
835906
#ifdef __cplusplus
836907
}
837908
#endif
838909
839910
#endif
@@ -1221,11 +1292,11 @@
12211292
" if {[info exists ::jim_argv0]} {\n"
12221293
" if {[string match \"*/*\" $::jim_argv0]} {\n"
12231294
" return [file join [pwd] $::jim_argv0]\n"
12241295
" }\n"
12251296
" foreach path [split [env PATH \"\"] $::tcl_platform(pathSeparator)] {\n"
1226
-" set exec [file join [pwd] $path $::jim_argv0]\n"
1297
+" set exec [file join [pwd] [string map {\\\\ /} $path] $::jim_argv0]\n"
12271298
" if {[file executable $exec]} {\n"
12281299
" return $exec\n"
12291300
" }\n"
12301301
" }\n"
12311302
" }\n"
@@ -1555,11 +1626,10 @@
15551626
"}\n"
15561627
);
15571628
}
15581629
15591630
1560
-#include <unistd.h>
15611631
#include <stdio.h>
15621632
#include <string.h>
15631633
#include <errno.h>
15641634
#include <fcntl.h>
15651635
@@ -1567,10 +1637,11 @@
15671637
#if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_SELECT) && defined(HAVE_NETINET_IN_H) && defined(HAVE_NETDB_H) && defined(HAVE_ARPA_INET_H)
15681638
#include <sys/socket.h>
15691639
#include <netinet/in.h>
15701640
#include <arpa/inet.h>
15711641
#include <netdb.h>
1642
+#include <unistd.h>
15721643
#ifdef HAVE_SYS_UN_H
15731644
#include <sys/un.h>
15741645
#endif
15751646
#else
15761647
#define JIM_ANSIC
@@ -1627,15 +1698,16 @@
16271698
{
16281699
AioFile *af = privData;
16291700
16301701
JIM_NOTUSED(interp);
16311702
1632
- Jim_DecrRefCount(interp, af->filename);
1633
-
16341703
if (!(af->OpenFlags & AIO_KEEPOPEN)) {
16351704
fclose(af->fp);
16361705
}
1706
+
1707
+ Jim_DecrRefCount(interp, af->filename);
1708
+
16371709
#ifdef jim_ext_eventloop
16381710
16391711
if (af->rEvent) {
16401712
Jim_DeleteFileHandler(interp, af->fp);
16411713
}
@@ -2052,106 +2124,121 @@
20522124
return aio_eventinfo(interp, af, JIM_EVENT_EXCEPTION, &af->wEvent, argc, argv);
20532125
}
20542126
#endif
20552127
20562128
static const jim_subcmd_type aio_command_table[] = {
2057
- { .cmd = "read",
2058
- .args = "?-nonewline? ?len?",
2059
- .function = aio_cmd_read,
2060
- .minargs = 0,
2061
- .maxargs = 2,
2062
- .description = "Read and return bytes from the stream. To eof if no len."
2063
- },
2064
- { .cmd = "copyto",
2065
- .args = "handle ?size?",
2066
- .function = aio_cmd_copy,
2067
- .minargs = 1,
2068
- .maxargs = 2,
2069
- .description = "Copy up to 'size' bytes to the given filehandle, or to eof if no size."
2070
- },
2071
- { .cmd = "gets",
2072
- .args = "?var?",
2073
- .function = aio_cmd_gets,
2074
- .minargs = 0,
2075
- .maxargs = 1,
2076
- .description = "Read one line and return it or store it in the var"
2077
- },
2078
- { .cmd = "puts",
2079
- .args = "?-nonewline? str",
2080
- .function = aio_cmd_puts,
2081
- .minargs = 1,
2082
- .maxargs = 2,
2083
- .description = "Write the string, with newline unless -nonewline"
2084
- },
2085
- { .cmd = "flush",
2086
- .function = aio_cmd_flush,
2087
- .description = "Flush the stream"
2088
- },
2089
- { .cmd = "eof",
2090
- .function = aio_cmd_eof,
2091
- .description = "Returns 1 if stream is at eof"
2092
- },
2093
- { .cmd = "close",
2094
- .flags = JIM_MODFLAG_FULLARGV,
2095
- .function = aio_cmd_close,
2096
- .description = "Closes the stream"
2097
- },
2098
- { .cmd = "seek",
2099
- .args = "offset ?start|current|end",
2100
- .function = aio_cmd_seek,
2101
- .minargs = 1,
2102
- .maxargs = 2,
2103
- .description = "Seeks in the stream (default 'current')"
2104
- },
2105
- { .cmd = "tell",
2106
- .function = aio_cmd_tell,
2107
- .description = "Returns the current seek position"
2108
- },
2109
- { .cmd = "filename",
2110
- .function = aio_cmd_filename,
2111
- .description = "Returns the original filename"
2129
+ { "read",
2130
+ "?-nonewline? ?len?",
2131
+ aio_cmd_read,
2132
+ 0,
2133
+ 2,
2134
+
2135
+ },
2136
+ { "copyto",
2137
+ "handle ?size?",
2138
+ aio_cmd_copy,
2139
+ 1,
2140
+ 2,
2141
+
2142
+ },
2143
+ { "gets",
2144
+ "?var?",
2145
+ aio_cmd_gets,
2146
+ 0,
2147
+ 1,
2148
+
2149
+ },
2150
+ { "puts",
2151
+ "?-nonewline? str",
2152
+ aio_cmd_puts,
2153
+ 1,
2154
+ 2,
2155
+
2156
+ },
2157
+ { "flush",
2158
+ NULL,
2159
+ aio_cmd_flush,
2160
+ 0,
2161
+ 0,
2162
+
2163
+ },
2164
+ { "eof",
2165
+ NULL,
2166
+ aio_cmd_eof,
2167
+ 0,
2168
+ 0,
2169
+
2170
+ },
2171
+ { "close",
2172
+ NULL,
2173
+ aio_cmd_close,
2174
+ 0,
2175
+ 0,
2176
+ JIM_MODFLAG_FULLARGV,
2177
+
2178
+ },
2179
+ { "seek",
2180
+ "offset ?start|current|end",
2181
+ aio_cmd_seek,
2182
+ 1,
2183
+ 2,
2184
+
2185
+ },
2186
+ { "tell",
2187
+ NULL,
2188
+ aio_cmd_tell,
2189
+ 0,
2190
+ 0,
2191
+
2192
+ },
2193
+ { "filename",
2194
+ NULL,
2195
+ aio_cmd_filename,
2196
+ 0,
2197
+ 0,
2198
+
21122199
},
21132200
#ifdef O_NDELAY
2114
- { .cmd = "ndelay",
2115
- .args = "?0|1?",
2116
- .function = aio_cmd_ndelay,
2117
- .minargs = 0,
2118
- .maxargs = 1,
2119
- .description = "Set O_NDELAY (if arg). Returns current/new setting."
2201
+ { "ndelay",
2202
+ "?0|1?",
2203
+ aio_cmd_ndelay,
2204
+ 0,
2205
+ 1,
2206
+
21202207
},
21212208
#endif
2122
- { .cmd = "buffering",
2123
- .args = "none|line|full",
2124
- .function = aio_cmd_buffering,
2125
- .minargs = 1,
2126
- .maxargs = 1,
2127
- .description = "Sets buffering"
2209
+ { "buffering",
2210
+ "none|line|full",
2211
+ aio_cmd_buffering,
2212
+ 1,
2213
+ 1,
2214
+
21282215
},
21292216
#ifdef jim_ext_eventloop
2130
- { .cmd = "readable",
2131
- .args = "?readable-script?",
2132
- .minargs = 0,
2133
- .maxargs = 1,
2134
- .function = aio_cmd_readable,
2135
- .description = "Returns script, or invoke readable-script when readable, {} to remove",
2136
- },
2137
- { .cmd = "writable",
2138
- .args = "?writable-script?",
2139
- .minargs = 0,
2140
- .maxargs = 1,
2141
- .function = aio_cmd_writable,
2142
- .description = "Returns script, or invoke writable-script when writable, {} to remove",
2143
- },
2144
- { .cmd = "onexception",
2145
- .args = "?exception-script?",
2146
- .minargs = 0,
2147
- .maxargs = 1,
2148
- .function = aio_cmd_onexception,
2149
- .description = "Returns script, or invoke exception-script when oob data, {} to remove",
2217
+ { "readable",
2218
+ "?readable-script?",
2219
+ aio_cmd_readable,
2220
+ 0,
2221
+ 1,
2222
+
2223
+ },
2224
+ { "writable",
2225
+ "?writable-script?",
2226
+ aio_cmd_writable,
2227
+ 0,
2228
+ 1,
2229
+
2230
+ },
2231
+ { "onexception",
2232
+ "?exception-script?",
2233
+ aio_cmd_onexception,
2234
+ 0,
2235
+ 1,
2236
+
21502237
},
21512238
#endif
2152
- { 0 }
2239
+ { NULL }
21532240
};
21542241
21552242
static int JimAioSubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
21562243
{
21572244
return Jim_CallSubCmd(interp, Jim_ParseSubCmd(interp, aio_command_table, argc, argv), argc, argv);
@@ -2158,60 +2245,46 @@
21582245
}
21592246
21602247
static int JimAioOpenCommand(Jim_Interp *interp, int argc,
21612248
Jim_Obj *const *argv)
21622249
{
2163
- FILE *fp;
2164
- const char *hdlfmt;
21652250
const char *mode;
2251
+ const char *filename;
21662252
21672253
if (argc != 2 && argc != 3) {
21682254
Jim_WrongNumArgs(interp, 1, argv, "filename ?mode?");
21692255
return JIM_ERR;
21702256
}
21712257
21722258
mode = (argc == 3) ? Jim_String(argv[2]) : "r";
2173
- hdlfmt = Jim_String(argv[1]);
2174
- if (Jim_CompareStringImmediate(interp, argv[1], "stdin")) {
2175
- fp = stdin;
2176
- }
2177
- else if (Jim_CompareStringImmediate(interp, argv[1], "stdout")) {
2178
- fp = stdout;
2179
- }
2180
- else if (Jim_CompareStringImmediate(interp, argv[1], "stderr")) {
2181
- fp = stderr;
2182
- }
2183
- else {
2184
- const char *filename = Jim_String(argv[1]);
2185
-
2259
+ filename = Jim_String(argv[1]);
21862260
21872261
#ifdef jim_ext_tclcompat
2188
-
2189
- if (*filename == '|') {
2190
- Jim_Obj *evalObj[3];
2191
-
2192
- evalObj[0] = Jim_NewStringObj(interp, "popen", -1);
2193
- evalObj[1] = Jim_NewStringObj(interp, filename + 1, -1);
2194
- evalObj[2] = Jim_NewStringObj(interp, mode, -1);
2195
-
2196
- return Jim_EvalObjVector(interp, 3, evalObj);
2197
- }
2198
-#endif
2199
- hdlfmt = "aio.handle%ld";
2200
- fp = NULL;
2201
- }
2202
-
2203
-
2204
- return JimMakeChannel(interp, fp, -1, argv[1], hdlfmt, 0, mode);
2262
+
2263
+ if (*filename == '|') {
2264
+ Jim_Obj *evalObj[3];
2265
+
2266
+ evalObj[0] = Jim_NewStringObj(interp, "popen", -1);
2267
+ evalObj[1] = Jim_NewStringObj(interp, filename + 1, -1);
2268
+ evalObj[2] = Jim_NewStringObj(interp, mode, -1);
2269
+
2270
+ return Jim_EvalObjVector(interp, 3, evalObj);
2271
+ }
2272
+#endif
2273
+ return JimMakeChannel(interp, NULL, -1, argv[1], "aio.handle%ld", 0, mode);
22052274
}
22062275
22072276
static int JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filename,
22082277
const char *hdlfmt, int family, const char *mode)
22092278
{
22102279
AioFile *af;
22112280
char buf[AIO_CMD_LEN];
22122281
int OpenFlags = 0;
2282
+
2283
+ if (filename == NULL) {
2284
+ filename = Jim_NewStringObj(interp, hdlfmt, -1);
2285
+ }
22132286
22142287
Jim_IncrRefCount(filename);
22152288
22162289
if (fh == NULL) {
22172290
if (fd < 0) {
@@ -2225,11 +2298,13 @@
22252298
OpenFlags = AIO_KEEPOPEN;
22262299
}
22272300
22282301
if (fh == NULL) {
22292302
JimAioSetError(interp, filename);
2230
- close(fd);
2303
+ if (fd >= 0) {
2304
+ close(fd);
2305
+ }
22312306
Jim_DecrRefCount(interp, filename);
22322307
return JIM_ERR;
22332308
}
22342309
22352310
@@ -2239,13 +2314,13 @@
22392314
af->fd = fileno(fh);
22402315
af->filename = filename;
22412316
#ifdef FD_CLOEXEC
22422317
if ((OpenFlags & AIO_KEEPOPEN) == 0) {
22432318
fcntl(af->fd, F_SETFD, FD_CLOEXEC);
2244
- af->OpenFlags = OpenFlags;
22452319
}
22462320
#endif
2321
+ af->OpenFlags = OpenFlags;
22472322
#ifdef O_NDELAY
22482323
af->flags = fcntl(af->fd, F_GETFL);
22492324
#endif
22502325
af->addr_family = family;
22512326
snprintf(buf, sizeof(buf), hdlfmt, Jim_GetId(interp));
@@ -2277,21 +2352,26 @@
22772352
#ifndef JIM_ANSIC
22782353
Jim_CreateCommand(interp, "socket", JimAioSockCommand, NULL, NULL);
22792354
#endif
22802355
22812356
2282
- Jim_EvalGlobal(interp, "open stdin; open stdout; open stderr");
2357
+ JimMakeChannel(interp, stdin, -1, NULL, "stdin", 0, "r");
2358
+ JimMakeChannel(interp, stdout, -1, NULL, "stdout", 0, "w");
2359
+ JimMakeChannel(interp, stderr, -1, NULL, "stderr", 0, "w");
22832360
22842361
return JIM_OK;
22852362
}
22862363
22872364
22882365
#include <errno.h>
22892366
#include <stdio.h>
22902367
#include <string.h>
2368
+
2369
+
2370
+#ifdef HAVE_DIRENT_H
22912371
#include <dirent.h>
2292
-
2372
+#endif
22932373
22942374
int Jim_ReaddirCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
22952375
{
22962376
const char *dirPath;
22972377
DIR *dirPtr;
@@ -2834,16 +2914,27 @@
28342914
28352915
#include <limits.h>
28362916
#include <stdlib.h>
28372917
#include <string.h>
28382918
#include <stdio.h>
2839
-#include <unistd.h>
28402919
#include <errno.h>
28412920
#include <sys/stat.h>
2842
-#include <sys/param.h>
2921
+
2922
+
2923
+#ifdef HAVE_UTIMES
28432924
#include <sys/time.h>
2844
-
2925
+#endif
2926
+#ifdef HAVE_UNISTD_H
2927
+#include <unistd.h>
2928
+#elif defined(_MSC_VER)
2929
+#include <direct.h>
2930
+#define F_OK 0
2931
+#define W_OK 2
2932
+#define R_OK 4
2933
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
2934
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
2935
+#endif
28452936
28462937
# ifndef MAXPATHLEN
28472938
# define MAXPATHLEN JIM_PATH_LEN
28482939
# endif
28492940
@@ -2854,29 +2945,35 @@
28542945
return "file";
28552946
}
28562947
else if (S_ISDIR(mode)) {
28572948
return "directory";
28582949
}
2950
+#ifdef S_ISCHR
28592951
else if (S_ISCHR(mode)) {
28602952
return "characterSpecial";
28612953
}
2954
+#endif
2955
+#ifdef S_ISBLK
28622956
else if (S_ISBLK(mode)) {
28632957
return "blockSpecial";
28642958
}
2959
+#endif
2960
+#ifdef S_ISFIFO
28652961
else if (S_ISFIFO(mode)) {
28662962
return "fifo";
2963
+ }
2964
+#endif
28672965
#ifdef S_ISLNK
2868
- }
28692966
else if (S_ISLNK(mode)) {
28702967
return "link";
2968
+ }
28712969
#endif
28722970
#ifdef S_ISSOCK
2873
- }
28742971
else if (S_ISSOCK(mode)) {
28752972
return "socket";
2973
+ }
28762974
#endif
2877
- }
28782975
return "unknown";
28792976
}
28802977
28812978
28822979
static int set_array_int_value(Jim_Interp *interp, Jim_Obj *container, const char *key,
@@ -2939,11 +3036,11 @@
29393036
Jim_SetResultString(interp, ".", -1);
29403037
}
29413038
else if (p == path) {
29423039
Jim_SetResultString(interp, "/", -1);
29433040
}
2944
-#if defined(__MINGW32__)
3041
+#if defined(__MINGW32__) || defined(_MSC_VER)
29453042
else if (p[-1] == ':') {
29463043
29473044
Jim_SetResultString(interp, path, p - path + 1);
29483045
}
29493046
#endif
@@ -3030,11 +3127,11 @@
30303127
30313128
if (*part == '/') {
30323129
30333130
last = newname;
30343131
}
3035
-#if defined(__MINGW32__)
3132
+#if defined(__MINGW32__) || defined(_MSC_VER)
30363133
else if (strchr(part, ':')) {
30373134
30383135
last = newname;
30393136
}
30403137
#endif
@@ -3099,11 +3196,16 @@
30993196
return file_access(interp, argv[0], W_OK);
31003197
}
31013198
31023199
static int file_cmd_executable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
31033200
{
3201
+#ifdef X_OK
31043202
return file_access(interp, argv[0], X_OK);
3203
+#else
3204
+ Jim_SetResultBool(interp, 1);
3205
+ return JIM_OK;
3206
+#endif
31053207
}
31063208
31073209
static int file_cmd_exists(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
31083210
{
31093211
return file_access(interp, argv[0], F_OK);
@@ -3430,193 +3532,193 @@
34303532
}
34313533
return StoreStatData(interp, argv[1], &sb);
34323534
}
34333535
34343536
static const jim_subcmd_type file_command_table[] = {
3435
- { .cmd = "atime",
3436
- .args = "name",
3437
- .function = file_cmd_atime,
3438
- .minargs = 1,
3439
- .maxargs = 1,
3440
- .description = "Last access time"
3441
- },
3442
- { .cmd = "mtime",
3443
- .args = "name ?time?",
3444
- .function = file_cmd_mtime,
3445
- .minargs = 1,
3446
- .maxargs = 2,
3447
- .description = "Get or set last modification time"
3448
- },
3449
- { .cmd = "copy",
3450
- .args = "?-force? source dest",
3451
- .function = file_cmd_copy,
3452
- .minargs = 2,
3453
- .maxargs = 3,
3454
- .description = "Copy source file to destination file"
3455
- },
3456
- { .cmd = "dirname",
3457
- .args = "name",
3458
- .function = file_cmd_dirname,
3459
- .minargs = 1,
3460
- .maxargs = 1,
3461
- .description = "Directory part of the name"
3462
- },
3463
- { .cmd = "rootname",
3464
- .args = "name",
3465
- .function = file_cmd_rootname,
3466
- .minargs = 1,
3467
- .maxargs = 1,
3468
- .description = "Name without any extension"
3469
- },
3470
- { .cmd = "extension",
3471
- .args = "name",
3472
- .function = file_cmd_extension,
3473
- .minargs = 1,
3474
- .maxargs = 1,
3475
- .description = "Last extension including the dot"
3476
- },
3477
- { .cmd = "tail",
3478
- .args = "name",
3479
- .function = file_cmd_tail,
3480
- .minargs = 1,
3481
- .maxargs = 1,
3482
- .description = "Last component of the name"
3483
- },
3484
- { .cmd = "normalize",
3485
- .args = "name",
3486
- .function = file_cmd_normalize,
3487
- .minargs = 1,
3488
- .maxargs = 1,
3489
- .description = "Normalized path of name"
3490
- },
3491
- { .cmd = "join",
3492
- .args = "name ?name ...?",
3493
- .function = file_cmd_join,
3494
- .minargs = 1,
3495
- .maxargs = -1,
3496
- .description = "Join multiple path components"
3497
- },
3498
- { .cmd = "readable",
3499
- .args = "name",
3500
- .function = file_cmd_readable,
3501
- .minargs = 1,
3502
- .maxargs = 1,
3503
- .description = "Is file readable"
3504
- },
3505
- { .cmd = "writable",
3506
- .args = "name",
3507
- .function = file_cmd_writable,
3508
- .minargs = 1,
3509
- .maxargs = 1,
3510
- .description = "Is file writable"
3511
- },
3512
- { .cmd = "executable",
3513
- .args = "name",
3514
- .function = file_cmd_executable,
3515
- .minargs = 1,
3516
- .maxargs = 1,
3517
- .description = "Is file executable"
3518
- },
3519
- { .cmd = "exists",
3520
- .args = "name",
3521
- .function = file_cmd_exists,
3522
- .minargs = 1,
3523
- .maxargs = 1,
3524
- .description = "Does file exist"
3525
- },
3526
- { .cmd = "delete",
3527
- .args = "?-force|--? name ...",
3528
- .function = file_cmd_delete,
3529
- .minargs = 1,
3530
- .maxargs = -1,
3531
- .description = "Deletes the files or directories (must be empty unless -force)"
3532
- },
3533
- { .cmd = "mkdir",
3534
- .args = "dir ...",
3535
- .function = file_cmd_mkdir,
3536
- .minargs = 1,
3537
- .maxargs = -1,
3538
- .description = "Creates the directories"
3537
+ { "atime",
3538
+ "name",
3539
+ file_cmd_atime,
3540
+ 1,
3541
+ 1,
3542
+
3543
+ },
3544
+ { "mtime",
3545
+ "name ?time?",
3546
+ file_cmd_mtime,
3547
+ 1,
3548
+ 2,
3549
+
3550
+ },
3551
+ { "copy",
3552
+ "?-force? source dest",
3553
+ file_cmd_copy,
3554
+ 2,
3555
+ 3,
3556
+
3557
+ },
3558
+ { "dirname",
3559
+ "name",
3560
+ file_cmd_dirname,
3561
+ 1,
3562
+ 1,
3563
+
3564
+ },
3565
+ { "rootname",
3566
+ "name",
3567
+ file_cmd_rootname,
3568
+ 1,
3569
+ 1,
3570
+
3571
+ },
3572
+ { "extension",
3573
+ "name",
3574
+ file_cmd_extension,
3575
+ 1,
3576
+ 1,
3577
+
3578
+ },
3579
+ { "tail",
3580
+ "name",
3581
+ file_cmd_tail,
3582
+ 1,
3583
+ 1,
3584
+
3585
+ },
3586
+ { "normalize",
3587
+ "name",
3588
+ file_cmd_normalize,
3589
+ 1,
3590
+ 1,
3591
+
3592
+ },
3593
+ { "join",
3594
+ "name ?name ...?",
3595
+ file_cmd_join,
3596
+ 1,
3597
+ -1,
3598
+
3599
+ },
3600
+ { "readable",
3601
+ "name",
3602
+ file_cmd_readable,
3603
+ 1,
3604
+ 1,
3605
+
3606
+ },
3607
+ { "writable",
3608
+ "name",
3609
+ file_cmd_writable,
3610
+ 1,
3611
+ 1,
3612
+
3613
+ },
3614
+ { "executable",
3615
+ "name",
3616
+ file_cmd_executable,
3617
+ 1,
3618
+ 1,
3619
+
3620
+ },
3621
+ { "exists",
3622
+ "name",
3623
+ file_cmd_exists,
3624
+ 1,
3625
+ 1,
3626
+
3627
+ },
3628
+ { "delete",
3629
+ "?-force|--? name ...",
3630
+ file_cmd_delete,
3631
+ 1,
3632
+ -1,
3633
+
3634
+ },
3635
+ { "mkdir",
3636
+ "dir ...",
3637
+ file_cmd_mkdir,
3638
+ 1,
3639
+ -1,
3640
+
35393641
},
35403642
#ifdef HAVE_MKSTEMP
3541
- { .cmd = "tempfile",
3542
- .args = "?template?",
3543
- .function = file_cmd_tempfile,
3544
- .minargs = 0,
3545
- .maxargs = 1,
3546
- .description = "Creates a temporary filename"
3643
+ { "tempfile",
3644
+ "?template?",
3645
+ file_cmd_tempfile,
3646
+ 0,
3647
+ 1,
3648
+
35473649
},
35483650
#endif
3549
- { .cmd = "rename",
3550
- .args = "?-force? source dest",
3551
- .function = file_cmd_rename,
3552
- .minargs = 2,
3553
- .maxargs = 3,
3554
- .description = "Renames a file"
3651
+ { "rename",
3652
+ "?-force? source dest",
3653
+ file_cmd_rename,
3654
+ 2,
3655
+ 3,
3656
+
35553657
},
35563658
#if defined(HAVE_READLINK)
3557
- { .cmd = "readlink",
3558
- .args = "name",
3559
- .function = file_cmd_readlink,
3560
- .minargs = 1,
3561
- .maxargs = 1,
3562
- .description = "Value of the symbolic link"
3563
- },
3564
-#endif
3565
- { .cmd = "size",
3566
- .args = "name",
3567
- .function = file_cmd_size,
3568
- .minargs = 1,
3569
- .maxargs = 1,
3570
- .description = "Size of file"
3571
- },
3572
- { .cmd = "stat",
3573
- .args = "name var",
3574
- .function = file_cmd_stat,
3575
- .minargs = 2,
3576
- .maxargs = 2,
3577
- .description = "Stores results of stat in var array"
3578
- },
3579
- { .cmd = "lstat",
3580
- .args = "name var",
3581
- .function = file_cmd_lstat,
3582
- .minargs = 2,
3583
- .maxargs = 2,
3584
- .description = "Stores results of lstat in var array"
3585
- },
3586
- { .cmd = "type",
3587
- .args = "name",
3588
- .function = file_cmd_type,
3589
- .minargs = 1,
3590
- .maxargs = 1,
3591
- .description = "Returns type of the file"
3659
+ { "readlink",
3660
+ "name",
3661
+ file_cmd_readlink,
3662
+ 1,
3663
+ 1,
3664
+
3665
+ },
3666
+#endif
3667
+ { "size",
3668
+ "name",
3669
+ file_cmd_size,
3670
+ 1,
3671
+ 1,
3672
+
3673
+ },
3674
+ { "stat",
3675
+ "name var",
3676
+ file_cmd_stat,
3677
+ 2,
3678
+ 2,
3679
+
3680
+ },
3681
+ { "lstat",
3682
+ "name var",
3683
+ file_cmd_lstat,
3684
+ 2,
3685
+ 2,
3686
+
3687
+ },
3688
+ { "type",
3689
+ "name",
3690
+ file_cmd_type,
3691
+ 1,
3692
+ 1,
3693
+
35923694
},
35933695
#ifdef HAVE_GETEUID
3594
- { .cmd = "owned",
3595
- .args = "name",
3596
- .function = file_cmd_owned,
3597
- .minargs = 1,
3598
- .maxargs = 1,
3599
- .description = "Returns 1 if owned by the current owner"
3600
- },
3601
-#endif
3602
- { .cmd = "isdirectory",
3603
- .args = "name",
3604
- .function = file_cmd_isdirectory,
3605
- .minargs = 1,
3606
- .maxargs = 1,
3607
- .description = "Returns 1 if name is a directory"
3608
- },
3609
- { .cmd = "isfile",
3610
- .args = "name",
3611
- .function = file_cmd_isfile,
3612
- .minargs = 1,
3613
- .maxargs = 1,
3614
- .description = "Returns 1 if name is a file"
3615
- },
3616
- {
3617
- .cmd = 0
3696
+ { "owned",
3697
+ "name",
3698
+ file_cmd_owned,
3699
+ 1,
3700
+ 1,
3701
+
3702
+ },
3703
+#endif
3704
+ { "isdirectory",
3705
+ "name",
3706
+ file_cmd_isdirectory,
3707
+ 1,
3708
+ 1,
3709
+
3710
+ },
3711
+ { "isfile",
3712
+ "name",
3713
+ file_cmd_isfile,
3714
+ 1,
3715
+ 1,
3716
+
3717
+ },
3718
+ {
3719
+ NULL
36183720
}
36193721
};
36203722
36213723
static int Jim_CdCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
36223724
{
@@ -3644,11 +3746,11 @@
36443746
36453747
if (getcwd(cwd, cwd_len) == NULL) {
36463748
Jim_SetResultString(interp, "Failed to get pwd", -1);
36473749
return JIM_ERR;
36483750
}
3649
-#if defined(__MINGW32__)
3751
+#if defined(__MINGW32__) || defined(_MSC_VER)
36503752
{
36513753
36523754
char *p = cwd;
36533755
while ((p = strchr(p, '\\')) != NULL) {
36543756
*p++ = '/';
@@ -3734,14 +3836,17 @@
37343836
37353837
37363838
#include <errno.h>
37373839
#include <signal.h>
37383840
3739
-#define XXX printf("@%s:%d\n", __FILE__, __LINE__); fflush(stdout);
3740
-
37413841
#if defined(__MINGW32__)
37423842
3843
+ #ifndef STRICT
3844
+ #define STRICT
3845
+ #endif
3846
+ #define WIN32_LEAN_AND_MEAN
3847
+ #include <windows.h>
37433848
#include <fcntl.h>
37443849
37453850
typedef HANDLE fdtype;
37463851
typedef HANDLE pidtype;
37473852
#define JIM_BAD_FD INVALID_HANDLE_VALUE
@@ -5022,12 +5127,15 @@
50225127
50235128
#include <stdlib.h>
50245129
#include <string.h>
50255130
#include <stdio.h>
50265131
#include <time.h>
5132
+
5133
+
5134
+#ifdef HAVE_SYS_TIME_H
50275135
#include <sys/time.h>
5028
-
5136
+#endif
50295137
50305138
static int clock_cmd_format(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
50315139
{
50325140
50335141
char buf[100];
@@ -5111,51 +5219,55 @@
51115219
51125220
return JIM_OK;
51135221
}
51145222
51155223
static const jim_subcmd_type clock_command_table[] = {
5116
- { .cmd = "seconds",
5117
- .function = clock_cmd_seconds,
5118
- .minargs = 0,
5119
- .maxargs = 0,
5120
- .description = "Returns the current time as seconds since the epoch"
5121
- },
5122
- { .cmd = "clicks",
5123
- .function = clock_cmd_micros,
5124
- .minargs = 0,
5125
- .maxargs = 0,
5126
- .description = "Returns the current time in 'clicks'"
5127
- },
5128
- { .cmd = "microseconds",
5129
- .function = clock_cmd_micros,
5130
- .minargs = 0,
5131
- .maxargs = 0,
5132
- .description = "Returns the current time in microseconds"
5133
- },
5134
- { .cmd = "milliseconds",
5135
- .function = clock_cmd_millis,
5136
- .minargs = 0,
5137
- .maxargs = 0,
5138
- .description = "Returns the current time in milliseconds"
5139
- },
5140
- { .cmd = "format",
5141
- .args = "seconds ?-format format?",
5142
- .function = clock_cmd_format,
5143
- .minargs = 1,
5144
- .maxargs = 3,
5145
- .description = "Format the given time"
5224
+ { "seconds",
5225
+ NULL,
5226
+ clock_cmd_seconds,
5227
+ 0,
5228
+ 0,
5229
+
5230
+ },
5231
+ { "clicks",
5232
+ NULL,
5233
+ clock_cmd_micros,
5234
+ 0,
5235
+ 0,
5236
+
5237
+ },
5238
+ { "microseconds",
5239
+ NULL,
5240
+ clock_cmd_micros,
5241
+ 0,
5242
+ 0,
5243
+
5244
+ },
5245
+ { "milliseconds",
5246
+ NULL,
5247
+ clock_cmd_millis,
5248
+ 0,
5249
+ 0,
5250
+
5251
+ },
5252
+ { "format",
5253
+ "seconds ?-format format?",
5254
+ clock_cmd_format,
5255
+ 1,
5256
+ 3,
5257
+
51465258
},
51475259
#ifdef HAVE_STRPTIME
5148
- { .cmd = "scan",
5149
- .args = "str -format format",
5150
- .function = clock_cmd_scan,
5151
- .minargs = 3,
5152
- .maxargs = 3,
5153
- .description = "Determine the time according to the given format"
5260
+ { "scan",
5261
+ "str -format format",
5262
+ clock_cmd_scan,
5263
+ 3,
5264
+ 3,
5265
+
51545266
},
51555267
#endif
5156
- { 0 }
5268
+ { NULL }
51575269
};
51585270
51595271
int Jim_clockInit(Jim_Interp *interp)
51605272
{
51615273
if (Jim_PackageProvide(interp, "clock", "1.0", JIM_ERRMSG))
@@ -5168,11 +5280,10 @@
51685280
51695281
#include <limits.h>
51705282
#include <stdlib.h>
51715283
#include <string.h>
51725284
#include <stdio.h>
5173
-#include <unistd.h>
51745285
#include <errno.h>
51755286
51765287
51775288
static int array_cmd_exists(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
51785289
{
@@ -5335,53 +5446,53 @@
53355446
53365447
return rc;
53375448
}
53385449
53395450
static const jim_subcmd_type array_command_table[] = {
5340
- { .cmd = "exists",
5341
- .args = "arrayName",
5342
- .function = array_cmd_exists,
5343
- .minargs = 1,
5344
- .maxargs = 1,
5345
- .description = "Does array exist?"
5346
- },
5347
- { .cmd = "get",
5348
- .args = "arrayName ?pattern?",
5349
- .function = array_cmd_get,
5350
- .minargs = 1,
5351
- .maxargs = 2,
5352
- .description = "Array contents as name value list"
5353
- },
5354
- { .cmd = "names",
5355
- .args = "arrayName ?pattern?",
5356
- .function = array_cmd_names,
5357
- .minargs = 1,
5358
- .maxargs = 2,
5359
- .description = "Array keys as a list"
5360
- },
5361
- { .cmd = "set",
5362
- .args = "arrayName list",
5363
- .function = array_cmd_set,
5364
- .minargs = 2,
5365
- .maxargs = 2,
5366
- .description = "Set array from list"
5367
- },
5368
- { .cmd = "size",
5369
- .args = "arrayName",
5370
- .function = array_cmd_size,
5371
- .minargs = 1,
5372
- .maxargs = 1,
5373
- .description = "Number of elements in array"
5374
- },
5375
- { .cmd = "unset",
5376
- .args = "arrayName ?pattern?",
5377
- .function = array_cmd_unset,
5378
- .minargs = 1,
5379
- .maxargs = 2,
5380
- .description = "Unset elements of an array"
5381
- },
5382
- { .cmd = 0,
5451
+ { "exists",
5452
+ "arrayName",
5453
+ array_cmd_exists,
5454
+ 1,
5455
+ 1,
5456
+
5457
+ },
5458
+ { "get",
5459
+ "arrayName ?pattern?",
5460
+ array_cmd_get,
5461
+ 1,
5462
+ 2,
5463
+
5464
+ },
5465
+ { "names",
5466
+ "arrayName ?pattern?",
5467
+ array_cmd_names,
5468
+ 1,
5469
+ 2,
5470
+
5471
+ },
5472
+ { "set",
5473
+ "arrayName list",
5474
+ array_cmd_set,
5475
+ 2,
5476
+ 2,
5477
+
5478
+ },
5479
+ { "size",
5480
+ "arrayName",
5481
+ array_cmd_size,
5482
+ 1,
5483
+ 1,
5484
+
5485
+ },
5486
+ { "unset",
5487
+ "arrayName ?pattern?",
5488
+ array_cmd_unset,
5489
+ 1,
5490
+ 2,
5491
+
5492
+ },
5493
+ { NULL
53835494
}
53845495
};
53855496
53865497
int Jim_arrayInit(Jim_Interp *interp)
53875498
{
@@ -5430,14 +5541,14 @@
54305541
#include <assert.h>
54315542
#include <errno.h>
54325543
#include <time.h>
54335544
#include <setjmp.h>
54345545
5435
-#include <unistd.h>
5546
+
5547
+#ifdef HAVE_SYS_TIME_H
54365548
#include <sys/time.h>
5437
-
5438
-
5549
+#endif
54395550
#ifdef HAVE_BACKTRACE
54405551
#include <execinfo.h>
54415552
#endif
54425553
#ifdef HAVE_CRT_EXTERNS_H
54435554
#include <crt_externs.h>
@@ -11387,18 +11498,18 @@
1138711498
}
1138811499
1138911500
1139011501
1139111502
static const char * const jimReturnCodes[] = {
11392
- [JIM_OK] = "ok",
11393
- [JIM_ERR] = "error",
11394
- [JIM_RETURN] = "return",
11395
- [JIM_BREAK] = "break",
11396
- [JIM_CONTINUE] = "continue",
11397
- [JIM_SIGNAL] = "signal",
11398
- [JIM_EXIT] = "exit",
11399
- [JIM_EVAL] = "eval",
11503
+ "ok",
11504
+ "error",
11505
+ "return",
11506
+ "break",
11507
+ "continue",
11508
+ "signal",
11509
+ "exit",
11510
+ "eval",
1140011511
NULL
1140111512
};
1140211513
1140311514
#define jimReturnCodesSize (sizeof(jimReturnCodes)/sizeof(*jimReturnCodes))
1140411515
@@ -11458,11 +11569,11 @@
1145811569
1145911570
enum
1146011571
{
1146111572
1146211573
11463
- JIM_EXPROP_MUL = JIM_TT_EXPR_OP,
11574
+ JIM_EXPROP_MUL = JIM_TT_EXPR_OP,
1146411575
JIM_EXPROP_DIV,
1146511576
JIM_EXPROP_MOD,
1146611577
JIM_EXPROP_SUB,
1146711578
JIM_EXPROP_ADD,
1146811579
JIM_EXPROP_LSHIFT,
@@ -11501,32 +11612,32 @@
1150111612
JIM_EXPROP_COLON_RIGHT,
1150211613
1150311614
JIM_EXPROP_POW,
1150411615
1150511616
11506
- JIM_EXPROP_STREQ,
11617
+ JIM_EXPROP_STREQ,
1150711618
JIM_EXPROP_STRNE,
1150811619
JIM_EXPROP_STRIN,
1150911620
JIM_EXPROP_STRNI,
1151011621
1151111622
11512
- JIM_EXPROP_NOT,
11623
+ JIM_EXPROP_NOT,
1151311624
JIM_EXPROP_BITNOT,
1151411625
JIM_EXPROP_UNARYMINUS,
1151511626
JIM_EXPROP_UNARYPLUS,
1151611627
1151711628
11518
- JIM_EXPROP_FUNC_FIRST,
11629
+ JIM_EXPROP_FUNC_FIRST,
1151911630
JIM_EXPROP_FUNC_INT = JIM_EXPROP_FUNC_FIRST,
1152011631
JIM_EXPROP_FUNC_ABS,
1152111632
JIM_EXPROP_FUNC_DOUBLE,
1152211633
JIM_EXPROP_FUNC_ROUND,
1152311634
JIM_EXPROP_FUNC_RAND,
1152411635
JIM_EXPROP_FUNC_SRAND,
1152511636
1152611637
11527
- JIM_EXPROP_FUNC_SIN,
11638
+ JIM_EXPROP_FUNC_SIN,
1152811639
JIM_EXPROP_FUNC_COS,
1152911640
JIM_EXPROP_FUNC_TAN,
1153011641
JIM_EXPROP_FUNC_ASIN,
1153111642
JIM_EXPROP_FUNC_ACOS,
1153211643
JIM_EXPROP_FUNC_ATAN,
@@ -12237,90 +12348,92 @@
1223712348
LAZY_OP,
1223812349
LAZY_LEFT,
1223912350
LAZY_RIGHT
1224012351
};
1224112352
12242
-
1224312353
static const struct Jim_ExprOperator Jim_ExprOperators[] = {
12244
- [JIM_EXPROP_FUNC_INT] = {"int", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12245
- [JIM_EXPROP_FUNC_DOUBLE] = {"double", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12246
- [JIM_EXPROP_FUNC_ABS] = {"abs", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12247
- [JIM_EXPROP_FUNC_ROUND] = {"round", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12248
- [JIM_EXPROP_FUNC_RAND] = {"rand", 400, 0, JimExprOpNone, LAZY_NONE},
12249
- [JIM_EXPROP_FUNC_SRAND] = {"srand", 400, 1, JimExprOpIntUnary, LAZY_NONE},
12354
+ {"*", 200, 2, JimExprOpBin, LAZY_NONE},
12355
+ {"/", 200, 2, JimExprOpBin, LAZY_NONE},
12356
+ {"%", 200, 2, JimExprOpIntBin, LAZY_NONE},
12357
+
12358
+ {"-", 100, 2, JimExprOpBin, LAZY_NONE},
12359
+ {"+", 100, 2, JimExprOpBin, LAZY_NONE},
12360
+
12361
+ {"<<", 90, 2, JimExprOpIntBin, LAZY_NONE},
12362
+ {">>", 90, 2, JimExprOpIntBin, LAZY_NONE},
12363
+
12364
+ {"<<<", 90, 2, JimExprOpIntBin, LAZY_NONE},
12365
+ {">>>", 90, 2, JimExprOpIntBin, LAZY_NONE},
12366
+
12367
+ {"<", 80, 2, JimExprOpBin, LAZY_NONE},
12368
+ {">", 80, 2, JimExprOpBin, LAZY_NONE},
12369
+ {"<=", 80, 2, JimExprOpBin, LAZY_NONE},
12370
+ {">=", 80, 2, JimExprOpBin, LAZY_NONE},
12371
+
12372
+ {"==", 70, 2, JimExprOpBin, LAZY_NONE},
12373
+ {"!=", 70, 2, JimExprOpBin, LAZY_NONE},
12374
+
12375
+ {"&", 50, 2, JimExprOpIntBin, LAZY_NONE},
12376
+ {"^", 49, 2, JimExprOpIntBin, LAZY_NONE},
12377
+ {"|", 48, 2, JimExprOpIntBin, LAZY_NONE},
12378
+
12379
+ {"&&", 10, 2, NULL, LAZY_OP},
12380
+ {NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT},
12381
+ {NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT},
12382
+
12383
+ {"||", 9, 2, NULL, LAZY_OP},
12384
+ {NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT},
12385
+ {NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT},
12386
+
12387
+ {"?", 5, 2, JimExprOpNull, LAZY_OP},
12388
+ {NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT},
12389
+ {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT},
12390
+
12391
+ {":", 5, 2, JimExprOpNull, LAZY_OP},
12392
+ {NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT},
12393
+ {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT},
12394
+
12395
+ {"**", 250, 2, JimExprOpBin, LAZY_NONE},
12396
+
12397
+ {"eq", 60, 2, JimExprOpStrBin, LAZY_NONE},
12398
+ {"ne", 60, 2, JimExprOpStrBin, LAZY_NONE},
12399
+
12400
+ {"in", 55, 2, JimExprOpStrBin, LAZY_NONE},
12401
+ {"ni", 55, 2, JimExprOpStrBin, LAZY_NONE},
12402
+
12403
+ {"!", 300, 1, JimExprOpNumUnary, LAZY_NONE},
12404
+ {"~", 300, 1, JimExprOpIntUnary, LAZY_NONE},
12405
+ {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE},
12406
+ {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE},
12407
+
12408
+
12409
+
12410
+ {"int", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12411
+ {"abs", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12412
+ {"double", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12413
+ {"round", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12414
+ {"rand", 400, 0, JimExprOpNone, LAZY_NONE},
12415
+ {"srand", 400, 1, JimExprOpIntUnary, LAZY_NONE},
1225012416
1225112417
#ifdef JIM_MATH_FUNCTIONS
12252
- [JIM_EXPROP_FUNC_SIN] = {"sin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12253
- [JIM_EXPROP_FUNC_COS] = {"cos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12254
- [JIM_EXPROP_FUNC_TAN] = {"tan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12255
- [JIM_EXPROP_FUNC_ASIN] = {"asin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12256
- [JIM_EXPROP_FUNC_ACOS] = {"acos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12257
- [JIM_EXPROP_FUNC_ATAN] = {"atan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12258
- [JIM_EXPROP_FUNC_SINH] = {"sinh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12259
- [JIM_EXPROP_FUNC_COSH] = {"cosh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12260
- [JIM_EXPROP_FUNC_TANH] = {"tanh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12261
- [JIM_EXPROP_FUNC_CEIL] = {"ceil", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12262
- [JIM_EXPROP_FUNC_FLOOR] = {"floor", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12263
- [JIM_EXPROP_FUNC_EXP] = {"exp", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12264
- [JIM_EXPROP_FUNC_LOG] = {"log", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12265
- [JIM_EXPROP_FUNC_LOG10] = {"log10", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12266
- [JIM_EXPROP_FUNC_SQRT] = {"sqrt", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12267
- [JIM_EXPROP_FUNC_POW] = {"pow", 400, 2, JimExprOpBin, LAZY_NONE},
12418
+ {"sin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12419
+ {"cos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12420
+ {"tan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12421
+ {"asin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12422
+ {"acos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12423
+ {"atan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12424
+ {"sinh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12425
+ {"cosh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12426
+ {"tanh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12427
+ {"ceil", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12428
+ {"floor", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12429
+ {"exp", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12430
+ {"log", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12431
+ {"log10", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12432
+ {"sqrt", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12433
+ {"pow", 400, 2, JimExprOpBin, LAZY_NONE},
1226812434
#endif
12269
-
12270
- [JIM_EXPROP_NOT] = {"!", 300, 1, JimExprOpNumUnary, LAZY_NONE},
12271
- [JIM_EXPROP_BITNOT] = {"~", 300, 1, JimExprOpIntUnary, LAZY_NONE},
12272
- [JIM_EXPROP_UNARYMINUS] = {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE},
12273
- [JIM_EXPROP_UNARYPLUS] = {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE},
12274
-
12275
- [JIM_EXPROP_POW] = {"**", 250, 2, JimExprOpBin, LAZY_NONE},
12276
-
12277
- [JIM_EXPROP_MUL] = {"*", 200, 2, JimExprOpBin, LAZY_NONE},
12278
- [JIM_EXPROP_DIV] = {"/", 200, 2, JimExprOpBin, LAZY_NONE},
12279
- [JIM_EXPROP_MOD] = {"%", 200, 2, JimExprOpIntBin, LAZY_NONE},
12280
-
12281
- [JIM_EXPROP_SUB] = {"-", 100, 2, JimExprOpBin, LAZY_NONE},
12282
- [JIM_EXPROP_ADD] = {"+", 100, 2, JimExprOpBin, LAZY_NONE},
12283
-
12284
- [JIM_EXPROP_ROTL] = {"<<<", 90, 2, JimExprOpIntBin, LAZY_NONE},
12285
- [JIM_EXPROP_ROTR] = {">>>", 90, 2, JimExprOpIntBin, LAZY_NONE},
12286
- [JIM_EXPROP_LSHIFT] = {"<<", 90, 2, JimExprOpIntBin, LAZY_NONE},
12287
- [JIM_EXPROP_RSHIFT] = {">>", 90, 2, JimExprOpIntBin, LAZY_NONE},
12288
-
12289
- [JIM_EXPROP_LT] = {"<", 80, 2, JimExprOpBin, LAZY_NONE},
12290
- [JIM_EXPROP_GT] = {">", 80, 2, JimExprOpBin, LAZY_NONE},
12291
- [JIM_EXPROP_LTE] = {"<=", 80, 2, JimExprOpBin, LAZY_NONE},
12292
- [JIM_EXPROP_GTE] = {">=", 80, 2, JimExprOpBin, LAZY_NONE},
12293
-
12294
- [JIM_EXPROP_NUMEQ] = {"==", 70, 2, JimExprOpBin, LAZY_NONE},
12295
- [JIM_EXPROP_NUMNE] = {"!=", 70, 2, JimExprOpBin, LAZY_NONE},
12296
-
12297
- [JIM_EXPROP_STREQ] = {"eq", 60, 2, JimExprOpStrBin, LAZY_NONE},
12298
- [JIM_EXPROP_STRNE] = {"ne", 60, 2, JimExprOpStrBin, LAZY_NONE},
12299
-
12300
- [JIM_EXPROP_STRIN] = {"in", 55, 2, JimExprOpStrBin, LAZY_NONE},
12301
- [JIM_EXPROP_STRNI] = {"ni", 55, 2, JimExprOpStrBin, LAZY_NONE},
12302
-
12303
- [JIM_EXPROP_BITAND] = {"&", 50, 2, JimExprOpIntBin, LAZY_NONE},
12304
- [JIM_EXPROP_BITXOR] = {"^", 49, 2, JimExprOpIntBin, LAZY_NONE},
12305
- [JIM_EXPROP_BITOR] = {"|", 48, 2, JimExprOpIntBin, LAZY_NONE},
12306
-
12307
- [JIM_EXPROP_LOGICAND] = {"&&", 10, 2, NULL, LAZY_OP},
12308
- [JIM_EXPROP_LOGICOR] = {"||", 9, 2, NULL, LAZY_OP},
12309
-
12310
- [JIM_EXPROP_TERNARY] = {"?", 5, 2, JimExprOpNull, LAZY_OP},
12311
- [JIM_EXPROP_COLON] = {":", 5, 2, JimExprOpNull, LAZY_OP},
12312
-
12313
-
12314
- [JIM_EXPROP_TERNARY_LEFT] = {NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT},
12315
- [JIM_EXPROP_TERNARY_RIGHT] = {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT},
12316
- [JIM_EXPROP_COLON_LEFT] = {NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT},
12317
- [JIM_EXPROP_COLON_RIGHT] = {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT},
12318
- [JIM_EXPROP_LOGICAND_LEFT] = {NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT},
12319
- [JIM_EXPROP_LOGICAND_RIGHT] = {NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT},
12320
- [JIM_EXPROP_LOGICOR_LEFT] = {NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT},
12321
- [JIM_EXPROP_LOGICOR_RIGHT] = {NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT},
1232212435
};
1232312436
1232412437
#define JIM_EXPR_OPERATORS_NUM \
1232512438
(sizeof(Jim_ExprOperators)/sizeof(struct Jim_ExprOperator))
1232612439
@@ -12461,11 +12574,11 @@
1246112574
{
1246212575
int i;
1246312576
int bestIdx = -1, bestLen = 0;
1246412577
1246512578
12466
- for (i = JIM_TT_EXPR_OP; i < (signed)JIM_EXPR_OPERATORS_NUM; i++) {
12579
+ for (i = 0; i < (signed)JIM_EXPR_OPERATORS_NUM; i++) {
1246712580
const char *opname;
1246812581
int oplen;
1246912582
1247012583
opname = Jim_ExprOperators[i].name;
1247112584
if (opname == NULL) {
@@ -12472,11 +12585,11 @@
1247212585
continue;
1247312586
}
1247412587
oplen = strlen(opname);
1247512588
1247612589
if (strncmp(opname, pc->p, oplen) == 0 && oplen > bestLen) {
12477
- bestIdx = i;
12590
+ bestIdx = i + JIM_TT_EXPR_OP;
1247812591
bestLen = oplen;
1247912592
}
1248012593
}
1248112594
if (bestIdx == -1) {
1248212595
return JIM_ERR;
@@ -12505,11 +12618,15 @@
1250512618
return JIM_OK;
1250612619
}
1250712620
1250812621
static const struct Jim_ExprOperator *JimExprOperatorInfoByOpcode(int opcode)
1250912622
{
12510
- return &Jim_ExprOperators[opcode];
12623
+ static Jim_ExprOperator dummy_op;
12624
+ if (opcode < JIM_TT_EXPR_OP) {
12625
+ return &dummy_op;
12626
+ }
12627
+ return &Jim_ExprOperators[opcode - JIM_TT_EXPR_OP];
1251112628
}
1251212629
1251312630
const char *jim_tt_name(int type)
1251412631
{
1251512632
static const char * const tt_names[JIM_TT_EXPR_OP] =
@@ -12520,11 +12637,11 @@
1252012637
}
1252112638
else {
1252212639
const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(type);
1252312640
static char buf[20];
1252412641
12525
- if (op && op->name) {
12642
+ if (op->name) {
1252612643
return op->name;
1252712644
}
1252812645
sprintf(buf, "(%d)", type);
1252912646
return buf;
1253012647
}
@@ -12592,21 +12709,19 @@
1259212709
1259312710
for (i = 0; i < expr->len; i++) {
1259412711
ScriptToken *t = &expr->token[i];
1259512712
const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(t->type);
1259612713
12597
- if (op) {
12598
- stacklen -= op->arity;
12599
- if (stacklen < 0) {
12600
- break;
12601
- }
12602
- if (t->type == JIM_EXPROP_TERNARY || t->type == JIM_EXPROP_TERNARY_LEFT) {
12603
- ternary++;
12604
- }
12605
- else if (t->type == JIM_EXPROP_COLON || t->type == JIM_EXPROP_COLON_LEFT) {
12606
- ternary--;
12607
- }
12714
+ stacklen -= op->arity;
12715
+ if (stacklen < 0) {
12716
+ break;
12717
+ }
12718
+ if (t->type == JIM_EXPROP_TERNARY || t->type == JIM_EXPROP_TERNARY_LEFT) {
12719
+ ternary++;
12720
+ }
12721
+ else if (t->type == JIM_EXPROP_COLON || t->type == JIM_EXPROP_COLON_LEFT) {
12722
+ ternary--;
1260812723
}
1260912724
1261012725
1261112726
stacklen++;
1261212727
}
@@ -12656,11 +12771,12 @@
1265612771
expr->token[expr->len].type = t->type + 2;
1265712772
expr->len++;
1265812773
1265912774
1266012775
for (i = leftindex - 1; i > 0; i--) {
12661
- if (JimExprOperatorInfoByOpcode(expr->token[i].type)->lazy == LAZY_LEFT) {
12776
+ const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(expr->token[i].type);
12777
+ if (op->lazy == LAZY_LEFT) {
1266212778
if (JimWideValue(expr->token[i - 1].objPtr) + i - 1 >= leftindex) {
1266312779
JimWideValue(expr->token[i - 1].objPtr) += 2;
1266412780
}
1266512781
}
1266612782
}
@@ -12783,12 +12899,13 @@
1278312899
1278412900
Jim_InitStack(&stack);
1278512901
1278612902
for (i = 0; i < tokenlist->count; i++) {
1278712903
ParseToken *t = &tokenlist->list[i];
12904
+ const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(t->type);
1278812905
12789
- if (JimExprOperatorInfoByOpcode(t->type)->lazy == LAZY_OP) {
12906
+ if (op->lazy == LAZY_OP) {
1279012907
count += 2;
1279112908
1279212909
if (t->type == JIM_EXPROP_TERNARY) {
1279312910
have_ternary = 1;
1279412911
}
@@ -17349,14 +17466,12 @@
1734917466
return JIM_ERR;
1735017467
}
1735117468
objPtr = Jim_NewDictObj(interp, argv + 2, argc - 2);
1735217469
Jim_SetResult(interp, objPtr);
1735317470
return JIM_OK;
17354
-
17355
- default:
17356
- abort();
1735717471
}
17472
+ return JIM_ERR;
1735817473
}
1735917474
1736017475
1736117476
static int Jim_SubstCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
1736217477
{
@@ -18397,13 +18512,11 @@
1839718512
1839818513
return JIM_OK;
1839918514
}
1840018515
1840118516
static const jim_subcmd_type dummy_subcmd = {
18402
- .cmd = "dummy",
18403
- .function = subcmd_null,
18404
- .flags = JIM_MODFLAG_HIDDEN,
18517
+ "dummy", NULL, subcmd_null, 0, 0, JIM_MODFLAG_HIDDEN
1840518518
};
1840618519
1840718520
static void add_commands(Jim_Interp *interp, const jim_subcmd_type * ct, const char *sep)
1840818521
{
1840918522
const char *s = "";
@@ -18443,26 +18556,10 @@
1844318556
if (ct->args && *ct->args) {
1844418557
Jim_AppendStrings(interp, Jim_GetResult(interp), " ", ct->args, NULL);
1844518558
}
1844618559
}
1844718560
18448
-static void show_full_usage(Jim_Interp *interp, const jim_subcmd_type * ct, int argc,
18449
- Jim_Obj *const *argv)
18450
-{
18451
- Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
18452
- for (; ct->cmd; ct++) {
18453
- if (!(ct->flags & JIM_MODFLAG_HIDDEN)) {
18454
-
18455
- add_cmd_usage(interp, ct, argv[0]);
18456
- if (ct->description) {
18457
- Jim_AppendStrings(interp, Jim_GetResult(interp), "\n\n ", ct->description, NULL);
18458
- }
18459
- Jim_AppendStrings(interp, Jim_GetResult(interp), "\n\n", NULL);
18460
- }
18461
- }
18462
-}
18463
-
1846418561
static void set_wrong_args(Jim_Interp *interp, const jim_subcmd_type * command_table, Jim_Obj *subcmd)
1846518562
{
1846618563
Jim_SetResultString(interp, "wrong # args: must be \"", -1);
1846718564
add_cmd_usage(interp, command_table, subcmd);
1846818565
Jim_AppendStrings(interp, Jim_GetResult(interp), "\"", NULL);
@@ -18483,23 +18580,16 @@
1848318580
1848418581
if (argc < 2) {
1848518582
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
1848618583
Jim_AppendStrings(interp, Jim_GetResult(interp), "wrong # args: should be \"", cmdname,
1848718584
" command ...\"\n", NULL);
18488
- Jim_AppendStrings(interp, Jim_GetResult(interp), "Use \"", cmdname, " -help\" or \"",
18489
- cmdname, " -help command\" for help", NULL);
18585
+ Jim_AppendStrings(interp, Jim_GetResult(interp), "Use \"", cmdname, " -help ?command?\" for help", NULL);
1849018586
return 0;
1849118587
}
1849218588
1849318589
cmd = argv[1];
1849418590
18495
- if (argc == 2 && Jim_CompareStringImmediate(interp, cmd, "-usage")) {
18496
-
18497
- show_full_usage(interp, command_table, argc, argv);
18498
- return &dummy_subcmd;
18499
- }
18500
-
1850118591
1850218592
if (Jim_CompareStringImmediate(interp, cmd, "-help")) {
1850318593
if (argc == 2) {
1850418594
1850518595
show_cmd_usage(interp, command_table, argc, argv);
@@ -18560,13 +18650,10 @@
1856018650
1856118651
if (help) {
1856218652
Jim_SetResultString(interp, "Usage: ", -1);
1856318653
1856418654
add_cmd_usage(interp, ct, argv[0]);
18565
- if (ct->description) {
18566
- Jim_AppendStrings(interp, Jim_GetResult(interp), "\n\n", ct->description, NULL);
18567
- }
1856818655
return &dummy_subcmd;
1856918656
}
1857018657
1857118658
1857218659
if (argc - 2 < ct->minargs || (ct->maxargs >= 0 && argc - 2 > ct->maxargs)) {
@@ -18607,75 +18694,10 @@
1860718694
Jim_ParseSubCmd(interp, (const jim_subcmd_type *)Jim_CmdPrivData(interp), argc, argv);
1860818695
1860918696
return Jim_CallSubCmd(interp, ct, argc, argv);
1861018697
}
1861118698
18612
-
18613
-int
18614
-Jim_CheckCmdUsage(Jim_Interp *interp, const jim_subcmd_type * command_table, int argc,
18615
- Jim_Obj *const *argv)
18616
-{
18617
-
18618
- if (argc == 2) {
18619
- if (Jim_CompareStringImmediate(interp, argv[1], "-usage")
18620
- || Jim_CompareStringImmediate(interp, argv[1], "-help")) {
18621
- Jim_SetResultString(interp, "Usage: ", -1);
18622
- add_cmd_usage(interp, command_table, NULL);
18623
- if (command_table->description) {
18624
- Jim_AppendStrings(interp, Jim_GetResult(interp), "\n\n", command_table->description,
18625
- NULL);
18626
- }
18627
- return JIM_OK;
18628
- }
18629
- }
18630
- if (argc >= 2 && command_table->function) {
18631
-
18632
-
18633
- Jim_Obj *nargv[4];
18634
- int nargc = 0;
18635
- const char *subcmd = NULL;
18636
-
18637
- if (Jim_CompareStringImmediate(interp, argv[1], "-subcommands")) {
18638
- Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
18639
- add_commands(interp, (jim_subcmd_type *) command_table->function, " ");
18640
- return JIM_OK;
18641
- }
18642
-
18643
- if (Jim_CompareStringImmediate(interp, argv[1], "-subhelp")
18644
- || Jim_CompareStringImmediate(interp, argv[1], "-help")) {
18645
- subcmd = "-help";
18646
- }
18647
- else if (Jim_CompareStringImmediate(interp, argv[1], "-subusage")) {
18648
- subcmd = "-usage";
18649
- }
18650
-
18651
- if (subcmd) {
18652
- nargv[nargc++] = Jim_NewStringObj(interp, "$handle", -1);
18653
- nargv[nargc++] = Jim_NewStringObj(interp, subcmd, -1);
18654
- if (argc >= 3) {
18655
- nargv[nargc++] = argv[2];
18656
- }
18657
- Jim_ParseSubCmd(interp, (jim_subcmd_type *) command_table->function, nargc, nargv);
18658
- Jim_FreeNewObj(interp, nargv[0]);
18659
- Jim_FreeNewObj(interp, nargv[1]);
18660
- return 0;
18661
- }
18662
- }
18663
-
18664
-
18665
- if (argc - 1 < command_table->minargs || (command_table->maxargs >= 0
18666
- && argc - 1 > command_table->maxargs)) {
18667
- set_wrong_args(interp, command_table, NULL);
18668
- Jim_AppendStrings(interp, Jim_GetResult(interp), "\nUse \"", Jim_String(argv[0]),
18669
- " -help\" for help", NULL);
18670
- return JIM_ERR;
18671
- }
18672
-
18673
-
18674
- return -1;
18675
-}
18676
-
1867718699
#include <ctype.h>
1867818700
#include <stdlib.h>
1867918701
#include <string.h>
1868018702
#include <stdio.h>
1868118703
#include <assert.h>
@@ -20347,10 +20369,128 @@
2034720369
{
2034820370
free(preg->program);
2034920371
}
2035020372
2035120373
#endif
20374
+
20375
+#if defined(_WIN32) || defined(WIN32)
20376
+#ifndef STRICT
20377
+#define STRICT
20378
+#endif
20379
+#define WIN32_LEAN_AND_MEAN
20380
+#include <windows.h>
20381
+
20382
+#if defined(HAVE_DLOPEN_COMPAT)
20383
+void *dlopen(const char *path, int mode)
20384
+{
20385
+ JIM_NOTUSED(mode);
20386
+
20387
+ return (void *)LoadLibraryA(path);
20388
+}
20389
+
20390
+int dlclose(void *handle)
20391
+{
20392
+ FreeLibrary((HANDLE)handle);
20393
+ return 0;
20394
+}
20395
+
20396
+void *dlsym(void *handle, const char *symbol)
20397
+{
20398
+ return GetProcAddress((HMODULE)handle, symbol);
20399
+}
20400
+
20401
+char *dlerror(void)
20402
+{
20403
+ static char msg[121];
20404
+ FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
20405
+ LANG_NEUTRAL, msg, sizeof(msg) - 1, NULL);
20406
+ return msg;
20407
+}
20408
+#endif
20409
+
20410
+#ifdef _MSC_VER
20411
+
20412
+#include <sys/timeb.h>
20413
+
20414
+
20415
+int gettimeofday(struct timeval *tv, void *unused)
20416
+{
20417
+ struct _timeb tb;
20418
+
20419
+ _ftime(&tb);
20420
+ tv->tv_sec = tb.time;
20421
+ tv->tv_usec = tb.millitm * 1000;
20422
+
20423
+ return 0;
20424
+}
20425
+
20426
+
20427
+DIR *opendir(const char *name)
20428
+{
20429
+ DIR *dir = 0;
20430
+
20431
+ if (name && name[0]) {
20432
+ size_t base_length = strlen(name);
20433
+ const char *all =
20434
+ strchr("/\\", name[base_length - 1]) ? "*" : "/*";
20435
+
20436
+ if ((dir = (DIR *) Jim_Alloc(sizeof *dir)) != 0 &&
20437
+ (dir->name = (char *)Jim_Alloc(base_length + strlen(all) + 1)) != 0) {
20438
+ strcat(strcpy(dir->name, name), all);
20439
+
20440
+ if ((dir->handle = (long)_findfirst(dir->name, &dir->info)) != -1)
20441
+ dir->result.d_name = 0;
20442
+ else {
20443
+ Jim_Free(dir->name);
20444
+ Jim_Free(dir);
20445
+ dir = 0;
20446
+ }
20447
+ }
20448
+ else {
20449
+ Jim_Free(dir);
20450
+ dir = 0;
20451
+ errno = ENOMEM;
20452
+ }
20453
+ }
20454
+ else {
20455
+ errno = EINVAL;
20456
+ }
20457
+ return dir;
20458
+}
20459
+
20460
+int closedir(DIR * dir)
20461
+{
20462
+ int result = -1;
20463
+
20464
+ if (dir) {
20465
+ if (dir->handle != -1)
20466
+ result = _findclose(dir->handle);
20467
+ Jim_Free(dir->name);
20468
+ Jim_Free(dir);
20469
+ }
20470
+ if (result == -1)
20471
+ errno = EBADF;
20472
+ return result;
20473
+}
20474
+
20475
+struct dirent *readdir(DIR * dir)
20476
+{
20477
+ struct dirent *result = 0;
20478
+
20479
+ if (dir && dir->handle != -1) {
20480
+ if (!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) {
20481
+ result = &dir->result;
20482
+ result->d_name = dir->info.name;
20483
+ }
20484
+ }
20485
+ else {
20486
+ errno = EBADF;
20487
+ }
20488
+ return result;
20489
+}
20490
+#endif
20491
+#endif
2035220492
#ifndef JIM_BOOTSTRAP_LIB_ONLY
2035320493
#include <errno.h>
2035420494
#include <string.h>
2035520495
2035620496
#ifdef USE_LINENOISE
2035720497
--- autosetup/jimsh0.c
+++ autosetup/jimsh0.c
@@ -16,24 +16,99 @@
16 #define jim_ext_exec
17 #define jim_ext_clock
18 #define jim_ext_array
19 #define jim_ext_stdlib
20 #define jim_ext_tclcompat
21 #if defined(__MINGW32__)
 
 
 
 
 
 
22 #define TCL_PLATFORM_OS "mingw"
23 #define TCL_PLATFORM_PLATFORM "windows"
24 #define TCL_PLATFORM_PATH_SEPARATOR ";"
25 #define HAVE_MKDIR_ONE_ARG
26 #define HAVE_SYSTEM
27 #define WIN32_LEAN_AND_MEAN
28 #include <windows.h>
 
29 #else
30 #define TCL_PLATFORM_OS "unknown"
31 #define TCL_PLATFORM_PLATFORM "unix"
32 #define TCL_PLATFORM_PATH_SEPARATOR ":"
33 #define HAVE_VFORK
34 #define HAVE_WAITPID
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35 #endif
36 #ifndef UTF8_UTIL_H
37 #define UTF8_UTIL_H
38
39 int utf8_fromunicode(char *p, unsigned short uc);
@@ -102,11 +177,11 @@
102 #endif
103
104 #define UCHAR(c) ((unsigned char)(c))
105
106
107 #define JIM_VERSION 72
108
109 #define JIM_OK 0
110 #define JIM_ERR 1
111 #define JIM_RETURN 2
112 #define JIM_BREAK 3
@@ -816,24 +891,20 @@
816 const char *cmd;
817 const char *args;
818 tclmod_cmd_function *function;
819 short minargs;
820 short maxargs;
821 unsigned flags;
822 const char *description;
823 } jim_subcmd_type;
824
825 const jim_subcmd_type *
826 Jim_ParseSubCmd(Jim_Interp *interp, const jim_subcmd_type *command_table, int argc, Jim_Obj *const *argv);
827
828 int Jim_SubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
829
830 int Jim_CallSubCmd(Jim_Interp *interp, const jim_subcmd_type *ct, int argc, Jim_Obj *const *argv);
831
832 int
833 Jim_CheckCmdUsage(Jim_Interp *interp, const jim_subcmd_type *command_table, int argc, Jim_Obj *const *argv);
834
835 #ifdef __cplusplus
836 }
837 #endif
838
839 #endif
@@ -1221,11 +1292,11 @@
1221 " if {[info exists ::jim_argv0]} {\n"
1222 " if {[string match \"*/*\" $::jim_argv0]} {\n"
1223 " return [file join [pwd] $::jim_argv0]\n"
1224 " }\n"
1225 " foreach path [split [env PATH \"\"] $::tcl_platform(pathSeparator)] {\n"
1226 " set exec [file join [pwd] $path $::jim_argv0]\n"
1227 " if {[file executable $exec]} {\n"
1228 " return $exec\n"
1229 " }\n"
1230 " }\n"
1231 " }\n"
@@ -1555,11 +1626,10 @@
1555 "}\n"
1556 );
1557 }
1558
1559
1560 #include <unistd.h>
1561 #include <stdio.h>
1562 #include <string.h>
1563 #include <errno.h>
1564 #include <fcntl.h>
1565
@@ -1567,10 +1637,11 @@
1567 #if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_SELECT) && defined(HAVE_NETINET_IN_H) && defined(HAVE_NETDB_H) && defined(HAVE_ARPA_INET_H)
1568 #include <sys/socket.h>
1569 #include <netinet/in.h>
1570 #include <arpa/inet.h>
1571 #include <netdb.h>
 
1572 #ifdef HAVE_SYS_UN_H
1573 #include <sys/un.h>
1574 #endif
1575 #else
1576 #define JIM_ANSIC
@@ -1627,15 +1698,16 @@
1627 {
1628 AioFile *af = privData;
1629
1630 JIM_NOTUSED(interp);
1631
1632 Jim_DecrRefCount(interp, af->filename);
1633
1634 if (!(af->OpenFlags & AIO_KEEPOPEN)) {
1635 fclose(af->fp);
1636 }
 
 
 
1637 #ifdef jim_ext_eventloop
1638
1639 if (af->rEvent) {
1640 Jim_DeleteFileHandler(interp, af->fp);
1641 }
@@ -2052,106 +2124,121 @@
2052 return aio_eventinfo(interp, af, JIM_EVENT_EXCEPTION, &af->wEvent, argc, argv);
2053 }
2054 #endif
2055
2056 static const jim_subcmd_type aio_command_table[] = {
2057 { .cmd = "read",
2058 .args = "?-nonewline? ?len?",
2059 .function = aio_cmd_read,
2060 .minargs = 0,
2061 .maxargs = 2,
2062 .description = "Read and return bytes from the stream. To eof if no len."
2063 },
2064 { .cmd = "copyto",
2065 .args = "handle ?size?",
2066 .function = aio_cmd_copy,
2067 .minargs = 1,
2068 .maxargs = 2,
2069 .description = "Copy up to 'size' bytes to the given filehandle, or to eof if no size."
2070 },
2071 { .cmd = "gets",
2072 .args = "?var?",
2073 .function = aio_cmd_gets,
2074 .minargs = 0,
2075 .maxargs = 1,
2076 .description = "Read one line and return it or store it in the var"
2077 },
2078 { .cmd = "puts",
2079 .args = "?-nonewline? str",
2080 .function = aio_cmd_puts,
2081 .minargs = 1,
2082 .maxargs = 2,
2083 .description = "Write the string, with newline unless -nonewline"
2084 },
2085 { .cmd = "flush",
2086 .function = aio_cmd_flush,
2087 .description = "Flush the stream"
2088 },
2089 { .cmd = "eof",
2090 .function = aio_cmd_eof,
2091 .description = "Returns 1 if stream is at eof"
2092 },
2093 { .cmd = "close",
2094 .flags = JIM_MODFLAG_FULLARGV,
2095 .function = aio_cmd_close,
2096 .description = "Closes the stream"
2097 },
2098 { .cmd = "seek",
2099 .args = "offset ?start|current|end",
2100 .function = aio_cmd_seek,
2101 .minargs = 1,
2102 .maxargs = 2,
2103 .description = "Seeks in the stream (default 'current')"
2104 },
2105 { .cmd = "tell",
2106 .function = aio_cmd_tell,
2107 .description = "Returns the current seek position"
2108 },
2109 { .cmd = "filename",
2110 .function = aio_cmd_filename,
2111 .description = "Returns the original filename"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2112 },
2113 #ifdef O_NDELAY
2114 { .cmd = "ndelay",
2115 .args = "?0|1?",
2116 .function = aio_cmd_ndelay,
2117 .minargs = 0,
2118 .maxargs = 1,
2119 .description = "Set O_NDELAY (if arg). Returns current/new setting."
2120 },
2121 #endif
2122 { .cmd = "buffering",
2123 .args = "none|line|full",
2124 .function = aio_cmd_buffering,
2125 .minargs = 1,
2126 .maxargs = 1,
2127 .description = "Sets buffering"
2128 },
2129 #ifdef jim_ext_eventloop
2130 { .cmd = "readable",
2131 .args = "?readable-script?",
2132 .minargs = 0,
2133 .maxargs = 1,
2134 .function = aio_cmd_readable,
2135 .description = "Returns script, or invoke readable-script when readable, {} to remove",
2136 },
2137 { .cmd = "writable",
2138 .args = "?writable-script?",
2139 .minargs = 0,
2140 .maxargs = 1,
2141 .function = aio_cmd_writable,
2142 .description = "Returns script, or invoke writable-script when writable, {} to remove",
2143 },
2144 { .cmd = "onexception",
2145 .args = "?exception-script?",
2146 .minargs = 0,
2147 .maxargs = 1,
2148 .function = aio_cmd_onexception,
2149 .description = "Returns script, or invoke exception-script when oob data, {} to remove",
2150 },
2151 #endif
2152 { 0 }
2153 };
2154
2155 static int JimAioSubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
2156 {
2157 return Jim_CallSubCmd(interp, Jim_ParseSubCmd(interp, aio_command_table, argc, argv), argc, argv);
@@ -2158,60 +2245,46 @@
2158 }
2159
2160 static int JimAioOpenCommand(Jim_Interp *interp, int argc,
2161 Jim_Obj *const *argv)
2162 {
2163 FILE *fp;
2164 const char *hdlfmt;
2165 const char *mode;
 
2166
2167 if (argc != 2 && argc != 3) {
2168 Jim_WrongNumArgs(interp, 1, argv, "filename ?mode?");
2169 return JIM_ERR;
2170 }
2171
2172 mode = (argc == 3) ? Jim_String(argv[2]) : "r";
2173 hdlfmt = Jim_String(argv[1]);
2174 if (Jim_CompareStringImmediate(interp, argv[1], "stdin")) {
2175 fp = stdin;
2176 }
2177 else if (Jim_CompareStringImmediate(interp, argv[1], "stdout")) {
2178 fp = stdout;
2179 }
2180 else if (Jim_CompareStringImmediate(interp, argv[1], "stderr")) {
2181 fp = stderr;
2182 }
2183 else {
2184 const char *filename = Jim_String(argv[1]);
2185
2186
2187 #ifdef jim_ext_tclcompat
2188
2189 if (*filename == '|') {
2190 Jim_Obj *evalObj[3];
2191
2192 evalObj[0] = Jim_NewStringObj(interp, "popen", -1);
2193 evalObj[1] = Jim_NewStringObj(interp, filename + 1, -1);
2194 evalObj[2] = Jim_NewStringObj(interp, mode, -1);
2195
2196 return Jim_EvalObjVector(interp, 3, evalObj);
2197 }
2198 #endif
2199 hdlfmt = "aio.handle%ld";
2200 fp = NULL;
2201 }
2202
2203
2204 return JimMakeChannel(interp, fp, -1, argv[1], hdlfmt, 0, mode);
2205 }
2206
2207 static int JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filename,
2208 const char *hdlfmt, int family, const char *mode)
2209 {
2210 AioFile *af;
2211 char buf[AIO_CMD_LEN];
2212 int OpenFlags = 0;
 
 
 
 
2213
2214 Jim_IncrRefCount(filename);
2215
2216 if (fh == NULL) {
2217 if (fd < 0) {
@@ -2225,11 +2298,13 @@
2225 OpenFlags = AIO_KEEPOPEN;
2226 }
2227
2228 if (fh == NULL) {
2229 JimAioSetError(interp, filename);
2230 close(fd);
 
 
2231 Jim_DecrRefCount(interp, filename);
2232 return JIM_ERR;
2233 }
2234
2235
@@ -2239,13 +2314,13 @@
2239 af->fd = fileno(fh);
2240 af->filename = filename;
2241 #ifdef FD_CLOEXEC
2242 if ((OpenFlags & AIO_KEEPOPEN) == 0) {
2243 fcntl(af->fd, F_SETFD, FD_CLOEXEC);
2244 af->OpenFlags = OpenFlags;
2245 }
2246 #endif
 
2247 #ifdef O_NDELAY
2248 af->flags = fcntl(af->fd, F_GETFL);
2249 #endif
2250 af->addr_family = family;
2251 snprintf(buf, sizeof(buf), hdlfmt, Jim_GetId(interp));
@@ -2277,21 +2352,26 @@
2277 #ifndef JIM_ANSIC
2278 Jim_CreateCommand(interp, "socket", JimAioSockCommand, NULL, NULL);
2279 #endif
2280
2281
2282 Jim_EvalGlobal(interp, "open stdin; open stdout; open stderr");
 
 
2283
2284 return JIM_OK;
2285 }
2286
2287
2288 #include <errno.h>
2289 #include <stdio.h>
2290 #include <string.h>
 
 
 
2291 #include <dirent.h>
2292
2293
2294 int Jim_ReaddirCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
2295 {
2296 const char *dirPath;
2297 DIR *dirPtr;
@@ -2834,16 +2914,27 @@
2834
2835 #include <limits.h>
2836 #include <stdlib.h>
2837 #include <string.h>
2838 #include <stdio.h>
2839 #include <unistd.h>
2840 #include <errno.h>
2841 #include <sys/stat.h>
2842 #include <sys/param.h>
 
 
2843 #include <sys/time.h>
2844
 
 
 
 
 
 
 
 
 
 
2845
2846 # ifndef MAXPATHLEN
2847 # define MAXPATHLEN JIM_PATH_LEN
2848 # endif
2849
@@ -2854,29 +2945,35 @@
2854 return "file";
2855 }
2856 else if (S_ISDIR(mode)) {
2857 return "directory";
2858 }
 
2859 else if (S_ISCHR(mode)) {
2860 return "characterSpecial";
2861 }
 
 
2862 else if (S_ISBLK(mode)) {
2863 return "blockSpecial";
2864 }
 
 
2865 else if (S_ISFIFO(mode)) {
2866 return "fifo";
 
 
2867 #ifdef S_ISLNK
2868 }
2869 else if (S_ISLNK(mode)) {
2870 return "link";
 
2871 #endif
2872 #ifdef S_ISSOCK
2873 }
2874 else if (S_ISSOCK(mode)) {
2875 return "socket";
 
2876 #endif
2877 }
2878 return "unknown";
2879 }
2880
2881
2882 static int set_array_int_value(Jim_Interp *interp, Jim_Obj *container, const char *key,
@@ -2939,11 +3036,11 @@
2939 Jim_SetResultString(interp, ".", -1);
2940 }
2941 else if (p == path) {
2942 Jim_SetResultString(interp, "/", -1);
2943 }
2944 #if defined(__MINGW32__)
2945 else if (p[-1] == ':') {
2946
2947 Jim_SetResultString(interp, path, p - path + 1);
2948 }
2949 #endif
@@ -3030,11 +3127,11 @@
3030
3031 if (*part == '/') {
3032
3033 last = newname;
3034 }
3035 #if defined(__MINGW32__)
3036 else if (strchr(part, ':')) {
3037
3038 last = newname;
3039 }
3040 #endif
@@ -3099,11 +3196,16 @@
3099 return file_access(interp, argv[0], W_OK);
3100 }
3101
3102 static int file_cmd_executable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
3103 {
 
3104 return file_access(interp, argv[0], X_OK);
 
 
 
 
3105 }
3106
3107 static int file_cmd_exists(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
3108 {
3109 return file_access(interp, argv[0], F_OK);
@@ -3430,193 +3532,193 @@
3430 }
3431 return StoreStatData(interp, argv[1], &sb);
3432 }
3433
3434 static const jim_subcmd_type file_command_table[] = {
3435 { .cmd = "atime",
3436 .args = "name",
3437 .function = file_cmd_atime,
3438 .minargs = 1,
3439 .maxargs = 1,
3440 .description = "Last access time"
3441 },
3442 { .cmd = "mtime",
3443 .args = "name ?time?",
3444 .function = file_cmd_mtime,
3445 .minargs = 1,
3446 .maxargs = 2,
3447 .description = "Get or set last modification time"
3448 },
3449 { .cmd = "copy",
3450 .args = "?-force? source dest",
3451 .function = file_cmd_copy,
3452 .minargs = 2,
3453 .maxargs = 3,
3454 .description = "Copy source file to destination file"
3455 },
3456 { .cmd = "dirname",
3457 .args = "name",
3458 .function = file_cmd_dirname,
3459 .minargs = 1,
3460 .maxargs = 1,
3461 .description = "Directory part of the name"
3462 },
3463 { .cmd = "rootname",
3464 .args = "name",
3465 .function = file_cmd_rootname,
3466 .minargs = 1,
3467 .maxargs = 1,
3468 .description = "Name without any extension"
3469 },
3470 { .cmd = "extension",
3471 .args = "name",
3472 .function = file_cmd_extension,
3473 .minargs = 1,
3474 .maxargs = 1,
3475 .description = "Last extension including the dot"
3476 },
3477 { .cmd = "tail",
3478 .args = "name",
3479 .function = file_cmd_tail,
3480 .minargs = 1,
3481 .maxargs = 1,
3482 .description = "Last component of the name"
3483 },
3484 { .cmd = "normalize",
3485 .args = "name",
3486 .function = file_cmd_normalize,
3487 .minargs = 1,
3488 .maxargs = 1,
3489 .description = "Normalized path of name"
3490 },
3491 { .cmd = "join",
3492 .args = "name ?name ...?",
3493 .function = file_cmd_join,
3494 .minargs = 1,
3495 .maxargs = -1,
3496 .description = "Join multiple path components"
3497 },
3498 { .cmd = "readable",
3499 .args = "name",
3500 .function = file_cmd_readable,
3501 .minargs = 1,
3502 .maxargs = 1,
3503 .description = "Is file readable"
3504 },
3505 { .cmd = "writable",
3506 .args = "name",
3507 .function = file_cmd_writable,
3508 .minargs = 1,
3509 .maxargs = 1,
3510 .description = "Is file writable"
3511 },
3512 { .cmd = "executable",
3513 .args = "name",
3514 .function = file_cmd_executable,
3515 .minargs = 1,
3516 .maxargs = 1,
3517 .description = "Is file executable"
3518 },
3519 { .cmd = "exists",
3520 .args = "name",
3521 .function = file_cmd_exists,
3522 .minargs = 1,
3523 .maxargs = 1,
3524 .description = "Does file exist"
3525 },
3526 { .cmd = "delete",
3527 .args = "?-force|--? name ...",
3528 .function = file_cmd_delete,
3529 .minargs = 1,
3530 .maxargs = -1,
3531 .description = "Deletes the files or directories (must be empty unless -force)"
3532 },
3533 { .cmd = "mkdir",
3534 .args = "dir ...",
3535 .function = file_cmd_mkdir,
3536 .minargs = 1,
3537 .maxargs = -1,
3538 .description = "Creates the directories"
3539 },
3540 #ifdef HAVE_MKSTEMP
3541 { .cmd = "tempfile",
3542 .args = "?template?",
3543 .function = file_cmd_tempfile,
3544 .minargs = 0,
3545 .maxargs = 1,
3546 .description = "Creates a temporary filename"
3547 },
3548 #endif
3549 { .cmd = "rename",
3550 .args = "?-force? source dest",
3551 .function = file_cmd_rename,
3552 .minargs = 2,
3553 .maxargs = 3,
3554 .description = "Renames a file"
3555 },
3556 #if defined(HAVE_READLINK)
3557 { .cmd = "readlink",
3558 .args = "name",
3559 .function = file_cmd_readlink,
3560 .minargs = 1,
3561 .maxargs = 1,
3562 .description = "Value of the symbolic link"
3563 },
3564 #endif
3565 { .cmd = "size",
3566 .args = "name",
3567 .function = file_cmd_size,
3568 .minargs = 1,
3569 .maxargs = 1,
3570 .description = "Size of file"
3571 },
3572 { .cmd = "stat",
3573 .args = "name var",
3574 .function = file_cmd_stat,
3575 .minargs = 2,
3576 .maxargs = 2,
3577 .description = "Stores results of stat in var array"
3578 },
3579 { .cmd = "lstat",
3580 .args = "name var",
3581 .function = file_cmd_lstat,
3582 .minargs = 2,
3583 .maxargs = 2,
3584 .description = "Stores results of lstat in var array"
3585 },
3586 { .cmd = "type",
3587 .args = "name",
3588 .function = file_cmd_type,
3589 .minargs = 1,
3590 .maxargs = 1,
3591 .description = "Returns type of the file"
3592 },
3593 #ifdef HAVE_GETEUID
3594 { .cmd = "owned",
3595 .args = "name",
3596 .function = file_cmd_owned,
3597 .minargs = 1,
3598 .maxargs = 1,
3599 .description = "Returns 1 if owned by the current owner"
3600 },
3601 #endif
3602 { .cmd = "isdirectory",
3603 .args = "name",
3604 .function = file_cmd_isdirectory,
3605 .minargs = 1,
3606 .maxargs = 1,
3607 .description = "Returns 1 if name is a directory"
3608 },
3609 { .cmd = "isfile",
3610 .args = "name",
3611 .function = file_cmd_isfile,
3612 .minargs = 1,
3613 .maxargs = 1,
3614 .description = "Returns 1 if name is a file"
3615 },
3616 {
3617 .cmd = 0
3618 }
3619 };
3620
3621 static int Jim_CdCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
3622 {
@@ -3644,11 +3746,11 @@
3644
3645 if (getcwd(cwd, cwd_len) == NULL) {
3646 Jim_SetResultString(interp, "Failed to get pwd", -1);
3647 return JIM_ERR;
3648 }
3649 #if defined(__MINGW32__)
3650 {
3651
3652 char *p = cwd;
3653 while ((p = strchr(p, '\\')) != NULL) {
3654 *p++ = '/';
@@ -3734,14 +3836,17 @@
3734
3735
3736 #include <errno.h>
3737 #include <signal.h>
3738
3739 #define XXX printf("@%s:%d\n", __FILE__, __LINE__); fflush(stdout);
3740
3741 #if defined(__MINGW32__)
3742
 
 
 
 
 
3743 #include <fcntl.h>
3744
3745 typedef HANDLE fdtype;
3746 typedef HANDLE pidtype;
3747 #define JIM_BAD_FD INVALID_HANDLE_VALUE
@@ -5022,12 +5127,15 @@
5022
5023 #include <stdlib.h>
5024 #include <string.h>
5025 #include <stdio.h>
5026 #include <time.h>
 
 
 
5027 #include <sys/time.h>
5028
5029
5030 static int clock_cmd_format(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
5031 {
5032
5033 char buf[100];
@@ -5111,51 +5219,55 @@
5111
5112 return JIM_OK;
5113 }
5114
5115 static const jim_subcmd_type clock_command_table[] = {
5116 { .cmd = "seconds",
5117 .function = clock_cmd_seconds,
5118 .minargs = 0,
5119 .maxargs = 0,
5120 .description = "Returns the current time as seconds since the epoch"
5121 },
5122 { .cmd = "clicks",
5123 .function = clock_cmd_micros,
5124 .minargs = 0,
5125 .maxargs = 0,
5126 .description = "Returns the current time in 'clicks'"
5127 },
5128 { .cmd = "microseconds",
5129 .function = clock_cmd_micros,
5130 .minargs = 0,
5131 .maxargs = 0,
5132 .description = "Returns the current time in microseconds"
5133 },
5134 { .cmd = "milliseconds",
5135 .function = clock_cmd_millis,
5136 .minargs = 0,
5137 .maxargs = 0,
5138 .description = "Returns the current time in milliseconds"
5139 },
5140 { .cmd = "format",
5141 .args = "seconds ?-format format?",
5142 .function = clock_cmd_format,
5143 .minargs = 1,
5144 .maxargs = 3,
5145 .description = "Format the given time"
 
 
 
 
5146 },
5147 #ifdef HAVE_STRPTIME
5148 { .cmd = "scan",
5149 .args = "str -format format",
5150 .function = clock_cmd_scan,
5151 .minargs = 3,
5152 .maxargs = 3,
5153 .description = "Determine the time according to the given format"
5154 },
5155 #endif
5156 { 0 }
5157 };
5158
5159 int Jim_clockInit(Jim_Interp *interp)
5160 {
5161 if (Jim_PackageProvide(interp, "clock", "1.0", JIM_ERRMSG))
@@ -5168,11 +5280,10 @@
5168
5169 #include <limits.h>
5170 #include <stdlib.h>
5171 #include <string.h>
5172 #include <stdio.h>
5173 #include <unistd.h>
5174 #include <errno.h>
5175
5176
5177 static int array_cmd_exists(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
5178 {
@@ -5335,53 +5446,53 @@
5335
5336 return rc;
5337 }
5338
5339 static const jim_subcmd_type array_command_table[] = {
5340 { .cmd = "exists",
5341 .args = "arrayName",
5342 .function = array_cmd_exists,
5343 .minargs = 1,
5344 .maxargs = 1,
5345 .description = "Does array exist?"
5346 },
5347 { .cmd = "get",
5348 .args = "arrayName ?pattern?",
5349 .function = array_cmd_get,
5350 .minargs = 1,
5351 .maxargs = 2,
5352 .description = "Array contents as name value list"
5353 },
5354 { .cmd = "names",
5355 .args = "arrayName ?pattern?",
5356 .function = array_cmd_names,
5357 .minargs = 1,
5358 .maxargs = 2,
5359 .description = "Array keys as a list"
5360 },
5361 { .cmd = "set",
5362 .args = "arrayName list",
5363 .function = array_cmd_set,
5364 .minargs = 2,
5365 .maxargs = 2,
5366 .description = "Set array from list"
5367 },
5368 { .cmd = "size",
5369 .args = "arrayName",
5370 .function = array_cmd_size,
5371 .minargs = 1,
5372 .maxargs = 1,
5373 .description = "Number of elements in array"
5374 },
5375 { .cmd = "unset",
5376 .args = "arrayName ?pattern?",
5377 .function = array_cmd_unset,
5378 .minargs = 1,
5379 .maxargs = 2,
5380 .description = "Unset elements of an array"
5381 },
5382 { .cmd = 0,
5383 }
5384 };
5385
5386 int Jim_arrayInit(Jim_Interp *interp)
5387 {
@@ -5430,14 +5541,14 @@
5430 #include <assert.h>
5431 #include <errno.h>
5432 #include <time.h>
5433 #include <setjmp.h>
5434
5435 #include <unistd.h>
 
5436 #include <sys/time.h>
5437
5438
5439 #ifdef HAVE_BACKTRACE
5440 #include <execinfo.h>
5441 #endif
5442 #ifdef HAVE_CRT_EXTERNS_H
5443 #include <crt_externs.h>
@@ -11387,18 +11498,18 @@
11387 }
11388
11389
11390
11391 static const char * const jimReturnCodes[] = {
11392 [JIM_OK] = "ok",
11393 [JIM_ERR] = "error",
11394 [JIM_RETURN] = "return",
11395 [JIM_BREAK] = "break",
11396 [JIM_CONTINUE] = "continue",
11397 [JIM_SIGNAL] = "signal",
11398 [JIM_EXIT] = "exit",
11399 [JIM_EVAL] = "eval",
11400 NULL
11401 };
11402
11403 #define jimReturnCodesSize (sizeof(jimReturnCodes)/sizeof(*jimReturnCodes))
11404
@@ -11458,11 +11569,11 @@
11458
11459 enum
11460 {
11461
11462
11463 JIM_EXPROP_MUL = JIM_TT_EXPR_OP,
11464 JIM_EXPROP_DIV,
11465 JIM_EXPROP_MOD,
11466 JIM_EXPROP_SUB,
11467 JIM_EXPROP_ADD,
11468 JIM_EXPROP_LSHIFT,
@@ -11501,32 +11612,32 @@
11501 JIM_EXPROP_COLON_RIGHT,
11502
11503 JIM_EXPROP_POW,
11504
11505
11506 JIM_EXPROP_STREQ,
11507 JIM_EXPROP_STRNE,
11508 JIM_EXPROP_STRIN,
11509 JIM_EXPROP_STRNI,
11510
11511
11512 JIM_EXPROP_NOT,
11513 JIM_EXPROP_BITNOT,
11514 JIM_EXPROP_UNARYMINUS,
11515 JIM_EXPROP_UNARYPLUS,
11516
11517
11518 JIM_EXPROP_FUNC_FIRST,
11519 JIM_EXPROP_FUNC_INT = JIM_EXPROP_FUNC_FIRST,
11520 JIM_EXPROP_FUNC_ABS,
11521 JIM_EXPROP_FUNC_DOUBLE,
11522 JIM_EXPROP_FUNC_ROUND,
11523 JIM_EXPROP_FUNC_RAND,
11524 JIM_EXPROP_FUNC_SRAND,
11525
11526
11527 JIM_EXPROP_FUNC_SIN,
11528 JIM_EXPROP_FUNC_COS,
11529 JIM_EXPROP_FUNC_TAN,
11530 JIM_EXPROP_FUNC_ASIN,
11531 JIM_EXPROP_FUNC_ACOS,
11532 JIM_EXPROP_FUNC_ATAN,
@@ -12237,90 +12348,92 @@
12237 LAZY_OP,
12238 LAZY_LEFT,
12239 LAZY_RIGHT
12240 };
12241
12242
12243 static const struct Jim_ExprOperator Jim_ExprOperators[] = {
12244 [JIM_EXPROP_FUNC_INT] = {"int", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12245 [JIM_EXPROP_FUNC_DOUBLE] = {"double", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12246 [JIM_EXPROP_FUNC_ABS] = {"abs", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12247 [JIM_EXPROP_FUNC_ROUND] = {"round", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12248 [JIM_EXPROP_FUNC_RAND] = {"rand", 400, 0, JimExprOpNone, LAZY_NONE},
12249 [JIM_EXPROP_FUNC_SRAND] = {"srand", 400, 1, JimExprOpIntUnary, LAZY_NONE},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12250
12251 #ifdef JIM_MATH_FUNCTIONS
12252 [JIM_EXPROP_FUNC_SIN] = {"sin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12253 [JIM_EXPROP_FUNC_COS] = {"cos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12254 [JIM_EXPROP_FUNC_TAN] = {"tan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12255 [JIM_EXPROP_FUNC_ASIN] = {"asin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12256 [JIM_EXPROP_FUNC_ACOS] = {"acos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12257 [JIM_EXPROP_FUNC_ATAN] = {"atan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12258 [JIM_EXPROP_FUNC_SINH] = {"sinh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12259 [JIM_EXPROP_FUNC_COSH] = {"cosh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12260 [JIM_EXPROP_FUNC_TANH] = {"tanh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12261 [JIM_EXPROP_FUNC_CEIL] = {"ceil", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12262 [JIM_EXPROP_FUNC_FLOOR] = {"floor", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12263 [JIM_EXPROP_FUNC_EXP] = {"exp", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12264 [JIM_EXPROP_FUNC_LOG] = {"log", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12265 [JIM_EXPROP_FUNC_LOG10] = {"log10", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12266 [JIM_EXPROP_FUNC_SQRT] = {"sqrt", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12267 [JIM_EXPROP_FUNC_POW] = {"pow", 400, 2, JimExprOpBin, LAZY_NONE},
12268 #endif
12269
12270 [JIM_EXPROP_NOT] = {"!", 300, 1, JimExprOpNumUnary, LAZY_NONE},
12271 [JIM_EXPROP_BITNOT] = {"~", 300, 1, JimExprOpIntUnary, LAZY_NONE},
12272 [JIM_EXPROP_UNARYMINUS] = {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE},
12273 [JIM_EXPROP_UNARYPLUS] = {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE},
12274
12275 [JIM_EXPROP_POW] = {"**", 250, 2, JimExprOpBin, LAZY_NONE},
12276
12277 [JIM_EXPROP_MUL] = {"*", 200, 2, JimExprOpBin, LAZY_NONE},
12278 [JIM_EXPROP_DIV] = {"/", 200, 2, JimExprOpBin, LAZY_NONE},
12279 [JIM_EXPROP_MOD] = {"%", 200, 2, JimExprOpIntBin, LAZY_NONE},
12280
12281 [JIM_EXPROP_SUB] = {"-", 100, 2, JimExprOpBin, LAZY_NONE},
12282 [JIM_EXPROP_ADD] = {"+", 100, 2, JimExprOpBin, LAZY_NONE},
12283
12284 [JIM_EXPROP_ROTL] = {"<<<", 90, 2, JimExprOpIntBin, LAZY_NONE},
12285 [JIM_EXPROP_ROTR] = {">>>", 90, 2, JimExprOpIntBin, LAZY_NONE},
12286 [JIM_EXPROP_LSHIFT] = {"<<", 90, 2, JimExprOpIntBin, LAZY_NONE},
12287 [JIM_EXPROP_RSHIFT] = {">>", 90, 2, JimExprOpIntBin, LAZY_NONE},
12288
12289 [JIM_EXPROP_LT] = {"<", 80, 2, JimExprOpBin, LAZY_NONE},
12290 [JIM_EXPROP_GT] = {">", 80, 2, JimExprOpBin, LAZY_NONE},
12291 [JIM_EXPROP_LTE] = {"<=", 80, 2, JimExprOpBin, LAZY_NONE},
12292 [JIM_EXPROP_GTE] = {">=", 80, 2, JimExprOpBin, LAZY_NONE},
12293
12294 [JIM_EXPROP_NUMEQ] = {"==", 70, 2, JimExprOpBin, LAZY_NONE},
12295 [JIM_EXPROP_NUMNE] = {"!=", 70, 2, JimExprOpBin, LAZY_NONE},
12296
12297 [JIM_EXPROP_STREQ] = {"eq", 60, 2, JimExprOpStrBin, LAZY_NONE},
12298 [JIM_EXPROP_STRNE] = {"ne", 60, 2, JimExprOpStrBin, LAZY_NONE},
12299
12300 [JIM_EXPROP_STRIN] = {"in", 55, 2, JimExprOpStrBin, LAZY_NONE},
12301 [JIM_EXPROP_STRNI] = {"ni", 55, 2, JimExprOpStrBin, LAZY_NONE},
12302
12303 [JIM_EXPROP_BITAND] = {"&", 50, 2, JimExprOpIntBin, LAZY_NONE},
12304 [JIM_EXPROP_BITXOR] = {"^", 49, 2, JimExprOpIntBin, LAZY_NONE},
12305 [JIM_EXPROP_BITOR] = {"|", 48, 2, JimExprOpIntBin, LAZY_NONE},
12306
12307 [JIM_EXPROP_LOGICAND] = {"&&", 10, 2, NULL, LAZY_OP},
12308 [JIM_EXPROP_LOGICOR] = {"||", 9, 2, NULL, LAZY_OP},
12309
12310 [JIM_EXPROP_TERNARY] = {"?", 5, 2, JimExprOpNull, LAZY_OP},
12311 [JIM_EXPROP_COLON] = {":", 5, 2, JimExprOpNull, LAZY_OP},
12312
12313
12314 [JIM_EXPROP_TERNARY_LEFT] = {NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT},
12315 [JIM_EXPROP_TERNARY_RIGHT] = {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT},
12316 [JIM_EXPROP_COLON_LEFT] = {NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT},
12317 [JIM_EXPROP_COLON_RIGHT] = {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT},
12318 [JIM_EXPROP_LOGICAND_LEFT] = {NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT},
12319 [JIM_EXPROP_LOGICAND_RIGHT] = {NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT},
12320 [JIM_EXPROP_LOGICOR_LEFT] = {NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT},
12321 [JIM_EXPROP_LOGICOR_RIGHT] = {NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT},
12322 };
12323
12324 #define JIM_EXPR_OPERATORS_NUM \
12325 (sizeof(Jim_ExprOperators)/sizeof(struct Jim_ExprOperator))
12326
@@ -12461,11 +12574,11 @@
12461 {
12462 int i;
12463 int bestIdx = -1, bestLen = 0;
12464
12465
12466 for (i = JIM_TT_EXPR_OP; i < (signed)JIM_EXPR_OPERATORS_NUM; i++) {
12467 const char *opname;
12468 int oplen;
12469
12470 opname = Jim_ExprOperators[i].name;
12471 if (opname == NULL) {
@@ -12472,11 +12585,11 @@
12472 continue;
12473 }
12474 oplen = strlen(opname);
12475
12476 if (strncmp(opname, pc->p, oplen) == 0 && oplen > bestLen) {
12477 bestIdx = i;
12478 bestLen = oplen;
12479 }
12480 }
12481 if (bestIdx == -1) {
12482 return JIM_ERR;
@@ -12505,11 +12618,15 @@
12505 return JIM_OK;
12506 }
12507
12508 static const struct Jim_ExprOperator *JimExprOperatorInfoByOpcode(int opcode)
12509 {
12510 return &Jim_ExprOperators[opcode];
 
 
 
 
12511 }
12512
12513 const char *jim_tt_name(int type)
12514 {
12515 static const char * const tt_names[JIM_TT_EXPR_OP] =
@@ -12520,11 +12637,11 @@
12520 }
12521 else {
12522 const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(type);
12523 static char buf[20];
12524
12525 if (op && op->name) {
12526 return op->name;
12527 }
12528 sprintf(buf, "(%d)", type);
12529 return buf;
12530 }
@@ -12592,21 +12709,19 @@
12592
12593 for (i = 0; i < expr->len; i++) {
12594 ScriptToken *t = &expr->token[i];
12595 const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(t->type);
12596
12597 if (op) {
12598 stacklen -= op->arity;
12599 if (stacklen < 0) {
12600 break;
12601 }
12602 if (t->type == JIM_EXPROP_TERNARY || t->type == JIM_EXPROP_TERNARY_LEFT) {
12603 ternary++;
12604 }
12605 else if (t->type == JIM_EXPROP_COLON || t->type == JIM_EXPROP_COLON_LEFT) {
12606 ternary--;
12607 }
12608 }
12609
12610
12611 stacklen++;
12612 }
@@ -12656,11 +12771,12 @@
12656 expr->token[expr->len].type = t->type + 2;
12657 expr->len++;
12658
12659
12660 for (i = leftindex - 1; i > 0; i--) {
12661 if (JimExprOperatorInfoByOpcode(expr->token[i].type)->lazy == LAZY_LEFT) {
 
12662 if (JimWideValue(expr->token[i - 1].objPtr) + i - 1 >= leftindex) {
12663 JimWideValue(expr->token[i - 1].objPtr) += 2;
12664 }
12665 }
12666 }
@@ -12783,12 +12899,13 @@
12783
12784 Jim_InitStack(&stack);
12785
12786 for (i = 0; i < tokenlist->count; i++) {
12787 ParseToken *t = &tokenlist->list[i];
 
12788
12789 if (JimExprOperatorInfoByOpcode(t->type)->lazy == LAZY_OP) {
12790 count += 2;
12791
12792 if (t->type == JIM_EXPROP_TERNARY) {
12793 have_ternary = 1;
12794 }
@@ -17349,14 +17466,12 @@
17349 return JIM_ERR;
17350 }
17351 objPtr = Jim_NewDictObj(interp, argv + 2, argc - 2);
17352 Jim_SetResult(interp, objPtr);
17353 return JIM_OK;
17354
17355 default:
17356 abort();
17357 }
 
17358 }
17359
17360
17361 static int Jim_SubstCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
17362 {
@@ -18397,13 +18512,11 @@
18397
18398 return JIM_OK;
18399 }
18400
18401 static const jim_subcmd_type dummy_subcmd = {
18402 .cmd = "dummy",
18403 .function = subcmd_null,
18404 .flags = JIM_MODFLAG_HIDDEN,
18405 };
18406
18407 static void add_commands(Jim_Interp *interp, const jim_subcmd_type * ct, const char *sep)
18408 {
18409 const char *s = "";
@@ -18443,26 +18556,10 @@
18443 if (ct->args && *ct->args) {
18444 Jim_AppendStrings(interp, Jim_GetResult(interp), " ", ct->args, NULL);
18445 }
18446 }
18447
18448 static void show_full_usage(Jim_Interp *interp, const jim_subcmd_type * ct, int argc,
18449 Jim_Obj *const *argv)
18450 {
18451 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
18452 for (; ct->cmd; ct++) {
18453 if (!(ct->flags & JIM_MODFLAG_HIDDEN)) {
18454
18455 add_cmd_usage(interp, ct, argv[0]);
18456 if (ct->description) {
18457 Jim_AppendStrings(interp, Jim_GetResult(interp), "\n\n ", ct->description, NULL);
18458 }
18459 Jim_AppendStrings(interp, Jim_GetResult(interp), "\n\n", NULL);
18460 }
18461 }
18462 }
18463
18464 static void set_wrong_args(Jim_Interp *interp, const jim_subcmd_type * command_table, Jim_Obj *subcmd)
18465 {
18466 Jim_SetResultString(interp, "wrong # args: must be \"", -1);
18467 add_cmd_usage(interp, command_table, subcmd);
18468 Jim_AppendStrings(interp, Jim_GetResult(interp), "\"", NULL);
@@ -18483,23 +18580,16 @@
18483
18484 if (argc < 2) {
18485 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
18486 Jim_AppendStrings(interp, Jim_GetResult(interp), "wrong # args: should be \"", cmdname,
18487 " command ...\"\n", NULL);
18488 Jim_AppendStrings(interp, Jim_GetResult(interp), "Use \"", cmdname, " -help\" or \"",
18489 cmdname, " -help command\" for help", NULL);
18490 return 0;
18491 }
18492
18493 cmd = argv[1];
18494
18495 if (argc == 2 && Jim_CompareStringImmediate(interp, cmd, "-usage")) {
18496
18497 show_full_usage(interp, command_table, argc, argv);
18498 return &dummy_subcmd;
18499 }
18500
18501
18502 if (Jim_CompareStringImmediate(interp, cmd, "-help")) {
18503 if (argc == 2) {
18504
18505 show_cmd_usage(interp, command_table, argc, argv);
@@ -18560,13 +18650,10 @@
18560
18561 if (help) {
18562 Jim_SetResultString(interp, "Usage: ", -1);
18563
18564 add_cmd_usage(interp, ct, argv[0]);
18565 if (ct->description) {
18566 Jim_AppendStrings(interp, Jim_GetResult(interp), "\n\n", ct->description, NULL);
18567 }
18568 return &dummy_subcmd;
18569 }
18570
18571
18572 if (argc - 2 < ct->minargs || (ct->maxargs >= 0 && argc - 2 > ct->maxargs)) {
@@ -18607,75 +18694,10 @@
18607 Jim_ParseSubCmd(interp, (const jim_subcmd_type *)Jim_CmdPrivData(interp), argc, argv);
18608
18609 return Jim_CallSubCmd(interp, ct, argc, argv);
18610 }
18611
18612
18613 int
18614 Jim_CheckCmdUsage(Jim_Interp *interp, const jim_subcmd_type * command_table, int argc,
18615 Jim_Obj *const *argv)
18616 {
18617
18618 if (argc == 2) {
18619 if (Jim_CompareStringImmediate(interp, argv[1], "-usage")
18620 || Jim_CompareStringImmediate(interp, argv[1], "-help")) {
18621 Jim_SetResultString(interp, "Usage: ", -1);
18622 add_cmd_usage(interp, command_table, NULL);
18623 if (command_table->description) {
18624 Jim_AppendStrings(interp, Jim_GetResult(interp), "\n\n", command_table->description,
18625 NULL);
18626 }
18627 return JIM_OK;
18628 }
18629 }
18630 if (argc >= 2 && command_table->function) {
18631
18632
18633 Jim_Obj *nargv[4];
18634 int nargc = 0;
18635 const char *subcmd = NULL;
18636
18637 if (Jim_CompareStringImmediate(interp, argv[1], "-subcommands")) {
18638 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
18639 add_commands(interp, (jim_subcmd_type *) command_table->function, " ");
18640 return JIM_OK;
18641 }
18642
18643 if (Jim_CompareStringImmediate(interp, argv[1], "-subhelp")
18644 || Jim_CompareStringImmediate(interp, argv[1], "-help")) {
18645 subcmd = "-help";
18646 }
18647 else if (Jim_CompareStringImmediate(interp, argv[1], "-subusage")) {
18648 subcmd = "-usage";
18649 }
18650
18651 if (subcmd) {
18652 nargv[nargc++] = Jim_NewStringObj(interp, "$handle", -1);
18653 nargv[nargc++] = Jim_NewStringObj(interp, subcmd, -1);
18654 if (argc >= 3) {
18655 nargv[nargc++] = argv[2];
18656 }
18657 Jim_ParseSubCmd(interp, (jim_subcmd_type *) command_table->function, nargc, nargv);
18658 Jim_FreeNewObj(interp, nargv[0]);
18659 Jim_FreeNewObj(interp, nargv[1]);
18660 return 0;
18661 }
18662 }
18663
18664
18665 if (argc - 1 < command_table->minargs || (command_table->maxargs >= 0
18666 && argc - 1 > command_table->maxargs)) {
18667 set_wrong_args(interp, command_table, NULL);
18668 Jim_AppendStrings(interp, Jim_GetResult(interp), "\nUse \"", Jim_String(argv[0]),
18669 " -help\" for help", NULL);
18670 return JIM_ERR;
18671 }
18672
18673
18674 return -1;
18675 }
18676
18677 #include <ctype.h>
18678 #include <stdlib.h>
18679 #include <string.h>
18680 #include <stdio.h>
18681 #include <assert.h>
@@ -20347,10 +20369,128 @@
20347 {
20348 free(preg->program);
20349 }
20350
20351 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20352 #ifndef JIM_BOOTSTRAP_LIB_ONLY
20353 #include <errno.h>
20354 #include <string.h>
20355
20356 #ifdef USE_LINENOISE
20357
--- autosetup/jimsh0.c
+++ autosetup/jimsh0.c
@@ -16,24 +16,99 @@
16 #define jim_ext_exec
17 #define jim_ext_clock
18 #define jim_ext_array
19 #define jim_ext_stdlib
20 #define jim_ext_tclcompat
21 #if defined(_MSC_VER)
22 #define TCL_PLATFORM_OS "windows"
23 #define TCL_PLATFORM_PLATFORM "windows"
24 #define TCL_PLATFORM_PATH_SEPARATOR ";"
25 #define HAVE_MKDIR_ONE_ARG
26 #define HAVE_SYSTEM
27 #elif defined(__MINGW32__)
28 #define TCL_PLATFORM_OS "mingw"
29 #define TCL_PLATFORM_PLATFORM "windows"
30 #define TCL_PLATFORM_PATH_SEPARATOR ";"
31 #define HAVE_MKDIR_ONE_ARG
32 #define HAVE_SYSTEM
33 #define HAVE_SYS_TIME_H
34 #define HAVE_DIRENT_H
35 #define HAVE_UNISTD_H
36 #else
37 #define TCL_PLATFORM_OS "unknown"
38 #define TCL_PLATFORM_PLATFORM "unix"
39 #define TCL_PLATFORM_PATH_SEPARATOR ":"
40 #define HAVE_VFORK
41 #define HAVE_WAITPID
42 #define HAVE_SYS_TIME_H
43 #define HAVE_DIRENT_H
44 #define HAVE_UNISTD_H
45 #endif
46 #ifndef JIM_WIN32COMPAT_H
47 #define JIM_WIN32COMPAT_H
48
49
50
51
52 #if defined(_WIN32) || defined(WIN32)
53
54 #define HAVE_DLOPEN
55 void *dlopen(const char *path, int mode);
56 int dlclose(void *handle);
57 void *dlsym(void *handle, const char *symbol);
58 char *dlerror(void);
59
60 #ifdef _MSC_VER
61
62
63 #if _MSC_VER >= 1000
64 #pragma warning(disable:4146)
65 #endif
66
67 #include <limits.h>
68 #define jim_wide _int64
69 #ifndef LLONG_MAX
70 #define LLONG_MAX 9223372036854775807I64
71 #endif
72 #ifndef LLONG_MIN
73 #define LLONG_MIN (-LLONG_MAX - 1I64)
74 #endif
75 #define JIM_WIDE_MIN LLONG_MIN
76 #define JIM_WIDE_MAX LLONG_MAX
77 #define JIM_WIDE_MODIFIER "I64d"
78 #define strcasecmp _stricmp
79 #define strtoull _strtoui64
80 #define snprintf _snprintf
81
82 #include <io.h>
83
84 struct timeval {
85 long tv_sec;
86 long tv_usec;
87 };
88
89 int gettimeofday(struct timeval *tv, void *unused);
90
91 #define HAVE_OPENDIR
92 struct dirent {
93 char *d_name;
94 };
95
96 typedef struct DIR {
97 long handle;
98 struct _finddata_t info;
99 struct dirent result;
100 char *name;
101 } DIR;
102
103 DIR *opendir(const char *name);
104 int closedir(DIR *dir);
105 struct dirent *readdir(DIR *dir);
106 #endif
107
108 #endif
109
110 #endif
111 #ifndef UTF8_UTIL_H
112 #define UTF8_UTIL_H
113
114 int utf8_fromunicode(char *p, unsigned short uc);
@@ -102,11 +177,11 @@
177 #endif
178
179 #define UCHAR(c) ((unsigned char)(c))
180
181
182 #define JIM_VERSION 73
183
184 #define JIM_OK 0
185 #define JIM_ERR 1
186 #define JIM_RETURN 2
187 #define JIM_BREAK 3
@@ -816,24 +891,20 @@
891 const char *cmd;
892 const char *args;
893 tclmod_cmd_function *function;
894 short minargs;
895 short maxargs;
896 unsigned short flags;
 
897 } jim_subcmd_type;
898
899 const jim_subcmd_type *
900 Jim_ParseSubCmd(Jim_Interp *interp, const jim_subcmd_type *command_table, int argc, Jim_Obj *const *argv);
901
902 int Jim_SubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
903
904 int Jim_CallSubCmd(Jim_Interp *interp, const jim_subcmd_type *ct, int argc, Jim_Obj *const *argv);
905
 
 
 
906 #ifdef __cplusplus
907 }
908 #endif
909
910 #endif
@@ -1221,11 +1292,11 @@
1292 " if {[info exists ::jim_argv0]} {\n"
1293 " if {[string match \"*/*\" $::jim_argv0]} {\n"
1294 " return [file join [pwd] $::jim_argv0]\n"
1295 " }\n"
1296 " foreach path [split [env PATH \"\"] $::tcl_platform(pathSeparator)] {\n"
1297 " set exec [file join [pwd] [string map {\\\\ /} $path] $::jim_argv0]\n"
1298 " if {[file executable $exec]} {\n"
1299 " return $exec\n"
1300 " }\n"
1301 " }\n"
1302 " }\n"
@@ -1555,11 +1626,10 @@
1626 "}\n"
1627 );
1628 }
1629
1630
 
1631 #include <stdio.h>
1632 #include <string.h>
1633 #include <errno.h>
1634 #include <fcntl.h>
1635
@@ -1567,10 +1637,11 @@
1637 #if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_SELECT) && defined(HAVE_NETINET_IN_H) && defined(HAVE_NETDB_H) && defined(HAVE_ARPA_INET_H)
1638 #include <sys/socket.h>
1639 #include <netinet/in.h>
1640 #include <arpa/inet.h>
1641 #include <netdb.h>
1642 #include <unistd.h>
1643 #ifdef HAVE_SYS_UN_H
1644 #include <sys/un.h>
1645 #endif
1646 #else
1647 #define JIM_ANSIC
@@ -1627,15 +1698,16 @@
1698 {
1699 AioFile *af = privData;
1700
1701 JIM_NOTUSED(interp);
1702
 
 
1703 if (!(af->OpenFlags & AIO_KEEPOPEN)) {
1704 fclose(af->fp);
1705 }
1706
1707 Jim_DecrRefCount(interp, af->filename);
1708
1709 #ifdef jim_ext_eventloop
1710
1711 if (af->rEvent) {
1712 Jim_DeleteFileHandler(interp, af->fp);
1713 }
@@ -2052,106 +2124,121 @@
2124 return aio_eventinfo(interp, af, JIM_EVENT_EXCEPTION, &af->wEvent, argc, argv);
2125 }
2126 #endif
2127
2128 static const jim_subcmd_type aio_command_table[] = {
2129 { "read",
2130 "?-nonewline? ?len?",
2131 aio_cmd_read,
2132 0,
2133 2,
2134
2135 },
2136 { "copyto",
2137 "handle ?size?",
2138 aio_cmd_copy,
2139 1,
2140 2,
2141
2142 },
2143 { "gets",
2144 "?var?",
2145 aio_cmd_gets,
2146 0,
2147 1,
2148
2149 },
2150 { "puts",
2151 "?-nonewline? str",
2152 aio_cmd_puts,
2153 1,
2154 2,
2155
2156 },
2157 { "flush",
2158 NULL,
2159 aio_cmd_flush,
2160 0,
2161 0,
2162
2163 },
2164 { "eof",
2165 NULL,
2166 aio_cmd_eof,
2167 0,
2168 0,
2169
2170 },
2171 { "close",
2172 NULL,
2173 aio_cmd_close,
2174 0,
2175 0,
2176 JIM_MODFLAG_FULLARGV,
2177
2178 },
2179 { "seek",
2180 "offset ?start|current|end",
2181 aio_cmd_seek,
2182 1,
2183 2,
2184
2185 },
2186 { "tell",
2187 NULL,
2188 aio_cmd_tell,
2189 0,
2190 0,
2191
2192 },
2193 { "filename",
2194 NULL,
2195 aio_cmd_filename,
2196 0,
2197 0,
2198
2199 },
2200 #ifdef O_NDELAY
2201 { "ndelay",
2202 "?0|1?",
2203 aio_cmd_ndelay,
2204 0,
2205 1,
2206
2207 },
2208 #endif
2209 { "buffering",
2210 "none|line|full",
2211 aio_cmd_buffering,
2212 1,
2213 1,
2214
2215 },
2216 #ifdef jim_ext_eventloop
2217 { "readable",
2218 "?readable-script?",
2219 aio_cmd_readable,
2220 0,
2221 1,
2222
2223 },
2224 { "writable",
2225 "?writable-script?",
2226 aio_cmd_writable,
2227 0,
2228 1,
2229
2230 },
2231 { "onexception",
2232 "?exception-script?",
2233 aio_cmd_onexception,
2234 0,
2235 1,
2236
2237 },
2238 #endif
2239 { NULL }
2240 };
2241
2242 static int JimAioSubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
2243 {
2244 return Jim_CallSubCmd(interp, Jim_ParseSubCmd(interp, aio_command_table, argc, argv), argc, argv);
@@ -2158,60 +2245,46 @@
2245 }
2246
2247 static int JimAioOpenCommand(Jim_Interp *interp, int argc,
2248 Jim_Obj *const *argv)
2249 {
 
 
2250 const char *mode;
2251 const char *filename;
2252
2253 if (argc != 2 && argc != 3) {
2254 Jim_WrongNumArgs(interp, 1, argv, "filename ?mode?");
2255 return JIM_ERR;
2256 }
2257
2258 mode = (argc == 3) ? Jim_String(argv[2]) : "r";
2259 filename = Jim_String(argv[1]);
 
 
 
 
 
 
 
 
 
 
 
 
2260
2261 #ifdef jim_ext_tclcompat
2262
2263 if (*filename == '|') {
2264 Jim_Obj *evalObj[3];
2265
2266 evalObj[0] = Jim_NewStringObj(interp, "popen", -1);
2267 evalObj[1] = Jim_NewStringObj(interp, filename + 1, -1);
2268 evalObj[2] = Jim_NewStringObj(interp, mode, -1);
2269
2270 return Jim_EvalObjVector(interp, 3, evalObj);
2271 }
2272 #endif
2273 return JimMakeChannel(interp, NULL, -1, argv[1], "aio.handle%ld", 0, mode);
 
 
 
 
 
2274 }
2275
2276 static int JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filename,
2277 const char *hdlfmt, int family, const char *mode)
2278 {
2279 AioFile *af;
2280 char buf[AIO_CMD_LEN];
2281 int OpenFlags = 0;
2282
2283 if (filename == NULL) {
2284 filename = Jim_NewStringObj(interp, hdlfmt, -1);
2285 }
2286
2287 Jim_IncrRefCount(filename);
2288
2289 if (fh == NULL) {
2290 if (fd < 0) {
@@ -2225,11 +2298,13 @@
2298 OpenFlags = AIO_KEEPOPEN;
2299 }
2300
2301 if (fh == NULL) {
2302 JimAioSetError(interp, filename);
2303 if (fd >= 0) {
2304 close(fd);
2305 }
2306 Jim_DecrRefCount(interp, filename);
2307 return JIM_ERR;
2308 }
2309
2310
@@ -2239,13 +2314,13 @@
2314 af->fd = fileno(fh);
2315 af->filename = filename;
2316 #ifdef FD_CLOEXEC
2317 if ((OpenFlags & AIO_KEEPOPEN) == 0) {
2318 fcntl(af->fd, F_SETFD, FD_CLOEXEC);
 
2319 }
2320 #endif
2321 af->OpenFlags = OpenFlags;
2322 #ifdef O_NDELAY
2323 af->flags = fcntl(af->fd, F_GETFL);
2324 #endif
2325 af->addr_family = family;
2326 snprintf(buf, sizeof(buf), hdlfmt, Jim_GetId(interp));
@@ -2277,21 +2352,26 @@
2352 #ifndef JIM_ANSIC
2353 Jim_CreateCommand(interp, "socket", JimAioSockCommand, NULL, NULL);
2354 #endif
2355
2356
2357 JimMakeChannel(interp, stdin, -1, NULL, "stdin", 0, "r");
2358 JimMakeChannel(interp, stdout, -1, NULL, "stdout", 0, "w");
2359 JimMakeChannel(interp, stderr, -1, NULL, "stderr", 0, "w");
2360
2361 return JIM_OK;
2362 }
2363
2364
2365 #include <errno.h>
2366 #include <stdio.h>
2367 #include <string.h>
2368
2369
2370 #ifdef HAVE_DIRENT_H
2371 #include <dirent.h>
2372 #endif
2373
2374 int Jim_ReaddirCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
2375 {
2376 const char *dirPath;
2377 DIR *dirPtr;
@@ -2834,16 +2914,27 @@
2914
2915 #include <limits.h>
2916 #include <stdlib.h>
2917 #include <string.h>
2918 #include <stdio.h>
 
2919 #include <errno.h>
2920 #include <sys/stat.h>
2921
2922
2923 #ifdef HAVE_UTIMES
2924 #include <sys/time.h>
2925 #endif
2926 #ifdef HAVE_UNISTD_H
2927 #include <unistd.h>
2928 #elif defined(_MSC_VER)
2929 #include <direct.h>
2930 #define F_OK 0
2931 #define W_OK 2
2932 #define R_OK 4
2933 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
2934 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
2935 #endif
2936
2937 # ifndef MAXPATHLEN
2938 # define MAXPATHLEN JIM_PATH_LEN
2939 # endif
2940
@@ -2854,29 +2945,35 @@
2945 return "file";
2946 }
2947 else if (S_ISDIR(mode)) {
2948 return "directory";
2949 }
2950 #ifdef S_ISCHR
2951 else if (S_ISCHR(mode)) {
2952 return "characterSpecial";
2953 }
2954 #endif
2955 #ifdef S_ISBLK
2956 else if (S_ISBLK(mode)) {
2957 return "blockSpecial";
2958 }
2959 #endif
2960 #ifdef S_ISFIFO
2961 else if (S_ISFIFO(mode)) {
2962 return "fifo";
2963 }
2964 #endif
2965 #ifdef S_ISLNK
 
2966 else if (S_ISLNK(mode)) {
2967 return "link";
2968 }
2969 #endif
2970 #ifdef S_ISSOCK
 
2971 else if (S_ISSOCK(mode)) {
2972 return "socket";
2973 }
2974 #endif
 
2975 return "unknown";
2976 }
2977
2978
2979 static int set_array_int_value(Jim_Interp *interp, Jim_Obj *container, const char *key,
@@ -2939,11 +3036,11 @@
3036 Jim_SetResultString(interp, ".", -1);
3037 }
3038 else if (p == path) {
3039 Jim_SetResultString(interp, "/", -1);
3040 }
3041 #if defined(__MINGW32__) || defined(_MSC_VER)
3042 else if (p[-1] == ':') {
3043
3044 Jim_SetResultString(interp, path, p - path + 1);
3045 }
3046 #endif
@@ -3030,11 +3127,11 @@
3127
3128 if (*part == '/') {
3129
3130 last = newname;
3131 }
3132 #if defined(__MINGW32__) || defined(_MSC_VER)
3133 else if (strchr(part, ':')) {
3134
3135 last = newname;
3136 }
3137 #endif
@@ -3099,11 +3196,16 @@
3196 return file_access(interp, argv[0], W_OK);
3197 }
3198
3199 static int file_cmd_executable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
3200 {
3201 #ifdef X_OK
3202 return file_access(interp, argv[0], X_OK);
3203 #else
3204 Jim_SetResultBool(interp, 1);
3205 return JIM_OK;
3206 #endif
3207 }
3208
3209 static int file_cmd_exists(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
3210 {
3211 return file_access(interp, argv[0], F_OK);
@@ -3430,193 +3532,193 @@
3532 }
3533 return StoreStatData(interp, argv[1], &sb);
3534 }
3535
3536 static const jim_subcmd_type file_command_table[] = {
3537 { "atime",
3538 "name",
3539 file_cmd_atime,
3540 1,
3541 1,
3542
3543 },
3544 { "mtime",
3545 "name ?time?",
3546 file_cmd_mtime,
3547 1,
3548 2,
3549
3550 },
3551 { "copy",
3552 "?-force? source dest",
3553 file_cmd_copy,
3554 2,
3555 3,
3556
3557 },
3558 { "dirname",
3559 "name",
3560 file_cmd_dirname,
3561 1,
3562 1,
3563
3564 },
3565 { "rootname",
3566 "name",
3567 file_cmd_rootname,
3568 1,
3569 1,
3570
3571 },
3572 { "extension",
3573 "name",
3574 file_cmd_extension,
3575 1,
3576 1,
3577
3578 },
3579 { "tail",
3580 "name",
3581 file_cmd_tail,
3582 1,
3583 1,
3584
3585 },
3586 { "normalize",
3587 "name",
3588 file_cmd_normalize,
3589 1,
3590 1,
3591
3592 },
3593 { "join",
3594 "name ?name ...?",
3595 file_cmd_join,
3596 1,
3597 -1,
3598
3599 },
3600 { "readable",
3601 "name",
3602 file_cmd_readable,
3603 1,
3604 1,
3605
3606 },
3607 { "writable",
3608 "name",
3609 file_cmd_writable,
3610 1,
3611 1,
3612
3613 },
3614 { "executable",
3615 "name",
3616 file_cmd_executable,
3617 1,
3618 1,
3619
3620 },
3621 { "exists",
3622 "name",
3623 file_cmd_exists,
3624 1,
3625 1,
3626
3627 },
3628 { "delete",
3629 "?-force|--? name ...",
3630 file_cmd_delete,
3631 1,
3632 -1,
3633
3634 },
3635 { "mkdir",
3636 "dir ...",
3637 file_cmd_mkdir,
3638 1,
3639 -1,
3640
3641 },
3642 #ifdef HAVE_MKSTEMP
3643 { "tempfile",
3644 "?template?",
3645 file_cmd_tempfile,
3646 0,
3647 1,
3648
3649 },
3650 #endif
3651 { "rename",
3652 "?-force? source dest",
3653 file_cmd_rename,
3654 2,
3655 3,
3656
3657 },
3658 #if defined(HAVE_READLINK)
3659 { "readlink",
3660 "name",
3661 file_cmd_readlink,
3662 1,
3663 1,
3664
3665 },
3666 #endif
3667 { "size",
3668 "name",
3669 file_cmd_size,
3670 1,
3671 1,
3672
3673 },
3674 { "stat",
3675 "name var",
3676 file_cmd_stat,
3677 2,
3678 2,
3679
3680 },
3681 { "lstat",
3682 "name var",
3683 file_cmd_lstat,
3684 2,
3685 2,
3686
3687 },
3688 { "type",
3689 "name",
3690 file_cmd_type,
3691 1,
3692 1,
3693
3694 },
3695 #ifdef HAVE_GETEUID
3696 { "owned",
3697 "name",
3698 file_cmd_owned,
3699 1,
3700 1,
3701
3702 },
3703 #endif
3704 { "isdirectory",
3705 "name",
3706 file_cmd_isdirectory,
3707 1,
3708 1,
3709
3710 },
3711 { "isfile",
3712 "name",
3713 file_cmd_isfile,
3714 1,
3715 1,
3716
3717 },
3718 {
3719 NULL
3720 }
3721 };
3722
3723 static int Jim_CdCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
3724 {
@@ -3644,11 +3746,11 @@
3746
3747 if (getcwd(cwd, cwd_len) == NULL) {
3748 Jim_SetResultString(interp, "Failed to get pwd", -1);
3749 return JIM_ERR;
3750 }
3751 #if defined(__MINGW32__) || defined(_MSC_VER)
3752 {
3753
3754 char *p = cwd;
3755 while ((p = strchr(p, '\\')) != NULL) {
3756 *p++ = '/';
@@ -3734,14 +3836,17 @@
3836
3837
3838 #include <errno.h>
3839 #include <signal.h>
3840
 
 
3841 #if defined(__MINGW32__)
3842
3843 #ifndef STRICT
3844 #define STRICT
3845 #endif
3846 #define WIN32_LEAN_AND_MEAN
3847 #include <windows.h>
3848 #include <fcntl.h>
3849
3850 typedef HANDLE fdtype;
3851 typedef HANDLE pidtype;
3852 #define JIM_BAD_FD INVALID_HANDLE_VALUE
@@ -5022,12 +5127,15 @@
5127
5128 #include <stdlib.h>
5129 #include <string.h>
5130 #include <stdio.h>
5131 #include <time.h>
5132
5133
5134 #ifdef HAVE_SYS_TIME_H
5135 #include <sys/time.h>
5136 #endif
5137
5138 static int clock_cmd_format(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
5139 {
5140
5141 char buf[100];
@@ -5111,51 +5219,55 @@
5219
5220 return JIM_OK;
5221 }
5222
5223 static const jim_subcmd_type clock_command_table[] = {
5224 { "seconds",
5225 NULL,
5226 clock_cmd_seconds,
5227 0,
5228 0,
5229
5230 },
5231 { "clicks",
5232 NULL,
5233 clock_cmd_micros,
5234 0,
5235 0,
5236
5237 },
5238 { "microseconds",
5239 NULL,
5240 clock_cmd_micros,
5241 0,
5242 0,
5243
5244 },
5245 { "milliseconds",
5246 NULL,
5247 clock_cmd_millis,
5248 0,
5249 0,
5250
5251 },
5252 { "format",
5253 "seconds ?-format format?",
5254 clock_cmd_format,
5255 1,
5256 3,
5257
5258 },
5259 #ifdef HAVE_STRPTIME
5260 { "scan",
5261 "str -format format",
5262 clock_cmd_scan,
5263 3,
5264 3,
5265
5266 },
5267 #endif
5268 { NULL }
5269 };
5270
5271 int Jim_clockInit(Jim_Interp *interp)
5272 {
5273 if (Jim_PackageProvide(interp, "clock", "1.0", JIM_ERRMSG))
@@ -5168,11 +5280,10 @@
5280
5281 #include <limits.h>
5282 #include <stdlib.h>
5283 #include <string.h>
5284 #include <stdio.h>
 
5285 #include <errno.h>
5286
5287
5288 static int array_cmd_exists(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
5289 {
@@ -5335,53 +5446,53 @@
5446
5447 return rc;
5448 }
5449
5450 static const jim_subcmd_type array_command_table[] = {
5451 { "exists",
5452 "arrayName",
5453 array_cmd_exists,
5454 1,
5455 1,
5456
5457 },
5458 { "get",
5459 "arrayName ?pattern?",
5460 array_cmd_get,
5461 1,
5462 2,
5463
5464 },
5465 { "names",
5466 "arrayName ?pattern?",
5467 array_cmd_names,
5468 1,
5469 2,
5470
5471 },
5472 { "set",
5473 "arrayName list",
5474 array_cmd_set,
5475 2,
5476 2,
5477
5478 },
5479 { "size",
5480 "arrayName",
5481 array_cmd_size,
5482 1,
5483 1,
5484
5485 },
5486 { "unset",
5487 "arrayName ?pattern?",
5488 array_cmd_unset,
5489 1,
5490 2,
5491
5492 },
5493 { NULL
5494 }
5495 };
5496
5497 int Jim_arrayInit(Jim_Interp *interp)
5498 {
@@ -5430,14 +5541,14 @@
5541 #include <assert.h>
5542 #include <errno.h>
5543 #include <time.h>
5544 #include <setjmp.h>
5545
5546
5547 #ifdef HAVE_SYS_TIME_H
5548 #include <sys/time.h>
5549 #endif
 
5550 #ifdef HAVE_BACKTRACE
5551 #include <execinfo.h>
5552 #endif
5553 #ifdef HAVE_CRT_EXTERNS_H
5554 #include <crt_externs.h>
@@ -11387,18 +11498,18 @@
11498 }
11499
11500
11501
11502 static const char * const jimReturnCodes[] = {
11503 "ok",
11504 "error",
11505 "return",
11506 "break",
11507 "continue",
11508 "signal",
11509 "exit",
11510 "eval",
11511 NULL
11512 };
11513
11514 #define jimReturnCodesSize (sizeof(jimReturnCodes)/sizeof(*jimReturnCodes))
11515
@@ -11458,11 +11569,11 @@
11569
11570 enum
11571 {
11572
11573
11574 JIM_EXPROP_MUL = JIM_TT_EXPR_OP,
11575 JIM_EXPROP_DIV,
11576 JIM_EXPROP_MOD,
11577 JIM_EXPROP_SUB,
11578 JIM_EXPROP_ADD,
11579 JIM_EXPROP_LSHIFT,
@@ -11501,32 +11612,32 @@
11612 JIM_EXPROP_COLON_RIGHT,
11613
11614 JIM_EXPROP_POW,
11615
11616
11617 JIM_EXPROP_STREQ,
11618 JIM_EXPROP_STRNE,
11619 JIM_EXPROP_STRIN,
11620 JIM_EXPROP_STRNI,
11621
11622
11623 JIM_EXPROP_NOT,
11624 JIM_EXPROP_BITNOT,
11625 JIM_EXPROP_UNARYMINUS,
11626 JIM_EXPROP_UNARYPLUS,
11627
11628
11629 JIM_EXPROP_FUNC_FIRST,
11630 JIM_EXPROP_FUNC_INT = JIM_EXPROP_FUNC_FIRST,
11631 JIM_EXPROP_FUNC_ABS,
11632 JIM_EXPROP_FUNC_DOUBLE,
11633 JIM_EXPROP_FUNC_ROUND,
11634 JIM_EXPROP_FUNC_RAND,
11635 JIM_EXPROP_FUNC_SRAND,
11636
11637
11638 JIM_EXPROP_FUNC_SIN,
11639 JIM_EXPROP_FUNC_COS,
11640 JIM_EXPROP_FUNC_TAN,
11641 JIM_EXPROP_FUNC_ASIN,
11642 JIM_EXPROP_FUNC_ACOS,
11643 JIM_EXPROP_FUNC_ATAN,
@@ -12237,90 +12348,92 @@
12348 LAZY_OP,
12349 LAZY_LEFT,
12350 LAZY_RIGHT
12351 };
12352
 
12353 static const struct Jim_ExprOperator Jim_ExprOperators[] = {
12354 {"*", 200, 2, JimExprOpBin, LAZY_NONE},
12355 {"/", 200, 2, JimExprOpBin, LAZY_NONE},
12356 {"%", 200, 2, JimExprOpIntBin, LAZY_NONE},
12357
12358 {"-", 100, 2, JimExprOpBin, LAZY_NONE},
12359 {"+", 100, 2, JimExprOpBin, LAZY_NONE},
12360
12361 {"<<", 90, 2, JimExprOpIntBin, LAZY_NONE},
12362 {">>", 90, 2, JimExprOpIntBin, LAZY_NONE},
12363
12364 {"<<<", 90, 2, JimExprOpIntBin, LAZY_NONE},
12365 {">>>", 90, 2, JimExprOpIntBin, LAZY_NONE},
12366
12367 {"<", 80, 2, JimExprOpBin, LAZY_NONE},
12368 {">", 80, 2, JimExprOpBin, LAZY_NONE},
12369 {"<=", 80, 2, JimExprOpBin, LAZY_NONE},
12370 {">=", 80, 2, JimExprOpBin, LAZY_NONE},
12371
12372 {"==", 70, 2, JimExprOpBin, LAZY_NONE},
12373 {"!=", 70, 2, JimExprOpBin, LAZY_NONE},
12374
12375 {"&", 50, 2, JimExprOpIntBin, LAZY_NONE},
12376 {"^", 49, 2, JimExprOpIntBin, LAZY_NONE},
12377 {"|", 48, 2, JimExprOpIntBin, LAZY_NONE},
12378
12379 {"&&", 10, 2, NULL, LAZY_OP},
12380 {NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT},
12381 {NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT},
12382
12383 {"||", 9, 2, NULL, LAZY_OP},
12384 {NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT},
12385 {NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT},
12386
12387 {"?", 5, 2, JimExprOpNull, LAZY_OP},
12388 {NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT},
12389 {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT},
12390
12391 {":", 5, 2, JimExprOpNull, LAZY_OP},
12392 {NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT},
12393 {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT},
12394
12395 {"**", 250, 2, JimExprOpBin, LAZY_NONE},
12396
12397 {"eq", 60, 2, JimExprOpStrBin, LAZY_NONE},
12398 {"ne", 60, 2, JimExprOpStrBin, LAZY_NONE},
12399
12400 {"in", 55, 2, JimExprOpStrBin, LAZY_NONE},
12401 {"ni", 55, 2, JimExprOpStrBin, LAZY_NONE},
12402
12403 {"!", 300, 1, JimExprOpNumUnary, LAZY_NONE},
12404 {"~", 300, 1, JimExprOpIntUnary, LAZY_NONE},
12405 {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE},
12406 {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE},
12407
12408
12409
12410 {"int", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12411 {"abs", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12412 {"double", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12413 {"round", 400, 1, JimExprOpNumUnary, LAZY_NONE},
12414 {"rand", 400, 0, JimExprOpNone, LAZY_NONE},
12415 {"srand", 400, 1, JimExprOpIntUnary, LAZY_NONE},
12416
12417 #ifdef JIM_MATH_FUNCTIONS
12418 {"sin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12419 {"cos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12420 {"tan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12421 {"asin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12422 {"acos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12423 {"atan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12424 {"sinh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12425 {"cosh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12426 {"tanh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12427 {"ceil", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12428 {"floor", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12429 {"exp", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12430 {"log", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12431 {"log10", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12432 {"sqrt", 400, 1, JimExprOpDoubleUnary, LAZY_NONE},
12433 {"pow", 400, 2, JimExprOpBin, LAZY_NONE},
12434 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12435 };
12436
12437 #define JIM_EXPR_OPERATORS_NUM \
12438 (sizeof(Jim_ExprOperators)/sizeof(struct Jim_ExprOperator))
12439
@@ -12461,11 +12574,11 @@
12574 {
12575 int i;
12576 int bestIdx = -1, bestLen = 0;
12577
12578
12579 for (i = 0; i < (signed)JIM_EXPR_OPERATORS_NUM; i++) {
12580 const char *opname;
12581 int oplen;
12582
12583 opname = Jim_ExprOperators[i].name;
12584 if (opname == NULL) {
@@ -12472,11 +12585,11 @@
12585 continue;
12586 }
12587 oplen = strlen(opname);
12588
12589 if (strncmp(opname, pc->p, oplen) == 0 && oplen > bestLen) {
12590 bestIdx = i + JIM_TT_EXPR_OP;
12591 bestLen = oplen;
12592 }
12593 }
12594 if (bestIdx == -1) {
12595 return JIM_ERR;
@@ -12505,11 +12618,15 @@
12618 return JIM_OK;
12619 }
12620
12621 static const struct Jim_ExprOperator *JimExprOperatorInfoByOpcode(int opcode)
12622 {
12623 static Jim_ExprOperator dummy_op;
12624 if (opcode < JIM_TT_EXPR_OP) {
12625 return &dummy_op;
12626 }
12627 return &Jim_ExprOperators[opcode - JIM_TT_EXPR_OP];
12628 }
12629
12630 const char *jim_tt_name(int type)
12631 {
12632 static const char * const tt_names[JIM_TT_EXPR_OP] =
@@ -12520,11 +12637,11 @@
12637 }
12638 else {
12639 const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(type);
12640 static char buf[20];
12641
12642 if (op->name) {
12643 return op->name;
12644 }
12645 sprintf(buf, "(%d)", type);
12646 return buf;
12647 }
@@ -12592,21 +12709,19 @@
12709
12710 for (i = 0; i < expr->len; i++) {
12711 ScriptToken *t = &expr->token[i];
12712 const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(t->type);
12713
12714 stacklen -= op->arity;
12715 if (stacklen < 0) {
12716 break;
12717 }
12718 if (t->type == JIM_EXPROP_TERNARY || t->type == JIM_EXPROP_TERNARY_LEFT) {
12719 ternary++;
12720 }
12721 else if (t->type == JIM_EXPROP_COLON || t->type == JIM_EXPROP_COLON_LEFT) {
12722 ternary--;
 
 
12723 }
12724
12725
12726 stacklen++;
12727 }
@@ -12656,11 +12771,12 @@
12771 expr->token[expr->len].type = t->type + 2;
12772 expr->len++;
12773
12774
12775 for (i = leftindex - 1; i > 0; i--) {
12776 const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(expr->token[i].type);
12777 if (op->lazy == LAZY_LEFT) {
12778 if (JimWideValue(expr->token[i - 1].objPtr) + i - 1 >= leftindex) {
12779 JimWideValue(expr->token[i - 1].objPtr) += 2;
12780 }
12781 }
12782 }
@@ -12783,12 +12899,13 @@
12899
12900 Jim_InitStack(&stack);
12901
12902 for (i = 0; i < tokenlist->count; i++) {
12903 ParseToken *t = &tokenlist->list[i];
12904 const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(t->type);
12905
12906 if (op->lazy == LAZY_OP) {
12907 count += 2;
12908
12909 if (t->type == JIM_EXPROP_TERNARY) {
12910 have_ternary = 1;
12911 }
@@ -17349,14 +17466,12 @@
17466 return JIM_ERR;
17467 }
17468 objPtr = Jim_NewDictObj(interp, argv + 2, argc - 2);
17469 Jim_SetResult(interp, objPtr);
17470 return JIM_OK;
 
 
 
17471 }
17472 return JIM_ERR;
17473 }
17474
17475
17476 static int Jim_SubstCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
17477 {
@@ -18397,13 +18512,11 @@
18512
18513 return JIM_OK;
18514 }
18515
18516 static const jim_subcmd_type dummy_subcmd = {
18517 "dummy", NULL, subcmd_null, 0, 0, JIM_MODFLAG_HIDDEN
 
 
18518 };
18519
18520 static void add_commands(Jim_Interp *interp, const jim_subcmd_type * ct, const char *sep)
18521 {
18522 const char *s = "";
@@ -18443,26 +18556,10 @@
18556 if (ct->args && *ct->args) {
18557 Jim_AppendStrings(interp, Jim_GetResult(interp), " ", ct->args, NULL);
18558 }
18559 }
18560
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18561 static void set_wrong_args(Jim_Interp *interp, const jim_subcmd_type * command_table, Jim_Obj *subcmd)
18562 {
18563 Jim_SetResultString(interp, "wrong # args: must be \"", -1);
18564 add_cmd_usage(interp, command_table, subcmd);
18565 Jim_AppendStrings(interp, Jim_GetResult(interp), "\"", NULL);
@@ -18483,23 +18580,16 @@
18580
18581 if (argc < 2) {
18582 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
18583 Jim_AppendStrings(interp, Jim_GetResult(interp), "wrong # args: should be \"", cmdname,
18584 " command ...\"\n", NULL);
18585 Jim_AppendStrings(interp, Jim_GetResult(interp), "Use \"", cmdname, " -help ?command?\" for help", NULL);
 
18586 return 0;
18587 }
18588
18589 cmd = argv[1];
18590
 
 
 
 
 
 
18591
18592 if (Jim_CompareStringImmediate(interp, cmd, "-help")) {
18593 if (argc == 2) {
18594
18595 show_cmd_usage(interp, command_table, argc, argv);
@@ -18560,13 +18650,10 @@
18650
18651 if (help) {
18652 Jim_SetResultString(interp, "Usage: ", -1);
18653
18654 add_cmd_usage(interp, ct, argv[0]);
 
 
 
18655 return &dummy_subcmd;
18656 }
18657
18658
18659 if (argc - 2 < ct->minargs || (ct->maxargs >= 0 && argc - 2 > ct->maxargs)) {
@@ -18607,75 +18694,10 @@
18694 Jim_ParseSubCmd(interp, (const jim_subcmd_type *)Jim_CmdPrivData(interp), argc, argv);
18695
18696 return Jim_CallSubCmd(interp, ct, argc, argv);
18697 }
18698
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18699 #include <ctype.h>
18700 #include <stdlib.h>
18701 #include <string.h>
18702 #include <stdio.h>
18703 #include <assert.h>
@@ -20347,10 +20369,128 @@
20369 {
20370 free(preg->program);
20371 }
20372
20373 #endif
20374
20375 #if defined(_WIN32) || defined(WIN32)
20376 #ifndef STRICT
20377 #define STRICT
20378 #endif
20379 #define WIN32_LEAN_AND_MEAN
20380 #include <windows.h>
20381
20382 #if defined(HAVE_DLOPEN_COMPAT)
20383 void *dlopen(const char *path, int mode)
20384 {
20385 JIM_NOTUSED(mode);
20386
20387 return (void *)LoadLibraryA(path);
20388 }
20389
20390 int dlclose(void *handle)
20391 {
20392 FreeLibrary((HANDLE)handle);
20393 return 0;
20394 }
20395
20396 void *dlsym(void *handle, const char *symbol)
20397 {
20398 return GetProcAddress((HMODULE)handle, symbol);
20399 }
20400
20401 char *dlerror(void)
20402 {
20403 static char msg[121];
20404 FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
20405 LANG_NEUTRAL, msg, sizeof(msg) - 1, NULL);
20406 return msg;
20407 }
20408 #endif
20409
20410 #ifdef _MSC_VER
20411
20412 #include <sys/timeb.h>
20413
20414
20415 int gettimeofday(struct timeval *tv, void *unused)
20416 {
20417 struct _timeb tb;
20418
20419 _ftime(&tb);
20420 tv->tv_sec = tb.time;
20421 tv->tv_usec = tb.millitm * 1000;
20422
20423 return 0;
20424 }
20425
20426
20427 DIR *opendir(const char *name)
20428 {
20429 DIR *dir = 0;
20430
20431 if (name && name[0]) {
20432 size_t base_length = strlen(name);
20433 const char *all =
20434 strchr("/\\", name[base_length - 1]) ? "*" : "/*";
20435
20436 if ((dir = (DIR *) Jim_Alloc(sizeof *dir)) != 0 &&
20437 (dir->name = (char *)Jim_Alloc(base_length + strlen(all) + 1)) != 0) {
20438 strcat(strcpy(dir->name, name), all);
20439
20440 if ((dir->handle = (long)_findfirst(dir->name, &dir->info)) != -1)
20441 dir->result.d_name = 0;
20442 else {
20443 Jim_Free(dir->name);
20444 Jim_Free(dir);
20445 dir = 0;
20446 }
20447 }
20448 else {
20449 Jim_Free(dir);
20450 dir = 0;
20451 errno = ENOMEM;
20452 }
20453 }
20454 else {
20455 errno = EINVAL;
20456 }
20457 return dir;
20458 }
20459
20460 int closedir(DIR * dir)
20461 {
20462 int result = -1;
20463
20464 if (dir) {
20465 if (dir->handle != -1)
20466 result = _findclose(dir->handle);
20467 Jim_Free(dir->name);
20468 Jim_Free(dir);
20469 }
20470 if (result == -1)
20471 errno = EBADF;
20472 return result;
20473 }
20474
20475 struct dirent *readdir(DIR * dir)
20476 {
20477 struct dirent *result = 0;
20478
20479 if (dir && dir->handle != -1) {
20480 if (!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) {
20481 result = &dir->result;
20482 result->d_name = dir->info.name;
20483 }
20484 }
20485 else {
20486 errno = EBADF;
20487 }
20488 return result;
20489 }
20490 #endif
20491 #endif
20492 #ifndef JIM_BOOTSTRAP_LIB_ONLY
20493 #include <errno.h>
20494 #include <string.h>
20495
20496 #ifdef USE_LINENOISE
20497
--- src/jim-win32compat.h
+++ src/jim-win32compat.h
@@ -3,13 +3,10 @@
33
44
/* Compatibility for Windows (mingw and msvc, not cygwin */
55
66
/* Note that at this point we don't yet have access to jimautoconf.h */
77
#if defined(_WIN32) || defined(WIN32)
8
-#ifndef STRICT
9
-#define STRICT
10
-#endif /* STRICT */
118
129
#define HAVE_DLOPEN
1310
void *dlopen(const char *path, int mode);
1411
int dlclose(void *handle);
1512
void *dlsym(void *handle, const char *symbol);
@@ -20,12 +17,11 @@
2017
2118
#if _MSC_VER >= 1000
2219
#pragma warning(disable:4146)
2320
#endif
2421
25
-#define strcasecmp _stricmp
26
-
22
+#include <limits.h>
2723
#define jim_wide _int64
2824
#ifndef LLONG_MAX
2925
#define LLONG_MAX 9223372036854775807I64
3026
#endif
3127
#ifndef LLONG_MIN
@@ -32,25 +28,24 @@
3228
#define LLONG_MIN (-LLONG_MAX - 1I64)
3329
#endif
3430
#define JIM_WIDE_MIN LLONG_MIN
3531
#define JIM_WIDE_MAX LLONG_MAX
3632
#define JIM_WIDE_MODIFIER "I64d"
33
+#define strcasecmp _stricmp
34
+#define strtoull _strtoui64
35
+#define snprintf _snprintf
3736
3837
#include <io.h>
3938
40
-#define HAVE_GETTIMEOFDAY
41
-#ifndef NO_TIMEVAL
4239
struct timeval {
4340
long tv_sec;
4441
long tv_usec;
4542
};
46
-#endif /* NO_TIMEVAL */
4743
4844
int gettimeofday(struct timeval *tv, void *unused);
4945
5046
#define HAVE_OPENDIR
51
-#ifndef NO_DIRENT
5247
struct dirent {
5348
char *d_name;
5449
};
5550
5651
typedef struct DIR {
@@ -61,11 +56,10 @@
6156
} DIR;
6257
6358
DIR *opendir(const char *name);
6459
int closedir(DIR *dir);
6560
struct dirent *readdir(DIR *dir);
66
-#endif /* NO_DIRENT */
6761
#endif /* _MSC_VER */
6862
6963
#endif /* WIN32 */
7064
7165
#endif
7266
--- src/jim-win32compat.h
+++ src/jim-win32compat.h
@@ -3,13 +3,10 @@
3
4 /* Compatibility for Windows (mingw and msvc, not cygwin */
5
6 /* Note that at this point we don't yet have access to jimautoconf.h */
7 #if defined(_WIN32) || defined(WIN32)
8 #ifndef STRICT
9 #define STRICT
10 #endif /* STRICT */
11
12 #define HAVE_DLOPEN
13 void *dlopen(const char *path, int mode);
14 int dlclose(void *handle);
15 void *dlsym(void *handle, const char *symbol);
@@ -20,12 +17,11 @@
20
21 #if _MSC_VER >= 1000
22 #pragma warning(disable:4146)
23 #endif
24
25 #define strcasecmp _stricmp
26
27 #define jim_wide _int64
28 #ifndef LLONG_MAX
29 #define LLONG_MAX 9223372036854775807I64
30 #endif
31 #ifndef LLONG_MIN
@@ -32,25 +28,24 @@
32 #define LLONG_MIN (-LLONG_MAX - 1I64)
33 #endif
34 #define JIM_WIDE_MIN LLONG_MIN
35 #define JIM_WIDE_MAX LLONG_MAX
36 #define JIM_WIDE_MODIFIER "I64d"
 
 
 
37
38 #include <io.h>
39
40 #define HAVE_GETTIMEOFDAY
41 #ifndef NO_TIMEVAL
42 struct timeval {
43 long tv_sec;
44 long tv_usec;
45 };
46 #endif /* NO_TIMEVAL */
47
48 int gettimeofday(struct timeval *tv, void *unused);
49
50 #define HAVE_OPENDIR
51 #ifndef NO_DIRENT
52 struct dirent {
53 char *d_name;
54 };
55
56 typedef struct DIR {
@@ -61,11 +56,10 @@
61 } DIR;
62
63 DIR *opendir(const char *name);
64 int closedir(DIR *dir);
65 struct dirent *readdir(DIR *dir);
66 #endif /* NO_DIRENT */
67 #endif /* _MSC_VER */
68
69 #endif /* WIN32 */
70
71 #endif
72
--- src/jim-win32compat.h
+++ src/jim-win32compat.h
@@ -3,13 +3,10 @@
3
4 /* Compatibility for Windows (mingw and msvc, not cygwin */
5
6 /* Note that at this point we don't yet have access to jimautoconf.h */
7 #if defined(_WIN32) || defined(WIN32)
 
 
 
8
9 #define HAVE_DLOPEN
10 void *dlopen(const char *path, int mode);
11 int dlclose(void *handle);
12 void *dlsym(void *handle, const char *symbol);
@@ -20,12 +17,11 @@
17
18 #if _MSC_VER >= 1000
19 #pragma warning(disable:4146)
20 #endif
21
22 #include <limits.h>
 
23 #define jim_wide _int64
24 #ifndef LLONG_MAX
25 #define LLONG_MAX 9223372036854775807I64
26 #endif
27 #ifndef LLONG_MIN
@@ -32,25 +28,24 @@
28 #define LLONG_MIN (-LLONG_MAX - 1I64)
29 #endif
30 #define JIM_WIDE_MIN LLONG_MIN
31 #define JIM_WIDE_MAX LLONG_MAX
32 #define JIM_WIDE_MODIFIER "I64d"
33 #define strcasecmp _stricmp
34 #define strtoull _strtoui64
35 #define snprintf _snprintf
36
37 #include <io.h>
38
 
 
39 struct timeval {
40 long tv_sec;
41 long tv_usec;
42 };
 
43
44 int gettimeofday(struct timeval *tv, void *unused);
45
46 #define HAVE_OPENDIR
 
47 struct dirent {
48 char *d_name;
49 };
50
51 typedef struct DIR {
@@ -61,11 +56,10 @@
56 } DIR;
57
58 DIR *opendir(const char *name);
59 int closedir(DIR *dir);
60 struct dirent *readdir(DIR *dir);
 
61 #endif /* _MSC_VER */
62
63 #endif /* WIN32 */
64
65 #endif
66
+1 -1
--- src/jim.h
+++ src/jim.h
@@ -126,11 +126,11 @@
126126
* ---------------------------------------------------------------------------*/
127127
128128
/* Jim version numbering: every version of jim is marked with a
129129
* successive integer number. This is version 0. The first
130130
* stable version will be 1, then 2, 3, and so on. */
131
-#define JIM_VERSION 72
131
+#define JIM_VERSION 73
132132
133133
#define JIM_OK 0
134134
#define JIM_ERR 1
135135
#define JIM_RETURN 2
136136
#define JIM_BREAK 3
137137
--- src/jim.h
+++ src/jim.h
@@ -126,11 +126,11 @@
126 * ---------------------------------------------------------------------------*/
127
128 /* Jim version numbering: every version of jim is marked with a
129 * successive integer number. This is version 0. The first
130 * stable version will be 1, then 2, 3, and so on. */
131 #define JIM_VERSION 72
132
133 #define JIM_OK 0
134 #define JIM_ERR 1
135 #define JIM_RETURN 2
136 #define JIM_BREAK 3
137
--- src/jim.h
+++ src/jim.h
@@ -126,11 +126,11 @@
126 * ---------------------------------------------------------------------------*/
127
128 /* Jim version numbering: every version of jim is marked with a
129 * successive integer number. This is version 0. The first
130 * stable version will be 1, then 2, 3, and so on. */
131 #define JIM_VERSION 73
132
133 #define JIM_OK 0
134 #define JIM_ERR 1
135 #define JIM_RETURN 2
136 #define JIM_BREAK 3
137

Keyboard Shortcuts

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