Skip to content

Commit

Permalink
Revert "Merge pull request #20288 from JuliaLang/jn/lists-with-spaces"
Browse files Browse the repository at this point in the history
This reverts commit 083806c, reversing
changes made to b77bcc8.
  • Loading branch information
KristofferC committed Feb 2, 2017
1 parent 9bdcb93 commit 78281a0
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 103 deletions.
2 changes: 1 addition & 1 deletion base/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function showerror(io::IO, ex::BoundsError)
if isa(ex.i, Range)
print(io, ex.i)
else
join(io, ex.i, ", ")
join(io, ex.i, ',')
end
print(io, ']')
end
Expand Down
71 changes: 41 additions & 30 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,26 +120,26 @@ function show_default(io::IO, x::ANY)
print(io, '(')
nf = nfields(t)
nb = sizeof(x)
if nf != 0 || nb == 0
if nf != 0 || nb==0
if !show_circular(io, x)
recur_io = IOContext(io, :SHOWN_SET => x)
for i in 1:nf
for i=1:nf
f = fieldname(t, i)
if !isdefined(x, f)
print(io, undef_ref_str)
else
show(recur_io, getfield(x, f))
end
if i < nf
print(io, ", ")
print(io, ',')
end
end
end
else
print(io, "0x")
p = data_pointer_from_objref(x)
for i in (nb - 1):-1:0
print(io, hex(unsafe_load(convert(Ptr{UInt8}, p + i)), 2))
for i=nb-1:-1:0
print(io, hex(unsafe_load(convert(Ptr{UInt8}, p+i)), 2))
end
end
print(io,')')
Expand Down Expand Up @@ -353,14 +353,18 @@ function show_delim_array(io::IO, itr::Union{AbstractArray,SimpleVector}, op, de
if !haskey(io, :compact)
recur_io = IOContext(recur_io, :compact => true)
end
newline = true
first = true
i = i1
if l >= i1
while true
if !isassigned(itr, i)
print(io, undef_ref_str)
multiline = false
else
x = itr[i]
multiline = isa(x,AbstractArray) && ndims(x)>1 && !isempty(x)
newline && multiline && println(io)
show(recur_io, x)
end
i += 1
Expand All @@ -370,7 +374,12 @@ function show_delim_array(io::IO, itr::Union{AbstractArray,SimpleVector}, op, de
end
first = false
print(io, delim)
print(io, ' ')
if multiline
println(io); println(io)
newline = false
else
newline = true
end
end
end
end
Expand All @@ -382,23 +391,31 @@ function show_delim_array(io::IO, itr, op, delim, cl, delim_one, i1=1, n=typemax
if !show_circular(io, itr)
recur_io = IOContext(io, :SHOWN_SET => itr)
state = start(itr)
newline = true
first = true
while i1 > 1 && !done(itr, state)
while i1 > 1 && !done(itr,state)
_, state = next(itr, state)
i1 -= 1
end
if !done(itr, state)
if !done(itr,state)
while true
x, state = next(itr, state)
x, state = next(itr,state)
multiline = isa(x,AbstractArray) && ndims(x)>1 && !isempty(x)
newline && multiline && println(io)
show(recur_io, x)
i1 += 1
if done(itr, state) || i1 > n
if done(itr,state) || i1 > n
delim_one && first && print(io, delim)
break
end
first = false
print(io, delim)
print(io, ' ')
if multiline
println(io); println(io)
newline = false
else
newline = true
end
end
end
end
Expand Down Expand Up @@ -564,12 +581,10 @@ function show_list(io::IO, items, sep, indent::Int, prec::Int=0, enclose_operato
end
# show an indented list inside the parens (op, cl)
function show_enclosed_list(io::IO, op, items, sep, cl, indent, prec=0, encl_ops=false)
print(io, op)
show_list(io, items, sep, indent, prec, encl_ops)
print(io, cl)
print(io, op); show_list(io, items, sep, indent, prec, encl_ops); print(io, cl)
end

# show a normal (non-operator) function call, e.g. f(x, y) or A[z]
# show a normal (non-operator) function call, e.g. f(x,y) or A[z]
function show_call(io::IO, head, func, func_args, indent)
op, cl = expr_calls[head]
if isa(func, Symbol) || (isa(func, Expr) &&
Expand All @@ -585,12 +600,12 @@ function show_call(io::IO, head, func, func_args, indent)
end
if !isempty(func_args) && isa(func_args[1], Expr) && func_args[1].head === :parameters
print(io, op)
show_list(io, func_args[2:end], ", ", indent)
show_list(io, func_args[2:end], ',', indent)
print(io, "; ")
show_list(io, func_args[1].args, ", ", indent)
show_list(io, func_args[1].args, ',', indent)
print(io, cl)
else
show_enclosed_list(io, op, func_args, ", ", cl, indent)
show_enclosed_list(io, op, func_args, ",", cl, indent)
end
end

Expand Down Expand Up @@ -711,7 +726,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
print(io, ')')
end

# infix (i.e. "x <: y" or "x = y")
# infix (i.e. "x<:y" or "x = y")
elseif (head in expr_infix_any && nargs==2) || (head === :(:) && nargs==3)
func_prec = operator_precedence(head)
head_ = head in expr_infix_wide ? " $head " : head
Expand All @@ -721,24 +736,20 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
show_list(io, args, head_, indent, func_prec, true)
end

# list (i.e. "(1, 2, 3)" or "[1, 2, 3]")
# list (i.e. "(1,2,3)" or "[1,2,3]")
elseif haskey(expr_parens, head) # :tuple/:vcat
op, cl = expr_parens[head]
if head === :vcat
sep = "; "
sep = ";"
elseif head === :hcat || head === :row
sep = " "
else
sep = ", "
sep = ","
end
head !== :row && print(io, op)
show_list(io, args, sep, indent)
if nargs == 1
if head === :tuple
print(io, ',')
elseif head === :vcat
print(io, ';')
end
if (head === :tuple || head === :vcat) && nargs == 1
print(io, sep)
end
head !== :row && print(io, cl)

Expand Down Expand Up @@ -773,7 +784,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
elseif isa(func,Symbol) && func in uni_ops && length(func_args) == 1
show_unquoted(io, func, indent)
if isa(func_args[1], Expr) || func_args[1] in all_ops
show_enclosed_list(io, '(', func_args, ", ", ')', indent, func_prec)
show_enclosed_list(io, '(', func_args, ",", ')', indent, func_prec)
else
show_unquoted(io, func_args[1])
end
Expand All @@ -795,7 +806,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
print(io, "(")
show_unquoted(io, func, indent)
print(io, ")")
show_enclosed_list(io, op, func_args, ", ", cl, indent)
show_enclosed_list(io, op, func_args, ",", cl, indent)
else
show_call(io, head, func, func_args, indent)
end
Expand Down
29 changes: 9 additions & 20 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,6 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt
else if (vt == jl_uniontype_type) {
n += jl_printf(out, "Union{");
while (jl_is_uniontype(v)) {
// tail-recurse on b to flatten the printing of the Union structure in the common case
n += jl_static_show_x(out, ((jl_uniontype_t*)v)->a, depth);
n += jl_printf(out, ", ");
v = ((jl_uniontype_t*)v)->b;
Expand All @@ -1517,37 +1516,27 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt
n += jl_static_show_x(out, (jl_value_t*)ua->var, depth->prev);
}
else if (vt == jl_tvar_type) {
// show type-var bounds only if they aren't going to be printed by UnionAll later
jl_tvar_t *var = (jl_tvar_t*)v;
struct recur_list *p;
struct recur_list *p = depth;
int showbounds = 1;
for (p = depth; p != NULL; p = p->prev) {
if (jl_is_unionall(p->v) && ((jl_unionall_t*)p->v)->var == var) {
while (showbounds && p) {
if (jl_is_unionall(p->v) && ((jl_unionall_t*)p->v)->var == var)
showbounds = 0;
break;
}
p = p->prev;
}
jl_value_t *lb = var->lb, *ub = var->ub;
if (showbounds && lb != jl_bottom_type) {
// show type-var lower bound if it is defined
int ua = jl_is_unionall(lb);
if (ua)
n += jl_printf(out, "(");
if (jl_is_unionall(lb)) n += jl_printf(out, "(");
n += jl_static_show_x(out, lb, depth);
if (ua)
n += jl_printf(out, ")");
if (jl_is_unionall(lb)) n += jl_printf(out, ")");
n += jl_printf(out, "<:");
}
n += jl_printf(out, "%s", jl_symbol_name(var->name));
if (showbounds && (ub != (jl_value_t*)jl_any_type || lb != jl_bottom_type)) {
// show type-var upper bound if it is defined, or if we showed the lower bound
int ua = jl_is_unionall(ub);
if (showbounds && ub != (jl_value_t*)jl_any_type) {
n += jl_printf(out, "<:");
if (ua)
n += jl_printf(out, "(");
if (jl_is_unionall(ub)) n += jl_printf(out, "(");
n += jl_static_show_x(out, ub, depth);
if (ua)
n += jl_printf(out, ")");
if (jl_is_unionall(ub)) n += jl_printf(out, ")");
}
}
else if (vt == jl_module_type) {
Expand Down
8 changes: 4 additions & 4 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes --startup-file=no`
println(ARGS)
""")
@test readchomp(`$exename $testfile foo -bar --baz`) ==
"String[\"foo\", \"-bar\", \"--baz\"]"
"String[\"foo\",\"-bar\",\"--baz\"]"
@test readchomp(`$exename $testfile -- foo -bar --baz`) ==
"String[\"foo\", \"-bar\", \"--baz\"]"
"String[\"foo\",\"-bar\",\"--baz\"]"
@test readchomp(`$exename -L $testfile -e 'exit(0)' -- foo -bar --baz`) ==
"String[\"foo\", \"-bar\", \"--baz\"]"
"String[\"foo\",\"-bar\",\"--baz\"]"
@test split(readchomp(`$exename -L $testfile $testfile`), '\n') ==
["String[\"$(escape(testfile))\"]", "String[]"]
@test !success(`$exename --foo $testfile`)
@test readchomp(`$exename -L $testfile -e 'exit(0)' -- foo -bar -- baz`) == "String[\"foo\", \"-bar\", \"--\", \"baz\"]"
@test readchomp(`$exename -L $testfile -e 'exit(0)' -- foo -bar -- baz`) == "String[\"foo\",\"-bar\",\"--\",\"baz\"]"
finally
rm(testfile)
end
Expand Down
10 changes: 5 additions & 5 deletions test/offsetarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ targets1 = ["0-dimensional $OAs_name.OffsetArray{Float64,0,Array{Float64,0}}:\n1
"$OAs_name.OffsetArray{Float64,2,Array{Float64,2}} with indices 2:2×3:3:\n 1.0",
"$OAs_name.OffsetArray{Float64,3,Array{Float64,3}} with indices 2:2×3:3×4:4:\n[:, :, 4] =\n 1.0",
"$OAs_name.OffsetArray{Float64,4,Array{Float64,4}} with indices 2:2×3:3×4:4×5:5:\n[:, :, 4, 5] =\n 1.0"]
targets2 = ["(1.0, 1.0)",
"([1.0], [1.0])",
"([1.0], [1.0])",
"([1.0], [1.0])",
"([1.0], [1.0])"]
targets2 = ["(1.0,1.0)",
"([1.0],[1.0])",
"(\n[1.0],\n\n[1.0])",
"(\n[1.0],\n\n[1.0])",
"(\n[1.0],\n\n[1.0])"]
for n = 0:4
a = OffsetArray(ones(Float64,ntuple(d->1,n)), ntuple(identity,n))
show(IOContext(io, limit=true), MIME("text/plain"), a)
Expand Down
4 changes: 2 additions & 2 deletions test/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ let ex = :(a + b)
ex.typ = Integer
@test string(ex) == "(a + b)::Integer"
end
foo13825{T, N}(::Array{T,N}, ::Array, ::Vector) = nothing
foo13825{T,N}(::Array{T,N}, ::Array, ::Vector) = nothing
@test startswith(string(first(methods(foo13825))),
"foo13825{T, N}(::Array{T,N}, ::Array, ::Array{T,1} where T)")
"foo13825{T,N}(::Array{T,N}, ::Array, ::Array{T,1} where T)")

type TLayout
x::Int8
Expand Down
2 changes: 1 addition & 1 deletion test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ function test_dict_completion(dict_name)
@test c == Any["66]"]
s = "$dict_name[("
c, r = test_complete(s)
@test c == Any["(\"q\", 3)]"]
@test c == Any["(\"q\",3)]"]
s = "$dict_name[\"\\alp"
c, r = test_complete(s)
@test c == String["\\alpha"]
Expand Down
10 changes: 5 additions & 5 deletions test/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,12 @@ let undefvar
err_str = @except_strbt (-1)^0.25 DomainError
@test contains(err_str, "Exponentiation yielding a complex result requires a complex argument")

err_str = @except_str (1, 2, 3)[4] BoundsError
@test err_str == "BoundsError: attempt to access (1, 2, 3)\n at index [4]"
err_str = @except_str (1,2,3)[4] BoundsError
@test err_str == "BoundsError: attempt to access (1,2,3)\n at index [4]"

err_str = @except_str [5, 4, 3][-2, 1] BoundsError
@test err_str == "BoundsError: attempt to access 3-element Array{$Int,1} at index [-2, 1]"
err_str = @except_str [5, 4, 3][1:5] BoundsError
err_str = @except_str [5,4,3][-2,1] BoundsError
@test err_str == "BoundsError: attempt to access 3-element Array{$Int,1} at index [-2,1]"
err_str = @except_str [5,4,3][1:5] BoundsError
@test err_str == "BoundsError: attempt to access 3-element Array{$Int,1} at index [1:5]"

err_str = @except_str 0::Bool TypeError
Expand Down
Loading

0 comments on commit 78281a0

Please sign in to comment.