diff --git a/src/core/core.janet b/src/core/core.janet index 4de55615..fd797b40 100644 --- a/src/core/core.janet +++ b/src/core/core.janet @@ -1687,18 +1687,20 @@ value, one key will be ignored." table." [env path & args] (def {:as as - :prefix prefix} (table ;args)) + :prefix prefix + :export ep} (table ;args)) (def newenv (require path ;args)) (def prefix (or (and as (string as "/")) prefix (string path "/"))) (loop [[k v] :pairs newenv :when (not (v :private))] - (def newv (table/setproto @{:private true} v)) + (def newv (table/setproto @{:private (not ep)} v)) (put env (symbol prefix k) newv))) (defmacro import "Import a module. First requires the module, and then merges its symbols into the current environment, prepending a given prefix as needed. (use the :as or :prefix option to set a prefix). If no prefix is provided, - use the name of the module as a prefix." + use the name of the module as a prefix. One can also use :export true + to re-export the imported symbols." [path & args] (def argm (map (fn [x] (if (keyword? x) diff --git a/src/core/io.c b/src/core/io.c index 2f89c53f..204d440e 100644 --- a/src/core/io.c +++ b/src/core/io.c @@ -404,7 +404,7 @@ static const JanetReg io_cfuns[] = { FILE *janet_getfile(const Janet *argv, int32_t n, int *flags) { IOFile *iof = janet_getabstract(argv, n, &cfun_io_filetype); - *flags = iof->flags; + if (NULL != flags) *flags = iof->flags; return iof->file; } diff --git a/src/include/janet.h b/src/include/janet.h index edffaf83..b909dcfe 100644 --- a/src/include/janet.h +++ b/src/include/janet.h @@ -1256,7 +1256,6 @@ JANET_API int32_t janet_getargindex(const Janet *argv, int32_t n, int32_t length JANET_API FILE *janet_getfile(const Janet *argv, int32_t n, int *flags); - /* Marshal API */ JANET_API void janet_marshal_int(JanetMarshalContext *ctx, int32_t value); JANET_API void janet_marshal_byte(JanetMarshalContext *ctx, uint8_t value);