Skip to content

Commit 0d2c662

Browse files
authored
Format implementation functions set a known variable *BYTECOUNTER* (#402)
* Format implementation functions set a known variable *BYTECOUNTER* The generic functions deal with updating the application variable. \INCHAR eliminated in favor of \INCCODE.EOLC to make clear what it does. OPENSTRINGSTREAM streams have their own format, and the string is always fattened. READBITMAP doesn't mix character and byte reading * AOFD: Don't execute \STRINGSTREAM.INIT This creates a file device that is not used anywhere. The function OPENSTRINGSTREAM provides the functionality that this file device suggests that it would provide, but that functionality seems suspect at best. The function is left in the system for now, probably should be deleted at some point in the future so we don't try to maintain it if we trip over it. * TTYIN: Fix an ancient coding error but still doesn't solve the (DIRECTORY ?= problem #402 * LLREAD, FILEIO, XCCS: Improve charcode backing, copychars Added \BACKCCODE.EOLC that backs up over EOL encoding bytes, simplifies \RSTRING2. \XCCSBACKCCODE returns T/NIL according to whether it succeeded. \XCCSOUTCHAR uses IPLUS16 for CHARPOSITION COPYCHARS makes no assumptions about EOL encoding But still no solution for #402 * LLREAD, TTYIN.LCOM fix #402 The bug showed up in TTYIN, but it was actually a bad edit in the generic backccode. TTYIN.LCOM is just a recompile--that had never been done with various new declarations.
1 parent d6d4795 commit 0d2c662

File tree

24 files changed

+1325
-803
lines changed

24 files changed

+1325
-803
lines changed

library/UNICODE

Lines changed: 155 additions & 48 deletions
Large diffs are not rendered by default.

library/UNICODE.LCOM

-158 Bytes
Binary file not shown.

lispusers/ISO8859IO

Lines changed: 90 additions & 77 deletions
Large diffs are not rendered by default.

lispusers/ISO8859IO.LCOM

-3.58 KB
Binary file not shown.

sources/AOFD

Lines changed: 126 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
(DEFINE-FILE-INFO READTABLE "INTERLISP" PACKAGE "INTERLISP")
2-
(FILECREATED "13-Jun-2021 11:35:32" {DSK}<Users>kaplan>Local>medley3.5>git-medley>sources>AOFD.;2 35745
1+
(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10 FORMAT XCCS)
2+
(FILECREATED " 9-Aug-2021 23:30:19" {DSK}<Users>kaplan>Local>medley3.5>git-medley>sources>AOFD.;5 38301
33

4-
changes to%: (FNS CLOSEF INPUT OUTPUT RANDACCESSP \MAKEBASEBYTESTREAM \BASEBYTES.PEEKBIN
5-
\SEARCHOPENFILES)
4+
changes to%: (VARS AOFDCOMS)
5+
(FNS \STRINGSTREAM.INIT)
66

7-
previous date%: "10-May-2021 15:44:43"
8-
{DSK}<Users>kaplan>Local>medley3.5>git-medley>sources>AOFD.;1)
7+
previous date%: " 8-Aug-2021 00:11:00"
8+
{DSK}<Users>kaplan>Local>medley3.5>git-medley>sources>AOFD.;4)
99

1010

1111
(* ; "
@@ -36,12 +36,15 @@ Copyright (c) 1981-1987, 1990, 2021 by Venue & Xerox Corporation.
3636
\BASEBYTES.PEEKBIN \BASEBYTES.TRUNCATEFN \BASEBYTES.OPENFN \BASEBYTES.BLOCKIO)
3737
(GLOBALVARS \BASEBYTESDEVICE)
3838
(DECLARE%: DONTEVAL@LOAD (P (\BASEBYTES.IO.INIT)))
39-
(FNS OPENSTRINGSTREAM))
40-
[COMS
41-
(* ;; "STREAM interface for old-style strings")
39+
(FNS OPENSTRINGSTREAM MAKE-STRING-FORMAT)
40+
(P (MAKE-STRING-FORMAT)))
41+
(COMS
42+
(* ;; "STREAM interface for old-style strings. However (RMK), it appears never to be used, and even commonlisp string-streams are created using the Interlisp OPENSTRINGSTREAM above. For now, keep the function, but don't execute it")
4243

4344
(FNS \STRINGSTREAM.INIT)
44-
(DECLARE%: DONTEVAL@LOAD DOCOPY (P (\STRINGSTREAM.INIT]
45+
46+
(* ;; "(DECLARE%%: DONTEVAL@LOAD DOCOPY (P (\STRINGSTREAM.INIT)))")
47+
)
4548
(COMS (FNS GETSTREAM \ADDOFD \CLEAROFD \DELETEOFD \GETSTREAM \SEARCHOPENFILES)
4649
(DECLARE%: DONTCOPY (EXPORT (MACROS \INSTREAMARG \OUTSTREAMARG \STREAMARG)))
4750
(MACROS GETOFD \GETOFD))
@@ -532,50 +535,98 @@ Copyright (c) 1981-1987, 1990, 2021 by Venue & Xerox Corporation.
532535
(DEFINEQ
533536

534537
(OPENSTRINGSTREAM
535-
[LAMBDA (STR ACCESS) (* rmk%: "28-Mar-85 08:40")
536-
537-
(* ;; "Does not register the stream on \OPENFILES, nor does it search \OPENFILES for a previously opened stream. Thus, this implementation does not side-effect the string as the 10 does. However, the temporary coercion of strings to open streams in \GETSTREAM does simulate the side-effecting. Note that a string stream is unnamed.")
538-
539-
(PROG (STREAM FATP)
540-
(OR (STRINGP STR)
541-
(\ILLEGAL.ARG STR))
542-
(SETQ FATP (ffetch (STRINGP FATSTRINGP) of STR))
543-
[SETQ STREAM (\MAKEBASEBYTESTREAM (OR (ffetch (STRINGP BASE) of STR)
544-
T)
545-
(COND
546-
(FATP (UNFOLD (ffetch (STRINGP OFFST) of STR)
547-
BYTESPERWORD))
548-
(T (ffetch (STRINGP OFFST) of STR)))
549-
(COND
550-
(FATP (UNFOLD (ffetch (STRINGP LENGTH) of STR)
551-
BYTESPERWORD))
552-
(T (ffetch (STRINGP LENGTH) of STR)))
553-
(SELECTQ ACCESS
554-
((INPUT OUTPUT BOTH)
555-
ACCESS)
556-
(NIL 'INPUT)
557-
(\ILLEGAL.ARG ACCESS]
558-
(PROGN (* ;
559-
"Minor differences between a basebytestream and a stringstream")
560-
(if FATP
561-
then (freplace (STREAM CHARSET) of STREAM with \NORUNCODE))
562-
(freplace USERCLOSEABLE of STREAM with T)
563-
(freplace USERVISIBLE of STREAM with T)
564-
(SELECTQ (SYSTEMTYPE)
565-
(VAX (freplace F2 of STREAM with 0)
566-
(freplace STRMBINFN of STREAM with (FUNCTION \STRINGBIN)))
567-
NIL))
568-
(RETURN STREAM])
538+
[LAMBDA (STR ACCESS) (* ; "Edited 8-Aug-2021 00:02 by rmk:")
539+
(* rmk%: "28-Mar-85 08:40")
540+
541+
(* ;; "We fatten thin strings at the start so that the byte-level functions (bin, bout, getfileptr, setfrileptr) give the same (2-bytes per character) picture of the byte sequence even if we started out thin.")
542+
543+
(* ;; "Does not register the stream on \OPENFILES, nor does it search \OPENFILES for a previously opened stream. ")
544+
545+
(SELECTQ ACCESS
546+
((INPUT OUTPUT BOTH))
547+
(NIL (SETQ ACCESS 'INPUT))
548+
(\ILLEGAL.ARG ACCESS))
549+
(CL:UNLESS (STRINGP STR)
550+
(\ILLEGAL.ARG STR))
551+
(LET (STREAM)
552+
(IF (AND (EQ ACCESS 'INPUT)
553+
(NOT (ffetch (STRINGP FATSTRINGP) of STR)))
554+
THEN (\FATTENSTRING STR)
555+
ELSE (\SMASHABLESTRING STR T))
556+
557+
(* ;; "String storage is now fat")
558+
559+
(SETQ STREAM (\MAKEBASEBYTESTREAM (OR (ffetch (STRINGP BASE) of STR)
560+
T)
561+
(UNFOLD (ffetch (STRINGP OFFST) of STR)
562+
BYTESPERWORD)
563+
(UNFOLD (ffetch (STRINGP LENGTH) of STR)
564+
BYTESPERWORD)
565+
ACCESS))
566+
567+
(* ;; "Differences between a basebytestream and a stringstream")
568+
569+
(\EXTERNALFORMAT STREAM :STRING)
570+
(freplace USERCLOSEABLE of STREAM with T)
571+
(freplace USERVISIBLE of STREAM with T)
572+
STREAM])
573+
574+
(MAKE-STRING-FORMAT
575+
[LAMBDA NIL (* ; "Edited 8-Aug-2021 00:10 by rmk:")
576+
577+
(* ;; "We are looking at an in-core string, we know that EOL is CR, that the characters have the internal (XCCS) encoding, and that the string is fat. ")
578+
579+
(MAKE-EXTERNALFORMAT :STRING [FUNCTION (LAMBDA (STRM COUNTP)
580+
(DECLARE (USEDFREE *BYTECOUNTER*))
581+
(CL:WHEN COUNTP (SETQ *BYTECOUNTER* 2))
582+
(\WIN STRM]
583+
[FUNCTION (LAMBDA (STRM NOERROR)
584+
(CL:WHEN (\PEEKBIN STRM NOERROR)
585+
586+
(* ;; "This guards against the EOF error")
587+
588+
(PROG1 (LOGOR (LLSH (\BIN STRM)
589+
8)
590+
(\PEEKBIN STRM NOERROR))
591+
(\BACKFILEPTR STRM)))]
592+
[FUNCTION (LAMBDA (STRM COUNTP)
593+
(DECLARE (USEDFREE *BYTECOUNTER*))
594+
(CL:WHEN (\BACKFILEPTR STRM)
595+
(IF (\BACKFILEPTR STRM)
596+
THEN (CL:WHEN COUNTP (SETQ *BYTECOUNTER* 2))
597+
T
598+
ELSEIF COUNTP
599+
THEN (SETQ *BYTECOUNTER* 1)))]
600+
[FUNCTION (LAMBDA (STRM CODE)
601+
(\WOUT STRM CODE)
602+
CODE]
603+
NIL
604+
'CR])
569605
)
570606

607+
(MAKE-STRING-FORMAT)
608+
571609

572610

573-
(* ;; "STREAM interface for old-style strings")
611+
(* ;;
612+
"STREAM interface for old-style strings. However (RMK), it appears never to be used, and even commonlisp string-streams are created using the Interlisp OPENSTRINGSTREAM above. For now, keep the function, but don't execute it"
613+
)
574614

575615
(DEFINEQ
576616

577617
(\STRINGSTREAM.INIT
578-
[LAMBDA NIL (* bvm%: "14-Feb-85 00:25")
618+
[LAMBDA NIL (* ; "Edited 9-Aug-2021 23:30 by rmk:")
619+
620+
(* ;; "RMK: This is described as creating a file device for %"old style%" strings. But the variable that it sets is never referenced. The common lisp functions that treat strings as streams all seem to go through OPENSTRINGSTREAM, which now has a proper external format.")
621+
622+
(* ;; "Moreover, it appears that the BIN function defined here, in terms of GNC, would have had the effect of updating the string pointer of the string as visible using ordinary string functions. ")
623+
624+
(* ;; "Finally, this appears to be read only. No BOUT is provided.")
625+
626+
(* ;; "")
627+
628+
(* ;; " In sum: this is a candidate for removal.")
629+
579630
(SETQ \STRINGSTREAM.FDEV (create FDEV
580631
DEVICENAME _ 'STRING
581632
CLOSEFILE _ (FUNCTION NILL)
@@ -588,7 +639,7 @@ Copyright (c) 1981-1987, 1990, 2021 by Venue & Xerox Corporation.
588639
HOSTNAMEP _ (FUNCTION NILL)
589640
OPENFILE _ (FUNCTION NILL)
590641
READPAGES _ (FUNCTION \ILLEGAL.DEVICEOP)
591-
REOPENFILE _ [FUNCTION (LAMBDA (FILE ACCESS RECOG OTHERINFO FDEV
642+
REOPENFILE _ [FUNCTION (LAMBDA (FILE ACCESS RECOG OTHERINFO FDEV
592643
STREAM)
593644
STREAM]
594645
SETFILEINFO _ (FUNCTION NILL)
@@ -597,13 +648,16 @@ Copyright (c) 1981-1987, 1990, 2021 by Venue & Xerox Corporation.
597648
BIN _ [FUNCTION (LAMBDA (STREAM)
598649
(replace F2 of STREAM
599650
with (COND
600-
((fetch F1 of STREAM)
601-
(PROG1 (fetch F1 of STREAM)
602-
(replace F1 of STREAM
603-
with NIL)))
604-
((GNCCODE (fetch FULLFILENAME
605-
of STREAM)))
606-
(T (\EOF.ACTION STREAM]
651+
((fetch F1 of STREAM)
652+
(PROG1 (fetch F1
653+
of STREAM)
654+
(replace F1
655+
of STREAM
656+
with NIL)))
657+
((GNCCODE (fetch
658+
FULLFILENAME
659+
of STREAM)))
660+
(T (\EOF.ACTION STREAM]
607661
PEEKBIN _ [FUNCTION (LAMBDA (STREAM NOERRORFLG)
608662
(OR (fetch F1 of STREAM)
609663
(CHCON1 (fetch FULLFILENAME
@@ -614,17 +668,19 @@ Copyright (c) 1981-1987, 1990, 2021 by Venue & Xerox Corporation.
614668
(NOT (EOFP STREAM]
615669
BACKFILEPTR _ [FUNCTION (LAMBDA (STREAM)
616670
(replace F1 of STREAM
617-
with (fetch F2 of STREAM]
671+
with (fetch F2 of STREAM
672+
]
618673
EOFP _ (FUNCTION (LAMBDA (STREAM)
619674
(AND (NOT (fetch F1 of STREAM))
620675
(EQ (NCHARS (fetch FULLFILENAME
621676
of STREAM))
622677
0])
623678
)
624-
(DECLARE%: DONTEVAL@LOAD DOCOPY
625679

626-
(\STRINGSTREAM.INIT)
627-
)
680+
681+
682+
(* ;; "(DECLARE%%: DONTEVAL@LOAD DOCOPY (P (\STRINGSTREAM.INIT)))")
683+
628684
(DEFINEQ
629685

630686
(GETSTREAM
@@ -748,16 +804,16 @@ Copyright (c) 1981-1987, 1990, 2021 by Venue & Xerox Corporation.
748804
)
749805
(PUTPROPS AOFD COPYRIGHT ("Venue & Xerox Corporation" 1981 1982 1983 1984 1985 1986 1987 1990 2021))
750806
(DECLARE%: DONTCOPY
751-
(FILEMAP (NIL (2373 3480 (\ADD-OPEN-STREAM 2383 . 2660) (\GENERIC-UNREGISTER-STREAM 2662 . 3478)) (
752-
3521 10778 (CLOSEALL 3531 . 4236) (CLOSEF 4238 . 5434) (EOFCLOSEF 5436 . 5732) (INPUT 5734 . 6506) (
753-
OPENP 6508 . 6907) (OUTPUT 6909 . 7683) (POSITION 7685 . 8497) (RANDACCESSP 8499 . 8974) (\IOMODEP
754-
8976 . 9613) (WHENCLOSE 9615 . 10776)) (10779 10901 (STREAMADDPROP 10789 . 10899)) (12065 24946 (
755-
\BASEBYTES.IO.INIT 12075 . 15271) (\MAKEBASEBYTESTREAM 15273 . 18585) (\MBS.OUTCHARFN 18587 . 18975) (
756-
\BASEBYTES.NAME.FROM.STREAM 18977 . 19440) (\BASEBYTES.BOUT 19442 . 20159) (\BASEBYTES.SETFILEPTR
757-
20161 . 20782) (\BASEBYTES.READP 20784 . 21420) (\BASEBYTES.BIN 21422 . 21953) (\BASEBYTES.PEEKBIN
758-
21955 . 22786) (\BASEBYTES.TRUNCATEFN 22788 . 23292) (\BASEBYTES.OPENFN 23294 . 23784) (
759-
\BASEBYTES.BLOCKIO 23786 . 24944)) (25069 27319 (OPENSTRINGSTREAM 25079 . 27317)) (27376 31012 (
760-
\STRINGSTREAM.INIT 27386 . 31010)) (31074 34646 (GETSTREAM 31084 . 31307) (\ADDOFD 31309 . 31596) (
761-
\CLEAROFD 31598 . 31879) (\DELETEOFD 31881 . 32032) (\GETSTREAM 32034 . 34198) (\SEARCHOPENFILES 34200
762-
. 34644)))))
807+
(FILEMAP (NIL (2615 3722 (\ADD-OPEN-STREAM 2625 . 2902) (\GENERIC-UNREGISTER-STREAM 2904 . 3720)) (
808+
3763 11020 (CLOSEALL 3773 . 4478) (CLOSEF 4480 . 5676) (EOFCLOSEF 5678 . 5974) (INPUT 5976 . 6748) (
809+
OPENP 6750 . 7149) (OUTPUT 7151 . 7925) (POSITION 7927 . 8739) (RANDACCESSP 8741 . 9216) (\IOMODEP
810+
9218 . 9855) (WHENCLOSE 9857 . 11018)) (11021 11143 (STREAMADDPROP 11031 . 11141)) (12307 25188 (
811+
\BASEBYTES.IO.INIT 12317 . 15513) (\MAKEBASEBYTESTREAM 15515 . 18827) (\MBS.OUTCHARFN 18829 . 19217) (
812+
\BASEBYTES.NAME.FROM.STREAM 19219 . 19682) (\BASEBYTES.BOUT 19684 . 20401) (\BASEBYTES.SETFILEPTR
813+
20403 . 21024) (\BASEBYTES.READP 21026 . 21662) (\BASEBYTES.BIN 21664 . 22195) (\BASEBYTES.PEEKBIN
814+
22197 . 23028) (\BASEBYTES.TRUNCATEFN 23030 . 23534) (\BASEBYTES.OPENFN 23536 . 24026) (
815+
\BASEBYTES.BLOCKIO 24028 . 25186)) (25311 28620 (OPENSTRINGSTREAM 25321 . 27038) (MAKE-STRING-FORMAT
816+
27040 . 28618)) (28892 33553 (\STRINGSTREAM.INIT 28902 . 33551)) (33630 37202 (GETSTREAM 33640 . 33863
817+
) (\ADDOFD 33865 . 34152) (\CLEAROFD 34154 . 34435) (\DELETEOFD 34437 . 34588) (\GETSTREAM 34590 .
818+
36754) (\SEARCHOPENFILES 36756 . 37200)))))
763819
STOP

sources/AOFD.LCOM

728 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)