diff options
Diffstat (limited to 'scheme/idest/batch/setpic.scm')
-rw-r--r-- | scheme/idest/batch/setpic.scm | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/scheme/idest/batch/setpic.scm b/scheme/idest/batch/setpic.scm index c0670a3..834a571 100644 --- a/scheme/idest/batch/setpic.scm +++ b/scheme/idest/batch/setpic.scm | |||
@@ -1,5 +1,5 @@ | |||
1 | ;; This file is part of Idest | 1 | ;; This file is part of Idest |
2 | ;; Copyright (C) 2011 Sergey Poznyakoff | 2 | ;; Copyright (C) 2011, 2015 Sergey Poznyakoff |
3 | ;; | 3 | ;; |
4 | ;; Idest is free software; you can redistribute it and/or modify | 4 | ;; Idest is free software; you can redistribute it and/or modify |
5 | ;; it under the terms of the GNU General Public License as published by | 5 | ;; it under the terms of the GNU General Public License as published by |
@@ -16,7 +16,8 @@ | |||
16 | 16 | ||
17 | (define-module (idest batch setpic)) | 17 | (define-module (idest batch setpic)) |
18 | 18 | ||
19 | (use-modules (ice-9 getopt-long)) | 19 | (use-modules (ice-9 getopt-long) |
20 | (rnrs io ports)) | ||
20 | 21 | ||
21 | (define-public description | 22 | (define-public description |
22 | "set attached picture from a file") | 23 | "set attached picture from a file") |
@@ -26,17 +27,16 @@ | |||
26 | (define (read-picture file) | 27 | (define (read-picture file) |
27 | (with-output-to-string | 28 | (with-output-to-string |
28 | (lambda () | 29 | (lambda () |
29 | (with-input-from-file | 30 | (let ((port (open-file-input-port file))) |
30 | file | 31 | (let ((get-byte (lambda () (get-u8 port)))) |
31 | (lambda () | 32 | (let loop ((n (get-byte))) |
32 | (let loop ((chr (read-char))) | ||
33 | (cond | 33 | (cond |
34 | ((not (eof-object? chr)) | 34 | ((not (eof-object? n)) |
35 | (let ((n (char->integer chr))) | 35 | (if (< n 16) |
36 | (if (< n 16) | 36 | (display "0")) |
37 | (display "0")) | 37 | (display (number->string n 16)) |
38 | (display (number->string n 16))) | 38 | (loop (get-byte)))))) |
39 | (loop (read-char)))))))))) | 39 | (close-port port))))) |
40 | 40 | ||
41 | (define-public (idest-init) | 41 | (define-public (idest-init) |
42 | (let* ((cmd (command-line)) | 42 | (let* ((cmd (command-line)) |