aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-12-11list, string: support any number of +/-n for indexSteve Bennett3-8/+39
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>
2020-12-11autosetup: keep clean the source tree on out-of-tree buildAntonio Borneo2-7/+6
If the build host doesn't have neither jimsh nor tclsh installed, during 'configure' the autosetup will build 'autosetup/jimsh0' inside the source tree. This happens also when out-of-tree build is used. Making dirty the source tree during out-of-tree build causes applications that use jimtcl as submodule (e.g. OpenOCD) to fail at 'make distcheck'. Modify 'autosetup-find-tclsh' to build 'jimsh0' in the current folder. For jimtcl project it would be the root of the source tree or the root of the out-of-tree build. Update 'Makefile.in' to search for 'jimsh0' in the new path during 'distclean'. Reported-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-11-30Makefile: remove examples.api/Makefile while 'distclean'Antonio Borneo1-1/+1
The working directory is not fully cleaned-up and remains dirty after 'make distclean'. Add file examples.api/Makefile in the list of files to remove during 'make distclean'. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-11-30.gitignore: add generated file /examples.api/MakefileAntonio Borneo1-0/+1
When building in-tree, the generated file is not ignored and the tree appears as dirty. Add the generated file to .gitignore. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-11-16expr: TIP 582 - comments in expressionsSteve Bennett4-10/+49
Add support for comments in expressions Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-11-16core: fix minor compiler warningSteve Bennett1-1/+1
Fixes #183 Reported-by: Stuart Cassoff <stwo@bell.net> Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-11-15redis: Add simple redis client extensionSteve Bennett5-0/+391
Using the hiredis client library. Synchronous API only. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-11-15eventloop: Add convenience functions for adding script file handlersSteve Bennett3-38/+63
Add Jim_CreateScriptFileHandler() to create a standard script filehandler event that evaluates the given script with Jim_EvalObjBackground() when the event occurs. Also add Jim_FindFileHandler() to find a registered event handler. Simplify aio by using these. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-11-14format: minor indentation fixSteve Bennett1-1/+1
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-11-14core: parser: fix for script with missing end quoteSteve Bennett2-0/+19
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>
2020-11-14tests: ssl: use flush, not closeSteve Bennett1-3/+3
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>
2020-11-14tests: aio tty: skip tests if stdout is not a ttySteve Bennett1-1/+1
Fixes: #182 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-11-09aio: socket: Fix tests connecting to 0.0.0.0Steve Bennett2-10/+25
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>
2020-11-08build: Fix build and tests for out-of-tree buildSteve Bennett10-34/+46
Loadable modules and tests Fixes #179 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-11-01scan.test: Be more lenient in floating point formatSteve Bennett1-4/+4
Some systems produce 5e-05 while some produce 5e-5. Both are acceptable. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-11-01build: Fix the appveyor buildSteve Bennett1-1/+2
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-10-31core: change "newVal" to "value" in [lset] usageD. Bohdan2-2/+2
2020-10-31core: put space before "..." in "wrong # args" msgD. Bohdan3-2/+16
Resolves #173.
2020-10-29build: Support sources with CRNL line endings0.80Steve Bennett2-2/+6
make-c-ext.tcl and parse-unidata.tcl now support input files with CRNL line endings Reported-by: Mark@TheMarkitecht.com Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-10-06docs: Fix minor typo in docsSteve Bennett2-2/+2
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-10-05bump version to 0.80Steve Bennett3-140/+233
Update documentation to indicate v0.80 and update Tcl_shipped.html Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-10-05build: some systems have backtrace but not execinfo.hSteve Bennett2-3/+3
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-10-04oo: fix super for >2 levels of inheritanceSteve Bennett1-2/+3
Need to find the baseclass based on the current method class, not based on the object class. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-09-27core: make unary "!" work with non-int booleansD. Bohdan2-1/+18
2020-09-23build: avoid a spurious compiler warningSteve Bennett1-1/+4
When compiled with -Os and arm-linux-musleabihf-gcc (crosstool-NG 1.24.0.92-e2957c3) 9.2.0 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-09-23build: Update autosetup to 0.7.0Steve Bennett10-89/+138
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-09-23docs: Update docs to indicate recent changes.Steve Bennett1-7/+12
Docs now indicate 0.79+, in preparation for 0.80 release And correctly indicate the changes since 0.79 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-09-23dict: add support for getwithdefault/getdefSteve Bennett3-3/+141
TIP 342 (https://core.tcl-lang.org/tips/doc/trunk/tip/342.md) Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-09-23docs: document operators lt, gt, le, geD. Bohdan1-0/+6
2020-09-23core: implement string comparison operatorsD. Bohdan2-4/+52
TIP 461
2020-09-23docs: reword paragraph on integer prefixesD. Bohdan1-5/+4
Thanks to @gromgit on GitHub for suggesting this phrasing.
2020-09-23core: implement 0d radix prefix for decimalD. Bohdan3-10/+22
TIP 472
2020-08-22docs: remove generation of "Last updated" fieldAntonio Cardace1-1/+1
The generation of this field makes the resulting Tcl.html different between builds, as it records the time of generation, remove this as it causes jimtcl rpms for different arches (on RHEL/Fedora) to have a file conflict on Tcl.html.
2020-07-31jimregexp: rename local regex functionsSteve Bennett3-16/+20
Avoid possible problems with when linking by renaming local regex to jim_regcomp, jim_regexec, etc. Fixes: #163 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-07-24aio: ssl: connection close isn't an errorSteve Bennett1-1/+5
A return code of SSL_ERROR_ZERO_RETURN means the connection was closed. It isn't an error. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-07-12string last: fix segfault with invalid indexSteve Bennett3-4/+13
[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>
2020-06-25docs: use "empty string" instead of "null string"Steve Bennett1-5/+5
Avoid ambiguity re null characters Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-06-25core: dicts (and arrays) now preserve insertion orderSteve Bennett8-181/+473
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>
2020-06-13core: info commands failed to match under some conditionsSteve Bennett2-18/+34
Now that proc names are stored as-is in the commands table, info commands needs to take into account matching both foo::test and ::foo::test against the pattern ::foo::* Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-06-13update .gitignore adding jimtcl.pc and tests/MakefileAntonio Borneo1-0/+2
Commit aa4427dee716 ("Add pkg-config support: jimtcl.pc") adds the build time file jimtcl.pc Commit 630df0da46f4 ("Update autosetup to v0.6.8") adds running make-template on tests/Makefile.in, producing tests/Makefile Add both jimtcl.pc and tests/Makefile to .gitignore Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-06-12core: tidy up command creation/replacementSteve Bennett1-50/+43
We can simply use Jim_ReplaceHashEntry() when replacing a command in non-local mode now that the proc epoch doesn't need to be incremented. And JimRemoveHashEntry() only has one caller, so fold it into Jim_DeleteHashEntry() Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-06-11core: improvements to garbage collectionSteve Bennett1-23/+18
Don't look up every object in the command table, since it can be slow to do that. Only lookup if the object looks like a reference. Also, script and expression objects can't contain references that aren't already contained in sub-objects, so there is no need to scan them for references. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-06-11time: show results less than 1us per iterationSteve Bennett1-4/+7
In this case, show the result as a decimal value Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-06-11core: improve the performance of listsSteve Bennett1-14/+25
Under some circumstances, such as lrepeat and lreverse we know the length of the final list, so allocate the final size immediately rather than growing the table in multiple steps. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-06-11dict exists: Improve performance when when key not foundSteve Bennett1-2/+2
Pass JIM_NONE to prevent an error message being generated which is subsequently thrown away. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-06-10core: fix regtest TEST 35Steve Bennett1-10/+8
The changes in cdfa4637afe broke TEST 35 because the cmd pointer is dereferenced before checking the procEpoch instead of afterwards. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-06-05update all extensions for new Jim_DeleteCommand() APISteve Bennett4-7/+7
Now argument is Jim_Obj *, not const char * Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-06-05tests: allow more time for some testsSteve Bennett3-18/+18
If running in a VM with very variable time Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-06-05tests: Fix some tests when certain features are disabledSteve Bennett3-7/+13
namespace, ssl Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-06-05core: improve performance through negative command cachingSteve Bennett2-14/+49
Instead of incrementing the proc epoch on every command removal and some command creation, cache previous deleted commands (empty structure only). Periodically increment the proc epoch and invalide all cached commands. This is especially a win when creating short lived commands. e.g. proc a {} { local proc b {} { # do something } # now b is removed } Signed-off-by: Steve Bennett <steveb@workware.net.au>