Skip to content

Commit

Permalink
clean up string indexing (#23799)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkamins authored and ararslan committed Sep 29, 2017
1 parent 41f3a8b commit 5a5dbed
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ by setting `JULIA_EDITOR`, `VISUAL` or `EDITOR` as an environment variable.
function edit(path::AbstractString, line::Integer=0)
command = editor()
name = basename(first(command))
issrc = length(path)>2 && path[end-2:end] == ".jl"
if issrc
if endswith(path, ".jl")
f = find_source_file(path)
f !== nothing && (path = f)
end
Expand Down
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function find_in_path(name::String, wd::Union{Void,String})
isabspath(name) && return name
base = name
if endswith(name,".jl")
base = name[1:end-3]
base = name[1:prevind(name, end-2)]
else
name = string(base,".jl")
end
Expand Down
4 changes: 2 additions & 2 deletions base/profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -640,14 +640,14 @@ function rtruncto(str::String, w::Int)
if length(str) <= w
return str
else
return string("...", str[end-w+4:end])
return string("...", str[chr2ind(str, length(str)-w+4):end])
end
end
function ltruncto(str::String, w::Int)
if length(str) <= w
return str
else
return string(str[1:w-4], "...")
return string(str[1:chr2ind(str,w-4)], "...")
end
end

Expand Down

0 comments on commit 5a5dbed

Please sign in to comment.