src/module-impl.lisp: Indent the first line of a C fragment on output.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 8 Aug 2019 00:49:41 +0000 (01:49 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 8 Aug 2019 00:49:41 +0000 (01:49 +0100)
If we make the text appear in the right column, then GCC (at least) will
print out the correct line of the original Sod module and underline the
right pieces of it in error messages.  Which is pretty awesome,
actually.

src/module-impl.lisp

index 44aa0b8..1eb2531 100644 (file)
                 (prin1 (subseq text 0 37) stream)
                 (write-string "..." stream))))
        (output-c-excursion stream location
-                           (lambda (stream) (write-string text stream))))))
+                           (lambda (stream)
+                             (awhen (file-location-column location)
+                               (dotimes (i it) (write-char #\space stream)))
+                             (write-string text stream))))))
 
 (defmethod make-load-form ((fragment c-fragment) &optional environment)
   (make-load-form-saving-slots fragment :environment environment))