n.c header order fixes

This commit is contained in:
ESL 2024-07-22 18:24:24 -04:00
parent d84362c0ab
commit 09e5b3b4f7
4 changed files with 15 additions and 10 deletions

3
n.c
View file

@ -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)
{

View file

@ -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)

View file

@ -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)))

View file

@ -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!