32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
(prefix sqlite3 sqlite3:)
data-structures
extras
files
matchable
md5
message-digest
posix
regex
regex-case
srfi-1
srfi-18
srfi-69
typed-records
|
>
>
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
(prefix sqlite3 sqlite3:)
data-structures
extras
files
matchable
md5
message-digest
pathname-expand
posix
posix-extras
regex
regex-case
srfi-1
srfi-18
srfi-69
typed-records
|
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
#f ;; I don't really care why this failed (at least for now)
(delete-file* fname)))
;;======================================================================
;; misc conversion, data manipulation functions
;;======================================================================
;; if it looks like a number -> convert it to a number, else return it
;;
(define (lazy-convert inval)
(let* ((as-num (if (string? inval)(string->number inval) #f)))
(or as-num inval)))
;; to '((a . 1)(b . 2)(c . "a silly thing")(d . ""))
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
#f ;; I don't really care why this failed (at least for now)
(delete-file* fname)))
;;======================================================================
;; misc conversion, data manipulation functions
;;======================================================================
;;======================================================================
;; return first command that exists, else #f
;;
(define (common:which cmds)
(if (null? cmds)
#f
(let loop ((hed (car cmds))
(tal (cdr cmds)))
(let ((res (with-input-from-pipe (conc "which " hed) read-line)))
(if (and (string? res)
(file-exists? res))
res
(if (null? tal)
#f
(loop (car tal)(cdr tal))))))))
(define (common:get-megatest-exe)
(let* ((mtexe (or (get-environment-variable "MT_MEGATEST")
(common:which '("megatest"))
"megatest")))
(if (file-exists? mtexe)
(realpath mtexe)
mtexe)))
(define (common:get-megatest-exe-dir)
(let* ((mtexe (common:get-megatest-exe)))
(pathname-directory mtexe)))
;; more generic and comprehensive version of get-megatest-exe
;;
(define (common:get-mtexe)
(let* ((mtpathdir (common:get-megatest-exe-dir)))
(or (common:get-megatest-exe)
(if mtpathdir
(conc mtpathdir"/megatest")
#f)
"megatest")))
(define (common:get-megatest-exe-path)
(let* ((mtpathdir (common:get-megatest-exe-dir)))
(conc mtpathdir":"(get-environment-variable "PATH") ":.")))
(define (realpath x) (resolve-pathname (pathname-expand (or x "/dev/null")) ))
;; if it looks like a number -> convert it to a number, else return it
;;
(define (lazy-convert inval)
(let* ((as-num (if (string? inval)(string->number inval) #f)))
(or as-num inval)))
;; to '((a . 1)(b . 2)(c . "a silly thing")(d . ""))
|