Overview
Context
Changes
Added configf-testing/Makefile version [4635f99b20].
|
1
2
3
4
5
6
7
|
+
+
+
+
+
+
+
|
%.o : %.scm
csc -J -c $< -o $*.o
c : c.o a.o
csc a.o c.o -o c
|
| | | | | |
Added configf-testing/a.scm version [b6730203d0].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
(declare (unit a))
(module a
*
(import scheme chicken posix)
(define (a:normalize-dir d)
(if (and (file-exists? d)
(directory? d))
(let ((curr (current-directory)))
(change-directory d)
(let ((nd (current-directory)))
(change-directory curr)
nd))
d))
)
|
| | | | | | | | | | | | | | | | | | | | |
Modified configf-testing/c.scm
from [4d512f0590]
to [3ae900a3b5].
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
|
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
47
48
49
50
51
52
|
+
+
+
-
+
+
-
+
+
+
+
+
+
+
|
(declare (uses a))
;; pretend to be a config file processor
(use posix srfi-69)
;; (define getenv get-environment-variable)
(define (print-hash-table ht)
(print "ht=")
(print "ht=" (hash-table->alist ht)))
(pp (hash-table->alist ht)))
(define cfgdata (conc "(use simple-md5)"
"(import a)"
"(set! getenv get-environment-variable)"
"(hash-table-set! ht \"PATH\" (getenv \"PATH\"))"
"(hash-table-set! ht \"currdir\" (current-directory))"
"(hash-table-set! ht \"md5sum\" (string->md5sum \"Hello\"))"))
"(hash-table-set! ht \"md5sum\" (string->md5sum \"Hello\"))"
;; in mtconfigf the below is not working
"(hash-table-set! ht \"var-tmp\" (a:normalize-dir \"/var/tmp\"))"))
(define (faux-cfg-processor ht cfgdata)
(let* ((proc-str (conc "(lambda (ht)" cfgdata ")")))
(with-input-from-string proc-str
(lambda ()
((eval (read)) ht)))))
(module cfgprocessor
*
(import ports data-structures chicken scheme files srfi-69 posix srfi-1)
(define (faux-cfg-processor-modularized ht cfgdata)
(let* ((proc-str (conc "(lambda (ht)" cfgdata ")")))
(with-input-from-string proc-str
(lambda ()
((eval (read)) ht)))))
)
(import cfgprocessor)
(import a)
(print "\nCan I run stuff from module \"a\":")
(print (a:normalize-dir "/var/tmp"))
(print "\nRun the non-modularized version")
(let ((ht (make-hash-table)))
(faux-cfg-processor ht cfgdata)
(print-hash-table ht))
(print "\nRun the modularized version")
(let ((ht (make-hash-table)))
(faux-cfg-processor-modularized ht cfgdata)
(print-hash-table ht))
|
| |