Skip to content

Commit f531e89

Browse files
committed
COREIO: More accurate directory name processing, added FILEDIRCASEARRAY
FILEDIRCASEARRAY does upper/lower case equivalents plus /<> for testing directory string equivalents. Could be in COREIO, but that's probably too early in the loadup.
1 parent 293c973 commit f531e89

File tree

2 files changed

+101
-39
lines changed

2 files changed

+101
-39
lines changed

sources/COREIO

Lines changed: 101 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10)
22

3-
(FILECREATED " 3-Jan-2022 20:02:51" {DSK}<Users>kaplan>Local>medley3.5>my-medley>sources>COREIO.;4 55136
3+
(FILECREATED "18-Jan-2022 11:22:04" {DSK}<Users>kaplan>Local>medley3.5>my-medley>sources>COREIO.;14 58002
44

5-
:CHANGES-TO (FNS \CORE.SETFILEINFO)
5+
:CHANGES-TO (FNS \CORE.DIRECTORYNAMEP)
66

7-
:PREVIOUS-DATE "22-Nov-2021 09:25:42"
8-
{DSK}<Users>kaplan>Local>medley3.5>my-medley>sources>COREIO.;3)
7+
:PREVIOUS-DATE "11-Jan-2022 16:45:02"
8+
{DSK}<Users>kaplan>Local>medley3.5>my-medley>sources>COREIO.;13)
99

1010

1111
(* ; "
@@ -27,6 +27,8 @@ Copyright (c) 1981-1988, 1990, 1993, 1999, 2018 by Venue & Xerox Corporation.
2727
\CORE.SETACCESSTIME \CORE.SETFILEINFO \CORE.GETNEXTBUFFER \CORE.UNPACKFILENAME)
2828
(FNS COREDEVICE \CREATECOREDEVICE)
2929
(FNS \NODIRCOREFDEV \NODIRCORE.OPENFILE)
30+
(FNS FILEDIRCASEARRAY)
31+
(VARS (FILEDIRCASEARRAY (FILEDIRCASEARRAY)))
3032
(DECLARE%: DONTCOPY (RECORDS CORE.PAGEENTRY COREFILEINFOBLK CORESTREAM COREDEVICE
3133
COREGENFILESTATE))
3234
(INITRECORDS COREFILEINFOBLK)
@@ -90,10 +92,34 @@ Copyright (c) 1981-1988, 1990, 1993, 1999, 2018 by Venue & Xerox Corporation.
9092
(RETURN (fetch IOFILEFULLNAME of INFOBLOCK])
9193

9294
(\CORE.DIRECTORYNAMEP
93-
[LAMBDA (DIRNAME DEV) (* ; "Edited 19-Feb-93 16:04 by jds")
94-
(LET [(DIR (UNPACKFILENAME.STRING DIRNAME 'DIRECTORY]
95-
(AND DIRNAME DIR (> (NCHARS DIR)
96-
0])
95+
[LAMBDA (DIRNAME DEV) (* ; "Edited 18-Jan-2022 11:17 by rmk")
96+
(* ; "Edited 10-Jan-2022 22:33 by rmk")
97+
98+
(* ;;
99+
 "Edited 9-Jan-2022 12:42 by rmk: Using the new FILEDIRCASEARRAY so that slashes and brackets match")
100+
101+
(* ;; "Edited 5-Jan-2022 15:03 by rmk: The previous definition didn't actually check to see if the directory existed. %"existed%" for COREIO means there is at least one file currently in that directory.")
102+
103+
(* ;; "Edited 19-Feb-93 16:04 by jds")
104+
105+
(CL:WHEN DIRNAME
106+
107+
(* ;; "The DIRNAME could be just {CORE}, which always is OK, or {CORE}xxx. If the latter, then we want it to be a directory and not a file (assuming that xxx and xxx> can't both exist.")
108+
109+
(IF (EQ (CHARCODE })
110+
(NTHCHARCODE DIRNAME -1))
111+
ELSE (CL:UNLESS (MEMB (NTHCHARCODE DIRNAME -1)
112+
(CHARCODE (> /)))
113+
(SETQ DIRNAME (CONCAT DIRNAME ">")))
114+
115+
(* ;; "DIRPOS because caller may not have stripped off the device. This will match the first < or / (or >)")
116+
117+
(FOR ENTRY (DIRPOS _ (STRPOS "<" DIRNAME 1 NIL NIL NIL FILEDIRCASEARRAY))
118+
FIRST (CL:UNLESS (EQ DIRPOS 1)
119+
(SETQ DIRNAME (SUBSTRING DIRNAME DIRPOS)))
120+
IN (CDR (FETCH COREDIRECTORY OF DEV)) WHEN (STRPOS DIRNAME (CAR ENTRY)
121+
1 NIL T NIL FILEDIRCASEARRAY)
122+
DO (RETURN T))))])
97123

98124
(\CORE.FINDPAGE
99125
[LAMBDA (STREAM PN) (* bvm%: "20-Apr-85 13:32")
@@ -351,28 +377,30 @@ Copyright (c) 1981-1988, 1990, 1993, 1999, 2018 by Venue & Xerox Corporation.
351377
(RETURN INFOBLOCK])
352378

353379
(\CORE.NAMESCAN
354-
[LAMBDA (NAME NAMELST CREATEFLG) (* ; "Edited 23-Oct-87 17:11 by bvm:")
380+
[LAMBDA (NAME NAMELST CREATEFLG)
381+
382+
(* ;; "Edited 11-Jan-2022 09:30 by rmk: Matching with FILEDIRCASEARRAY, for /")
383+
384+
(* ;; "Edited 23-Oct-87 17:11 by bvm:")
385+
355386
(COND
356387
((LISTP NAMELST)
357388
(bind NEWSEG NEXTNAME while [AND (CDR NAMELST)
358-
(COND
359-
((STRING-EQUAL (SETQ NEXTNAME (CAAR (CDR NAMELST)
360-
))
361-
NAME)
389+
(COND
390+
((STRING.EQUAL (SETQ NEXTNAME (CAAR (CDR NAMELST)))
391+
NAME FILEDIRCASEARRAY)
362392
(* ; "Found it")
363-
(RETURN (CADR NAMELST)))
364-
(T (UALPHORDER NEXTNAME NAME]
365-
do (* ;
366-
 "Segments are in order, so stop when (CDR NAMELST) is lexicographically greater than NAME")
367-
(SETQ NAMELST (CDR NAMELST)) finally (RETURN (COND
368-
((AND CREATEFLG (SETQ NEWSEG
369-
(
370-
 \CORE.NAMESEGMENT
371-
NAME)))
372-
(RPLACD NAMELST
373-
(CONS NEWSEG
374-
(CDR NAMELST)))
375-
NEWSEG])
393+
(RETURN (CADR NAMELST)))
394+
(T (ALPHORDER NEXTNAME NAME FILEDIRCASEARRAY]
395+
do (* ;
396+
 "Segments are in order, so stop when (CDR NAMELST) is lexicographically greater than NAME")
397+
(SETQ NAMELST (CDR NAMELST)) finally (RETURN (COND
398+
((AND CREATEFLG (SETQ NEWSEG
399+
(\CORE.NAMESEGMENT
400+
NAME)))
401+
(RPLACD NAMELST (CONS NEWSEG
402+
(CDR NAMELST)))
403+
NEWSEG])
376404

377405
(\CORE.NAMESEGMENT
378406
[LAMBDA (NAME) (* rmk%: "24-FEB-84 21:14")
@@ -710,7 +738,12 @@ Copyright (c) 1981-1988, 1990, 1993, 1999, 2018 by Venue & Xerox Corporation.
710738
(RETURN T])
711739

712740
(\CORE.UNPACKFILENAME
713-
[LAMBDA (NAME) (* ; "Edited 3-Nov-87 12:12 by bvm:")
741+
[LAMBDA (NAME) (* ; "Edited 10-Jan-2022 22:42 by rmk")
742+
743+
(* ;; "rmk; Convert / in ROOT to < or >")
744+
(* ; "Edited 10-Jan-2022 21:14 by rmk")
745+
746+
(* ;; "Edited 3-Nov-87 12:12 by bvm:")
714747

715748
(* ;; "Breaks up a file name atom into its fields which it sets freely in its caller")
716749

@@ -729,6 +762,17 @@ Copyright (c) 1981-1988, 1990, 1993, 1999, 2018 by Venue & Xerox Corporation.
729762
(SETQ DOT SEMI)))
730763
(SETQ ROOT (OR (SUBSTRING NAME START (SUB1 DOT))
731764
""))
765+
(CL:WHEN (STRPOS "/" ROOT)
766+
767+
(* ;; "If ROOT has slashes, convert to < ..> ..>")
768+
769+
(SETQ ROOT (DSUBST (CHARCODE >)
770+
(CHARCODE /)
771+
(CHCON ROOT)))
772+
(CL:WHEN (EQ (CAR ROOT)
773+
(CHARCODE >))
774+
(RPLACA ROOT (CHARCODE <)))
775+
(SETQ ROOT (CONCATCODES ROOT)))
732776
(SETQ EXT (COND
733777
((< DOT (- SEMI 1))
734778
(SUBSTRING NAME (ADD1 DOT)
@@ -858,6 +902,24 @@ Copyright (c) 1981-1988, 1990, 1993, 1999, 2018 by Venue & Xerox Corporation.
858902
(\CORE.SETACCESSTIME NAME ACCESS)
859903
NAME])
860904
)
905+
(DEFINEQ
906+
907+
(FILEDIRCASEARRAY
908+
[LAMBDA NIL (* ; "Edited 8-Jan-2022 20:15 by rmk")
909+
910+
(* ;; "Returns a case array suitable for case insensitive directory matching: <, >, and / all map together in any position. Presumably there are other well-formedness conditions that put < and > only in their proper positions.")
911+
(* ; "Edited 8-Jan-2022 20:12 by rmk")
912+
(for I (CA _ (CASEARRAY)) from (CHARCODE a) to (CHARCODE z)
913+
do [SETCASEARRAY CA I (IDIFFERENCE I (CONSTANT (IDIFFERENCE (CHARCODE a)
914+
(CHARCODE A]
915+
finally (SETCASEARRAY CA (CHARCODE <)
916+
(CHARCODE /))
917+
(SETCASEARRAY CA (CHARCODE >)
918+
(CHARCODE /))
919+
(RETURN CA])
920+
)
921+
922+
(RPAQ FILEDIRCASEARRAY (FILEDIRCASEARRAY))
861923
(DECLARE%: DONTCOPY
862924
(DECLARE%: EVAL@COMPILE
863925

@@ -955,16 +1017,16 @@ Copyright (c) 1981-1988, 1990, 1993, 1999, 2018 by Venue & Xerox Corporation.
9551017
(PUTPROPS COREIO COPYRIGHT ("Venue & Xerox Corporation" 1981 1982 1983 1984 1985 1986 1987 1988 1990
9561018
1993 1999 2018))
9571019
(DECLARE%: DONTCOPY
958-
(FILEMAP (NIL (1707 44342 (\CORE.CLOSEFILE 1717 . 2490) (\CORE.DELETEFILE 2492 . 4478) (
959-
\CORE.DIRECTORYNAMEP 4480 . 4741) (\CORE.FINDPAGE 4743 . 7972) (\CORE.GENERATEFILES 7974 . 10561) (
960-
\CORE.NEXTFILEFN 10563 . 11062) (\CORE.FILEINFOFN 11064 . 11293) (\CORE.GETFILEHANDLE 11295 . 13449) (
961-
\CORE.GETFILEINFO 13451 . 14414) (\CORE.GETFILEINFO.FROM.INFOBLOCK 14416 . 15953) (\CORE.GETFILENAME
962-
15955 . 18244) (\CORE.GETINFOBLOCK 18246 . 20869) (\CORE.NAMESCAN 20871 . 22638) (\CORE.NAMESEGMENT
963-
22640 . 23077) (\CORE.OPENFILE 23079 . 26198) (\COREFILE.SETPARAMETERS 26200 . 28381) (
964-
\CORE.PACKFILENAME 28383 . 28778) (\CORE.RELEASEPAGES 28780 . 29381) (\CORE.SETFILEPTR 29383 . 30482)
965-
(\CORE.UPDATEOF 30484 . 32113) (\CORE.BACKFILEPTR 32115 . 34323) (\CORE.SETEOFPTR 34325 . 36194) (
966-
\CORE.SETACCESSTIME 36196 . 36821) (\CORE.SETFILEINFO 36823 . 39125) (\CORE.GETNEXTBUFFER 39127 .
967-
43083) (\CORE.UNPACKFILENAME 43085 . 44340)) (44343 47976 (COREDEVICE 44353 . 44524) (
968-
\CREATECOREDEVICE 44526 . 47974)) (47977 50278 (\NODIRCOREFDEV 47987 . 48584) (\NODIRCORE.OPENFILE
969-
48586 . 50276)))))
1020+
(FILEMAP (NIL (1796 46254 (\CORE.CLOSEFILE 1806 . 2579) (\CORE.DELETEFILE 2581 . 4567) (
1021+
\CORE.DIRECTORYNAMEP 4569 . 6250) (\CORE.FINDPAGE 6252 . 9481) (\CORE.GENERATEFILES 9483 . 12070) (
1022+
\CORE.NEXTFILEFN 12072 . 12571) (\CORE.FILEINFOFN 12573 . 12802) (\CORE.GETFILEHANDLE 12804 . 14958) (
1023+
\CORE.GETFILEINFO 14960 . 15923) (\CORE.GETFILEINFO.FROM.INFOBLOCK 15925 . 17462) (\CORE.GETFILENAME
1024+
17464 . 19753) (\CORE.GETINFOBLOCK 19755 . 22378) (\CORE.NAMESCAN 22380 . 23927) (\CORE.NAMESEGMENT
1025+
23929 . 24366) (\CORE.OPENFILE 24368 . 27487) (\COREFILE.SETPARAMETERS 27489 . 29670) (
1026+
\CORE.PACKFILENAME 29672 . 30067) (\CORE.RELEASEPAGES 30069 . 30670) (\CORE.SETFILEPTR 30672 . 31771)
1027+
(\CORE.UPDATEOF 31773 . 33402) (\CORE.BACKFILEPTR 33404 . 35612) (\CORE.SETEOFPTR 35614 . 37483) (
1028+
\CORE.SETACCESSTIME 37485 . 38110) (\CORE.SETFILEINFO 38112 . 40414) (\CORE.GETNEXTBUFFER 40416 .
1029+
44372) (\CORE.UNPACKFILENAME 44374 . 46252)) (46255 49888 (COREDEVICE 46265 . 46436) (
1030+
\CREATECOREDEVICE 46438 . 49886)) (49889 52190 (\NODIRCOREFDEV 49899 . 50496) (\NODIRCORE.OPENFILE
1031+
50498 . 52188)) (52191 53096 (FILEDIRCASEARRAY 52201 . 53094)))))
9701032
STOP

sources/COREIO.LCOM

574 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)