From e59277504e7b7441729a2c6a097c72eb4142704d Mon Sep 17 00:00:00 2001 From: glenda Date: Sun, 11 Sep 2022 09:42:42 +0000 Subject: Better handling of shy results in the session --- main.c | 8 +------- quadnames.c | 8 ++++++-- runtime/start.apl | 11 ++++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/main.c b/main.c index f74468c..17ab041 100644 --- a/main.c +++ b/main.c @@ -50,14 +50,8 @@ restart: while(!off){ checkmem("main loop"); Datum *result = evalline(nil, stdin, 1); - if(result && !result->shy) + if(result) outputmain(result); - else{ - Datum *dummy = allocdatum(ArrayTag, 0); - dummy->array = mkrunearray(L""); - outputmain(dummy); - freedatum(dummy); - } freedatum(result); /* print("Unfreed arrays: %d\n", arrayalloccounts); diff --git a/quadnames.c b/quadnames.c index f00de5e..0727d3e 100644 --- a/quadnames.c +++ b/quadnames.c @@ -169,12 +169,16 @@ void outputmain(Datum *d) { Rune *str = ppdatum(d); - Array *strarray = mkrunearray(str); + Array *data = allocarray(AtypeArray, 1, 2); + data->shape[0] = 2; + data->arraydata[0] = mkscalarint(d->shy); + data->arraydata[1] = mkrunearray(str); if(session) - rundfn(L"0::⎕RAWIO←⍶ ⋄ ('→' ⍺) ⍈ ⍵", d, nil, strarray, session); + rundfn(L"0::⎕RAWIO←⍶ ⋄ ('→' (⍺)) ⍈ ⍵", d, nil, data, session); else setquadrawio(d); free(str); + freearray(data); } /* ⎕RAWIO */ diff --git a/runtime/start.apl b/runtime/start.apl index d65d0bc..64b8be8 100644 --- a/runtime/start.apl +++ b/runtime/start.apl @@ -8,9 +8,11 @@ } handleMain←{ 0::⍺ - data←⍵ - ⎕rawio←data - ⎕rawio←⎕ucs 10 + (shy data)←⍵ + _←{ + ⎕rawio←data + ⎕rawio←⎕ucs 10 + } IF ~shy ⎕rawio←prompt ≢prompt } @@ -28,8 +30,7 @@ data←⍵ ⎕rawio←data ⎕rawio←⎕ucs 10 - ⎕rawio←prompt - ≢prompt + 0 } handleQuoteQuad←{ 0::⍺ -- cgit v1.2.3