refuse -o - for an executable or an object
Only the text outputs knew `-' as stdout; compiling handed it to cc as a file name, and left a binary called `-' behind.
This commit is contained in:
12
sexc.scm
12
sexc.scm
@@ -59,8 +59,8 @@
|
||||
(value #f)
|
||||
(single-char #\m))
|
||||
(output ,(fmt #f "Write output to file. Default file name is a.out." nl
|
||||
(pad padding) "If -C or -m options are provided, defaults to stdout;" nl
|
||||
(pad padding) "`-' is stdout too")
|
||||
(pad padding) "With -C, -m or --public-interface, defaults to stdout," nl
|
||||
(pad padding) "which `-' names too")
|
||||
(required #f)
|
||||
(value #t)
|
||||
(single-char #\o))
|
||||
@@ -145,6 +145,12 @@
|
||||
(define (stdout-output? output)
|
||||
(or (eq? output 'default) (equal? output "-")))
|
||||
|
||||
;;; Whether ARGS ask for text, which `-o -' can send to stdout. An
|
||||
;;; executable or an object goes to cc's -o, where `-' is a file name
|
||||
(define (text-output? args)
|
||||
(any (lambda (option) (get-arg args option #f))
|
||||
'(emit-c macro-expand public-interface)))
|
||||
|
||||
(define (write-to-file-or-stdout output what)
|
||||
(if (stdout-output? output)
|
||||
(what)
|
||||
@@ -254,6 +260,8 @@ status, which is ours to pass on."
|
||||
(when help
|
||||
(print-help)
|
||||
(return #f))
|
||||
(when (and (equal? output "-") (not (text-output? args)))
|
||||
(error "-o - is stdout, which takes only -C, -m or --public-interface"))
|
||||
;; Read time comes before everything, so the features have to be
|
||||
;; in place before the first form is read
|
||||
(current-features
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
# The failure paths.
|
||||
#
|
||||
# Both need a process to show themselves, so neither fits the unit
|
||||
# suite: sexc has to fail when cc fails -- exiting 0 after a failed
|
||||
# compile makes every driver, sextest included, read it as success --
|
||||
# and it has to clean up its temporary .c when its own emission throws.
|
||||
# Each needs a process to show itself, so none fits the unit suite:
|
||||
# sexc has to fail when cc fails -- exiting 0 after a failed compile
|
||||
# makes every driver, sextest included, read it as success -- it has to
|
||||
# clean up its temporary .c when its own emission throws, and it has to
|
||||
# refuse `-o -' for an executable, which cc would write to a file named
|
||||
# `-'.
|
||||
#
|
||||
# Everything is built inside a scratch TMPDIR, so nothing is left here
|
||||
# to clean up.
|
||||
# Everything is built inside a scratch directory, so nothing is left
|
||||
# here to clean up.
|
||||
|
||||
SEXC ?= ../../sexc
|
||||
|
||||
@@ -21,6 +23,10 @@ check:
|
||||
echo "exit code FAILED: sexc reported success after cc failed"; \
|
||||
rm -rf $$d; exit 1; \
|
||||
fi; \
|
||||
if (cd $$d && $(abspath $(SEXC)) $(CURDIR)/hello.sex -o - >/dev/null 2>&1) || [ -e $$d/- ]; then \
|
||||
echo "exit code FAILED: -o - built an executable"; \
|
||||
rm -rf $$d; exit 1; \
|
||||
fi; \
|
||||
rm -rf $$d; echo "exit code ok"
|
||||
|
||||
.PHONY: check
|
||||
|
||||
Reference in New Issue
Block a user