cs & io: fix comparison of paths with different conventions

This commit is contained in:
Matthew Flatt 2021-05-12 18:05:10 -06:00
parent 4e5254dd77
commit 13ee90da4d
3 changed files with 19 additions and 11 deletions

View File

@ -12,6 +12,10 @@
(test #t path<? (bytes->path #"a") (bytes->path #"aa")) (test #t path<? (bytes->path #"a") (bytes->path #"aa"))
(test #f path<? (bytes->path #"aa") (bytes->path #"a")) (test #f path<? (bytes->path #"aa") (bytes->path #"a"))
(test #f equal? (bytes->path #"a" 'unix) (bytes->path #"a" 'windows))
(test #t equal? (bytes->path #"a" 'unix) (bytes->path #"a" 'unix))
(test #t equal? (bytes->path #"a" 'windows) (bytes->path #"a" 'windows))
(define (test-basic-extension path-replace-extension (define (test-basic-extension path-replace-extension
path-add-extension) path-add-extension)
(test (string->path "x.zo") path-replace-extension "x.rkt" ".zo") (test (string->path "x.zo") path-replace-extension "x.rkt" ".zo")
@ -1026,7 +1030,7 @@
(err/rt-test (string->path-element "" (system-path-convention-type) #t)) (err/rt-test (string->path-element "" (system-path-convention-type) #t))
(err/rt-test (string->path-element "a\0b" #t)) (err/rt-test (string->path-element "a\0b" #t))
(test (bytes->path #"\\\\?\\REL\\\\a/b") bytes->path-element #"a/b" 'windows #t) (test (bytes->path #"\\\\?\\REL\\\\a/b" 'windows) bytes->path-element #"a/b" 'windows #t)
(if (eq? 'windows (system-path-convention-type)) (if (eq? 'windows (system-path-convention-type))
(test (bytes->path #"\\\\?\\REL\\\\a/b") string->path-element "a/b" #t) (test (bytes->path #"\\\\?\\REL\\\\a/b") string->path-element "a/b" #t)
(test #f string->path-element "a/b" #t)) (test #f string->path-element "a/b" #t))

View File

@ -17136,7 +17136,7 @@
(bytes->string/locale_0 in-bstr_0 err-char_0 start6_0 unsafe-undefined)) (bytes->string/locale_0 in-bstr_0 err-char_0 start6_0 unsafe-undefined))
((in-bstr_0 err-char5_0) ((in-bstr_0 err-char5_0)
(bytes->string/locale_0 in-bstr_0 err-char5_0 0 unsafe-undefined)))))) (bytes->string/locale_0 in-bstr_0 err-char5_0 0 unsafe-undefined))))))
(define finish_2714 (define finish_2294
(make-struct-type-install-properties (make-struct-type-install-properties
'(path) '(path)
2 2
@ -17148,8 +17148,11 @@
prop:equal+hash prop:equal+hash
(list (list
(lambda (p1_0 p2_0 eql?_0) (lambda (p1_0 p2_0 eql?_0)
(let ((app_0 (path-bytes p1_0))) (if (let ((app_0 (path-bytes p1_0)))
(|#%app| eql?_0 app_0 (path-bytes p2_0)))) (|#%app| eql?_0 app_0 (path-bytes p2_0)))
(let ((app_0 (path-convention p1_0)))
(eq? app_0 (path-convention p2_0)))
#f))
(lambda (p_0 hc_0) (|#%app| hc_0 (path-bytes p_0))) (lambda (p_0 hc_0) (|#%app| hc_0 (path-bytes p_0)))
(lambda (p_0 hc_0) (|#%app| hc_0 (path-bytes p_0))))) (lambda (p_0 hc_0) (|#%app| hc_0 (path-bytes p_0)))))
(cons (cons
@ -17182,7 +17185,7 @@
#f #f
2 2
0)) 0))
(define effect_2995 (finish_2714 struct:path)) (define effect_2995 (finish_2294 struct:path))
(define path1.1 (define path1.1
(|#%name| (|#%name|
path path
@ -34395,11 +34398,11 @@
'subprocess 'subprocess
"(or/c (and/c output-port? file-stream-port?) #f 'stdout)" "(or/c (and/c output-port? file-stream-port?) #f 'stdout)"
stderr_0)) stderr_0))
(let ((lr1323 unsafe-undefined) (let ((lr1324 unsafe-undefined)
(group_0 unsafe-undefined) (group_0 unsafe-undefined)
(command_0 unsafe-undefined) (command_0 unsafe-undefined)
(exact/args_0 unsafe-undefined)) (exact/args_0 unsafe-undefined))
(set! lr1323 (set! lr1324
(call-with-values (call-with-values
(lambda () (lambda ()
(if (path-string? group/command_0) (if (path-string? group/command_0)
@ -34454,9 +34457,9 @@
((group_1 command_1 exact/args_1) ((group_1 command_1 exact/args_1)
(vector group_1 command_1 exact/args_1)) (vector group_1 command_1 exact/args_1))
(args (raise-binding-result-arity-error 3 args))))) (args (raise-binding-result-arity-error 3 args)))))
(set! group_0 (unsafe-vector*-ref lr1323 0)) (set! group_0 (unsafe-vector*-ref lr1324 0))
(set! command_0 (unsafe-vector*-ref lr1323 1)) (set! command_0 (unsafe-vector*-ref lr1324 1))
(set! exact/args_0 (unsafe-vector*-ref lr1323 2)) (set! exact/args_0 (unsafe-vector*-ref lr1324 2))
(call-with-values (call-with-values
(lambda () (lambda ()
(if (if (pair? exact/args_0) (if (if (pair? exact/args_0)

View File

@ -29,7 +29,8 @@
#:property prop:equal+hash #:property prop:equal+hash
(list (list
(lambda (p1 p2 eql?) (lambda (p1 p2 eql?)
(eql? (path-bytes p1) (path-bytes p2))) (and (eql? (path-bytes p1) (path-bytes p2))
(eq? (path-convention p1) (path-convention p2))))
(lambda (p hc) (lambda (p hc)
(hc (path-bytes p))) (hc (path-bytes p)))
(lambda (p hc) (lambda (p hc)