Indentation and typo fixes.
In particular, fix Olin's atrocious line-breaking of IFs.
This commit is contained in:
parent
8800f37a3b
commit
abc0cdb34d
|
@ -62,19 +62,20 @@
|
||||||
(lp (+ i 1) hits))
|
(lp (+ i 1) hits))
|
||||||
hits))))
|
hits))))
|
||||||
|
|
||||||
(if (and (zero? hits) (zero? start) (= end (string-length s))) s
|
(if (and (zero? hits) (zero? start) (= end (string-length s)))
|
||||||
|
s
|
||||||
|
(let* ((nlen (- (- end start) (* hits 2))) ; the new length
|
||||||
|
; of the
|
||||||
|
; unescaped
|
||||||
|
; string stores
|
||||||
|
; the result
|
||||||
|
(ns (make-string nlen)))
|
||||||
|
|
||||||
(let* ((nlen (- (- end start) (* hits 2))) ; the new
|
(let lp ((i start) (j 0)) ; sweep over the string
|
||||||
; length of the
|
|
||||||
; unescaped
|
|
||||||
; string
|
|
||||||
(ns (make-string nlen))) ; stores the result
|
|
||||||
|
|
||||||
(let lp ((i start) (j 0)) ; sweap over the string
|
|
||||||
(if (< j nlen)
|
(if (< j nlen)
|
||||||
(lp (cond
|
(lp (cond
|
||||||
((esc-seq? i) ; unescape
|
((esc-seq? i) ; unescape
|
||||||
; escape-sequence
|
; escape-sequence
|
||||||
(string-set! ns j
|
(string-set! ns j
|
||||||
(let ((d1 (string-ref s (+ i 1)))
|
(let ((d1 (string-ref s (+ i 1)))
|
||||||
(d2 (string-ref s (+ i 2))))
|
(d2 (string-ref s (+ i 2))))
|
||||||
|
@ -127,10 +128,12 @@
|
||||||
(lambda (c i)
|
(lambda (c i)
|
||||||
(+ i
|
(+ i
|
||||||
(if (char-set-contains? escaped-chars c)
|
(if (char-set-contains? escaped-chars c)
|
||||||
3 1)))
|
3
|
||||||
|
1)))
|
||||||
0
|
0
|
||||||
s))) ; new length of escaped string
|
s))) ; new length of escaped string
|
||||||
(if (= nlen (string-length s)) s
|
(if (= nlen (string-length s))
|
||||||
|
s
|
||||||
(let ((ns (make-string nlen)))
|
(let ((ns (make-string nlen)))
|
||||||
(string-fold
|
(string-fold
|
||||||
(lambda (c i) ; replace each occurance of an
|
(lambda (c i) ; replace each occurance of an
|
||||||
|
@ -175,22 +178,21 @@
|
||||||
(string-join plist "/")) ; Insert slashes between elts of PLIST.
|
(string-join plist "/")) ; Insert slashes between elts of PLIST.
|
||||||
|
|
||||||
(define (simplify-uri-path p)
|
(define (simplify-uri-path p)
|
||||||
(if (null? p) #f ; P must be non-null
|
(if (null? p)
|
||||||
|
#f ; P must be non-null
|
||||||
(let lp ((path-list (cdr p))
|
(let lp ((path-list (cdr p))
|
||||||
(stack (list (car p))))
|
(stack (list (car p))))
|
||||||
(if (null? path-list) ; we're done
|
(if (null? path-list) ; we're done
|
||||||
(reverse stack)
|
(reverse stack)
|
||||||
(cond
|
(cond
|
||||||
((string=? (car path-list) "..") ; back up
|
((string=? (car path-list) "..") ; back up
|
||||||
; neither the empty path nor root
|
; neither the empty path nor root
|
||||||
(if (not (or (null? stack) (string=? (car stack) "")))
|
(if (not (or (null? stack) (string=? (car stack) "")))
|
||||||
(lp (cdr path-list) (cdr stack))
|
(lp (cdr path-list) (cdr stack))
|
||||||
#f))
|
#f))
|
||||||
((string=? (car path-list) ".") ; leave this
|
((string=? (car path-list) ".") ; leave this
|
||||||
(lp (cdr path-list) stack))
|
(lp (cdr path-list) stack))
|
||||||
((string=? (car path-list) "") ; back to root
|
((string=? (car path-list) "") ; back to root
|
||||||
(lp (cdr path-list) '("")))
|
(lp (cdr path-list) '("")))
|
||||||
(else ; usual segment
|
(else ; usual segment
|
||||||
(lp (cdr path-list) (cons (car path-list) stack))))))))
|
(lp (cdr path-list) (cons (car path-list) stack))))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue