From 97fd55353a2cc0b874e30a3c3ed63bf0ec2edc59 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Mon, 4 Apr 2016 05:24:45 +1000 Subject: [PATCH] bootstrap: Add minimal package require support Makes it easier to run the test suite if a minmal 'package require' is supported. Also omit SSL code from jim-aio.c Signed-off-by: Steve Bennett --- bootstrap.tcl | 15 ++++++++++++--- jim-aio.c | 20 ++++++++++---------- make-bootstrap-jim | 2 +- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/bootstrap.tcl b/bootstrap.tcl index e7adf4b6..f6c404fa 100644 --- a/bootstrap.tcl +++ b/bootstrap.tcl @@ -1,3 +1,12 @@ -# No need for package support in the bootstrap jimsh, but -# Tcl extensions call package require -proc package {args} {} +# Minimal support for package require +# No error on failure since C extensions aren't handled +proc package {cmd pkg} { + if {$cmd eq "require"} { + foreach path $::auto_path { + if {[file exists $path/$pkg.tcl]} { + uplevel #0 [list source $path/$pkg.tcl] + return + } + } + } +} diff --git a/jim-aio.c b/jim-aio.c index 0d11648f..cefcaf83 100644 --- a/jim-aio.c +++ b/jim-aio.c @@ -192,7 +192,7 @@ static const JimAioFopsType stdio_fops = { NULL }; -#if defined(JIM_SSL) +#if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP) static SSL_CTX *JimAioSslCtx(Jim_Interp *interp); @@ -270,7 +270,7 @@ static const JimAioFopsType ssl_fops = { ssl_strerror, ssl_verify }; -#endif +#endif /* JIM_BOOTSTRAP */ static int JimAioSubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv); static AioFile *JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filename, @@ -1053,7 +1053,7 @@ static int aio_cmd_onexception(Jim_Interp *interp, int argc, Jim_Obj *const *arg } #endif -#if defined(JIM_SSL) +#if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP) static int aio_cmd_ssl(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { AioFile *af = Jim_CmdPrivData(interp); @@ -1156,7 +1156,7 @@ static int aio_cmd_verify(Jim_Interp *interp, int argc, Jim_Obj *const *argv) } return ret; } -#endif +#endif /* JIM_BOOTSTRAP */ static const jim_subcmd_type aio_command_table[] = { { "read", @@ -1315,7 +1315,7 @@ static const jim_subcmd_type aio_command_table[] = { /* Description: Returns script, or invoke exception-script when oob data, {} to remove */ }, #endif -#if defined(JIM_SSL) +#if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP) { "ssl", "?-server cert priv?", aio_cmd_ssl, @@ -1331,7 +1331,7 @@ static const jim_subcmd_type aio_command_table[] = { 0, /* Description: Verifies the certificate of a SSL/TLS channel */ }, -#endif +#endif /* JIM_BOOTSTRAP */ { NULL } }; @@ -1371,7 +1371,7 @@ static int JimAioOpenCommand(Jim_Interp *interp, int argc, return JimMakeChannel(interp, NULL, -1, argv[1], "aio.handle%ld", 0, mode) ? JIM_OK : JIM_ERR; } -#if defined(JIM_SSL) +#if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP) static void JimAioSslContextDelProc(struct Jim_Interp *interp, void *privData) { SSL_CTX_free((SSL_CTX *)privData); @@ -1394,7 +1394,7 @@ static SSL_CTX *JimAioSslCtx(Jim_Interp *interp) } return ssl_ctx; } -#endif +#endif /* JIM_BOOTSTRAP */ /** * Creates a channel for fh/fd/filename. @@ -1824,7 +1824,7 @@ int Jim_MakeTempFile(Jim_Interp *interp, const char *template) #endif } -#if defined(JIM_SSL) +#if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP) static int JimAioLoadSSLCertsCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { SSL_CTX *ssl_ctx; @@ -1844,7 +1844,7 @@ static int JimAioLoadSSLCertsCommand(Jim_Interp *interp, int argc, Jim_Obj *cons Jim_SetResultString(interp, ERR_error_string(ERR_get_error(), NULL), -1); return JIM_ERR; } -#endif +#endif /* JIM_BOOTSTRAP */ int Jim_aioInit(Jim_Interp *interp) { diff --git a/make-bootstrap-jim b/make-bootstrap-jim index 929eb4e7..ba3b2f86 100755 --- a/make-bootstrap-jim +++ b/make-bootstrap-jim @@ -44,7 +44,7 @@ cexts="aio readdir regexp file exec clock array" tclexts="bootstrap initjimsh glob stdlib tclcompat" # Note ordering -allexts="bootstrap aio readdir glob regexp file exec clock array stdlib tclcompat" +allexts="bootstrap aio readdir regexp file glob exec clock array stdlib tclcompat" echo "/* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */"