/usr/share/scsh-0.6/scsh/scsh-read.scm is in scsh-common-0.6 0.6.7-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | ;;; Copyright (c) 1993, 1994 by Olin Shivers.
;;; #! comment read-macro
;;; no case-folding
;;; -flag is a symbol
;;; #! means: skip chars until newline-bang-splat-newline.
;;; For Unix script headers.
(define script-skip
(lambda (c port)
(read-char port)
(let lp ((state 0))
(let ((advance-if (lambda (look-for)
(let ((c (read-char port)))
(if (eof-object? c)
(error
"EOF inside block comment -- #! missing a closing !#")
(lp (cond ((char=? c look-for) (+ state 1))
((char=? c #\newline) 1)
(else 0))))))))
(case state
((0) (advance-if #\newline))
((1) (advance-if #\!)) ; Found \n
((2) (advance-if #\#)) ; Found \n!
((3) (advance-if #\newline)) ; Found \n!#
((4) (read port))))))) ; Found \n!#\n -- done.
; was sub-read ^
(define-sharp-macro #\! script-skip)
;;; Readme and readme are distinct symbols.
(define preferred-case (lambda (x) x))
;;; These are now OK symbols: .. -geometry -O2 9x15 80x5+5+5 +Wn
(define (parse-token string port)
(if (let ((c (string-ref string 0)))
(or (char-numeric? c) (char=? c #\+) (char=? c #\-) (char=? c #\.)))
(cond ((string->number string))
((string=? string ".") dot)
(else (string->symbol (make-immutable! string))))
(string->symbol (make-immutable! string))))
;;; | is now an OK symbol (for pipes).
(set-standard-syntax! #\| #f
(lambda (c port)
(parse-token (sub-read-token c port) port)))
(define bel (ascii->char 7))
(define bs (ascii->char 8))
(define ff (ascii->char 12))
(define cr (ascii->char 13))
(define ht (ascii->char 9))
(define vt (ascii->char 11))
;;; Full ANSI C strings:
;;; - read as themselves: \\ \? \" \'
;;; - control chars:
;;; \a alert (bell -- ^g)
;;; \b backspace (^h)
;;; \f form feed (^l)
;;; \n newline (^j)
;;; \r carriage return (^m)
;;; \t tab (^i)
;;; \v vertical tab (^k)
;;; - octal escapes \nnn
;;; - hex escapes \xnn
;;; Is this the elegant thing to do? Too much might make it hard to shift
;;; to Unicode implementations. How about \^g for embedding control chars?
;;; And I haven't done anything about chars (as opposed to strings).
(set-standard-read-macro! #\" #t
(lambda (c port)
c ;ignored
(let* ((readc (lambda ()
(let ((c (read-char port)))
(if (eof-object? c)
(reading-error port "end of file within a string")
c))))
(read-digit (lambda (base base-name)
(let* ((c (readc))
(d (- (char->ascii c) (char->ascii #\0))))
(if (and (<= 0 d) (< d base)) d
(reading-error port
(string-append "invalid "
base-name
" code in string.")
d))))))
(let loop ((l '()) (i 0))
(let ((c (readc)))
(cond ((char=? c #\\)
(let* ((c (readc))
(rc (case c
((#\\ #\" #\? #\') c)
((#\a) bel)
((#\b) bs)
((#\f) ff)
((#\n) #\newline)
((#\r) cr)
((#\t) ht)
((#\v) vt)
((#\0 #\1 #\2 #\3)
(let* ((d1 (- (char->ascii c) (char->ascii #\0)))
(d2 (read-digit 8 "octal"))
(d3 (read-digit 8 "octal")))
(ascii->char (+ (* 64 d1) (+ (* 8 d2) d3)))))
((#\x)
(let ((d1 (read-digit 16 "hex"))
(d2 (read-digit 16 "hex")))
(ascii->char (+ (* 16 d1) d2))))
(else
(reading-error port
"invalid escaped character in string"
c)))))
(loop (cons rc l) (+ i 1))))
((char=? c #\")
(reverse-list->string l i))
(else
(loop (cons c l) (+ i 1)))))))))
|