Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,37 @@ using BinDeps

@BinDeps.setup

# Check for an iconv implementation with the GNU (non-POSIX) behavior:
# EILSEQ is returned when a sequence cannot be converted to target encoding,
# instead of succeeding and only returning the number of invalid conversions
# This non-standard behavior is required to allow replacing invalid sequences
# with a user-defined character.
# Implementations with this behavior include glibc, GNU libiconv (on which Mac
# OS X's is based) and win_iconv.
function validate_iconv(n, h)
# Needed to check libc
f = Libdl.dlsym_e(h, "iconv_open")
f == C_NULL && return false

cd = ccall(f, Ptr{Void}, (Cstring, Cstring), "ASCII", "UTF-8")
cd == Ptr{Void}(-1) && return false

s = "café"
a = similar(s.data)
inbufptr = Ref{Ptr{UInt8}}(pointer(s.data))
inbytesleft = Ref{Csize_t}(length(s.data))
outbufptr = Ref{Ptr{UInt8}}(pointer(a))
outbytesleft = Ref{Csize_t}(length(a))
ret = ccall(Libdl.dlsym_e(h, "iconv"), Csize_t,
(Ptr{Void}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
cd, inbufptr, inbytesleft, outbufptr, outbytesleft)
ccall(Libdl.dlsym_e(h, "iconv_close"), Void, (Ptr{Void},), cd) == -1 && return false

return ret == -1 % Csize_t && Libc.errno() == Libc.EILSEQ
end

libiconv = library_dependency("libiconv", aliases = ["libc", "iconv"],
# Check whether libc provides iconv_open (as on Linux)
validate = (n, h) -> Libdl.dlsym_e(h, "iconv_open") != C_NULL)
validate = validate_iconv)

@windows_only begin
using WinRPM
Expand Down