zsys.lsp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. (!*
  2. "ZSYS -- the system dependent file.
  3. Currently, the only code in it is MAKE-OPEN-FILE-NAME, which
  4. uses a semi machine-independant file description to create a
  5. filename suitable for OPEN in the resident system.
  6. N.B.: TO SET THIS CODE UP FOR A PARTICULAR INTEPRETER,
  7. REMOVE THE * FROM BEFORE THE APPROPRIATE SETQ BELOW.
  8. THAT SHOULD BE ALL YOU NEED TO DO.
  9. ")
  10. (COMPILETIME
  11. (GLOBAL '(G!:SYSTEM))
  12. (IF!_SYSTEM TOPS20
  13. (SETQ G!:SYSTEM 'PSL!-TOPS20))
  14. (IF!_SYSTEM UNIX
  15. (SETQ G!:SYSTEM 'PSL!-UNIX))
  16. (!* SETQ G!:SYSTEM 'IMSSS!-TENEX)
  17. (!* SETQ G!:SYSTEM 'UTAH!-TOPS10)
  18. (!* SETQ G!:SYSTEM 'UTAH!-TENEX)
  19. (!* SETQ G!:SYSTEM 'CMS)
  20. (!* SETQ G!:SYSTEM 'ORVYL)
  21. (PROGN (TERPRI)
  22. (PRIN2 "Filenames will be made for ")
  23. (PRIN2 G!:SYSTEM)
  24. (PRIN2 " system.")
  25. (TERPRI))
  26. )
  27. (FLUID '(F!:FILE!:ID F!:OLD!:FILE))
  28. (COMPILETIME
  29. (!*
  30. "This macro (and those following) are separated only for readability.
  31. The appropriate MAKE-xxx-NAME will provide the body of the definition
  32. for MAKE-OPEN-FILE-NAME.
  33. Note: (a) #DSCR can be mentioned free in the macros since it is the
  34. lambda variable for MAKE-OPEN-FILE-NAME.
  35. (b) ORVYL and CMS differ only in the delimiter they use.
  36. (c) When compiling, all these macros are REMOB'ed to clear up
  37. otherwise extraneous code.")
  38. (DM MAKE!-SYS!-FILE!-NAME (!#X)
  39. (SELECTQ G!:SYSTEM
  40. (PSL!-TOPS20 '(MAKE!-PSL!-TOPS20!-NAME))
  41. (PSL!-UNIX '(MAKE!-PSL!-UNIX!-NAME))
  42. (UTAH!-TENEX '(MAKE!-UTAH!-TENEX!-NAME))
  43. (UTAH!-TOPS10 '(MAKE!-UTAH!-TOPS10!-NAME))
  44. (IMSSS!-TENEX '(MAKE!-IMSSS!-TENEX!-NAME))
  45. (ORVYL '(MAKE!-IBM!-NAME !.))
  46. (CMS '(MAKE!-IBM!-NAME ! ))
  47. (ERROR 0
  48. (LIST "Don't know how to make file names for system "
  49. G!:SYSTEM))))
  50. (DM MAKE!-UTAH!-TENEX!-NAME (!#X)
  51. '(PROG (!#DIR !#NAM !#EXT)
  52. (RETURN
  53. (SETQ F!:OLD!:FILE
  54. (COND ((NULL (PAIRP !#DSCR))
  55. (ERROR 0 (LIST "BAD FILE DSCR: " !#DSCR)))
  56. ((NULL (CDR !#DSCR))
  57. (LIST (CONS (SETQ F!:FILE!:ID (CAR !#DSCR)) 'LSP)))
  58. ((EQ (CDR !#DSCR) '!;)
  59. (LIST (SETQ F!:FILE!:ID (CAR !#DSCR))))
  60. ((IDP (CDR !#DSCR))
  61. (PROGN (SETQ F!:FILE!:ID (CAR !#DSCR)) (LIST !#DSCR)))
  62. (T (PROGN (SETQ !#DIR (CAR !#DSCR))
  63. (SETQ F!:FILE!:ID (SETQ !#NAM (CADR !#DSCR)))
  64. (SETQ !#EXT
  65. (COND ((NULL (CDDR !#DSCR)) 'LSP)
  66. ((IDP (CDDR !#DSCR)) (CDDR !#DSCR))
  67. (T (CADDR !#DSCR))))
  68. (LIST 'DIR!: !#DIR (CONS !#NAM !#EXT)))))))))
  69. (!*
  70. "Use decimal equivalent of PPNs for tops 10. Maybe the ROCT switch
  71. in the interpreter will allow octal PPNS??")
  72. (DM MAKE!-UTAH!-TOPS10!-NAME (!#X)
  73. '(PROG (!#DIR !#NAM !#EXT)
  74. (RETURN
  75. (SETQ F!:OLD!:FILE
  76. (COND ((NULL (PAIRP !#DSCR))
  77. (ERROR 0 (LIST "BAD FILE DSCR: " !#DSCR)))
  78. ((NULL (CDR !#DSCR))
  79. (LIST (CONS (SETQ F!:FILE!:ID (CAR !#DSCR)) 'LSP)))
  80. ((EQ (CDR !#DSCR) '!;)
  81. (LIST (SETQ F!:FILE!:ID (CAR !#DSCR))))
  82. ((IDP (CDR !#DSCR))
  83. (PROGN (SETQ F!:FILE!:ID (CAR !#DSCR)) (LIST !#DSCR)))
  84. (T (PROGN (SETQ !#DIR (CAR !#DSCR))
  85. (COND ((NOT (AND (PAIRP !#DIR)
  86. (NUMBERP (CAR !#DIR))
  87. (NUMBERP (CADR !#DIR))))
  88. (BUG!-STOP
  89. "Bad PPN: USE (<n> <n>) w/ decimal equiv of octal PPN.")
  90. ))
  91. (SETQ F!:FILE!:ID (SETQ !#NAM (CADR !#DSCR)))
  92. (SETQ !#EXT
  93. (COND ((NULL (CDDR !#DSCR)) 'LSP)
  94. ((IDP (CDDR !#DSCR)) (CDDR !#DSCR))
  95. (T (CADDR !#DSCR))))
  96. (LIST !#DIR (CONS !#NAM !#EXT)))))))))
  97. (DM MAKE!-IMSSS!-TENEX!-NAME (!#X)
  98. '(PROG (DIR!#NAM !#EXT)
  99. (!* "#DSCR is a list")
  100. (RETURN
  101. (SETQ F!:OLD!:FILE
  102. (LIST (COND ((NULL (PAIRP !#DSCR))
  103. (ERROR 0 (LIST "BAD FILE DSCR: " !#DSCR)))
  104. ((NULL (CDR !#DSCR))
  105. (CONS (SETQ F!:FILE!:ID (CAR !#DSCR)) 'LSP))
  106. ((EQ (CDR !#DSCR) '!;)
  107. (SETQ F!:FILE!:ID (CAR !#DSCR)))
  108. ((IDP (CDR !#DSCR))
  109. (PROGN (SETQ F!:FILE!:ID (CAR !#DSCR)) !#DSCR))
  110. (T (PROGN
  111. (SETQ DIR!#NAM
  112. (COMPRESS
  113. (NCONCL (LIST '!! '!<)
  114. (EXPLODE (CAR !#DSCR))
  115. (LIST '!! '!>)
  116. (EXPLODE (CADR !#DSCR)))))
  117. (SETQ F!:FILE!:ID (CADR !#DSCR))
  118. (SETQ !#EXT
  119. (COND ((NULL (CDDR !#DSCR)) 'LSP)
  120. ((IDP (CDDR !#DSCR)) (CDDR !#DSCR))
  121. (T (CADDR !#DSCR))))
  122. (CONS DIR!#NAM !#EXT)))))))))
  123. (DM MAKE!-PSL!-TOPS20!-NAME (!#X)
  124. '(PROG (DIR!#NAM !#EXT)
  125. (!* "#DSCR is a list")
  126. (COND ((STRINGP !#DSCR) (MAKE !#DSCR NCONS)))
  127. (RETURN
  128. (SETQ F!:OLD!:FILE
  129. (COND ((NULL (PAIRP !#DSCR))
  130. (ERROR 0 (LIST "BAD FILE DSCR: " !#DSCR)))
  131. ((NULL (CDR !#DSCR))
  132. (COND ((STRINGP (CAR !#DSCR))
  133. (PROGN
  134. (SETQ F!:FILE!:ID
  135. (EXTRACT!-FILE!-ID (CAR !#DSCR)))
  136. (CAR !#DSCR)))
  137. (T (ID!-LIST!-TO!-STRING
  138. (LIST (SETQ F!:FILE!:ID (CAR !#DSCR))
  139. '!.
  140. 'LSP)))))
  141. ((EQ (CDR !#DSCR) '!;)
  142. (ID2STRING (SETQ F!:FILE!:ID (CAR !#DSCR))))
  143. ((IDP (CDR !#DSCR))
  144. (ID!-LIST!-TO!-STRING
  145. (LIST (SETQ F!:FILE!:ID (CAR !#DSCR)) '!. (CDR !#DSCR)))
  146. )
  147. (T (PROGN
  148. (SETQ DIR!#NAM
  149. (COMPRESS
  150. (NCONCL (LIST '!! '!<)
  151. (EXPLODE (CAR !#DSCR))
  152. (LIST '!! '!>)
  153. (EXPLODE (CADR !#DSCR)))))
  154. (SETQ F!:FILE!:ID (CADR !#DSCR))
  155. (SETQ !#EXT
  156. (COND ((NULL (CDDR !#DSCR)) 'LSP)
  157. ((IDP (CDDR !#DSCR)) (CDDR !#DSCR))
  158. (T (CADDR !#DSCR))))
  159. (ID!-LIST!-TO!-STRING (LIST DIR!#NAM '!. !#EXT)))))))))
  160. (DM MAKE!-PSL!-UNIX!-NAME (!#X)
  161. '(PROG (DIR!#NAM !#EXT)
  162. (!* "#DSCR is a list")
  163. (COND ((STRINGP !#DSCR) (MAKE !#DSCR NCONS)))
  164. (RETURN
  165. (SETQ F!:OLD!:FILE
  166. (COND ((NULL (PAIRP !#DSCR))
  167. (ERROR 0 (LIST "BAD FILE DSCR: " !#DSCR)))
  168. ((NULL (CDR !#DSCR))
  169. (COND ((STRINGP (CAR !#DSCR))
  170. (PROGN (SETQ F!:FILE!:ID
  171. (EXTRACT!-FILE!-ID (CAR
  172. !#DSCR)))
  173. (CAR !#DSCR)))
  174. (T (ID!-LIST!-TO!-STRING (LIST (SETQ
  175. F!:FILE!:ID
  176. (CAR
  177. !#DSCR))
  178. '!.
  179. 'LSP)))))
  180. ((EQ (CDR !#DSCR) '!;)
  181. (ID2STRING (SETQ F!:FILE!:ID (CAR !#DSCR))))
  182. ((IDP (CDR !#DSCR))
  183. (ID!-LIST!-TO!-STRING (LIST (SETQ F!:FILE!:ID
  184. (CAR !#DSCR))
  185. '!.
  186. (CDR !#DSCR))))
  187. (T (PROGN (SETQ DIR!#NAM
  188. (COMPRESS (NCONCL (EXPLODE (CAR
  189. !#DSCR))
  190. (LIST '!!
  191. '!/)
  192. (EXPLODE (CADR
  193. !#DSCR)))))
  194. (SETQ F!:FILE!:ID (CADR !#DSCR))
  195. (SETQ !#EXT
  196. (COND ((NULL (CDDR !#DSCR))
  197. 'LSP)
  198. ((IDP (CDDR !#DSCR))
  199. (CDDR !#DSCR))
  200. (T (CADDR !#DSCR))))
  201. (ID!-LIST!-TO!-STRING (LIST DIR!#NAM
  202. '!.
  203. !#EXT))))))))))
  204. (IF!_SYSTEM TOPS20 (PROGN
  205. (DE EXTRACT!-FILE!-ID (!#X)
  206. (PROG (!#Y)
  207. (!*
  208. "Take a TOPS-20 filename string and try to
  209. find a root file name in it")
  210. (SETQ !#Y (DREVERSE (EXPLODE2 !#X)))
  211. (SETQ !#X !#Y)
  212. LOOP1(COND ((OR (NULL !#X) (MEMQ (CAR !#X) '(!: !>))) (GO LOOP1END))
  213. ((EQ (CAR !#X) '!.) (PROGN (SETQ !#Y (CDR !#X)) (GO LOOP1END))))
  214. (SETQ !#X (CDR !#X))
  215. (GO LOOP1)
  216. LOOP1END
  217. (SETQ !#X !#Y)
  218. LOOP2(COND ((OR (NULL !#X) (NULL (CDR !#X))) (GO LOOP2END))
  219. ((MEMQ (CADR !#X) '(!> !:))
  220. (PROGN (RPLACD !#X NIL) (GO LOOP2END))))
  221. (SETQ !#X (CDR !#X))
  222. (GO LOOP2)
  223. LOOP2END
  224. (RETURN (ICOMPRESS (DREVERSE !#Y)))))
  225. (DE ID!-LIST!-TO!-STRING (!#X)
  226. (PROG (!#S)
  227. (SETQ !#S "")
  228. LOOP (COND ((NULL !#X) (RETURN !#S)))
  229. (SETQ !#S (CONCAT !#S (ID2STRING (CAR !#X))))
  230. (SETQ !#X (CDR !#X))
  231. (GO LOOP)))))
  232. (IF!_SYSTEM UNIX (PROGN
  233. (DE EXTRACT!-FILE!-ID (!#X)
  234. (PROG (!#Y)
  235. (!*
  236. "Take a UNIX filename string and try to
  237. find a root file name in it")
  238. (SETQ !#Y (DREVERSE (EXPLODE2 !#X)))
  239. (SETQ !#X !#Y)
  240. LOOP1(COND ((OR (NULL !#X) (MEMQ (CAR !#X) '(!: !>))) (GO LOOP1END))
  241. ((EQ (CAR !#X) '!.) (PROGN (SETQ !#Y (CDR !#X)) (GO LOOP1END))))
  242. (SETQ !#X (CDR !#X))
  243. (GO LOOP1)
  244. LOOP1END
  245. (SETQ !#X !#Y)
  246. LOOP2(COND ((OR (NULL !#X) (NULL (CDR !#X))) (GO LOOP2END))
  247. ((MEMQ (CADR !#X) '(!> !:))
  248. (PROGN (RPLACD !#X NIL) (GO LOOP2END))))
  249. (SETQ !#X (CDR !#X))
  250. (GO LOOP2)
  251. LOOP2END
  252. (RETURN (ICOMPRESS (DREVERSE !#Y)))))
  253. (FLUID '(!*LOWER))
  254. (!* "*LOWER when T all output (including EXPLODE) is in lowercase")
  255. (DE ID!-LIST!-TO!-STRING (!#X)
  256. (PROG (!#S !*LOWER)
  257. (SETQ !*LOWER T)
  258. (SETQ !#S "")
  259. LOOP (COND ((NULL !#X) (RETURN !#S)))
  260. (SETQ !#S (CONCAT !#S (LIST2STRING (EXPLODE2 (CAR !#X)))))
  261. (SETQ !#X (CDR !#X))
  262. (GO LOOP)))))
  263. (!* "IBM code got lost")
  264. (DE MAKE!-OPEN!-FILE!-NAME (!#DSCR) (MAKE!-SYS!-FILE!-NAME))
  265. (!* "Remove excess baggage once macros have been used.")
  266. (!* COND ((CODEP (CDR (GETD 'MAKE!-OPEN!-FILE!-NAME)))
  267. (PROGN (REMOB 'MAKE!-SYS!-FILE!-NAME)
  268. (REMOB 'MAKE!-UTAH!-TENEX!-NAME)
  269. (REMOB 'MAKE!-UTAH!-TOPS10!-NAME)
  270. (REMOB 'MAKE!-IMSSS!-TENEX!-NAME)
  271. (REMOB 'MAKE!-IBM!-NAME))))