section/keys can now be symbols and strings
This commit is contained in:
@@ -41,6 +41,12 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(define (section=? sect inp-sect)
|
||||||
|
(string-ci=? (format "~a" sect) (format "~a" inp-sect)))
|
||||||
|
|
||||||
|
(define (key=? key inp-key)
|
||||||
|
(section=? key inp-key))
|
||||||
|
|
||||||
(define (ini->file ini file #:private? [private? #f])
|
(define (ini->file ini file #:private? [private? #f])
|
||||||
(let* ((file (get-ini-file file))
|
(let* ((file (get-ini-file file))
|
||||||
(_ (make-parent-directory* file))
|
(_ (make-parent-directory* file))
|
||||||
@@ -54,7 +60,7 @@
|
|||||||
(let ((last-is-newline #f))
|
(let ((last-is-newline #f))
|
||||||
(for-each (lambda (section)
|
(for-each (lambda (section)
|
||||||
(let ((section-name (car section)))
|
(let ((section-name (car section)))
|
||||||
(if (eq? section-name 'nil)
|
(if (section=? section-name 'nil)
|
||||||
#t
|
#t
|
||||||
(begin
|
(begin
|
||||||
(unless last-is-newline (newline out))
|
(unless last-is-newline (newline out))
|
||||||
@@ -155,13 +161,13 @@
|
|||||||
(letrec ((g (lambda (ini)
|
(letrec ((g (lambda (ini)
|
||||||
(if (null? ini)
|
(if (null? ini)
|
||||||
def-val
|
def-val
|
||||||
(if (eq? section (caar ini))
|
(if (section=? section (caar ini))
|
||||||
(letrec ((f (lambda (l)
|
(letrec ((f (lambda (l)
|
||||||
(if (null? l)
|
(if (null? l)
|
||||||
def-val
|
def-val
|
||||||
(let ((entry (car l)))
|
(let ((entry (car l)))
|
||||||
(if (eq? (car entry) 'keyval)
|
(if (eq? (car entry) 'keyval)
|
||||||
(if (eq? (cadr entry) key)
|
(if (key=? (cadr entry) key)
|
||||||
(caddr entry)
|
(caddr entry)
|
||||||
(f (cdr l)))
|
(f (cdr l)))
|
||||||
(f (cdr l))))))))
|
(f (cdr l))))))))
|
||||||
@@ -180,7 +186,7 @@
|
|||||||
(list (list 'keyval key val))))
|
(list (list 'keyval key val))))
|
||||||
(let ((entry (car sect)))
|
(let ((entry (car sect)))
|
||||||
(if (eq? (car entry) 'keyval)
|
(if (eq? (car entry) 'keyval)
|
||||||
(if (eq? (cadr entry) key)
|
(if (key=? (cadr entry) key)
|
||||||
(begin
|
(begin
|
||||||
(set! found #t)
|
(set! found #t)
|
||||||
(cons (list 'keyval key val) (for-sect (cdr sect))))
|
(cons (list 'keyval key val) (for-sect (cdr sect))))
|
||||||
@@ -193,7 +199,7 @@
|
|||||||
(list (list section (list 'keyval key val))))
|
(list (list section (list 'keyval key val))))
|
||||||
(let* ((ini-section (car ini))
|
(let* ((ini-section (car ini))
|
||||||
(section-key (car ini-section)))
|
(section-key (car ini-section)))
|
||||||
(if (eq? section-key section)
|
(if (section=? section-key section)
|
||||||
(cons (cons section (for-sect (cdr ini-section))) (for-ini (cdr ini)))
|
(cons (cons section (for-sect (cdr ini-section))) (for-ini (cdr ini)))
|
||||||
(cons ini-section (for-ini (cdr ini)))))))))
|
(cons ini-section (for-ini (cdr ini)))))))))
|
||||||
(let ((new-ini (for-ini (mcdr ini))))
|
(let ((new-ini (for-ini (mcdr ini))))
|
||||||
|
|||||||
Reference in New Issue
Block a user