Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[297218]: news-items.lisp Maximize Restore History

Download this file

news-items.lisp    47 lines (46 with data), 2.1 kB

 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
39
40
41
42
43
44
45
46
(defun convert-news ()
(with-open-file (news-i (merge-pathnames "NEWS" *root*) :direction :input)
(with-open-file (news-o (merge-pathnames "news.lisp-expr" *root*)
:direction :output
:if-exists :supersede)
(loop for line = (read-line news-i nil nil)
with level = 0
with need-close-string = nil
while line
do
(progn
(setf line (regex-replace-all "\\\\" line "\\\\\\\\"))
(setf line (regex-replace-all "\"" line "\\\""))
(or
(when (scan "^(?i)changes in sbcl-([0-9a-zA-Z.]+) relative.*$" line)
(when need-close-string
(write-string "\"" news-o)
(setf need-close-string nil))
(dotimes (i level)
(write-string ")" news-o))
(setf level 1)
(setf line (regex-replace-all "^(?i)changes in sbcl-([0-9a-zA-Z.]+) relative.*$"
line
"(define-news \"\\1\"")))
(when (scan "^(?i)\\s*(\\*+)\\s*\\S.+$" line)
(when need-close-string
(write-string "\"" news-o))
(let ((c (length
(elt
(nth-value 1
(scan-to-strings "^(?i)\\s*(\\*+).+$" line)) 0))))
(dotimes (i (- level c))
(write-string ")" news-o))
(setf level (1+ c))
(write-string "(" news-o))
(setf need-close-string t)
(setf line (regex-replace-all "^\\s*\\*+\\s*(\\S.+)$" line "\"\\1"))))
(write-string line news-o)
(terpri news-o))
finally
(progn
(when need-close-string
(write-string "\"" news-o)
(setf need-close-string nil))
(dotimes (i level)
(write-string ")" news-o)))))))