History

codegen: produce #line directives pointing at otf.[ch].in

Sigrid Solveig Haflínudóttir committed 2 years ago

Commit baa3c241 parent a4302051 file · +11 −6Browse files

Unified · Split

gen.rkt+11−6
@@ -594,6 +594,7 @@ · 593 unmodified lines
594594
595595 (out (at out-dir "otf.h")
596596 (λ ()
597+ (printf "#line 1 \"otf.h.in\"\n")
597598 (printf "~a" (port->string (open-input-file (at in-dir "otf.h.in")) #:close? #t))
598599 (printf "\n")
599600 (printf "~a" (format gen-h))))
@@ -605,9 +606,13 @@ · 5 unmodified lines
605606
606607 (out (at out-dir "otf.c")
607608 (λ ()
608− (printf "~a"
609− (string-replace (port->string (open-input-file (at in-dir "otf.c.in")) #:close? #t)
610− "OTF_EXTRA_FIELDS\n"
611− (format extra-context-fields #:on-all remove-duplicates)))
612− (printf "\n")
613− (printf "~a" (format (λ (c) (gen-c c #f #f))))))
609+ (begin
610+ (define c-data (port->lines (open-input-file (at in-dir "otf.c.in")) #:close? #t))
611+ (define extra-fields-index (index-of c-data "OTF_EXTRA_FIELDS"))
612+ (define extra-fields-data
613+ (string-append (format extra-context-fields #:on-all remove-duplicates)
614+ (~a "#line " (+ extra-fields-index 2) "\"otf.c.in\"")))
615+ (printf "#line 1 \"otf.c.in\"\n")
616+ (for-each (λ (s) (printf "~a\n" s)) (list-set c-data extra-fields-index extra-fields-data))
617+ (printf "\n")
618+ (printf "~a" (format (λ (c) (gen-c c #f #f)))))))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t