Skip to content

Commit

Permalink
Deprecate is_<os> functions in favor of is<os>
Browse files Browse the repository at this point in the history
This makes them consistent with the vast majority of Base predicates,
which simply prefix with `is` rather than `is_`.
  • Loading branch information
ararslan committed Jun 2, 2017
1 parent ef9ab60 commit c50acf8
Show file tree
Hide file tree
Showing 71 changed files with 277 additions and 268 deletions.
6 changes: 3 additions & 3 deletions base/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function refresh_multi_line(termbuf::TerminalBuffer, terminal::UnixTerminal, buf
write_prompt(termbuf, prompt)
prompt = prompt_string(prompt)
# Count the '\n' at the end of the line if the terminal emulator does (specific to DOS cmd prompt)
miscountnl = @static is_windows() ? (isa(Terminals.pipe_reader(terminal), Base.TTY) && !Base.ispty(Terminals.pipe_reader(terminal))) : false
miscountnl = @static iswindows() ? (isa(Terminals.pipe_reader(terminal), Base.TTY) && !Base.ispty(Terminals.pipe_reader(terminal))) : false
lindent = strwidth(prompt)

# Now go through the buffer line by line
Expand Down Expand Up @@ -1577,7 +1577,7 @@ function run_interface(terminal, m::ModalInterface)
while !s.aborted
buf, ok, suspend = prompt!(terminal, m, s)
while suspend
@static if is_unix(); ccall(:jl_repl_raise_sigtstp, Cint, ()); end
@static if isunix(); ccall(:jl_repl_raise_sigtstp, Cint, ()); end
buf, ok, suspend = prompt!(terminal, m, s)
end
eval(Main,
Expand Down Expand Up @@ -1629,7 +1629,7 @@ function prompt!(term, prompt, s = init_state(term, prompt))
elseif state === :done
return buffer(s), true, false
elseif state === :suspend
if is_unix()
if isunix()
return buffer(s), true, true
end
else
Expand Down
6 changes: 3 additions & 3 deletions base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function complete_keyword(s::String)
end

function complete_path(path::AbstractString, pos; use_envpath=false)
if Base.is_unix() && ismatch(r"^~(?:/|$)", path)
if Base.isunix() && ismatch(r"^~(?:/|$)", path)
# if the path is just "~", don't consider the expanded username as a prefix
if path == "~"
dir, prefix = homedir(), ""
Expand Down Expand Up @@ -129,13 +129,13 @@ function complete_path(path::AbstractString, pos; use_envpath=false)
if startswith(file, prefix)
id = try isdir(joinpath(dir, file)) catch; false end
# joinpath is not used because windows needs to complete with double-backslash
push!(matches, id ? file * (@static is_windows() ? "\\\\" : "/") : file)
push!(matches, id ? file * (@static iswindows() ? "\\\\" : "/") : file)
end
end

if use_envpath && length(dir) == 0
# Look for files in PATH as well
local pathdirs = split(ENV["PATH"], @static is_windows() ? ";" : ":")
local pathdirs = split(ENV["PATH"], @static iswindows() ? ";" : ":")

for pathdir in pathdirs
local actualpath
Expand Down
4 changes: 2 additions & 2 deletions base/Terminals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ cmove_line_up(t::UnixTerminal, n) = (cmove_up(t, n); cmove_col(t, 1))
cmove_line_down(t::UnixTerminal, n) = (cmove_down(t, n); cmove_col(t, 1))
cmove_col(t::UnixTerminal, n) = (write(t.out_stream, '\r'); n > 1 && cmove_right(t, n - 1))

if is_windows()
if iswindows()
function raw!(t::TTYTerminal,raw::Bool)
check_open(t.in_stream)
if Base.ispty(t.in_stream)
Expand Down Expand Up @@ -152,7 +152,7 @@ function Base.displaysize(t::UnixTerminal)
return displaysize(t.out_stream)
end

if is_windows()
if iswindows()
hascolor(t::TTYTerminal) = true
else
function hascolor(t::TTYTerminal)
Expand Down
6 changes: 3 additions & 3 deletions base/c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Equivalent to the native `char` c-type.
"""
Cchar

if is_windows()
if iswindows()
const Clong = Int32
const Culong = UInt32
const Cwchar_t = UInt16
Expand Down Expand Up @@ -49,7 +49,7 @@ Equivalent to the native `wchar_t` c-type ([`Int32`](@ref)).
"""
Cwchar_t

if !is_windows()
if !iswindows()
const sizeof_mode_t = ccall(:jl_sizeof_mode_t, Cint, ())
if sizeof_mode_t == 2
const Cmode_t = Int16
Expand Down Expand Up @@ -118,7 +118,7 @@ end
# symbols are guaranteed not to contain embedded NUL
convert(::Type{Cstring}, s::Symbol) = Cstring(unsafe_convert(Ptr{Cchar}, s))

if is_windows()
if iswindows()
"""
Base.cwstring(s)
Expand Down
6 changes: 3 additions & 3 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ function repl_cmd(cmd, out)
end
cd(ENV["OLDPWD"])
else
cd(@static is_windows() ? dir : readchomp(`$shell -c "echo $(shell_escape(dir))"`))
cd(@static iswindows() ? dir : readchomp(`$shell -c "echo $(shell_escape(dir))"`))
end
else
cd()
end
ENV["OLDPWD"] = new_oldpwd
println(out, pwd())
else
run(ignorestatus(@static is_windows() ? cmd : (isa(STDIN, TTY) ? `$shell -i -c "$(shell_wrap_true(shell_name, cmd))"` : `$shell -c "$(shell_wrap_true(shell_name, cmd))"`)))
run(ignorestatus(@static iswindows() ? cmd : (isa(STDIN, TTY) ? `$shell -i -c "$(shell_wrap_true(shell_name, cmd))"` : `$shell -c "$(shell_wrap_true(shell_name, cmd))"`)))
end
nothing
end
Expand Down Expand Up @@ -380,7 +380,7 @@ function _start()
global is_interactive |= !isa(STDIN, Union{File, IOStream})
color_set || (global have_color = false)
else
term = Terminals.TTYTerminal(get(ENV, "TERM", @static is_windows() ? "" : "dumb"), STDIN, STDOUT, STDERR)
term = Terminals.TTYTerminal(get(ENV, "TERM", @static iswindows() ? "" : "dumb"), STDIN, STDOUT, STDERR)
global is_interactive = true
color_set || (global have_color = Terminals.hascolor(term))
quiet || REPL.banner(term,term)
Expand Down
2 changes: 1 addition & 1 deletion base/dSFMT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ end

## Windows entropy

if is_windows()
if iswindows()
function win32_SystemFunction036!(a::Array)
ccall((:SystemFunction036, :Advapi32), stdcall, UInt8, (Ptr{Void}, UInt32), a, sizeof(a))
end
Expand Down
2 changes: 1 addition & 1 deletion base/datafmt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ readdlm_auto(input::IO, dlm::Char, T::Type, eol::Char, auto::Bool; opts...) =
readdlm_string(readstring(input), dlm, T, eol, auto, val_opts(opts))
function readdlm_auto(input::AbstractString, dlm::Char, T::Type, eol::Char, auto::Bool; opts...)
optsd = val_opts(opts)
use_mmap = get(optsd, :use_mmap, is_windows() ? false : true)
use_mmap = get(optsd, :use_mmap, iswindows() ? false : true)
fsz = filesize(input)
if use_mmap && fsz > 0 && fsz < typemax(Int)
a = open(input, "r") do f
Expand Down
9 changes: 9 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,15 @@ end
@deprecate srand(filename::AbstractString, n::Integer=4) srand(read!(filename, Array{UInt32}(Int(n))))
@deprecate MersenneTwister(filename::AbstractString) srand(MersenneTwister(0), read!(filename, Array{UInt32}(Int(4))))

# Part of the underscore audit
for f in [:is_apple, :is_bsd, :is_linux, :is_unix, :is_windows]
newf = Symbol(replace(String(f), "_", ""))
@eval begin
@deprecate $f(os) $newf(os)
@deprecate $f() $newf()
end
end

# END 0.7 deprecations

# BEGIN 1.0 deprecations
Expand Down
2 changes: 1 addition & 1 deletion base/distributed/cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ end
function disable_nagle(sock)
# disable nagle on all OSes
ccall(:uv_tcp_nodelay, Cint, (Ptr{Void}, Cint), sock.handle, 1)
@static if is_linux()
@static if islinux()
# tcp_quickack is a linux only option
if ccall(:jl_tcp_quickack, Cint, (Ptr{Void}, Cint), sock.handle, 1) < 0
warn_once("Networking unoptimized ( Error enabling TCP_QUICKACK : ", Libc.strerror(Libc.errno()), " )")
Expand Down
6 changes: 3 additions & 3 deletions base/distributed/managers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,11 @@ end
const client_port = Ref{Cushort}(0)

function socket_reuse_port()
@static if is_linux() || is_apple()
@static if islinux() || isapple()
s = TCPSocket(delay = false)

# Linux requires the port to be bound before setting REUSEPORT, OSX after.
is_linux() && bind_client_port(s)
islinux() && bind_client_port(s)
rc = ccall(:jl_tcp_reuseport, Int32, (Ptr{Void},), s.handle)
if rc > 0 # SO_REUSEPORT is unsupported, just return the ephemerally bound socket
return s
Expand All @@ -470,7 +470,7 @@ function socket_reuse_port()
# provide a clean new socket
return TCPSocket()
end
is_apple() && bind_client_port(s)
isapple() && bind_client_port(s)
return s
else
return TCPSocket()
Expand Down
4 changes: 2 additions & 2 deletions base/env.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

if is_windows()
if iswindows()
const ERROR_ENVVAR_NOT_FOUND = UInt32(203)

_getenvlen(var::Vector{UInt16}) = ccall(:GetEnvironmentVariableW,stdcall,UInt32,(Ptr{UInt16},Ptr{UInt16},UInt32),var,C_NULL,0)
Expand Down Expand Up @@ -84,7 +84,7 @@ delete!(::EnvHash, k::AbstractString) = (_unsetenv(k); ENV)
setindex!(::EnvHash, v, k::AbstractString) = _setenv(k,string(v))
push!(::EnvHash, k::AbstractString, v) = setindex!(ENV, v, k)

if is_windows()
if iswindows()
start(hash::EnvHash) = (pos = ccall(:GetEnvironmentStringsW,stdcall,Ptr{UInt16},()); (pos,pos))
function done(hash::EnvHash, block::Tuple{Ptr{UInt16},Ptr{UInt16}})
if unsafe_load(block[1]) == 0
Expand Down
2 changes: 1 addition & 1 deletion base/event.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function wait()
# unreachable
end

if is_windows()
if iswindows()
pause() = ccall(:Sleep, stdcall, Void, (UInt32,), 0xffffffff)
else
pause() = ccall(:pause, Void, ())
Expand Down
10 changes: 5 additions & 5 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1294,11 +1294,11 @@ export

# platform-conditional code
@static,
is_windows,
is_linux,
is_apple,
is_bsd,
is_unix,
iswindows,
islinux,
isapple,
isbsd,
isunix,

# tasks
@schedule,
Expand Down
18 changes: 9 additions & 9 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function cd(dir::AbstractString)
end
cd() = cd(homedir())

if is_windows()
if iswindows()
function cd(f::Function, dir::AbstractString)
old = pwd()
try
Expand Down Expand Up @@ -91,7 +91,7 @@ this function throws an error. See [`mkpath`](@ref) for a function which creates
required intermediate directories.
"""
function mkdir(path::AbstractString, mode::Unsigned=0o777)
@static if is_windows()
@static if iswindows()
ret = ccall(:_wmkdir, Int32, (Cwstring,), path)
else
ret = ccall(:mkdir, Int32, (Cstring, UInt32), path, mode)
Expand Down Expand Up @@ -136,7 +136,7 @@ directory, then all contents are removed recursively.
function rm(path::AbstractString; force::Bool=false, recursive::Bool=false)
if islink(path) || !isdir(path)
try
@static if is_windows()
@static if iswindows()
# is writable on windows actually means "is deletable"
if (filemode(path) & 0o222) == 0
chmod(path, 0o777)
Expand All @@ -155,7 +155,7 @@ function rm(path::AbstractString; force::Bool=false, recursive::Bool=false)
rm(joinpath(path, p), force=force, recursive=true)
end
end
@static if is_windows()
@static if iswindows()
ret = ccall(:_wrmdir, Int32, (Cwstring,), path)
else
ret = ccall(:rmdir, Int32, (Cstring,), path)
Expand Down Expand Up @@ -254,7 +254,7 @@ function touch(path::AbstractString)
end
end

if is_windows()
if iswindows()

function tempdir()
temppath = Vector{UInt16}(32767)
Expand Down Expand Up @@ -536,7 +536,7 @@ function sendfile(src::AbstractString, dst::AbstractString)
end
end

if is_windows()
if iswindows()
const UV_FS_SYMLINK_JUNCTION = 0x0002
end

Expand All @@ -550,20 +550,20 @@ Creates a symbolic link to `target` with the name `link`.
soft symbolic links, such as Windows XP.
"""
function symlink(p::AbstractString, np::AbstractString)
@static if is_windows()
@static if iswindows()
if Sys.windows_version() < Sys.WINDOWS_VISTA_VER
error("Windows XP does not support soft symlinks")
end
end
flags = 0
@static if is_windows()
@static if iswindows()
if isdir(p)
flags |= UV_FS_SYMLINK_JUNCTION
p = abspath(p)
end
end
err = ccall(:jl_fs_symlink, Int32, (Cstring, Cstring, Cint), p, np, flags)
@static if is_windows()
@static if iswindows()
if err < 0 && !isdir(p)
Base.warn_once("Note: on Windows, creating file symlinks requires Administrator privileges.")
end
Expand Down
2 changes: 1 addition & 1 deletion base/filesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import Base:
skip, stat, unsafe_read, unsafe_write, transcode, uv_error, uvhandle,
uvtype, write

if is_windows()
if iswindows()
import Base: cwstring
end

Expand Down
2 changes: 1 addition & 1 deletion base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const LOAD_CACHE_PATH = String[]
function init_load_path()
vers = "v$(VERSION.major).$(VERSION.minor)"
if haskey(ENV, "JULIA_LOAD_PATH")
prepend!(LOAD_PATH, split(ENV["JULIA_LOAD_PATH"], @static is_windows() ? ';' : ':'))
prepend!(LOAD_PATH, split(ENV["JULIA_LOAD_PATH"], @static iswindows() ? ';' : ':'))
end
push!(LOAD_PATH, abspath(JULIA_HOME, "..", "local", "share", "julia", "site", vers))
push!(LOAD_PATH, abspath(JULIA_HOME, "..", "share", "julia", "site", vers))
Expand Down
Loading

0 comments on commit c50acf8

Please sign in to comment.