-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37912 from JuliaLang/jn/37735
Investigate and fix swprintf ccall test failure. Try to ensure the libc runtime is using UTF-8, regardless of the user locale selected. Closes #37735.
- Loading branch information
Showing
6 changed files
with
109 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
function withlocales(f, newlocales) | ||
# save current locales | ||
locales = Dict{Int,String}() | ||
for cat in 0:9999 | ||
cstr = ccall(:setlocale, Cstring, (Cint, Cstring), cat, C_NULL) | ||
if cstr != C_NULL | ||
locales[cat] = unsafe_string(cstr) | ||
end | ||
end | ||
timestrs = String[] | ||
try | ||
# change to each of given locales | ||
for lc in newlocales | ||
set = true | ||
for (cat, _) in locales | ||
set &= ccall(:setlocale, Cstring, (Cint, Cstring), cat, lc) != C_NULL | ||
end | ||
set && f() | ||
end | ||
finally | ||
# recover locales | ||
for (cat, lc) in locales | ||
cstr = ccall(:setlocale, Cstring, (Cint, Cstring), cat, lc) | ||
end | ||
end | ||
end |