refuse a second input file
It was never read, and nothing said so.
This commit is contained in:
15
sexc.scm
15
sexc.scm
@@ -146,11 +146,14 @@
|
|||||||
(map string->symbol (string-split (cdr entry) ",")))
|
(map string->symbol (string-split (cdr entry) ",")))
|
||||||
(filter (lambda (entry) (eq? (car entry) 'features)) args)))
|
(filter (lambda (entry) (eq? (car entry) 'features)) args)))
|
||||||
|
|
||||||
(define (get-input-file args)
|
(define (get-input-file args dash?)
|
||||||
(let ((rest-args (get-rest-args args)))
|
(let ((inputs (append (if dash? (list "-") (list)) (get-rest-args args))))
|
||||||
(if (null? rest-args)
|
(cond ((null? inputs) 'stdin)
|
||||||
'stdin
|
;; any after the first were never read, and nothing said so
|
||||||
(car rest-args))))
|
((pair? (cdr inputs))
|
||||||
|
(apply error "sexc compiles one input file at a time; given" inputs))
|
||||||
|
(dash? 'stdin)
|
||||||
|
(else (car inputs)))))
|
||||||
|
|
||||||
(define (stdout-output? output)
|
(define (stdout-output? output)
|
||||||
(or (eq? output 'default) (equal? output "-")))
|
(or (eq? output 'default) (equal? output "-")))
|
||||||
@@ -266,7 +269,7 @@ status, which is ours to pass on."
|
|||||||
(output (get-arg args 'output 'default))
|
(output (get-arg args 'output 'default))
|
||||||
(help (help-arg? args))
|
(help (help-arg? args))
|
||||||
|
|
||||||
(input (if (stdin-dash? raw-args) 'stdin (get-input-file args)))
|
(input (get-input-file args (stdin-dash? raw-args)))
|
||||||
(current-dir (current-directory)))
|
(current-dir (current-directory)))
|
||||||
(call/cc
|
(call/cc
|
||||||
(lambda (return)
|
(lambda (return)
|
||||||
|
|||||||
@@ -80,6 +80,18 @@
|
|||||||
(and (zero? (car run)) (substring-index "main" (cadr run)) #t)))
|
(and (zero? (car run)) (substring-index "main" (cadr run)) #t)))
|
||||||
(change-directory scratch)
|
(change-directory scratch)
|
||||||
|
|
||||||
|
;;; the second was never read, and nothing said so
|
||||||
|
(test-assert "a second input is refused"
|
||||||
|
(let ((run (sexc-run #f hello hello "-C" "-o" "-")))
|
||||||
|
(and (not (zero? (car run)))
|
||||||
|
(substring-index "one input file at a time" (caddr run))
|
||||||
|
#t)))
|
||||||
|
(test-assert "stdin besides a file too"
|
||||||
|
(let ((run (sexc-run hello-source "-" hello "-C" "-o" "-")))
|
||||||
|
(and (not (zero? (car run)))
|
||||||
|
(substring-index "one input file at a time" (caddr run))
|
||||||
|
#t)))
|
||||||
|
|
||||||
(test "-o - is refused for an executable" #f
|
(test "-o - is refused for an executable" #f
|
||||||
(sexc-succeeds? hello "-o" "-"))
|
(sexc-succeeds? hello "-o" "-"))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user