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

RFC: allow IOBuffer to be parameterized and remove start/stop_reading #11554

Merged
merged 4 commits into from
Jun 8, 2015
Merged
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
4 changes: 0 additions & 4 deletions base/LineEdit.jl
Original file line number Diff line number Diff line change
@@ -1569,7 +1569,6 @@ function prompt!(term, prompt, s = init_state(term, prompt))
raw!(term, true)
enable_bracketed_paste(term)
try
Base.start_reading(term)
activate(prompt, s, term)
while true
map = keymap(s, prompt)
@@ -1585,14 +1584,11 @@ function prompt!(term, prompt, s = init_state(term, prompt))
state = :done
end
if state == :abort
Base.stop_reading(term)
return buffer(s), false, false
elseif state == :done
Base.stop_reading(term)
return buffer(s), true, false
elseif state == :suspend
@unix_only begin
Base.stop_reading(term)
return buffer(s), true, true
end
else
2 changes: 0 additions & 2 deletions base/REPL.jl
Original file line number Diff line number Diff line change
@@ -800,11 +800,9 @@ function setup_interface(repl::LineEditREPL; hascolor = repl.hascolor, extra_rep
LineEdit.commit_line(s)
# This is slightly ugly but ok for now
terminal = LineEdit.terminal(s)
Base.stop_reading(terminal)
raw!(terminal, false) && disable_bracketed_paste(terminal)
LineEdit.mode(s).on_done(s, LineEdit.buffer(s), true)
raw!(terminal, true) && enable_bracketed_paste(terminal)
Base.start_reading(terminal)
else
break
end
23 changes: 0 additions & 23 deletions base/build.h

This file was deleted.

8 changes: 0 additions & 8 deletions base/client.jl
Original file line number Diff line number Diff line change
@@ -132,14 +132,6 @@ function eval_user_input(ast::ANY, show_value)
isa(STDIN,TTY) && println()
end

function repl_callback(ast::ANY, show_value)
global _repl_enough_stdin = true
Base.stop_reading(STDIN)
put!(repl_channel, (ast, show_value))
end

_repl_start = Condition()

syntax_deprecation_warnings(warn::Bool) =
ccall(:jl_parse_depwarn, Cint, (Cint,), warn)!=0

16 changes: 16 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
@@ -498,3 +498,19 @@ function _unsafe_setindex!(l::LinearIndexing, A::AbstractArray, x, J::Union(Real
depwarn("multidimensional indexed assignment with multidimensional arrays is deprecated, use vec to convert indices to vectors", :_unsafe_setindex!)
_unsafe_setindex!(l, A, x, _ensure_vectors(J...)...)
end

# 11554

read!(from::AbstractIOBuffer, p::Ptr, nb::Integer) = read!(from, p, Int(nb))
function read!(from::AbstractIOBuffer, p::Ptr, nb::Int)
depwarn("read!(::IOBuffer, ::Ptr) is unsafe and therefore deprecated", :read!)
from.readable || throw(ArgumentError("read failed, IOBuffer is not readable"))
avail = nb_available(from)
adv = min(avail, nb)
ccall(:memcpy, Ptr{Void}, (Ptr{Void}, Ptr{Void}, UInt), p, pointer(from.data, from.ptr), adv)
from.ptr += adv
if nb > avail
throw(EOFError())
end
p
end
43 changes: 21 additions & 22 deletions base/io.jl
Original file line number Diff line number Diff line change
@@ -37,18 +37,20 @@ write(io::IO, xs...) = for x in xs write(io, x) end
if ENDIAN_BOM == 0x01020304
function write(s::IO, x::Integer)
sz = sizeof(x)
local written::Int = 0
for n = sz:-1:1
write(s, (x>>>((n-1)<<3))%UInt8)
written += write(s, (x>>>((n-1)<<3))%UInt8)
end
sz
return written
end
else
function write(s::IO, x::Integer)
sz = sizeof(x)
local written::Int = 0
for n = 1:sz
write(s, (x>>>((n-1)<<3))%UInt8)
written += write(s, (x>>>((n-1)<<3))%UInt8)
end
sz
return written
end
end

@@ -62,44 +64,41 @@ function write(s::IO, a::AbstractArray)
for i in eachindex(a)
nb += write(s, a[i])
end
nb
return nb
end

function write(s::IO, ch::Char)
c = reinterpret(UInt32, ch)
if c < 0x80
write(s, c%UInt8)
return 1
return write(s, c%UInt8)
elseif c < 0x800
write(s, (( c >> 6 ) | 0xC0)%UInt8)
write(s, (( c & 0x3F ) | 0x80)%UInt8)
return 2
return (write(s, (( c >> 6 ) | 0xC0)%UInt8)) +
(write(s, (( c & 0x3F ) | 0x80)%UInt8))
elseif c < 0x10000
write(s, (( c >> 12 ) | 0xE0)%UInt8)
write(s, (((c >> 6) & 0x3F ) | 0x80)%UInt8)
write(s, (( c & 0x3F ) | 0x80)%UInt8)
return 3
return (write(s, (( c >> 12 ) | 0xE0)%UInt8)) +
(write(s, (((c >> 6) & 0x3F ) | 0x80)%UInt8)) +
(write(s, (( c & 0x3F ) | 0x80)%UInt8))
elseif c < 0x110000
write(s, (( c >> 18 ) | 0xF0)%UInt8)
write(s, (((c >> 12) & 0x3F ) | 0x80)%UInt8)
write(s, (((c >> 6) & 0x3F ) | 0x80)%UInt8)
write(s, (( c & 0x3F ) | 0x80)%UInt8)
return 4
return (write(s, (( c >> 18 ) | 0xF0)%UInt8)) +
(write(s, (((c >> 12) & 0x3F ) | 0x80)%UInt8)) +
(write(s, (((c >> 6) & 0x3F ) | 0x80)%UInt8)) +
(write(s, (( c & 0x3F ) | 0x80)%UInt8))
else
return write(s, '\ufffd')
end
end

function write(s::IO, p::Ptr, n::Integer)
local written::Int = 0
for i=1:n
write(s, unsafe_load(p, i))
written += write(s, unsafe_load(p, i))
end
n
return written
end

function write(io::IO, s::Symbol)
pname = unsafe_convert(Ptr{UInt8}, s)
write(io, pname, Int(ccall(:strlen, Csize_t, (Ptr{UInt8},), pname)))
return write(io, pname, Int(ccall(:strlen, Csize_t, (Ptr{UInt8},), pname)))
end

# all subtypes should implement this
Loading