From cbc635e8f4de48408768053a976dc7bd7177ba7a Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Tue, 17 Aug 2010 08:21:39 +1000 Subject: Clean up the indentation mess Use 'indent'. Not perfect, but at least consistent. Signed-off-by: Steve Bennett --- .indent.pro | 34 + Makefile.in | 25 +- README | 24 +- README.sqlite | 177 ++ STYLE | 1 - autoconf.h.in | 82 + config.h.in | 92 - configure | 212 +- configure.ac | 43 +- doc/AIO-Extension.txt | 0 doc/Embedder-HOWTO.txt | 0 doc/Makefile | 9 - doc/Sqlite-Extension.txt | 177 -- doc/Tcl.html.supplied | 0 doc/jim_man.txt | 98 - doc/jim_tcl.txt | 4037 --------------------------- doc/make-index | 55 - jim-aio.c | 408 +-- jim-array.c | 11 +- jim-bio.c | 15 +- jim-clock.c | 10 +- jim-eventloop.c | 175 +- jim-exec.c | 219 +- jim-file.c | 111 +- jim-interactive.c | 24 +- jim-load-static-exts.c | 61 + jim-load.c | 34 +- jim-nvp.c | 540 ++-- jim-package.c | 86 +- jim-posix.c | 21 +- jim-readdir.c | 29 +- jim-readline.c | 18 +- jim-regexp.c | 66 +- jim-sdl.c | 119 +- jim-signal.c | 19 +- jim-sqlite.c | 125 +- jim-sqlite3.c | 160 +- jim-subcmd.c | 69 +- jim-syslog.c | 76 +- jim-win32compat.c | 28 +- jim.c | 6363 +++++++++++++++++++++++-------------------- jim.h | 891 ++++++ jim.h.in | 893 ------ jim_tcl.txt | 4162 ++++++++++++++++++++++++++++ jimsh.c | 38 +- make-c-ext.sh | 11 +- make-jim-load-extensions.sh | 18 - make-load-extensions.sh | 18 - rlprompt.tcl | 33 +- tcltests/test.bin | Bin 259 -> 256 bytes tcltests/test_signal2.tcl | 40 + tcltests/test_trysignal.tcl | 16 + tests/expr-old.test | 16 +- tests/filecopy.test | 124 - tests/infoframe.test | 37 + tree.tcl | 8 +- 56 files changed, 10264 insertions(+), 9894 deletions(-) create mode 100644 .indent.pro create mode 100644 README.sqlite create mode 100644 autoconf.h.in delete mode 100644 config.h.in mode change 100644 => 100755 configure.ac delete mode 100644 doc/AIO-Extension.txt delete mode 100644 doc/Embedder-HOWTO.txt delete mode 100644 doc/Makefile delete mode 100644 doc/Sqlite-Extension.txt delete mode 100644 doc/Tcl.html.supplied delete mode 100644 doc/jim_man.txt delete mode 100644 doc/jim_tcl.txt delete mode 100755 doc/make-index create mode 100644 jim-load-static-exts.c create mode 100644 jim.h delete mode 100644 jim.h.in create mode 100644 jim_tcl.txt mode change 100755 => 100644 make-c-ext.sh delete mode 100755 make-jim-load-extensions.sh delete mode 100644 make-load-extensions.sh create mode 100644 tcltests/test_signal2.tcl create mode 100644 tcltests/test_trysignal.tcl create mode 100644 tests/infoframe.test diff --git a/.indent.pro b/.indent.pro new file mode 100644 index 0000000..128d563 --- /dev/null +++ b/.indent.pro @@ -0,0 +1,34 @@ +-ncs +-npcs +-nut +-bad +-bap +-bbb +-nbc +-nlp +-ci4 +-br +-ncdb +-nce +-cli4 +-d0 +-di1 +-nfc1 +-i4 +-l100 +-npsl +-TJim_Stack +-TJim_HashEntry +-TJim_HashTableType +-TJim_HashTable +-TJim_HashTableIterator +-TJim_Obj +-TJim_ObjType +-TJim_CallFrame +-TJim_Var +-TJim_Cmd +-TJim_PrngState +-TJim_Interp +-TJim_Reference +-TParseToken +-TParseTokenList diff --git a/Makefile.in b/Makefile.in index 6e42b38..b280621 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,4 @@ RANLIB ?= ranlib -SIZE ?= size # Configuration @@ -15,16 +14,14 @@ CFLAGS += -DTCL_LIBRARY=\"/lib/tcl6\" CFLAGS += -DJIM_TCL_COMPAT -DJIM_REFERENCES -CFLAGS += -DHAVE_CONFIG_H -Wall -g $(OPTIM) -I@SRCDIR@ -I. @EXTRA_CFLAGS@ +CFLAGS += -Wall -g $(OPTIM) -I@SRCDIR@ -I. @EXTRA_CFLAGS@ VPATH := @SRCDIR@ ifeq ($(jim_libtype),static) # Emulate tinytcl LIBJIM := libtcl6.a else - #LIBJIM := libjim_shared.so LIBJIM := libtcl6.so - #CFLAGS += -fPIC CFLAGS += $(SH_CFLAGS) endif @@ -41,18 +38,16 @@ EXTENSIONS_OBJS := $(patsubst %,jim-%.o,$(EXTENSIONS)) # Create C extensions from pure Tcl extensions jim-%.c: %.tcl echo $@ >>.clean - sh @SRCDIR@/make-c-ext.sh $@ $< + sh @SRCDIR@/make-c-ext.sh $< >$@ -OBJS += load_extensions.o +OBJS += jim-load-static-exts.o -TARGETS += $(LIBJIM) jimsh +all: jimsh -all: $(TARGETS) - if [ -d doc ]; then $(MAKE) -C doc all; fi +docs: Tcl.html jimsh: $(LIBJIM) jimsh.o $(CC) $(LDFLAGS) -o $@ jimsh.o $(LIBJIM) $(LDLIBS) @LIBDL@ -lm - $(SIZE) $@ ifeq ($(jim_libtype),static) $(LIBJIM): $(OBJS) $(EXTENSIONS_OBJS) @@ -63,15 +58,13 @@ $(LIBJIM): $(OBJS) $(EXTENSIONS_OBJS) $(CC) $(LDFLAGS) $(SH_LDFLAGS) -o $@ $^ endif -load_extensions.c: @SRCDIR@/make-jim-load-extensions.sh - sh @SRCDIR@/make-jim-load-extensions.sh $@ $(EXTENSIONS) - -install: +Tcl.html: jim_tcl.txt + asciidoc -o $@ -d manpage $^ clean: - rm -f *.o lib*.a $(TARGETS) load_extensions.c doc/Tcl.html + rm -f *.o lib*.a jimsh Tcl.html if [ -f .clean ]; then rm -f `cat .clean` .clean; fi distclean: clean - rm -f jim.h Makefile config.status config.log + rm -f autoconf.h Makefile config.status config.log rm -rf autom4te.cache diff --git a/README b/README index 214e5b7..0b4979a 100644 --- a/README +++ b/README @@ -116,28 +116,8 @@ Jim was tested under Linux, FreeBSD, MacosX, Windows XP (mingw, MVC). To compile jim itself try: - make jim - -On systems other than GNU/Linux, you may have to compile without "-ldl" -because it's not needed, but will cause a compilation error (no configure for -now... applications embedding Jim will probably have one already). - -In order to avoid to link against 'dl' just use: - - make LIBS="" jim - -For instructions about how to compile extensions just try 'make' -and see the available options. Check also the next section of this file. - --------------------------------------------------------------------------------- -HOW TO COMPILE IN SYSTEMS WITH JUST ANSI-C SUPPORT --------------------------------------------------------------------------------- - -Try: - - make LIBS="" DEFS="-DJIM_ANSIC" jim - -This should compile Jim almost everywhere there is a decent ANSI-C compiler. + ./configure + make -------------------------------------------------------------------------------- EXTENSIONS diff --git a/README.sqlite b/README.sqlite new file mode 100644 index 0000000..4346d25 --- /dev/null +++ b/README.sqlite @@ -0,0 +1,177 @@ +Jim Sqlite extension documentation. +Copyright 2005 Salvatore Sanfilippo + + +Overview +~~~~~~~~ + +The Sqlite extension makes possible to work with sqlite (http://www.sqlite.org) +databases from Jim. SQLite is a small C library that implements a +self-contained, embeddable, zero-configuration SQL database engine. This +means it is perfect for embedded systems, and for stand-alone applications +that need the power of SQL without to use an external server like Mysql. + +Basic usage +~~~~~~~~~~~ + +The Sqlite extension exports an Object Based interface for databases. In order +to open a database use: + + set f [sqlite.open dbname] + +The [sqlite.open] command returns a db handle, that is a command name that +can be used to perform operations on the database. A real example: + + . set db [sqlite.open test.db] + sqlite.handle0 + . $db query "SELECT * from tbl1" + {one hello! two 10} {one goodbye two 20} + +In the second line the handle is used as a command name, followed +by the 'method' or 'subcommand' ("query" in the example), and the arguments. + +The query method +~~~~~~~~~~~~~~~~ + +The query method has the following signature: + + $db query SqlQuery ?args? + +The sql query may contain occurrences of "%s" that are substituted +in the actual query with the following arguments, quoted in order +to make sure that the query is correct even if this arguments contain +"'" characters. So for example it is possible to write: + + . $db query "SELECT * from tbl1 WHERE one='%s'" hello! + {one hello! two 10} + +Instead of hello! it is possible to use a string with embedded "'": + + . $db query "SELECT * from tbl1 WHERE one='%s'" a'b + (no matches - the empty list is returned) + +This does not work instead using the Tcl variable expansion in the string: + + . $db query "SELECT * from tbl1 WHERE one='$foo'" + Runtime error, file "?", line 1: + near "b": syntax error + +In order to obtain an actual '%' character in the query, there is just +to use two, like in "foo %% bar". This is the same as the [format] argument. + +Specification of query results +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In one of the above examples, the following query was used: + + . $db query "SELECT * from tbl1" + {one hello! two 10} {one goodbye two 20} + +As you can see the result of a query is a list of lists. Every +element of the list represents a row, as a list of key/value pairs, +so actually every row is a Jim dictionary. + +The following example and generated output show how to take advantage +of this representation: + + . set res [$db query "SELECT * from tbl1"] + {one hello! two 10} {one goodbye two 20} + . foreach row $res {puts "One: $row(one), Two: $row(two)"} + One: hello!, Two: 10 + One: goodbye, Two: 20 + +To access every row sequentially is very simple, and field of a row +can be accessed using the $row(field) syntax. + +The close method +~~~~~~~~~~~~~~~~ + +In order to close the db, use the 'close' method that will have as side effect +to close the db and to remove the command associated with the db. +Just use: + + $db close + +Handling NULL values +~~~~~~~~~~~~~~~~~~~~ + +In the SQL language there is a special value NULL that is not the empty +string, so how to represent it in a typeless language like Tcl? +For default this extension will use the empty string, but it is possible +to specify a different string for the NULL value. + +In the above example there were two rows in the 'tbl1' table. Now +we can add usign the "sqlite" command line client another one with +a NULL value: + + sqlite> INSERT INTO tbl1 VALUES(NULL,30); + sqlite> .exit + +That's what the sqlite extension will return for default: + + . $db query "SELECT * from tbl1" + {one hello! two 10} {one goodbye two 20} {one {} two 30} + +As you can see in the last row, the NULL is represented as {}, that's +the empty string. Using the -null option of the 'query' command we +can change this default, and tell the sqlite extension to represent +the NULL value as a different string: + + . $db query -null <> "SELECT * from tbl1" + {one hello! two 10} {one goodbye two 20} {one <> two 30} + +This way if the emtpy string has some semantical value for your +dataset you can change it. + +Finding the ID of the last inserted row +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This is as simple as: + + . $db lastid + 10 + +Number of rows changed by the most recent query +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This is also very simple, there is just to use the 'changes' method +without arugments. + + . $db changes + 5 + +Note that if you drop an entire table the number of changes will +be reported as zero, because of details of the sqlite implementation. + +That's all, +Enjoy! +Salvatore Sanfilippo + +p.s. this extension is just the work of some hour thanks to the cool +clean C API that sqlite exports. Thanks to the author of sqlite for this +great work. + +In memory databases +~~~~~~~~~~~~~~~~~~~ + +SQLite is able to create in-memory databases instead to use files. +This is of course faster and does not need the ability to write +to the filesystem. Of course this databases are only useful for +temp data. + +In-memory DBs are used just like regular databases, just the name used to +open the database is :memory:. That's an example that does not use the +filesystem at all to create and work with the db. + + package require sqlite + set db [sqlite.open :memory:] + $db query {CREATE TABLE plays (id, author, title)} + $db query {INSERT INTO plays (id, author, title) VALUES (1, 'Goethe', 'Faust');} + $db query {INSERT INTO plays (id, author, title) VALUES (2, 'Shakespeare', 'Hamlet');} + $db query {INSERT INTO plays (id, author, title) VALUES (3, 'Sophocles', 'Oedipus Rex');} + set res [$db query "SELECT * FROM plays"] + $db close + foreach r $res {puts $r(author)} + +Of course once the Jim process is destroyed the database will no longer +exists. diff --git a/STYLE b/STYLE index eae5528..7a9b56c 100644 --- a/STYLE +++ b/STYLE @@ -62,4 +62,3 @@ C FEATURES Only C89 ANSI C is allowed. C99 features can't be used currently. GCC extensions are not allowed. - diff --git a/autoconf.h.in b/autoconf.h.in new file mode 100644 index 0000000..b07dcdd --- /dev/null +++ b/autoconf.h.in @@ -0,0 +1,82 @@ +/* autoconf.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `backtrace' function. */ +#undef HAVE_BACKTRACE + +/* Define to 1 if you have the `fork' function. */ +#undef HAVE_FORK + +/* Define to 1 if you have the `geteuid' function. */ +#undef HAVE_GETEUID + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if the system has the type `long long'. */ +#undef HAVE_LONG_LONG + +/* Define to 1 if you have the `lstat' function. */ +#undef HAVE_LSTAT + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `mkstemp' function. */ +#undef HAVE_MKSTEMP + +/* Define to 1 if you have the `realpath' function. */ +#undef HAVE_REALPATH + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strptime' function. */ +#undef HAVE_STRPTIME + +/* Define to 1 if you have the `sysinfo' function. */ +#undef HAVE_SYSINFO + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the `ualarm' function. */ +#undef HAVE_UALARM + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `vfork' function. */ +#undef HAVE_VFORK + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS diff --git a/config.h.in b/config.h.in deleted file mode 100644 index 58fc6d8..0000000 --- a/config.h.in +++ /dev/null @@ -1,92 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the `backtrace' function. */ -#undef HAVE_BACKTRACE - -/* Define to 1 if you have the declaration of `mkdir', and to 0 if you don't. - */ -#undef HAVE_DECL_MKDIR - -/* Define to 1 if you have the `fork' function. */ -#undef HAVE_FORK - -/* Define to 1 if you have the `geteuid' function. */ -#undef HAVE_GETEUID - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if the system has the type `long long'. */ -#undef HAVE_LONG_LONG - -/* Define to 1 if you have the `lstat' function. */ -#undef HAVE_LSTAT - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `mkstemp' function. */ -#undef HAVE_MKSTEMP - -/* Define to 1 if you have the `regcomp' function. */ -#undef HAVE_REGCOMP - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strptime' function. */ -#undef HAVE_STRPTIME - -/* Define to 1 if you have the `sysinfo' function. */ -#undef HAVE_SYSINFO - -/* Define to 1 if you have the `syslog' function. */ -#undef HAVE_SYSLOG - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the `ualarm' function. */ -#undef HAVE_UALARM - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the `vfork' function. */ -#undef HAVE_VFORK - -/* Define if mkdir(2) takes a single argument (no mode) */ -#undef MKDIR_ONE_ARG - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS diff --git a/configure b/configure index 98b5f33..768b9ce 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for jim 0.62. +# Generated by GNU Autoconf 2.65 for jim 0.63. # # Report bugs to . # @@ -552,8 +552,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='jim' PACKAGE_TARNAME='jim' -PACKAGE_VERSION='0.62' -PACKAGE_STRING='jim 0.62' +PACKAGE_VERSION='0.63' +PACKAGE_STRING='jim 0.63' PACKAGE_BUGREPORT='steveb@workware.net.au' PACKAGE_URL='' @@ -595,11 +595,11 @@ ac_includes_default="\ ac_subst_vars='LTLIBOBJS LIBOBJS +LIBDL SRCDIR EXTRA_CFLAGS JIM_LIBTYPE JIM_EXTENSIONS -LIBDL SH_LDFLAGS SH_CFLAGS host_os @@ -1218,7 +1218,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures jim 0.62 to adapt to many kinds of systems. +\`configure' configures jim 0.63 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1283,7 +1283,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of jim 0.62:";; + short | recursive ) echo "Configuration of jim 0.63:";; esac cat <<\_ACEOF @@ -1291,7 +1291,7 @@ Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --disable-fork do not use fork + --disable-fork do not use fork (no exec, etc.) --enable-math include support for math functions Optional Packages: @@ -1376,7 +1376,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -jim configure 0.62 +jim configure 0.63 generated by GNU Autoconf 2.65 Copyright (C) 2009 Free Software Foundation, Inc. @@ -1704,50 +1704,11 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_func - -# ac_fn_c_check_decl LINENO SYMBOL VAR -# ------------------------------------ -# Tests whether SYMBOL is declared, setting cache variable VAR accordingly. -ac_fn_c_check_decl () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5 -$as_echo_n "checking whether $2 is declared... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -#ifndef $2 - (void) $2; -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by jim $as_me 0.62, which was +It was created by jim $as_me 0.63, which was generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ @@ -2094,7 +2055,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_config_headers="$ac_config_headers config.h" +ac_config_headers="$ac_config_headers autoconf.h" # Checks for programs. @@ -3333,7 +3294,6 @@ HAVE_LONG_LONG="#define HAVE_LONG_LONG" fi - # Shared library support. Because we don't believe in automake! ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do @@ -3448,7 +3408,7 @@ if test "${enable_fork+set}" = set; then : if test "x$enableval" = "xno" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: * disabling fork" >&5 $as_echo "* disabling fork" >&6; } - EXTRA_CFLAGS="-DHAVE_NO_FORK" + EXTRA_CFLAGS="-DJIM_NOFORK" fi fi @@ -3478,8 +3438,30 @@ if test "${with_jim_ext+set}" = set; then : fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: enabling jim extensions: $jim_extensions" >&5 +$as_echo "enabling jim extensions: $jim_extensions" >&6; } +JIM_EXTENSIONS=$jim_extensions + +for i in $jim_extensions; do + EXTRA_CFLAGS="$EXTRA_CFLAGS -Djim_ext_$i" +done + +JIM_LIBTYPE=static + +# Check whether --with-jim-shared was given. +if test "${with_jim_shared+set}" = set; then : + withval=$with_jim_shared; + if test "x$withval" = "xyes" ; then + JIM_LIBTYPE=shared + fi + + +fi + +JIM_LIBTYPE=$JIM_LIBTYPE + -for ac_func in backtrace geteuid lstat mkstemp fork strptime sysinfo ualarm +for ac_func in ualarm sysinfo lstat fork vfork do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -3492,45 +3474,24 @@ _ACEOF fi done - -for ac_func in vfork +for ac_func in backtrace geteuid mkstemp realpath strptime do : - ac_fn_c_check_func "$LINENO" "vfork" "ac_cv_func_vfork" -if test "x$ac_cv_func_vfork" = x""yes; then : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_VFORK 1 +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF -else - IGNORE="$IGNORE exec posix signal eventloop" fi done -for ac_func in syslog -do : - ac_fn_c_check_func "$LINENO" "syslog" "ac_cv_func_syslog" -if test "x$ac_cv_func_syslog" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SYSLOG 1 -_ACEOF -else - IGNORE="$IGNORE syslog" -fi -done +EXTRA_CFLAGS=$EXTRA_CFLAGS -for ac_func in regcomp -do : - ac_fn_c_check_func "$LINENO" "regcomp" "ac_cv_func_regcomp" -if test "x$ac_cv_func_regcomp" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_REGCOMP 1 -_ACEOF +SRCDIR=`dirname $0` -else - IGNORE="$IGNORE regexp" -fi -done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } @@ -3571,93 +3532,11 @@ $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : LIBDL=-ldl -else - IGNORE="$IGNORE load" -fi - - -# Does mkdir() include a mode_t argument? -ac_fn_c_check_decl "$LINENO" "mkdir" "ac_cv_have_decl_mkdir" "$ac_includes_default" -if test "x$ac_cv_have_decl_mkdir" = x""yes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_MKDIR $ac_have_decl -_ACEOF -if test $ac_have_decl = 1; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if mkdir takes 2 arguments" >&5 -$as_echo_n "checking if mkdir takes 2 arguments... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - #include - -int -main () -{ -(void)mkdir("dummy"); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -$as_echo "#define MKDIR_ONE_ARG /**/" >>confdefs.h - - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi -# Remove extensions in $IGNORE from $jim_extensions - -for i in $IGNORE; do - jim_extensions=`echo "$jim_extensions" | sed -e "s/$i//"` -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: enabling jim extensions: $jim_extensions" >&5 -$as_echo "enabling jim extensions: $jim_extensions" >&6; } -JIM_EXTENSIONS=$jim_extensions - -for i in $jim_extensions; do - EXTRA_CFLAGS="$EXTRA_CFLAGS -Djim_ext_$i" -done - -JIM_LIBTYPE=static - -# Check whether --with-jim-shared was given. -if test "${with_jim_shared+set}" = set; then : - withval=$with_jim_shared; - if test "x$withval" = "xyes" ; then - JIM_LIBTYPE=shared - fi - - -fi - -JIM_LIBTYPE=$JIM_LIBTYPE - - - -EXTRA_CFLAGS=$EXTRA_CFLAGS - -SRCDIR=`dirname $0` - - ac_config_files="$ac_config_files Makefile" -ac_config_files="$ac_config_files jim.h" - cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -4163,7 +4042,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by jim $as_me 0.62, which was +This file was extended by jim $as_me 0.63, which was generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4225,7 +4104,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -jim config.status 0.62 +jim config.status 0.63 configured by $0, generated by GNU Autoconf 2.65, with options \\"\$ac_cs_config\\" @@ -4340,9 +4219,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 for ac_config_target in $ac_config_targets do case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "autoconf.h") CONFIG_HEADERS="$CONFIG_HEADERS autoconf.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "jim.h") CONFIG_FILES="$CONFIG_FILES jim.h" ;; *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac diff --git a/configure.ac b/configure.ac old mode 100644 new mode 100755 index 4b2712d..ddc9e3a --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.57) -AC_INIT([jim], [0.62], [steveb@workware.net.au]) -AC_CONFIG_HEADERS([config.h]) +AC_INIT([jim], [0.63], [steveb@workware.net.au]) +AC_CONFIG_HEADER(autoconf.h) # Checks for programs. AC_PROG_CC @@ -12,7 +12,6 @@ AC_PROG_MAKE_SET # Checks for types AC_CHECK_TYPES(long long,AC_SUBST(HAVE_LONG_LONG,["#define HAVE_LONG_LONG"])) - # Shared library support. Because we don't believe in automake! AC_CANONICAL_HOST case $host in @@ -25,11 +24,11 @@ case $host in esac AC_ARG_ENABLE(fork, - [ --disable-fork do not use fork], + [ --disable-fork do not use fork (no exec, etc.)], [ if test "x$enableval" = "xno" ; then AC_MSG_RESULT(* disabling fork) - EXTRA_CFLAGS="-DHAVE_NO_FORK" + EXTRA_CFLAGS="-DJIM_NOFORK" fi ], ) @@ -53,35 +52,6 @@ AC_ARG_WITH(jim-ext, fi ] ) - -AC_CHECK_FUNCS([backtrace geteuid lstat mkstemp fork strptime sysinfo ualarm]) - -AC_CHECK_FUNCS(vfork,,IGNORE="$IGNORE exec posix signal eventloop") -AC_CHECK_FUNCS(syslog,,IGNORE="$IGNORE syslog") -AC_CHECK_FUNCS(regcomp,,IGNORE="$IGNORE regexp") -AC_CHECK_LIB(dl, dlopen, AC_SUBST(LIBDL,-ldl), IGNORE="$IGNORE load") - -# Does mkdir() include a mode_t argument? -AC_CHECK_DECLS(mkdir, - [AC_MSG_CHECKING(if mkdir takes 2 arguments) - AC_TRY_COMPILE( - [#include - #include - ], - [(void)mkdir("dummy");], - [AC_MSG_RESULT(no) - AC_DEFINE(MKDIR_ONE_ARG,[],[Define if mkdir(2) takes a single argument (no mode)]) - ], - [AC_MSG_RESULT(yes)], - )] -) - -# Remove extensions in $IGNORE from $jim_extensions - -for i in $IGNORE; do - jim_extensions=`echo "$jim_extensions" | sed -e "s/$i//"` -done - AC_MSG_RESULT(enabling jim extensions: $jim_extensions) AC_SUBST(JIM_EXTENSIONS,$jim_extensions) for i in $jim_extensions; do @@ -99,10 +69,13 @@ AC_ARG_WITH(jim-shared, ) AC_SUBST(JIM_LIBTYPE,$JIM_LIBTYPE) +AC_CHECK_FUNCS([ualarm sysinfo lstat fork vfork]) +AC_CHECK_FUNCS([backtrace geteuid mkstemp realpath strptime]) AC_SUBST(EXTRA_CFLAGS,$EXTRA_CFLAGS) AC_SUBST(SRCDIR,`dirname $0`) +AC_CHECK_LIB(dl, dlopen,AC_SUBST(LIBDL,-ldl)) + AC_CONFIG_FILES([Makefile]) -AC_CONFIG_FILES([jim.h]) AC_OUTPUT diff --git a/doc/AIO-Extension.txt b/doc/AIO-Extension.txt deleted file mode 100644 index e69de29..0000000 diff --git a/doc/Embedder-HOWTO.txt b/doc/Embedder-HOWTO.txt deleted file mode 100644 index e69de29..0000000 diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index eef7bcb..0000000 --- a/doc/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -TCLSH := $(shell which jimsh) -ifeq ($(TCLSH),) -TCLSH := $(shell which tclsh) -endif - -all: Tcl.html - -Tcl.html: jim_tcl.txt make-index - $(TCLSH) make-index < jim_tcl.txt | asciidoc -o $@ -d manpage - diff --git a/doc/Sqlite-Extension.txt b/doc/Sqlite-Extension.txt deleted file mode 100644 index 4346d25..0000000 --- a/doc/Sqlite-Extension.txt +++ /dev/null @@ -1,177 +0,0 @@ -Jim Sqlite extension documentation. -Copyright 2005 Salvatore Sanfilippo - - -Overview -~~~~~~~~ - -The Sqlite extension makes possible to work with sqlite (http://www.sqlite.org) -databases from Jim. SQLite is a small C library that implements a -self-contained, embeddable, zero-configuration SQL database engine. This -means it is perfect for embedded systems, and for stand-alone applications -that need the power of SQL without to use an external server like Mysql. - -Basic usage -~~~~~~~~~~~ - -The Sqlite extension exports an Object Based interface for databases. In order -to open a database use: - - set f [sqlite.open dbname] - -The [sqlite.open] command returns a db handle, that is a command name that -can be used to perform operations on the database. A real example: - - . set db [sqlite.open test.db] - sqlite.handle0 - . $db query "SELECT * from tbl1" - {one hello! two 10} {one goodbye two 20} - -In the second line the handle is used as a command name, followed -by the 'method' or 'subcommand' ("query" in the example), and the arguments. - -The query method -~~~~~~~~~~~~~~~~ - -The query method has the following signature: - - $db query SqlQuery ?args? - -The sql query may contain occurrences of "%s" that are substituted -in the actual query with the following arguments, quoted in order -to make sure that the query is correct even if this arguments contain -"'" characters. So for example it is possible to write: - - . $db query "SELECT * from tbl1 WHERE one='%s'" hello! - {one hello! two 10} - -Instead of hello! it is possible to use a string with embedded "'": - - . $db query "SELECT * from tbl1 WHERE one='%s'" a'b - (no matches - the empty list is returned) - -This does not work instead using the Tcl variable expansion in the string: - - . $db query "SELECT * from tbl1 WHERE one='$foo'" - Runtime error, file "?", line 1: - near "b": syntax error - -In order to obtain an actual '%' character in the query, there is just -to use two, like in "foo %% bar". This is the same as the [format] argument. - -Specification of query results -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In one of the above examples, the following query was used: - - . $db query "SELECT * from tbl1" - {one hello! two 10} {one goodbye two 20} - -As you can see the result of a query is a list of lists. Every -element of the list represents a row, as a list of key/value pairs, -so actually every row is a Jim dictionary. - -The following example and generated output show how to take advantage -of this representation: - - . set res [$db query "SELECT * from tbl1"] - {one hello! two 10} {one goodbye two 20} - . foreach row $res {puts "One: $row(one), Two: $row(two)"} - One: hello!, Two: 10 - One: goodbye, Two: 20 - -To access every row sequentially is very simple, and field of a row -can be accessed using the $row(field) syntax. - -The close method -~~~~~~~~~~~~~~~~ - -In order to close the db, use the 'close' method that will have as side effect -to close the db and to remove the command associated with the db. -Just use: - - $db close - -Handling NULL values -~~~~~~~~~~~~~~~~~~~~ - -In the SQL language there is a special value NULL that is not the empty -string, so how to represent it in a typeless language like Tcl? -For default this extension will use the empty string, but it is possible -to specify a different string for the NULL value. - -In the above example there were two rows in the 'tbl1' table. Now -we can add usign the "sqlite" command line client another one with -a NULL value: - - sqlite> INSERT INTO tbl1 VALUES(NULL,30); - sqlite> .exit - -That's what the sqlite extension will return for default: - - . $db query "SELECT * from tbl1" - {one hello! two 10} {one goodbye two 20} {one {} two 30} - -As you can see in the last row, the NULL is represented as {}, that's -the empty string. Using the -null option of the 'query' command we -can change this default, and tell the sqlite extension to represent -the NULL value as a different string: - - . $db query -null <> "SELECT * from tbl1" - {one hello! two 10} {one goodbye two 20} {one <> two 30} - -This way if the emtpy string has some semantical value for your -dataset you can change it. - -Finding the ID of the last inserted row -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -This is as simple as: - - . $db lastid - 10 - -Number of rows changed by the most recent query -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -This is also very simple, there is just to use the 'changes' method -without arugments. - - . $db changes - 5 - -Note that if you drop an entire table the number of changes will -be reported as zero, because of details of the sqlite implementation. - -That's all, -Enjoy! -Salvatore Sanfilippo - -p.s. this extension is just the work of some hour thanks to the cool -clean C API that sqlite exports. Thanks to the author of sqlite for this -great work. - -In memory databases -~~~~~~~~~~~~~~~~~~~ - -SQLite is able to create in-memory databases instead to use files. -This is of course faster and does not need the ability to write -to the filesystem. Of course this databases are only useful for -temp data. - -In-memory DBs are used just like regular databases, just the name used to -open the database is :memory:. That's an example that does not use the -filesystem at all to create and work with the db. - - package require sqlite - set db [sqlite.open :memory:] - $db query {CREATE TABLE plays (id, author, title)} - $db query {INSERT INTO plays (id, author, title) VALUES (1, 'Goethe', 'Faust');} - $db query {INSERT INTO plays (id, author, title) VALUES (2, 'Shakespeare', 'Hamlet');} - $db query {INSERT INTO plays (id, author, title) VALUES (3, 'Sophocles', 'Oedipus Rex');} - set res [$db query "SELECT * FROM plays"] - $db close - foreach r $res {puts $r(author)} - -Of course once the Jim process is destroyed the database will no longer -exists. diff --git a/doc/Tcl.html.supplied b/doc/Tcl.html.supplied deleted file mode 100644 index e69de29..0000000 diff --git a/doc/jim_man.txt b/doc/jim_man.txt deleted file mode 100644 index fca664c..0000000 --- a/doc/jim_man.txt +++ /dev/null @@ -1,98 +0,0 @@ -Jim(n) -====== - -NAME ----- -Jim - a better Tcl - -SYNOPSIS --------- - - cc -ltcl6 - -or - - jimsh