aboutsummaryrefslogtreecommitdiff
path: root/jim.c
AgeCommit message (Collapse)AuthorFilesLines
2014-01-27jim.c: properly free cached callframesSteve Bennett1-6/+13
Commit 87ea45c91e removed the code to free cached callframes when the interpreter is freed. Restore that code. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-21many comment changes, some small code changesSteve Bennett1-202/+164
Sweep through and clean up all (most) of the comments in the code. While there, adjust some variable and function names to be more consistent, and make a few small code changes - again, mostly for consistency. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-21expr: Simplify JimExprParseIrrationalsSteve Bennett1-8/+8
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-18jim.c: fix some dict/list shimmering issuesSteve Bennett1-6/+8
Only do fast dict->list conversion if there is no string rep When converting list->dict, generate the string rep of a shared list to avoid loss of info when converting to dict. Also add a relevent test to dict.test Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-17jim.c: fix a compiler warning for gcc/glibcSteve Bennett1-1/+4
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15jim.c: simplify JimDictExpandArrayVariable()Steve Bennett1-18/+9
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15expr: remove custom number parsing for exprSteve Bennett1-55/+17
And clean up expr parsing slightly Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15jim.c: simplifiy Jim_StrEqObj()Steve Bennett1-20/+13
And use it from the expr evaluator Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15jim.c: Simplify calls to JimFreeCallFrame()Steve Bennett1-34/+13
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15jim.c: Use key dup and val dup for dictsSteve Bennett1-26/+20
Less manual handling of reference counts means less chance of error and less code. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15jim.c: Fix Jim_ReplaceHashEntry() for ref counted objectsSteve Bennett1-3/+15
If both a val dup and a val destructor exist, need to dup before destroying. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15jim.c: only complain on unfreed objects if --maintainerSteve Bennett1-2/+6
Probably only developers care about reference count mismatches at exit. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15jim.c: improve expression optimiserSteve Bennett1-74/+55
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15jim.c: many small code and doc cleanupsSteve Bennett1-96/+130
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15load: use AssocData to free load handlesSteve Bennett1-3/+0
Instead of an explicit call in jim.c, store load handles as AssocData so that it is automatically cleaned up. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-03Revert "Better handling of dict hash tables"Steve Bennett1-21/+43
This reverts commit 5155f363872af642ade631396d1d7303285c3481. It seems that this change has made dict element addition slower, so revert it. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-03tailcall: properly merge tailcall framesSteve Bennett1-68/+97
Resolve the tailcall command immediately in [tailcall] and stash it. If a tailcall is currently being evaluated, new tailcalls in the same frame are merged/deferred to evaluate in the same C stack frame. Can't merge tailcall evaluations across uplevel. Add some tests for these cases Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-03Remove tabs from source filesSteve Bennett1-117/+116
Tabs accidentally crept into source files in violaton of the style guide Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-21errors caught by [catch] shouldn't affect later stacktraceSteve Bennett1-0/+2
Currently if an error is caught with catch { }, the location of the error overrides the location of the next error that occurs. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-21Simplify UpdateStringOfxxx implementationsSteve Bennett1-50/+33
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-21Make identification of nan and inf more robustSteve Bennett1-58/+70
Use isinf() and isnan() when converting double to string to ensure that the value is given canonical form. And implement our own isinf and isnan if necessary
2013-12-21Implement more dict sub commandsSteve Bennett1-36/+85
dict for, values, incr, append, lappend, update, replace and info Also implement array stat (the same as dict info) Note that [dict info] and [array stat] are for useful for checking the behaviour of the hash randomiser Add Jim_EvalEnsemble() Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-21Better handling of dict hash tablesSteve Bennett1-43/+21
Set dup and free operations to automatically manage reference counting of dictionary keys and values. Replace Jim_ReplaceHashEntry() with JimDictReplaceHashEntry() Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-21Use Jim_StrDup() instead of strdup() internallySteve Bennett1-1/+1
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-21allow hash tables to be randomiseSteve Bennett1-2/+11
To avoid hash table collision attacks (n.runs-SA-2011.004) Note that this options is *off* by default, but it is reasonable to consider reversing this. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-21tailcall should resolve command in current namespaceSteve Bennett1-38/+57
Currently tailcall resolves the command in the parent namespace. This also fixes the deletion of [local] commands such that they are always correctly deleted. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-12Fix infinite loop with error in lsort -uniqueSteve Bennett1-5/+5
Reported-by: Sergei Gavrikov <sergei.gavrikov@gmail.com> Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-11Add support for lsort -uniqueSteve Bennett1-4/+43
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-11Add support for lsort -realSteve Bennett1-2/+26
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-09Fix aio close from non-global namespaceSteve Bennett1-0/+21
aio [open], as well as similar commands return the name of the created command. If this is done in the non-global namespace, the returned name is implicitly scoped to the current namespace while the actual command is created in the global namespace. Thus [close] does not work when invoked in that namespace. The solution is to return a fully qualified name, such as ::aio.handle3 Note that this may also be a problem for similar command such as [proc] and [alias] that return command names. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-11-28Fix dict/list shimmering with embedded nullsSteve Bennett1-3/+3
Reported-by: Andy <jimdevel@hummypkg.org.uk> Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-11-11Properly respect backslashes in commentsSteve Bennett1-7/+15
Reported-by: Sergei Gavrikov <sergei.gavrikov@gmail.com> Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-11-11Consider scripts with trailing backslash as unfinishedSteve Bennett1-1/+8
From the interactive prompt. Reported-by: Sergei Gavrikov <sergei.gavrikov@gmail.com> Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-11-06Fix [string tolower] buffer overflow for non-utf8Steve Bennett1-2/+2
Reported-by: Andy <jimdevel@hummypkg.org.uk> Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-09-19Build on platforms without isasciiSteve Bennett1-1/+10
Signed-off-by: Steve Bennett <steveb@workware.net.au> Reported-by: Paul Fertser <fercerpav@gmail.com>
2013-08-19Fixes to make behaviour of Jim's 'binary' more compliant to Tcl.Vadim Zborovskii1-1/+3
2013-08-19Make Jim_IsBigEndian() publicSteve Bennett1-2/+2
And remove declarations of some obsolete functions Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-08-18[local] requires at least one argumentSteve Bennett1-0/+5
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-08-02Minor code cleanupsSteve Bennett1-10/+5
Prefer Jim_String() and Jim_Length() over Jim_GetString() where it makes sense. Use Jim_ListGetIndex() where success is guaranteed. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-08-02Allow object pool to be disabledSteve Bennett1-0/+8
Compile time option, for maintainer debugging Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-07-24Fix a bug in JimNumberBase()Steve Bennett1-1/+2
If the number started with an invalid prefix, e.g. "0x + 1", number parsing would begin past the end of the string. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-07-22Make Jim_CheckSignal() a macroSteve Bennett1-9/+0
For performance reasons Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-07-22Ensure that signals can break vwaitSteve Bennett1-3/+12
The following should break when a handled signal is caught. catch -signal { vwait forever } Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-03-28Properly handle systems where (-ve % +ve) returns +veSteve Bennett1-1/+3
Can't just use abs() This is the correct fix rather than c7e5c48 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-03-28Need abs() since modulo of -ve is impl dependentSteve Bennett1-1/+1
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-03-27More small improvements to JimWideToStringSteve Bennett1-4/+4
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-03-27Further improvements to JimWideToStringSteve Bennett1-36/+27
Small time and space improvements Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-03-27Implement WideToString locally, printf is slowLauri Kasanen1-2/+37
Even though it shouldn't need to, sprintf uses the libc-internal mutex, locale support, and other parts making it slow. [while] busy loop - 306 ms 311 ms - [for] busy loop - 180 ms 182 ms - mini loops - 146 ms 146 ms - fibonacci(25) - 191 ms 176 ms 92.1466 heapsort - 138 ms 131 ms 94.9275 sieve - 182 ms 143 ms 78.5714 sieve [dict] - 162 ms 138 ms 85.1852 ary - 188 ms 166 ms 88.2979 ary [dict] - 173 ms 156 ms 90.1734 repeat - 132 ms 130 ms - upvar - 142 ms 147 ms - nested loops - 173 ms 173 ms - rotate - 22 ms 22 ms - dynamic code - 108 ms 97 ms 89.8148 dynamic code (list) - 45 ms 46 ms - PI digits - 333 ms 319 ms 95.7958 expand - 46 ms 45 ms - wiki.tcl.tk/8566 - 251 ms 235 ms 93.6255 mandel - 212 ms 199 ms 93.8679 Signed-off-by: Lauri Kasanen <cand@gmx.com>
2013-03-27Remove most quotingType allocations in JimMakeListStringRepLauri Kasanen1-5/+14
Only two bits are needed, so also change to unsigned char from int. Signed-off-by: Lauri Kasanen <cand@gmx.com>
2013-03-26Avoid list allocations under four pointers (16/32 bytes)Lauri Kasanen1-2/+10
It's more overhead than usable space to get space for two pointers. Signed-off-by: Lauri Kasanen <cand@gmx.com>