File: utils.scm

package info (click to toggle)
gwave 20031224-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,512 kB
  • ctags: 1,065
  • sloc: ansic: 8,029; lisp: 1,619; sh: 1,202; makefile: 170
file content (24 lines) | stat: -rw-r--r-- 670 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
;
; general-purpose scheme utility functions 
;

(define-module (app gwave utils)
  :use-module (ice-9 regex)
)

(debug-enable 'backtrace)
(debug-enable 'debug)

; join - a procedure like the perl function "join:"
; concatenate list of strings, putting a seperator string between each
; element of the list.
(define-public (join s l)
  (cond ((null? l)     "")
        ((= 1 (length l))     (car l))
        (else (string-append (car l) s (join s (cdr l))))))

; filter out shell metacharacters from a string
(define metachars-regexp (make-regexp "[\t <>\(\)|&;^\$]+"))
(define-public (filter-metachars s)
  (regexp-substitute/global #f metachars-regexp s 'pre 'post))