Age | Commit message (Collapse) | Author | Files | Lines |
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Since signals aren't supported there and we need signals for some
of these tests.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
These tests provoke the issues raised in #245 plus
some additional issues.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
The end of word check was wrong and return true when it should not.
Fixes #246
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Some systems need a little extra time for the child process
to start and acquire the lock.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Dictionary lookups with simple integers are more efficient
than with "node<integer>"
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
file executable doesn't do anything useful on Windows
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
These tests were only working accidentally (typo >$@w).
In fact since open |... already provides a pipe on output
there is no need to create one manually, so the first test
can run under Tcl too.
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>
|
|
Only on unix systems, wait for any child process
This was broken with a recent commit, so add an explicit test
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Although the interface is different ('$handle stat' vs 'chan configure -stat')
the behaviour is the same.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
On win32, a process is identified by a HANDLE, but for identifying
a running process we should use GetProcessId() to return a meaningful integer.
This means we need to be able to back and forth between a pid and a process handle
(phandle). We also need to be careful to get the pid before the process handle closes
since it isn't available afterwards.
Also call the handle to intptr_t for open_osfhandle() to avoid a compiler warning.
Fixes #217
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>
|
|
Needs include, lib paths when jim is not installed
Fixes: #216
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>
|
|
bootstrap jimsh doesn't have garbage collection, so move
such tests into ref.test
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>
|
|
Quote the build dir or and the path to jimsh/tclsh
in the Makefile in case they contain spaces.
Also fix a few problems in tests/ that arise when the build
and/or source dir contain spaces.
Fixes #199
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
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>
|
|
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
In the case where interp is not supported
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
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>
|
|
Fixes #191
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Reported-by: D. Bohdan <dbohdan@dbohdan.com>
|
|
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>
|
|
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>
|
|
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>
|
|
It is especially convenient to add -1 for something like:
lindex $list end-$BACK-1
or:
string range $str $p $p+$len-1
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Add support for comments in expressions
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Ensure that 'info complete' returns 0 for a script is missing
the end quote such as "abc$def
Fixes #181
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Using 'close w' with an ssl socket doesn't really work
because this is done only on the underlying socket.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Fixes: #182
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
It is not portable to connect to 0.0.0.0, expecting this to the same
as connecting to localhost/127.0.0.1, and the same for IPv6.
So explicitly connect to 127.0.0.1 or [::1]
Fixes #180
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Loadable modules and tests
Fixes #179
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Some systems produce 5e-05 while some produce 5e-5.
Both are acceptable.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
|
|
Resolves #173.
|
|
|
|
TIP 342 (https://core.tcl-lang.org/tips/doc/trunk/tip/342.md)
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
TIP 461
|
|
TIP 472
|
|
[string last foo bar -1] gave segfault due to missing
check for invalid index.
Fixes #161
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|
|
Although the documentation has always stated that, like Tcl,
insertion order of dictionaries was preserved, this has never
been the case. Instead, dictionaries were implemented as simple
hash tables that did not preserve order.
Now, a new implementation of dictionaries preserves insertion
order and has a number of other benefits.
Instead of hashing keys and storing keys and values in the hash table,
the keys and values are not stored in a separate table, exactly as
lists are stored, with alternating key, value pairs. Iterating over the
dictionary is exactly like iterating over a list, where the order is consistent.
The hash table uses closed hashing rather than open hashing to avoid
allocatation of hash entry structures. Instead a fixed (but expandable)
hash table maps the key hash to the offset in the key/value table.
This use of offsets means that if the key/value table grows, the offsets
remain valid. Likewise, if the hash table needs to grow, the key, value table
remains unchanged.
In addition to the offset (which indexes to the value, and 0 means the hash table entry is unused),
the original hash is stored in the hash table. This reduces the need for object
comparisons on hash entry collisions.
The collision resolution algorithm is the same as that used by Python:
peturb >>= 5;
idx = (5 * idx + 1 + peturb) & dict->sizemask;
In order to reduce collisions, the hash table is expanded once it reaches
half full. This is more conservative that Python where the table is expanded
when it is two thirds full.
Note that if a hash collision occurs and then the original entry
that cased the hash collision is removed, we still need to continue
iterating when searching for the new key. Don't stop at the now-empty
slot. So these entries are marked with offset=-1 to indicate that
they need to be skipped.
In addition, the new faster hashing algorithm from Tcl 8.7 is used.
This the hash for integers to be calculated efficiently without requiring
them to be converted to string form first.
This implementation is modelled largely on the Python dict implementation.
Overall the performance should be an improvement over the current implementation,
whilst preserving order. Dictionary creating and insertion should be faster
as hash entries do not need to be allocated and resizing should be slightly faster.
Entry lookup should be about the same, except may be faster for pure integer keys.
Below are some indicative benchmarks.
OLD NEW
dict-create-1.1 Create empty dict 97.2ns .
dict-create-1.2 Create small dict 440ns -27%
dict-create-1.3 Create medium dict 1.54us -57%
dict-create-1.4 Create large dict (int keys) 130us -80%
dict-create-1.5 Create large dict (string keys) 143us -75%
dict-set-1.1 Replace existing item 258ns -34%
dict-set-1.2 Replace nonexistent item 365ns -49%
dict-exists-1.1 Find existing item 55.7ns -5%
dict-exists-1.2 Find nonexistent item 55.0ns -5%
Signed-off-by: Steve Bennett <steveb@workware.net.au>
|