diff options
author | antirez <antirez> | 2005-04-02 10:08:33 +0000 |
---|---|---|
committer | antirez <antirez> | 2005-04-02 10:08:33 +0000 |
commit | 49e34e447b54aad20aac86b17c38b35ca7b1203a (patch) | |
tree | 61046b422b849bac9e49a13da7e165ae13005340 | |
parent | 69fdf299c3480aac7f22bbe8ec45b0fe5168a9cc (diff) | |
download | jimtcl-49e34e447b54aad20aac86b17c38b35ca7b1203a.zip jimtcl-49e34e447b54aad20aac86b17c38b35ca7b1203a.tar.gz jimtcl-49e34e447b54aad20aac86b17c38b35ca7b1203a.tar.bz2 |
Added a very immature start of a Jim standard library.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | jim-stdlib-1.0.tcl | 41 | ||||
-rw-r--r-- | jim.c | 19 |
4 files changed, 62 insertions, 5 deletions
@@ -1,3 +1,8 @@ +2005-04-02 11:09 antirez + + * ChangeLog, Makefile: Changes to Makefile to reflect that now + libraries must have the version in the .so/.dll filename. + 2005-04-02 10:54 antirez * ChangeLog, jim.c: win32 opendir() and related compatibility API. @@ -27,7 +27,7 @@ INSTALL_PROGRAM= $(INSTALL) INSTALL_DATA= $(INSTALL) -m 644 DESTDIR = /usr/local/bin/ -PROGRAMS = jim +PROGRAMS = jim jim.exe JIM_OBJECTS = jim.o jimsh.o LIBS = -ldl diff --git a/jim-stdlib-1.0.tcl b/jim-stdlib-1.0.tcl new file mode 100644 index 0000000..a2c555f --- /dev/null +++ b/jim-stdlib-1.0.tcl @@ -0,0 +1,41 @@ +# Jim stdlib - a pure-Jim extension library for Jim +# +# Copyright 2005 Salvatore Sanfilippo <antirez@invece.org> +# +# $Id: jim-stdlib-1.0.tcl,v 1.1 2005/04/02 10:08:33 antirez Exp $ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# A copy of the license is also included in the source distribution +# of Jim, as a TXT file name called LICENSE. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# To use this library just do [package require stdlib] +# Make sure this file is in one directory specified in $jim_libpath + +package provide stdlib 1.0 + +### Functional programming ### + +proc curry {cmd args} { + lambda args [list cmd [list pref $args]] { + uplevel 1 [list $cmd {expand}$pref {expand}$args] + } +} + +### Control structures ### + +proc repeat {n body} { + for {set i 0} {$i < $n} {incr i} { + uplevel 1 $body + } +} @@ -2,7 +2,7 @@ * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org> * Copyright 2005 Clemens Hintze <c.hintze@gmx.net> * - * $Id: jim.c,v 1.141 2005/04/02 08:54:27 antirez Exp $ + * $Id: jim.c,v 1.142 2005/04/02 10:08:33 antirez Exp $ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -7397,6 +7397,10 @@ static int JimPackageMatchVersion(int needed, int actual, int flags) int Jim_PackageProvide(Jim_Interp *interp, const char *name, const char *ver, int flags) { + int intVersion; + /* Check if the version format is ok */ + if (JimPackageVersionToInt(interp, ver, &intVersion, JIM_ERRMSG) != JIM_OK) + return JIM_ERR; /* If the package was already provided returns an error. */ if (Jim_FindHashEntry(&interp->packages, name) != NULL) { if (flags & JIM_ERRMSG) { @@ -11295,9 +11299,9 @@ static int Jim_PackageCoreCommand(Jim_Interp *interp, int argc, { int option; const char *options[] = { - "require", NULL + "require", "provide", NULL }; - enum {OPT_REQUIRE}; + enum {OPT_REQUIRE, OPT_PROVIDE}; if (argc < 2) { Jim_WrongNumArgs(interp, 1, argv, "option ?arguments ...?"); @@ -11326,6 +11330,13 @@ static int Jim_PackageCoreCommand(Jim_Interp *interp, int argc, if (ver == NULL) return JIM_ERR; Jim_SetResultString(interp, ver, -1); + } else if (option == OPT_PROVIDE) { + if (argc != 4) { + Jim_WrongNumArgs(interp, 2, argv, "package version"); + return JIM_ERR; + } + return Jim_PackageProvide(interp, Jim_GetString(argv[2], NULL), + Jim_GetString(argv[3], NULL), JIM_ERRMSG); } return JIM_OK; } @@ -11462,7 +11473,7 @@ int Jim_InteractivePrompt(Jim_Interp *interp) printf("Welcome to Jim version %d.%d, " "Copyright (c) 2005 Salvatore Sanfilippo\n", JIM_VERSION / 100, JIM_VERSION % 100); - printf("CVS ID: $Id: jim.c,v 1.141 2005/04/02 08:54:27 antirez Exp $\n"); + printf("CVS ID: $Id: jim.c,v 1.142 2005/04/02 10:08:33 antirez Exp $\n"); Jim_SetVariableStrWithStr(interp, "jim_interactive", "1"); while (1) { char buf[1024]; |