From e2ebfbb7d19ff3b990eb51dc9843200053cbbf98 Mon Sep 17 00:00:00 2001 From: glenda Date: Sat, 10 Sep 2022 16:25:05 +0000 Subject: Improve the session a lot --- main.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index adcc662..e1734f9 100644 --- a/main.c +++ b/main.c @@ -9,6 +9,7 @@ Biobuf *stdin; static int booted = 0; static Rune *startfile = L"runtime/start.apl"; +static Rune *stdlibfile = L"runtime/stdlib.apl"; void threadmain(int argc, char *argv[]) @@ -34,15 +35,7 @@ threadmain(int argc, char *argv[]) ErrorGuard *eg = newerrorguard(mkscalarint(0), nil); restart: if(setjmp(eg->jmp)){ - ThreadData *td = getthreaddata(); - Rune *msg = errorstr(td->lasterror); - if(td->lasterrormsg){ - if(runestrlen(msg) == 0) - print("%S\n", td->lasterrormsg); - else - print("%S: %S\n", errorstr(td->lasterror), td->lasterrormsg); - }else - print("%S\n", errorstr(td->lasterror)); + displayerror(); while(getcurrentdfn()) popdfnframe(); goto restart; @@ -50,20 +43,21 @@ restart: if(!booted){ booted = 1; - Array *path = mkrunearray(startfile); - runfile(path); - freearray(path); + runfile(mkrunearray(stdlibfile)); + runfile(mkrunearray(startfile)); } while(!off){ checkmem("main loop"); - /* if(needsnewline){ - print("\n"); - needsnewline = 0; - } */ Datum *result = evalline(nil, stdin, 1); if(result && !result->shy) - setquotequad(result); + setquad(result); + else{ + Datum *dummy = allocdatum(ArrayTag, 0); + dummy->array = mkrunearray(L""); + setquad(dummy); + freedatum(dummy); + } freedatum(result); /* print("Unfreed arrays: %d\n", arrayalloccounts); -- cgit v1.2.3