Skip to content

Commit 8850bb9

Browse files
committed
fix:avoiding error caused by soft links
1 parent df9a071 commit 8850bb9

1 file changed

Lines changed: 21 additions & 18 deletions

File tree

analysis/tokenizer.sls

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,27 @@
105105
([path] (source-file->annotations (read-string path) path))
106106
([source path] (source-file->annotations source path (consume-sps-auxiliary source) #t))
107107
([source path start-position tolerant?]
108-
(let ([port (open-string-input-port source)]
109-
[source-file-descriptor (make-source-file-descriptor path (open-file-input-port path))])
110-
(set-port-position! port start-position)
111-
(filter annotation?
112-
(let loop ([position start-position])
113-
(try
114-
(let-values ([(ann end-pos) (get-datum/annotations port source-file-descriptor position)])
115-
(if (= position (port-position port))
116-
'()
117-
`(,ann . ,(loop (port-position port)))))
118-
(except e
119-
[(and tolerant? (condition? e))
120-
(let ([after (private:tolerant-parse->patch source)])
121-
(if (= (string-length after) (string-length source))
122-
(source-file->annotations after path start-position #f)
123-
(error 'tokenizer-error (condition-message e) (condition-irritants e))))]
124-
[(condition? e) (error 'tokenizer-error0 path `(,source ,path ,position ,tolerant? ,(condition-who e) ,(condition-message e) ,(condition-irritants e)))]
125-
[else (warning 'tokenizer-error0 path `(,source ,path ,position ,tolerant? ,(condition-who e) ,(condition-message e) ,(condition-irritants e)))]))))))))
108+
(if (file-exists? path)
109+
(let ([port (open-string-input-port source)]
110+
[source-file-descriptor (make-source-file-descriptor path (open-file-input-port path))])
111+
(set-port-position! port start-position)
112+
(filter annotation?
113+
(let loop ([position start-position])
114+
(try
115+
(let-values ([(ann end-pos) (get-datum/annotations port source-file-descriptor position)])
116+
(if (= position (port-position port))
117+
'()
118+
`(,ann . ,(loop (port-position port)))))
119+
(except e
120+
[(and tolerant? (condition? e))
121+
(let ([after (private:tolerant-parse->patch source)])
122+
(if (= (string-length after) (string-length source))
123+
(source-file->annotations after path start-position #f)
124+
(error 'tokenizer-error (condition-message e) (condition-irritants e))))]
125+
[(condition? e) (error 'tokenizer-error0 path `(,source ,path ,position ,tolerant? ,(condition-who e) ,(condition-message e) ,(condition-irritants e)))]
126+
[else (warning 'tokenizer-error0 path `(,source ,path ,position ,tolerant? ,(condition-who e) ,(condition-message e) ,(condition-irritants e)))])))))
127+
(warning 'no-such-file-warning path '())))))
128+
126129
;https://github.com/cisco/ChezScheme/blob/e63e5af1a5d6805c96fa8977e7bd54b3b516cff6/s/7.ss#L268-L280
127130
; consume
128131
; #!/usr/bin/env scheme-script

0 commit comments

Comments
 (0)