aboutsummaryrefslogtreecommitdiff
path: root/jim.c
AgeCommit message (Collapse)AuthorFilesLines
2016-08-28zlib: Fix arg error checkingSteve Bennett1-1/+5
It is wrong to call Jim_WrongNumArgs() with argc == 0. Instead -1 should be returned from the subcmd function to display the standard error message. Add a --maintainer check for this condition in Jim_WrongNumArgs() and fix the zlib unit tests. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-08-17Don't unconditionally define _GNU_SOURCESteve Bennett1-3/+10
Also, fix build if JIM_OPTIMIZATION is disabled Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-08-17expr: fixes for pow/**Steve Bennett1-22/+53
- integer version is much faster - handle -ve numbers - ** is right associative - add tests from Tcl 8.6 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-08-17expr: fix adjacent terms in function callsSteve Bennett1-90/+91
Previously two adjacent terms were incorrectly accepted, such as in pow(2 3) Correctly generate an error in this case and improve the error message when an expression fails to parse correctly. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-08-17expr: Improve mathfunc handlingSteve Bennett1-17/+50
Previously math functions with multiple arguments were handling poorly. For example: pow(1.0 + 3.0 - 2, .8 * 5) was evaluated as: pow(1.0 + 3.0, 2 - .8 * 5) Now commas correctly separate function parameters. Also, the error messages are more consistent and informative in the case of an invalid expression. Update and re-enable tests in tests/expr-old.test accordingly Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-08-17expr: add support for atan2, hypot and fmodSteve Bennett1-58/+63
And enable some more math tests Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-07-10Boolean contstants in expr, `string is boolean` classificationNikita Borodikhin1-6/+103
* named boolean values in `expr` are internally converted to int * named constants are lower-case only
2016-03-27Prevent static analysers from thinking that variable fn might be used whilst ↵Evan Hunter1-0/+1
null
2016-03-27Fix shift operator so result is the expected 64 bit valueEvan Hunter1-2/+2
2016-03-27jim: Jim_ScriptIsComplete() now takes an objectSteve Bennett1-32/+27
Rather than taking a string and a length, it is simpler and more efficient to take a Jim_Obj Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-03-27Small code cleanupsSteve Bennett1-33/+23
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-02-11jim.c,jim.h: fix typosSteve Bennett1-1/+1
As identified by frgm Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-01-18Add the tcl_platform(engine) array element.mistachkin1-0/+1
2015-11-30jim: fix typos in commentsAntonio Borneo1-3/+3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2015-11-30jim: highlight switch's case fall-throughAntonio Borneo1-0/+6
Add comment to highlight that fall through is the desired behaviour for cases ending without break. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2015-07-08jim.c: fix typoSvyatoslav Mishyn1-2/+2
"does not exists" => "does not exist"
2015-06-28typosSvyatoslav Mishyn1-6/+6
2015-06-26jim.c: fix comment for Jim_String()Steve Bennett1-1/+1
Reported-by: Svyatoslav Mishyn <juef@openmailbox.org> Signed-off-by: Steve Bennett <steveb@workware.net.au>
2015-06-03chained tailcalls were not always being runSteve Bennett1-30/+20
There is no need to protect against merging tailcalls across uplevel since any tailcalls should already be fully resolved. This fixes a problem with the following only running one loop: foreach a {b c d} { command-with-tailcall $a } In particular: dict for {a b} {1 2 3 4} { puts $a,$b } Reported-by: Jon Povey <jon.povey@emsolutions.com.au> Signed-off-by: Steve Bennett <steveb@workware.net.au>
2015-01-16Improve performance of script validation commitSteve Bennett1-43/+38
Commit 7edde0797 inadvertently reduced performance of the script evaluation fast path. Rename Jim_GetScript() to JimGetScript() - always returns a script, even on parse failure. Now JimValidScript() checks the script for parse error and generates the error message if necessary. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-12-31Throw an error when parsing a bad scriptSteve Bennett1-23/+30
If a script has a missing bracket (for example), currently it is silently ignored, except by [source] Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-12-09add support for [info source ?filename line?]Steve Bennett1-16/+25
Allows a script to be created with explicit source info Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-11-17Implement string cat (TIP #429)Steve Bennett1-2/+21
Signed-off-by: Steve Bennett <steveb@workware.net.au>
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>