2 ; general-purpose scheme utility functions
5 (define-module (app gwave utils)
6 :use-module (ice-9 regex)
9 (debug-enable 'backtrace)
12 ; join - a procedure like the perl function "join:"
13 ; concatenate list of strings, putting a seperator string between each
14 ; element of the list.
15 (define-public (join s l)
17 ((= 1 (length l)) (car l))
18 (else (string-append (car l) s (join s (cdr l))))))
20 ; filter out shell metacharacters from a string
21 (define metachars-regexp (make-regexp "[\t <>()|&;^\\$]+"))
22 (define-public (filter-metachars s)
23 (regexp-substitute/global #f metachars-regexp s 'pre 'post))
26 ; use regular expression to find portion of string like
27 ; <dot><upper case letters><dot>
28 (define-public (find-dotupper s)
29 (let* ((r (make-regexp "\\.([A-Z][A-Z]*)\\."))
30 (m (regexp-exec r s)))