aboutsummaryrefslogtreecommitdiff
path: root/jim.c
AgeCommit message (Collapse)AuthorFilesLines
2014-10-15Add more tcl compatiblitySteve Bennett1-3/+7
- Add wide() function to [expr] (same as int()) - Small error message changes Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-10-11jim.c: string to double conversion error messageSteve Bennett1-1/+1
Change the error message to match Tcl 8.6 "expected floating-point number" instead of "expected number" Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-10-10alias: don't rely on internal list never shimmeringSteve Bennett1-1/+4
It is possible for the alias prefix to shimmer, especially if the prefix is a list with a single element Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-07-26jim.c: make lindex work as identity function.Danyil Bohdan1-2/+2
2014-04-28jim.c: Squelch a coverity false positiveSteve Bennett1-1/+4
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-04-28jim.c: Simplify Jim_GetIndex() for int conversionSteve Bennett1-4/+7
This approach avoids a coverity warning Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-04-23jim.c: fix mem leak in foreachSteve Bennett1-3/+6
In this invalid script: foreach a {0 1 2} {} {3 4 5} { # ... } Courtesy of coverity Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-04-23jim.c: Fix invalid bit shiftSteve Bennett1-1/+1
Courtesy of coverity Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-04-23jim.c: fix a minor typoSteve Bennett1-1/+1
Courtesy of coverity Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-04-23jim.c: missing va_endSteve Bennett1-0/+2
Courtesy of coverity Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-03-19jim.c: Restore errors for Jim_EvalFile()Steve Bennett1-5/+8
Jim_EvalFile() needs to explictly add an error stack frame. Reported-by: Florian Schäfer <florian.schaefer+github@gmail.com> Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-03-18jim.c: check for missing quotes, etc. in eval, exprSteve Bennett1-56/+87
Throw an error if a script or expression is missing a trailing bracket, brace or quote rather than simply ignoring the error. Reported-by: Florian Schäfer <florian.schaefer+github@gmail.com> Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-03-14jim.c: preserve source info on interpolationSteve Bennett1-1/+6
Preserve the source info for an interpolated script where possible. e.g. set script "puts $x" Signed-off-by: Steve Bennett <steveb@workware.net.au>
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>