path-replace-suffix: raise exception when result should be an empty path

This commit is contained in:
Matthew Flatt 2013-11-03 10:04:00 -07:00
parent afcecc73f1
commit d23d2f8c5b
4 changed files with 955 additions and 933 deletions

View File

@ -28,6 +28,8 @@
path-add-suffix (string->some-system-path "p/x" 'unix) ".zo") path-add-suffix (string->some-system-path "p/x" 'unix) ".zo")
(test (string->some-system-path "p/x.zo" 'windows) (test (string->some-system-path "p/x.zo" 'windows)
path-add-suffix (string->some-system-path "p/x" 'windows) ".zo") path-add-suffix (string->some-system-path "p/x" 'windows) ".zo")
(err/rt-test (path-replace-suffix ".zo" ""))
(err/rt-test (path-replace-suffix ".zo" #""))
(define (make-/tf p exn?) (define (make-/tf p exn?)
(lambda args (lambda args

View File

@ -2,6 +2,8 @@ Version 5.90.0.10
Added chaperone-channel and impersonate-channel Added chaperone-channel and impersonate-channel
Change string->path-element and bytes->path-element to raise an Change string->path-element and bytes->path-element to raise an
exception for an empty [byte-]string argument exception for an empty [byte-]string argument
Change path-replace-suffix to raise an excpetion when a path element
would be made empty
Version 5.90.0.9 Version 5.90.0.9
Allow hash table chaperones and impersonators to support efficient Allow hash table chaperones and impersonators to support efficient

File diff suppressed because it is too large Load Diff

View File

@ -880,13 +880,18 @@
(define finish (define finish
(lambda (i sep i2) (lambda (i sep i2)
(bytes->path-element (bytes->path-element
(bytes-append (let ([res (bytes-append
(subbytes bs 0 i) (subbytes bs 0 i)
sep sep
(rest-bytes bs i2) (rest-bytes bs i2)
(if (string? sfx) (if (string? sfx)
(string->bytes/locale sfx (char->integer #\?)) (string->bytes/locale sfx (char->integer #\?))
sfx)) sfx))])
(if (zero? (bytes-length res))
(raise-arguments-error 'path-replace-suffix
"removing suffix makes path element empty"
"given path" s)
res))
(if (path-for-some-system? s) (if (path-for-some-system? s)
(path-convention-type s) (path-convention-type s)
(system-path-convention-type))))) (system-path-convention-type)))))