Skip to content

Commit

Permalink
Fix symbol references to be cross-platform
Browse files Browse the repository at this point in the history
For some reason, both ways work on Linux, but only this way works on
Windows, macOS, and FreeBSD.
  • Loading branch information
ararslan committed May 21, 2021
1 parent 1ffc461 commit a965cef
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/StringEncodings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ show(io::IO, exc::T) where {T<:Union{IncompleteSequenceError,OutputBufferError}}

function iconv_close(cd::Ptr{Nothing})
if cd != C_NULL
ccall((:iconv_close, libiconv), Cint, (Ptr{Nothing},), cd) == 0 ||
ccall((:libiconv_close, libiconv), Cint, (Ptr{Nothing},), cd) == 0 ||
throw(IConvError("iconv_close"))
end
end

function iconv_open(tocode::String, fromcode::String)
p = ccall((:iconv_open, libiconv), Ptr{Nothing}, (Cstring, Cstring), tocode, fromcode)
p = ccall((:libiconv_open, libiconv), Ptr{Nothing}, (Cstring, Cstring), tocode, fromcode)
if p != Ptr{Nothing}(-1)
return p
elseif errno() == EINVAL
Expand Down Expand Up @@ -131,7 +131,7 @@ function iconv!(cd::Ptr{Nothing}, inbuf::Vector{UInt8}, outbuf::Vector{UInt8},
inbytesleft_orig = inbytesleft[]
outbytesleft[] = BUFSIZE

ret = ccall((:iconv, libiconv), Csize_t,
ret = ccall((:libiconv, libiconv), Csize_t,
(Ptr{Nothing}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
cd, inbufptr, inbytesleft, outbufptr, outbytesleft)

Expand Down Expand Up @@ -163,7 +163,7 @@ function iconv_reset!(s::Union{StringEncoder, StringDecoder})

s.outbufptr[] = pointer(s.outbuf)
s.outbytesleft[] = BUFSIZE
ret = ccall((:iconv, libiconv), Csize_t,
ret = ccall((:libiconv, libiconv), Csize_t,
(Ptr{Nothing}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
s.cd, C_NULL, C_NULL, s.outbufptr, s.outbytesleft)

Expand Down Expand Up @@ -529,7 +529,7 @@ encode(s::AbstractString, enc::AbstractString) = encode(s, Encoding(enc))

function test_encoding(enc::String)
# We assume that an encoding is supported if it's possible to convert from it to UTF-8:
cd = ccall((:iconv_open, libiconv), Ptr{Nothing}, (Cstring, Cstring), enc, "UTF-8")
cd = ccall((:libiconv_open, libiconv), Ptr{Nothing}, (Cstring, Cstring), enc, "UTF-8")
if cd == Ptr{Nothing}(-1)
return false
else
Expand Down

0 comments on commit a965cef

Please sign in to comment.