Age | Commit message (Collapse) | Author | Files | Lines |
|
This means we get -commands and usage via -help
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
This changes especially makes buffered I/O work
with non-blocking channels.
- separate read and write buffering
- support for timeout on blocking read
- read/write on same channel in event loop with buffering
- read buffer is the same across read, gets, copyto
- autoflush non-blocking writes via event loop
- copyto can now copy to any filehandle-like command
- add some copyto tests
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
A typical error message now looks like this:
t4.tcl:2: Error: syntax error in expression: "blah"
Traceback (most recent call last):
File "t4.tcl", line 14
c 1 2 3
File "t4.tcl", line 10, in c
b a c
File "t4.tcl", line 6, in b
a A14
File "t4.tcl", line 2, in a
expr blah
This is produced by stackdump (that can be replaced), called by errorInfo.
Note that now stacktraces (stacktrace, info stacktrace, $opts(-errorinfo)) include
the running command at each level in addition to proc, file, line. In order for
scripts to detect this new format, a new entry tcl_platform entry has been added:
tcl_platform(stackFormat) = 4 (to signify 4 elements per frame)
In addition, instead of building the error stack frame as the stack
is unwound in response to an error, instead the entire current stack trace
is captured by stacktrace. This means that the trace extends beyond the try/catch
right back to the initial interpreter command.
The 'stacktrace' command is now implemented in C based on the same
code that generates the error stacktrace.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Now callers to JimInvokeCommand() are expected to push and eval frame.
Then we no longer need to carry currentScriptObj, argc, argv in the interp
since these are in the current eval frame.
Note that this change simply renames some unused fields in Jim_Interp for ABI
compatibility, but these will be removed in due course.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
loop i 5 {
loop j 6 {
# This breaks out of both loops
break 2
}
}
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
If deferred commands run on shutdown as stack frames
are unwound, it is possible that a command
is deleted but a later command still has a reference to it.
So instead of trying to optimise this case by freeing immediately,
cache deleted commands and let the be freed once all stack frames
are destroyed.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
always include 'proc' even if introspection disabled
correctly set 'proc' at the eval frame level that is currently running
in the given proc. This makes it easier to produce an accurate level stacktrace
even across uplevel, etc.
Update stacktrace to use the new info frame.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Sometimes it can be useful to provide an embedded interpreter
where introspection is not permitted.
This includes:
- info commands, procs, channels: only allow exact match, not glob pattern
- info frame: don't include cmd and proc in the returned dict
- info level: only return the command name, not the command arguments
- info body, args, statics: do not allow these to be called
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Not in source files
See https://ariadne.space/2021/12/21/stop-defining-feature-test-macros-in-your-code/
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
When this condition was caught, eval frame was incorrectly
popped even though it was never pushed.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Previously dict with returned the new dict value.
Also fix an issue in the case where a dict element
mirrors the name of the dictionary.
Fixes: #241
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Instead of using all time, these commands now use a monotonically
increasing system timer so that they are not affected by time (e.g. ntp) adjustments.
(But not on Windows since it doesn't work reliably)
Fixes #240
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Based on TIP 527, but not 100% compatible
Needs documentation
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Returns a dictionary with file, line, cmd, (possibly) proc and level.
And support 'info frame 0' for the current command.
Note that now all evaluation frames are captured, not just call frames.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Allows for a specialised allocator or debugging allocator.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
No need to copy a char that will be overwritten in the next line.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
If the expression is a simple integer, use it as-is rather
than converting to an expression and evaluating.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Needs to be #if not #ifdef for 'decl' checks.
Otherwise build fails on systems without these.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Go through the Jim versions where it makes sense so we can add debugging
or other features as required.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
The Appveyor build generates this otherwise:
In function 'Jim_WhileCoreCommand',
inlined from 'Jim_WhileCoreCommand' at jim.c:12096:12:
jim.c:12109:12: warning: 'boolean' may be used uninitialized [-Wmaybe-uninitialized]
12109 | if (!boolean)
| ^
jim.c: In function 'Jim_WhileCoreCommand':
jim.c:12105:13: note: 'boolean' was declared here
12105 | int boolean, retval;
| ^~~~~~~
|
|
Improve the check for an object that exists only in the command table with
reference count of one. The object being checked needs to be the same object
as the one in the command table. And also objects of type reference can
be in the command table so check those too.
Fixes #245
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
So don't try to find them as functions
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
When checking for "weak" references where the only reference is in the
command hash table, need to check the reference count of the key in the hash
table (this is the command name), not the reference count of the object
we are using to look up the command. Without this it is possible that a reference
(typically a lambda) will be collected even though there is still a reference to it.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
unset -nocomplain abc(missing)
was still returning an error message, but as
a normal return. It should return an empty result.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
In addition to "on codes ..."
it is now possible to trap on errorcode with
"trap sublist ..."
e.g.
try {
...
} trap CHILDSTATUS {msg opts} {
...
}
Fixes #204
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
There is no reason to allow a reference to contain leading and/or
trailing white space, so remove this check and simply treat
it as an invalid reference.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
oo.tcl returns globally qualified names like
::<reference.<tree___>.00000000000000000000>
So allow getref and setref to handle these qualified references
Fixes #218
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
This issue was caused by the fix in 24b234543c7322d2dd20339b45367fa3f4c53495
Because we used closed hashing for the dict hash table, it is important
that the table doesn't get too full, as it gets very inefficient due to
hash collisions. When allowing for space, also consider dummy entries that
consume slots. If there are too many dummy slots, the hash table is expanded,
clearing out the dummy slots.
Without this fix it is possible to get unlucky when filling a dictionary
and emptying it again (twice) will result all slots become dummy slots
and thus no more entries can be added.
See REGTEST 54
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Due to the way hash collisions are managed it is possible
to have a sequence where an entry is removed and then another
entry is replaced, however the replacement adds an additional
entry instead of updating the existing entry.
Can be reproduced like this as there is a hash collision between
these two keys:
dict set d 0,13 X
dict set d 8,4 Y
dict unset d 0,13
dict set d 8,4 Z
Should result in one entry in the dictionary, but instead ends with two.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Fixes: #210
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
When a reference is used as a command name (e.g. in oo.tcl) it
is created in the global namespace as ::<reference...
The current check for references that are commands with a reference
count of 1 doesn't take this into account so these references
were not being garbage collected.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Some users may not be ready to immediately move to the single-argument
expr, so provide a --compat option to configure to support the
previous behaviour as a transition strategy.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Fixes #198
Reported-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Avoid unexpected issues by concatenating multiple arguments.
This does create an incompatibility with early versions, but
it is generally trivial to convert existing code to one of two forms:
1. expr {$a + $b} -- usually correct
2. expr "$a + $b" -- usually incorrect
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
When namespace is disabled, Jim_memrchr is not needed
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Irrelevant warnings from some compilers
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Add -stride support to both lsearch and lsort
Add -index support to lsearch
Improve -index for lsort to support multiple indices
Also harmonise some error messages with Tcl 8.7
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
jim.h now includes JIM_ABI_VERSION that should be incremented whenever
the ABI changes. Then all loadable modules should call Jim_CheckAbiVersion()
to make sure they are loaded against the correct version.
Add Jim_PackageProvideCheck() that does both Jim_CheckAbiVersion()
and Jim_PackageProvide() to simplify the implementation of loadable extensions.
Also rename the "big" sqlite3 extension to just sqlite to avoid a naming conflict with
the smaller jim-sqlite3 extension.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Allows a debugger or tracing facility to be implemented
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
In order to test bootstrap jimsh, it is very helpful
if it can pass all the unit tests.
- Set tcl_platform(bootstrap) to 1 for bootstrap jimsh or 0 otherwise
- Use getref to determine in we have references, not ref since we
implement a poor-man's ref for bootstrap jimsh
- bootstrap jimsh package doesn't return a "Can't load package"
message if loading the package fails
- exec tests using [open |command] need pipe
- bootstrap jimsh can't set file times with [file mtime]
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
When boolean parsing was combined in commit
982ec4f524bc81a240cb729cf09bd3c677aea485
it broken parsing of boolean values in expressions that
weren't standalone.
e.g. expr {true} was fine, but expr {true ? 4 : 5} was not.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
In order for make-bootstrap-jim to reliably match #ifndef...JIM_BOOTSTRAP
with the corresponding #endif, a corresponding comment needs to be added
after the #endif
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
For speed and size, since it shares a lot of the same code with catch
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
It is convenient to be able to do just:
loop i 5 {
body
}
Where the start value is 0.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
This means that instead of just [list index 2+1], we can now do
[list index end-$n*2+1]
This applies to:
lindex, linsert, lreplace, lset, lrange, lsort, regexp, regsub
string index,first,last,range
Also add tests for both direct integer expressions and indexes.
Still needs doc update.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
This means that $variable references and [commands] are not expanded.
This should mitigate security concerns when using the 'integer expression' feature.
It means that you must do:
string repeat a $i*4
Not:
string repeat a {$i*4}
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
For convenience, many commands now accept integer expressions
rather than only simple integers.
These are:
loop, range, incr, string repeat, lrepeat, pack, unpack, rand
This simplifies many cases where previously expr {} or $() was required.
e.g.
foreach i [range 4+1 2*$b] { ... }
string repeat 2**$n a
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
This reverts commit 6b287b9c6b6ec8fbc62f1cbaad48547cf5a4b65c.
These are needed for reference counting.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|