Commit 46a7fdca 46a7fdca36e33c5afab5d567b5c38bce0d985f4f by Sergey Poznyakoff

Add "#!" magic to the beginning of the output script.

Improved diagnostics. Fixed bug in next-token-from-port.
1 parent df3e3482
...@@ -214,7 +214,8 @@ ...@@ -214,7 +214,8 @@
214 (>= i len)))))) 214 (>= i len))))))
215 #f) 215 #f)
216 (set! input-line-number (1+ input-line-number)) 216 (set! input-line-number (1+ input-line-number))
217 (if (and (char=? (string-ref line 0) #\.) 217 (if (and (not (string-null? line))
218 (char=? (string-ref line 0) #\.)
218 (char=? (string-ref line 1) #\.)) 219 (char=? (string-ref line 1) #\.))
219 (set! line (make-shared-substring line 1))) 220 (set! line (make-shared-substring line 1)))
220 (set! text (string-append text "\n" line))) 221 (set! text (string-append text "\n" line)))
...@@ -843,6 +844,7 @@ ...@@ -843,6 +844,7 @@
843 (call-with-output-file 844 (call-with-output-file
844 outfile 845 outfile
845 (lambda (port) 846 (lambda (port)
847 (display "#! /home/gray/mailutils/guimb/guimb --source\n!#\n" port)
846 (display (string-append 848 (display (string-append
847 ";;;; A Guile mailbox parser made from " filename) port) 849 ";;;; A Guile mailbox parser made from " filename) port)
848 (newline port) 850 (newline port)
...@@ -907,6 +909,8 @@ ...@@ -907,6 +909,8 @@
907 (value #t)) 909 (value #t))
908 (help (single-char #\h)))) 910 (help (single-char #\h))))
909 911
912 (define program-name (car (command-line)))
913
910 (for-each 914 (for-each
911 (lambda (x) 915 (lambda (x)
912 (cond 916 (cond
...@@ -922,7 +926,8 @@ ...@@ -922,7 +926,8 @@
922 926
923 (if (not filename) 927 (if (not filename)
924 (begin 928 (begin
925 (display "missing input filename") 929 (display program-name)
930 (display ": missing input filename")
926 (newline) 931 (newline)
927 (sieve-usage))) 932 (sieve-usage)))
928 933
...@@ -935,7 +940,9 @@ ...@@ -935,7 +940,9 @@
935 (exit 0))) 940 (exit 0)))
936 (if (not (file-exists? filename)) 941 (if (not (file-exists? filename))
937 (begin 942 (begin
938 (display (string-append "Input file " filename " does not exist.")) 943 (display (string-append
944 program-name
945 ": Input file " filename " does not exist."))
939 (newline) 946 (newline)
940 (exit 0)))) 947 (exit 0))))
941 948
...@@ -963,7 +970,8 @@ ...@@ -963,7 +970,8 @@
963 (output 970 (output
964 (sieve-save-program output)) 971 (sieve-save-program output))
965 ((not guimb?) 972 ((not guimb?)
966 (display "sieve.scm: Either use guimb to compile and execute the script") 973 (display program-name)
974 (display ": Either use guimb to compile and execute the script")
967 (newline) 975 (newline)
968 (display "or use --output option to save the Scheme program.") 976 (display "or use --output option to save the Scheme program.")
969 (newline) 977 (newline)
......