1+ using Libdl
12# Check for an iconv implementation with the GNU (non-POSIX) behavior:
23# EILSEQ is returned when a sequence cannot be converted to target encoding,
34# instead of succeeding and only returning the number of invalid conversions
67# Implementations with this behavior include glibc, GNU libiconv (on which Mac
78# OS X's is based) and win_iconv.
89function validate_iconv (lib, iconv_open, iconv_close, iconv)
9- h = Libdl . dlopen_e (lib)
10+ h = dlopen_e (lib)
1011 h == C_NULL && return false
1112 # Needed to check libc
12- f = Libdl . dlsym_e (h, iconv_open)
13+ f = dlsym_e (h, iconv_open)
1314 f == C_NULL && return false
1415
15- cd = ccall (f, Ptr{Void }, (Cstring, Cstring), " ASCII" , " UTF-8" )
16- cd == Ptr {Void } (- 1 ) && return false
16+ cd = ccall (f, Ptr{Nothing }, (Cstring, Cstring), " ASCII" , " UTF-8" )
17+ cd == Ptr {Nothing } (- 1 ) && return false
1718
1819 s = " café"
19- a = Vector {UInt8} (sizeof (s))
20+ a = Vector {UInt8} (undef, sizeof (s))
2021 inbufptr = Ref {Ptr{UInt8}} (pointer (s))
2122 inbytesleft = Ref {Csize_t} (sizeof (s))
2223 outbufptr = Ref {Ptr{UInt8}} (pointer (a))
2324 outbytesleft = Ref {Csize_t} (length (a))
24- ret = ccall (Libdl . dlsym_e (h, iconv), Csize_t,
25- (Ptr{Void }, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
25+ ret = ccall (dlsym_e (h, iconv), Csize_t,
26+ (Ptr{Nothing }, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
2627 cd, inbufptr, inbytesleft, outbufptr, outbytesleft)
27- ccall (Libdl . dlsym_e (h, iconv_close), Void , (Ptr{Void },), cd) == - 1 && return false
28+ ccall (dlsym_e (h, iconv_close), Nothing , (Ptr{Nothing },), cd) == - 1 && return false
2829
2930 return ret == - 1 % Csize_t && Libc. errno () == Libc. EILSEQ
3031end
@@ -60,7 +61,7 @@ download_info = Dict(
6061
6162# Detect already present libc iconv or libiconv
6263# (notably for Linux, Mac OS and other Unixes)
63- found_iconv = false
64+ global found_iconv = false
6465for lib in (" libc" , " libc-bin" , " libiconv" , " iconv" )
6566 if lib in (" libc" , " libc-bin" )
6667 global iconv_open = :iconv_open
@@ -72,7 +73,7 @@ for lib in ("libc", "libc-bin", "libiconv", "iconv")
7273 global iconv = :libiconv
7374 end
7475 if validate_iconv (lib, iconv_open, iconv_close, iconv)
75- found_iconv = true
76+ global found_iconv = true
7677 write (joinpath (@__DIR__ , " deps.jl" ),
7778 """
7879 ## This file autogenerated by Pkg.build(\\ "StringEncodings\\ ").
0 commit comments