|
1 | 1 | ;; |
2 | | -;; Copyright (C) 2024 The Goldfish Scheme Authors |
| 2 | +;; Copyright (C) 2026 The Goldfish Scheme Authors |
3 | 3 | ;; |
4 | 4 | ;; Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | ;; you may not use this file except in compliance with the License. |
|
40 | 40 | ) ;define |
41 | 41 |
|
42 | 42 | ;; Trim leading and trailing whitespace (space/tab) |
43 | | - (define (ini-trim str) |
| 43 | + (define (ini-string-trim str) |
44 | 44 | (let ((len (string-length str))) |
45 | 45 | (let loop-start |
46 | 46 | ((i 0)) |
|
79 | 79 | ;; Parse a section header line like "[name]" |
80 | 80 | ;; Returns section name string, or #f if not a section header |
81 | 81 | (define (parse-section-name line) |
82 | | - (let* ((trimmed (ini-trim line)) (len (string-length trimmed))) |
| 82 | + (let* ((trimmed (ini-string-trim line)) (len (string-length trimmed))) |
83 | 83 | (if (and (> len 1) |
84 | 84 | (char=? (string-ref trimmed 0) #\[) |
85 | 85 | (char=? (string-ref trimmed (- len 1)) #\]) |
86 | 86 | ) ;and |
87 | | - (ini-trim (substring trimmed 1 (- len 1))) |
| 87 | + (ini-string-trim (substring trimmed 1 (- len 1))) |
88 | 88 | #f |
89 | 89 | ) ;if |
90 | 90 | ) ;let* |
|
100 | 100 | (let ((line (read-line inport))) |
101 | 101 | (cond ((eof-object? line) (eof-object)) |
102 | 102 | (else (let* ((no-comment (remove-comment line comment-delim)) |
103 | | - (trimmed (ini-trim no-comment)) |
| 103 | + (trimmed (ini-string-trim no-comment)) |
104 | 104 | ) ; |
105 | 105 | (if (string=? trimmed "") |
106 | 106 | (loop) |
107 | 107 | (let ((section-name (parse-section-name trimmed))) |
108 | 108 | (cond (section-name (set! current-section (string->symbol section-name)) (loop)) |
109 | 109 | (else (let ((kv (split-at-first trimmed key-value-sep))) |
110 | 110 | (if kv |
111 | | - (let ((key-str (ini-trim (car kv))) (val-str (ini-trim (cdr kv)))) |
| 111 | + (let ((key-str (ini-string-trim (car kv))) (val-str (ini-string-trim (cdr kv)))) |
112 | 112 | (list current-section (string->symbol key-str) val-str) |
113 | 113 | ) ;let |
114 | 114 | (list current-section (string->symbol trimmed) #f) |
|
0 commit comments