File: pull-texi.scm

package info (click to toggle)
nyacc 1.09.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,540 kB
  • sloc: lisp: 34,985; sh: 682; makefile: 462; ansic: 279; javascript: 61; tcl: 27
file content (38 lines) | stat: -rwxr-xr-x 1,050 bytes parent folder | download | duplicates (3)
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