Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Official mirror of Jim Tcl, an open-source, small footprint implementation of Tcl

branch: master

jim.c: Restore errors for Jim_EvalFile()

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>
latest commit 301b522de4
Steve Bennett authored
Octocat-spinner-32 autosetup Update autosetup/jimsh0.c to the most recent version September 19, 2013
Octocat-spinner-32 examples.api Clean up jim_return.c example June 12, 2013
Octocat-spinner-32 examples.ext Create build-jim-ext for building extensions November 24, 2011
Octocat-spinner-32 examples Enhance examples/jtclsh.tcl November 11, 2013
Octocat-spinner-32 freebsd clemens and chi (same person :-) are OK with FreeBSD license. July 16, 2008
Octocat-spinner-32 sqlite3 Fix some compiler warnings December 16, 2011
Octocat-spinner-32 tests jim.c: check for missing quotes, etc. in eval, expr March 18, 2014
Octocat-spinner-32 tools Implement some new features October 15, 2010
Octocat-spinner-32 .gitignore Fix --shared build July 22, 2013
Octocat-spinner-32 .indent.pro Clean up the indentation mess October 15, 2010
Octocat-spinner-32 .project added eCos Jim Tcl repository. Work in progress. June 15, 2008
Octocat-spinner-32 AUTHORS fix encoding of all files to be utf-8, not latin1 January 17, 2014
Octocat-spinner-32 BUGS Fix for right-to-left associativity of ternary operator December 15, 2010
Octocat-spinner-32 DEVELOPING Update TODO to reflect the current state of Jim June 10, 2011
Octocat-spinner-32 LICENSE fix encoding of all files to be utf-8, not latin1 January 17, 2014
Octocat-spinner-32 Makefile.in build: make check is now an alias for make test January 17, 2014
Octocat-spinner-32 README Correct the documentation for 'local' December 02, 2011
Octocat-spinner-32 README.extensions Don't hardcode /lib/jim November 08, 2010
Octocat-spinner-32 README.metakit Document the Metakit extension August 31, 2011
Octocat-spinner-32 README.namespaces Add support for lightweight namespaces December 12, 2011
Octocat-spinner-32 README.oo Correct the documentation for 'local' December 02, 2011
Octocat-spinner-32 README.sqlite Remove old sqlite0 extension December 12, 2011
Octocat-spinner-32 README.utf-8 Correct the documentation for 'local' December 02, 2011
Octocat-spinner-32 STYLE Clean up the indentation mess October 15, 2010
Octocat-spinner-32 TODO Update TODO to reflect the current state of Jim June 10, 2011
Octocat-spinner-32 Tcl_shipped.html Update shipped Tcl.html January 22, 2014
Octocat-spinner-32 UnicodeData.txt Add UTF-8 support to Jim November 17, 2010
Octocat-spinner-32 auto.def Make identification of nan and inf more robust December 21, 2013
Octocat-spinner-32 bench.tcl bench.tcl: fix the pi benchmark January 15, 2014
Octocat-spinner-32 binary.tcl jim.c: check for missing quotes, etc. in eval, expr March 18, 2014
Octocat-spinner-32 bootstrap.tcl Add make-bootstrap-jim script June 03, 2011
Octocat-spinner-32 build-jim-ext.in build-jim-ext: load using ./$filename January 27, 2014
Octocat-spinner-32 configure Update autosetup to v0.6.5 March 28, 2013
Octocat-spinner-32 configure.ac Re-add a dummy configure.ac for automake June 16, 2011
Octocat-spinner-32 glob.tcl Allow abbreviations to glob options September 22, 2012
Octocat-spinner-32 initjimsh.tcl Add tcl_platform(pathSeparator) July 13, 2011
Octocat-spinner-32 jim-aio.c aio: fix open called with wrong number of arguments January 23, 2014
Octocat-spinner-32 jim-array.c array: array set to non-dict should fail January 15, 2014
Octocat-spinner-32 jim-clock.c many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim-config.h.in Allow jim to be used as an autoconf subdir November 09, 2010
Octocat-spinner-32 jim-eventloop.c many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim-eventloop.h many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim-exec.c many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim-file.c file: fix stat file size for large files March 03, 2014
Octocat-spinner-32 jim-format.c many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim-history.c many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim-interactive.c many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim-load.c load: use AssocData to free load handles January 15, 2014
Octocat-spinner-32 jim-mk.cpp metakit: subcmd no longer includes 'description' December 12, 2011
Octocat-spinner-32 jim-namespace.c namespace: disallow array element syntax for variables January 15, 2014
Octocat-spinner-32 jim-pack.c Add pack/unpack support for floating point August 19, 2013
Octocat-spinner-32 jim-package.c package: fix corruption of versions string February 06, 2014
Octocat-spinner-32 jim-posix.c Create build-jim-ext for building extensions November 24, 2011
Octocat-spinner-32 jim-readdir.c readdir: minor code cleanups January 15, 2014
Octocat-spinner-32 jim-readline.c Create build-jim-ext for building extensions November 24, 2011
Octocat-spinner-32 jim-regexp.c many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim-sdl.c Fix aio close from non-global namespace December 09, 2013
Octocat-spinner-32 jim-signal.c signal: make signal name lookup more efficient January 15, 2014
Octocat-spinner-32 jim-signal.h many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim-sqlite3.c sqlite3: minor code cleanups January 15, 2014
Octocat-spinner-32 jim-subcmd.c many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim-subcmd.h many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim-syslog.c many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim-tclprefix.c Quieten some compiler warnings December 13, 2011
Octocat-spinner-32 jim-win32.c Create build-jim-ext for building extensions November 24, 2011
Octocat-spinner-32 jim-win32compat.c Allow building with MSVC on windows November 07, 2011
Octocat-spinner-32 jim-win32compat.h many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim.c jim.c: Restore errors for Jim_EvalFile() March 19, 2014
Octocat-spinner-32 jim.h many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jim_tcl.txt file: simplify [file stat], var now optional January 15, 2014
Octocat-spinner-32 jimregexp.c many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jimregexp.h many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 jimsh.c jimsh: minor code cleanups January 15, 2014
Octocat-spinner-32 linenoise.c Fix [string tolower] buffer overflow for non-utf8 November 06, 2013
Octocat-spinner-32 linenoise.h Update linenoise.c to match recent github July 24, 2013
Octocat-spinner-32 make-bootstrap-jim Unbreak shared build on Windows. Collect all version ids to auto.def. August 23, 2013
Octocat-spinner-32 make-c-ext.tcl Add Jim_EvalSource() to replace Jim_Eval_Named() July 29, 2011
Octocat-spinner-32 make-index Fix make-index speed-up March 02, 2012
Octocat-spinner-32 make-load-static-exts.tcl Small changes to keep older compilers happy July 22, 2011
Octocat-spinner-32 make-release.sh Version now comes from jim.h June 24, 2011
Octocat-spinner-32 nshelper.tcl many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 oo.tcl oo: aliases are now commands, not procs December 16, 2011
Octocat-spinner-32 parse-unidata.tcl Add support for [string totitle] November 28, 2011
Octocat-spinner-32 regtest.tcl regtest: don't exit prematurely from test 32 January 18, 2014
Octocat-spinner-32 rlprompt.tcl Allow exit from .jimrc October 15, 2010
Octocat-spinner-32 stdlib.tcl many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 tcl.license.terms Correct the documentation for 'local' December 02, 2011
Octocat-spinner-32 tclcompat.tcl many comment changes, some small code changes January 21, 2014
Octocat-spinner-32 tree.tcl Correct the documentation for 'local' December 02, 2011
Octocat-spinner-32 utf8.c utf8: remove unused utf8_charequal() January 15, 2014
Octocat-spinner-32 utf8.h many comment changes, some small code changes January 21, 2014
README
The Jim Interpreter

A small-footprint implementation of the Tcl programming language.

--------------------------------------------------------------------------------
WHAT IS JIM?
--------------------------------------------------------------------------------

Jim is a small footprint implementation of the Tcl programming language
written from scratch. Currently Jim Tcl is very feature complete with
an extensive test suite (see the tests directory).
There are some Tcl commands and features which are not implemented
(and likely never will be), including namespaces, traces and Tk. However
Jim Tcl offers a number of both Tcl8.5 and Tcl8.6 features ({*}, dict, lassign,
tailcall and optional UTF-8 support) and some unique features.
These unique features include [lambda] with garbage collection, a general GC/references
system, arrays as syntax sugar for [dict]tionaries, object-based I/O and more.

Other common features of the Tcl programming language are present, like
the "everything is a string" behaviour, implemented internally as
dual ported objects to ensure that the execution time does not reflect
the semantic of the language :)

--------------------------------------------------------------------------------
WHEN JIM CAN BE USEFUL?
--------------------------------------------------------------------------------

1) If you are writing an application, and want to make it scriptable, with
Jim you have a way to do it that does not require to link your application
with a big system. You can include the Jim source directly in your project
and use the Jim API to write the glue code that makes your application
scriptable in Jim, with the following advantages:

- Jim is not the next "little language", but it's a Tcl implementation.
  You can reuse your knowledge if you already Tcl skills, or enjoy
  the availability of documentation, books, web resources, ...
  (for example check my online Tcl book at http://www.invece.org/tclwise)

- Jim is simple, 14k lines of core code. If you want to adapt it you can hack
  the source code to meet the needs of your application. It makes you
  able to have scripting for default, and avoid external dependences.

  Having scripting support *inside*, and in a way that a given version
  of your program always gets shipped a given version of Jim, you can
  write part of your application in Jim itself. Like it happens for
  Emacs/Elisp, or Gimp/Scheme, both this applications have the interpreter
  inside.

- Jim is Tcl, and Tcl looks like a configuration file if you want. So
  if you use Jim you have also a flexible syntax for your config file.
  This is a valid Tcl script:

     set MyFeature on
     ifssl {
       set SslPort 45000
       use compression
     }

  It looks like a configuration file, but if you implement the [ifssl]
  and [use] commands, it's a valid Tcl script.

- Tcl scales with the user. Not all know it, but Tcl is so powerful that
  you can reprogram the language in itself. Jim support this features
  of the Tcl programming language. You can write new control structures,
  use the flexible data types it offers (Lists are a central data structure,
  with Dictionaries that are also lists). Still Tcl is simpler for the
  casual programmer, especially if compared to other languages offering
  small footprint implementations (like Scheme and FORTH).

- Because of the Tcl semantic (pass by value, everything is a command
  since there are no reserved words), there is a nice API to glue
  your application with Jim. See under the Jim Tcl manual for more detail.

- Jim is supported. If you need commercial software, contact the original author
  at 'antirez@gmail.com' or the current maintainer at 'steveb@workware.net.au'.

2) The other "field" where Jim can be useful is obviously embedded systems.

3) We are working to make Jim as feature-complete as possible, thanks to
   dynamically loaded extensions it may stay as little as it is today
   but able to do interesting things for you. So it's not excluded that
   in the future Jim will be an option as general purpose language.
   But don't mind, for this there is already the mainstream Tcl
   implementation ;).

--------------------------------------------------------------------------------
HOW BIG IS IT?
--------------------------------------------------------------------------------

Jim with the default extensions configured and compiled with -Os is about 130k.
Without any extensions, it is about 85k.

--------------------------------------------------------------------------------
HOW FAST IS IT?
--------------------------------------------------------------------------------

Jim is in most code faster than Tcl7.6p2 (latest 7.x version),
and slower than Tcl 8.4.x. You can expect pretty decent performance
for such a little interpreter.

If you want a more precise measure, there is 'bench.tcl' inside this
distribution that will run both under Jim and Tcl, so just execute
it with both the interpreters and see what you get :)

--------------------------------------------------------------------------------
HOW TO COMPILE
--------------------------------------------------------------------------------

Jim was tested under Linux, FreeBSD, MacosX, eCos, QNX, Windows XP (mingw, MVC).

To compile jim itself try:

  ./configure
  make

--------------------------------------------------------------------------------
EXTENSIONS
--------------------------------------------------------------------------------

Many optional extensions are included. Some are C extensions and others are pure Tcl.
Form more information, try:

  ./configure --help

--------------------------------------------------------------------------------
HOW TO EMBED JIM INTO APPLICATIONS
--------------------------------------------------------------------------------

See the "examples.api" directory

--------------------------------------------------------------------------------
HOW TO WRITE EXTENSIONS FOR JIM
--------------------------------------------------------------------------------

See the extensions shipped with Jim, jim-readline.c, jim-clock.c, glob.tcl and oo.tcl

--------------------------------------------------------------------------------
COPYRIGHT and LICENSE
--------------------------------------------------------------------------------

Unless explicitly stated, all files within Jim repository are released
under following license:

/* Jim - A small embeddable Tcl interpreter
 *
 * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
 * Copyright 2005 Clemens Hintze <c.hintze@gmx.net>
 * Copyright 2005 patthoyts - Pat Thoyts <patthoyts@users.sf.net>
 * Copyright 2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
 * Copyright 2008 Andrew Lunn <andrew@lunn.ch>
 * Copyright 2008 Duane Ellis <openocd@duaneellis.com>
 * Copyright 2008 Uwe Klein <uklein@klein-messgeraete.de>
 * Copyright 2008 Steve Bennett <steveb@workware.net.au>
 * Copyright 2009 Nico Coesel <ncoesel@dealogic.nl>
 * Copyright 2009 Zachary T Welch zw@superlucidity.net
 * Copyright 2009 David Brownell
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above
 *    copyright notice, this list of conditions and the following
 *    disclaimer in the documentation and/or other materials
 *    provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * The views and conclusions contained in the software and documentation
 * are those of the authors and should not be interpreted as representing
 * official policies, either expressed or implied, of the Jim Tcl Project.
 */
--------------------------------------------------------------------------------
HISTORY
--------------------------------------------------------------------------------

"first Jim goal: to vent my need to hack on Tcl."

And actually this is exactly why I started Jim, in the first days
of Jenuary 2005. After a month of hacking Jim was able to run
simple scripts, now, after two months it started to be clear to
me that it was not just the next toy to throw away but something
that may evolve into a real interpreter. In the same time
Pat Thoyts and Clemens Hintze started to contribute code, so that
the development of new core commands was faster, and also more
people hacking on the same code had as result fixes in the API,
C macros, and so on.

Currently we are at the point that the core interpreter is almost finished
and it is entering the Beta stage. There is to add some other core command,
to do a code review to ensure quality of all the parts and to write
documentation.

We already started to work on extensions like OOP, event loop,
I/O, networking, regexp. Some extensions are already ready for
prime time, like the Sqlite extension and the ANSI I/O.

------------------------------------------------------------------------------
Thanks to...
------------------------------------------------------------------------------

- First of all, thanks to every guy that are listed in the AUTHORS file,
  that directly helped with code and ideas. Also check the ChangeLog
  file for additional credits about patches or bug reports.
- Elisa Manara that helped me to select this ill conceived name for
  an interpreter.
- Many people on the Tclers Chat that helped me to explore issues
  about the use and the implementation of the Tcl programming language.
- David Welton for the tech info sharing and our chats about
  programming languages design and the ability of software to "scale down".
- Martin S. Weber for the great help with Solaris issues, debugging of
  problems with [load] on this arch, 64bit tests.
- The authors of "valgrind", for this wonderful tool, that helped me a
  lot to fix bugs in minutes instead of hours.


----
Enjoy!
Salvatore Sanfilippo
10 Mar 2005


Something went wrong with that request. Please try again.