/usr/lib/name-to-file-name.scm is in scheme9 2013.11.26-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | ; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2009
; Placed in the Public Domain
;
; (name->file-name string) ==> string
;
; (load-from-library "name-to-file-name.scm")
;
; Map the given symbol name to a name that is a valid file name
; on most computer file systems. In particular, the procedure
; replaces the following characters:
;
; character(s) becomes
; @ at
; + plus
; * star
; / slash
; ? p (predicate)
; ! b (bang)
; = eq
; -> -to-
; < lt
; <= le
; > gt
; >= ge
;
; In addition a name that consists of a minus sign exclusively
; ("-") is replaced with "minus". All other special characters
; are replaced with an underscore. Non-special characters include
; the letters a-z, the digits 0-9, the minus sign, and the dot.
;
; Example: (name->file-name "sys:stat-pipe?") ==> "sys_stat-pipep"
; (name->file-name "a->b") ==> "a-to-b"
; (name->file-name "*foo*") ==> "starfoostar"
(define (name->file-name name)
(let xlate ((in (string->list name))
(out '()))
(cond ((null? in)
(if (string=? name "-")
"minus"
(apply string-append (reverse! out))))
((char=? #\@ (car in))
(xlate (cdr in) (cons "at" out)))
((char=? #\+ (car in))
(xlate (cdr in) (cons "plus" out)))
((char=? #\* (car in))
(xlate (cdr in) (cons "star" out)))
((char=? #\/ (car in))
(xlate (cdr in) (cons "slash" out)))
((char=? #\? (car in))
(xlate (cdr in) (cons "p" out)))
((char=? #\! (car in))
(xlate (cdr in) (cons "b" out)))
((char=? #\= (car in))
(xlate (cdr in) (cons "eq" out)))
((and (char=? #\- (car in))
(pair? (cdr in))
(char=? #\> (cadr in)))
(xlate (cddr in) (cons "-to-" out)))
((char=? #\< (car in))
(if (and (pair? (cdr in))
(char=? #\= (cadr in)))
(xlate (cddr in) (cons "le" out))
(xlate (cdr in) (cons "lt" out))))
((char=? #\> (car in))
(if (and (pair? (cdr in))
(char=? #\= (cadr in)))
(xlate (cddr in) (cons "ge" out))
(xlate (cdr in) (cons "gt" out))))
((or (char-numeric? (car in))
(char-alphabetic? (car in))
(memv (car in) '(#\- #\.)))
(xlate (cdr in) (cons (string (car in)) out)))
(else
(xlate (cdr in) (cons "_" out))))))
|