ffi/unsafe: changed the way ffi-lib uses a version number with ".dll"

Add the version with a "-" before ".dll", instead of with a "."
after ".dll".
This commit is contained in:
Matthew Flatt 2014-08-26 09:17:32 -06:00
parent 35eb65628e
commit b00638c52d
2 changed files with 21 additions and 4 deletions

View File

@ -33,7 +33,16 @@ Normally,
@item{@racket[version] is a list of versions to try in order with
@racket[#f] (i.e., no version) as the last element of the list;
for example, @racket['("2" #f)] indicates version 2 with a
fallback to a versionless library.}
fallback to a versionless library.
When the library suffix as reported by @racket[(system-type
'so-suffix)] is @filepath{.dylib}, then a version is added to
@racket[path] after a @filepath{.} and before the
@filepath{.dylib} suffix. When the library suffix is
@filepath{.dll}, then a version is added to @racket[path] after a
@filepath{-} and before the @filepath{.dll} suffix. For any
other suffix, the version number is added after the suffix plus
@filepath{.}.}
]
@ -110,7 +119,12 @@ Due to the way the operating system performs dynamic binding, loaded
libraries are associated with Racket (or DrRacket) for the duration of
the process. Re-evaluating @racket[ffi-lib] (or hitting the
@onscreen{Run} button in DrRacket) will not force a re-load of the
corresponding library.}
corresponding library.
@history[#:changed "6.1.0.5" @elem{Changed the way a version number is
added with a @filepath{.dll} suffix
to place it before the suffix,
instead of after.}]}
@defproc[(get-ffi-obj [objname (or/c string? bytes? symbol?)]
[lib (or/c ffi-lib? path-string? #f)]

View File

@ -104,7 +104,9 @@
(define lib-suffix (bytes->string/latin-1 (subbytes (system-type 'so-suffix) 1)))
(define lib-suffix-re (regexp (string-append "\\." lib-suffix "$")))
(define suffix-before-version? (not (equal? lib-suffix "dylib")))
(define suffix-before-version? (and (not (equal? lib-suffix "dylib"))
(not (equal? lib-suffix "dll"))))
(define version-sep (if (equal? lib-suffix "dll") "-" "."))
(provide (protect-out (rename-out [get-ffi-lib ffi-lib]))
ffi-lib? ffi-lib-name)
@ -129,7 +131,8 @@
(let* ([versions (if (list? version/s) version/s (list version/s))]
[versions (map (lambda (v)
(if (or (not v) (zero? (string-length v)))
"" (string-append "." v)))
""
(string-append version-sep v)))
versions)]
[fullpath (lambda (p) (path->complete-path (cleanse-path p)))]
[absolute? (absolute-path? name)]