Cleaned up the CONSTANT-GLOB? function a bit.
This commit is contained in:
parent
ff5d65fc30
commit
38c76cdf84
|
@ -129,21 +129,17 @@
|
|||
;;; Is the glob pattern free of *'s, ?'s and [...]'s?
|
||||
(define (constant-glob? pattern)
|
||||
(let ((patlen (string-length pattern)))
|
||||
(let lp ((i 0)
|
||||
(escape? #f)) ; Was last char an escape char (backslash)?
|
||||
(if (= i patlen)
|
||||
|
||||
(if escape?
|
||||
(error "Ill-formed glob pattern" pattern)
|
||||
#t)
|
||||
|
||||
(let lp ((i 0))
|
||||
(or (= i patlen)
|
||||
(let ((next-i (+ i 1)))
|
||||
(if escape? (lp next-i #f)
|
||||
(case (string-ref pattern i)
|
||||
((#\\) ; Escape char
|
||||
(if (= next-i patlen)
|
||||
(error "Ill-formed glob pattern -- ends in backslash"
|
||||
pattern)
|
||||
(lp (+ next-i 1))))
|
||||
((#\* #\? #\[) #f)
|
||||
((#\\) (lp next-i #t))
|
||||
(else (lp next-i #f)))
|
||||
(lp next-i #f)))))))
|
||||
(else (lp next-i))))))))
|
||||
|
||||
|
||||
;;; Make an effort to get the files in the putative directory PATH.
|
||||
|
|
Loading…
Reference in New Issue