From 1a6115e949ec6b60a3482c2523216afe1023ab25 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sat, 19 Sep 2020 23:41:34 +0100 Subject: [PATCH] Fix Muddle's CLOSE not flushing the output buffer. There were two problems here: - The FOPEN code in 56 uses new C.DISK/C.TTY flags to keep track of the channel type, so it knew what to do when closing the channel. The TOPS-20 open code had been modified to set these, but the ITS code hadn't, so CLOSE was assuming all channels were network channels. Fix: set those flags in ODSK and OTTY, as TOPS-20 does. - The BFCDSK flush routine had been modified to use byte pointer writes to write the last incomplete word for both TOPS-20 (SOUT) and ITS (SIOT). But on ITS, SIOT only works in unit mode, and Muddle opens files in block mode. Fix: restore the working code from Muddle 54 for writing the last word. The only difference is that BFCDSK can now be invoked with the leftover byte count (C) being zero, so it needs to check at the start to avoid duplicating the last word in that case. --- src/mudsys/fopen.36 | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/mudsys/fopen.36 b/src/mudsys/fopen.36 index da0bef55..8c7da90b 100644 --- a/src/mudsys/fopen.36 +++ b/src/mudsys/fopen.36 @@ -896,6 +896,8 @@ IFN ITS,[ ODSK: MOVE A,S.SNM(C) ; GET SNAME .SUSET [.SSNAM,,A] ; CLOBBER IT PUSHJ P,OPEN0 ; DO REAL LIVE OPEN + MOVEI 0,C.DISK + IORM 0,-2(B) ] IFE ITS,[ @@ -1759,6 +1761,8 @@ TTYLP2: MOVE C,T.SPDL+1(TB) ; POINT TO P BASE IORI A,20 ; THEN USE DISPLAY MODE HRLM A,S.DIR(C) ; STORE IN OPEN BLOCK PUSHJ P,OPEN2 ; OPEN THE TTY + MOVEI 0,C.TTY + IORM 0,-2(B) MOVE A,S.DEV(C) ; GET DEVICE NAME PUSHJ P,6TOCHS ; TO A STRING MOVE D,T.CHAN+1(TB) ; POINT TO CHANNEL @@ -4223,9 +4227,19 @@ IFE ITS,[ SUB TP,[2,,2] ] IFN ITS,[ - MOVE D,[440700,,A] - DOTCAL SIOT,[CHANNO(B),D,C] - .LOSE %LSFIL ;PRESUMABLY LOSSAGE MATTERS + JUMPE C,BFCDF2 ; NO CHARS LEFT TO WRITE? + PUSH P,[-5] ; KLUDGE ADDED TO FILL LAST WORD WITH ^C + ADDM C,(P) + MOVE C,A ; FOR FUNNY AOBJN PTR + HLL C,BUFSTR(B) ; POINT INTO WORD AFTER LAST CHAR + MOVEM 0,(A) + MOVEI 0,3 ; CONTROL C +BFCDF1: IDPB 0,C + AOSE (P) + JRST BFCDF1 + SUB P,[1,,1] + PUSHJ P,PGBIOO +BFCDF2: ] POP P,C JUMPN C,BFCLSD