You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/mail-filter/scmail/files/scmail-doc-encoding.patch

29 lines
1.2 KiB

--- a/doc/embed.scm
+++ b/doc/embed.scm
@@ -1,3 +1,4 @@
+(use gauche.charconv)
(use gauche.regexp)
(define (escape str)
(set! str (regexp-replace-all #/&/ str "&"))
@@ -15,12 +16,18 @@
(define (main args)
(call-with-input-file (cadr args)
(lambda (in)
- (let* ((content (port->string in))
+ (let* ((content (port->string (open-input-conversion-port in "*jp")))
(content (regexp-replace-all #/#\{(.*?)\}/ content
(lambda (m)
(string-append
"<pre>\n"
(read-file-and-escape (rxmatch-substring m 1))
- "</pre>\n")))))
+ "</pre>\n"))))
+ (content (regexp-replace #/(encoding=").*?(")/ content
+ (lambda (m)
+ (string-append
+ (rxmatch-substring m 1)
+ (ces-guess-from-string content "*jp")
+ (rxmatch-substring m 2))))))
(display content))))
0)