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")
(test (string->some-system-path "p/x.zo" 'windows)
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?)
(lambda args

View File

@ -2,6 +2,8 @@ Version 5.90.0.10
Added chaperone-channel and impersonate-channel
Change string->path-element and bytes->path-element to raise an
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
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
(lambda (i sep i2)
(bytes->path-element
(bytes-append
(subbytes bs 0 i)
sep
(rest-bytes bs i2)
(if (string? sfx)
(string->bytes/locale sfx (char->integer #\?))
sfx))
(let ([res (bytes-append
(subbytes bs 0 i)
sep
(rest-bytes bs i2)
(if (string? sfx)
(string->bytes/locale sfx (char->integer #\?))
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)
(path-convention-type s)
(system-path-convention-type)))))