~ chicken-core (chicken-5) f06dc5746cf4b0d15be21a03ccd105206f2589af


commit f06dc5746cf4b0d15be21a03ccd105206f2589af
Author:     Evan Hanson <evhan@foldling.org>
AuthorDate: Fri Apr 27 21:00:41 2018 +0200
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Fri Apr 27 21:18:25 2018 +0200

    Slightly nicer formatting of generated foreign-lambda* code
    
    This puts each string in a foreign-lambda* and foreign-primitive body on
    its own line (rather than all in one big long line), making it easier to
    track down errors produced by the C compiler.
    
    Closes #1387.
    
    Thanks to LemonBoy for the patch.
    
    Signed-off-by: felix <felix@call-with-current-continuation.org>

diff --git a/core.scm b/core.scm
index f94e1e64..ac35785f 100644
--- a/core.scm
+++ b/core.scm
@@ -1834,7 +1834,7 @@
 (define (expand-foreign-lambda* exp callback?)
   (let* ((rtype (second exp))
 	 (args (third exp))
-	 (body (apply string-append (cdddr exp)))
+	 (body (string-intersperse (cdddr exp) "\n"))
  	 (argtypes (map (lambda (x) (car x)) args))
 	 ;; C identifiers aren't hygienically renamed inside body strings
 	 (argnames (map cadr (strip-syntax args))))
@@ -1845,7 +1845,7 @@
   (let* ((hasrtype (and (pair? (cddr exp)) (not (string? (caddr exp)))))
 	 (rtype (if hasrtype (second exp) 'void))
 	 (args (strip-syntax (if hasrtype (third exp) (second exp))))
-	 (body (apply string-append (if hasrtype (cdddr exp) (cddr exp))))
+	 (body (string-intersperse (if hasrtype (cdddr exp) (cddr exp)) "\n"))
  	 (argtypes (map (lambda (x) (car x)) args))
 	 ;; C identifiers aren't hygienically renamed inside body strings
 	 (argnames (map cadr (strip-syntax args))))
Trap