1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#!/usr/bin/env guile -s
!#
;; pull-texi.scm
;;
;; Extract embedded texinfo from .scm files.
;;
;; Copyright (C) 2015 Matthew R. Wette
;;
;; This software is covered by the GNU GENERAL PUBLIC LICENCE, Version 3,
;; or any later version published by the Free Software Foundation. See the
;; file COPYING included with this distribution.
(use-modules (ice-9 rdelim))
(let* ((files (cdr (program-arguments))))
(for-each
(lambda (f)
(simple-format
#t "\n~A\n"
(string-join
(with-input-from-file f
(lambda ()
(let iter ((res '()) (pn #f) (line (read-line)))
(if (string? line)
(if pn
(if (and (> (string-length line) 2)
(string=? ";; " (substring line 0 3)))
(iter (cons (substring line 3) res) #t (read-line))
(iter res #f (read-line)))
(if (and (> (string-length line) 3)
(string=? ";; @" (substring line 0 4)))
(iter (cons (substring line 3) res) #t (read-line))
(iter res #f (read-line))))
(reverse res)))))
"\n")))
files))
;;; --- last line
|