diff --git a/n.c b/n.c index 3b044fc..c63362e 100644 --- a/n.c +++ b/n.c @@ -1,5 +1,6 @@ /* n.c -- generated via skint nsf2c.ssc n.sf */ +#include "s.h" #include "n.h" #ifdef NAN_BOXING @@ -999,8 +1000,6 @@ void oportputshared(obj x, obj p, int disp) { /* system-dependent extensions */ -#include "s.h" - extern int is_tty_port(obj o) { diff --git a/pre/n.sf b/pre/n.sf index 6dbaa7a..a037687 100644 --- a/pre/n.sf +++ b/pre/n.sf @@ -4,6 +4,7 @@ ; ;------------------------------------------------------------------------------ +(%include "s.h") ;------------------------------------------------------------------------------ @@ -1526,7 +1527,6 @@ void oportputshared(obj x, obj p, int disp) { ; system-dependent extensions (%localdef "/* system-dependent extensions */") -(%localdef "#include \"s.h\"") (%localdef " extern int is_tty_port(obj o) diff --git a/pre/nsf2c.ssc b/pre/nsf2c.ssc index 05b0df3..199c9ef 100644 --- a/pre/nsf2c.ssc +++ b/pre/nsf2c.ssc @@ -41,13 +41,19 @@ (display ".c -- generated via skint nsf2c.ssc " oport) (display (path-strip-directory ifname) oport) (display " */" oport) (newline oport) (newline oport) - (display "#include \"" oport) - (display mname oport) - (display ".h\"" oport) (newline oport) (newline oport) - (let loop ([x (read iport)]) + (let loop ([x (read iport)] [end-of-includes? #f]) (unless (eof-object? x) - (process-top-form x oport) - (loop (read iport)))) + (cond [end-of-includes? + (process-top-form x oport) + (loop (read iport) #t)] + [(and (list2? x) (eq? (car x) '%include) (string? (cadr x))) + (display "#include " oport) (write (cadr x) oport) (newline oport) + (loop (read iport) #f)] + [else ; switching to body forms + (display "#include \"" oport) (display mname oport) + (display ".h\"" oport) (newline oport) (newline oport) + (process-top-form x oport) + (loop (read iport) #t)]))) (close-input-port iport) (if (pair? ?ofname) (close-output-port oport))) diff --git a/pre/nsf2h.ssc b/pre/nsf2h.ssc index d0fb7f9..c4d62dc 100644 --- a/pre/nsf2h.ssc +++ b/pre/nsf2h.ssc @@ -117,7 +117,7 @@ extern char **cxg_argv; (case (car x) [(%definition) (display (cadr x) oport) (newline oport)] [(%localdef)] ; does not go into n.h - [(%include)]))) ; time.h already in prelude + [(%include)]))) ; all needed includes already included (define (process-file ifname . ?ofname) (define iport (open-input-file ifname)) ; relative to wd, not this script!