mirror of
https://github.com/janet-lang/janet
synced 2025-02-23 03:30:02 +00:00
Fix os.getenv error.
This commit is contained in:
parent
24f153a3bf
commit
90496b99e8
@ -133,6 +133,12 @@ void dstc_popscope(DstCompiler *c) {
|
||||
}
|
||||
|
||||
}
|
||||
/* Parent scopes inherit child's closure flag. Needed
|
||||
* for while loops. (if a while loop creates a closure, it
|
||||
* is compiled to a tail recursive iife) */
|
||||
if (oldscope->flags & DST_SCOPE_CLOSURE) {
|
||||
newscope->flags |= DST_SCOPE_CLOSURE;
|
||||
}
|
||||
/* Free the old scope */
|
||||
dst_v_free(oldscope->consts);
|
||||
dst_v_free(oldscope->syms);
|
||||
|
@ -90,6 +90,7 @@ struct DstSlot {
|
||||
#define DST_SCOPE_ENV 2
|
||||
#define DST_SCOPE_TOP 4
|
||||
#define DST_SCOPE_UNUSED 8
|
||||
#define DST_SCOPE_CLOSURE 16
|
||||
|
||||
/* A symbol and slot pair */
|
||||
typedef struct SymPair {
|
||||
|
@ -153,6 +153,9 @@ static int os_getenv(DstArgs args) {
|
||||
DST_ARG_STRING(k, args, 0);
|
||||
const char *cstr = (const char *) k;
|
||||
const char *res = getenv(cstr);
|
||||
if (!res) {
|
||||
DST_RETURN_NIL(args);
|
||||
}
|
||||
DST_RETURN(args, cstr
|
||||
? dst_cstringv(res)
|
||||
: dst_wrap_nil());
|
||||
|
@ -1152,7 +1152,7 @@ int dst_lib_compile(DstArgs args);
|
||||
#define DST_ARG_CFUNCTION(DEST, A, N) _DST_ARG(DST_CFUNCTION, cfunction, DEST, A, N)
|
||||
#define DST_ARG_ABSTRACT(DEST, A, N) _DST_ARG(DST_ABSTRACT, abstract, DEST, A, N)
|
||||
|
||||
#define DST_RETURN_NIL(A) return DST_SIGNAL_OK
|
||||
#define DST_RETURN_NIL(A) do { return DST_SIGNAL_OK; } while (0)
|
||||
#define DST_RETURN_FALSE(A) DST_RETURN(A, dst_wrap_false())
|
||||
#define DST_RETURN_TRUE(A) DST_RETURN(A, dst_wrap_true())
|
||||
#define DST_RETURN_BOOLEAN(A, X) DST_RETURN(A, dst_wrap_boolean(X))
|
||||
|
Loading…
x
Reference in New Issue
Block a user