Fix for auto-language.ss: if first line of program contains a snip, read-line fails and needs to be handled.

svn: r10074
This commit is contained in:
Danny Yoo 2008-06-01 02:23:55 +00:00
parent a5049573a3
commit 516231c1f9

View File

@ -16,7 +16,7 @@
(let ([lang-spec (send lang get-reader-module)]) (let ([lang-spec (send lang get-reader-module)])
(when lang-spec (when lang-spec
(let* ([lines (send lang get-metadata-lines)] (let* ([lines (send lang get-metadata-lines)]
[str (send text get-text [str (send text get-text
0 0
(send text paragraph-end-position (- lines 1)))] (send text paragraph-end-position (- lines 1)))]
[sp (open-input-string str)]) [sp (open-input-string str)])
@ -55,6 +55,8 @@
(define (looks-like-new-module-style? text) (define (looks-like-new-module-style? text)
(let* ([tp (open-input-text-editor text 0 'end (lambda (s) s) text #t)] (let* ([tp (open-input-text-editor text 0 'end (lambda (s) s) text #t)]
[l1 (read-line tp)]) [l1 (with-handlers ([exn:fail? (lambda (exn) eof)])
;; If tp contains a snip, read-line fails.
(read-line tp))])
(and (string? l1) (and (string? l1)
(regexp-match #rx"#lang .*$" l1))))) (regexp-match #rx"#lang .*$" l1)))))