Skip to content

Commit

Permalink
code cleanup and NEWS.md entry
Browse files Browse the repository at this point in the history
  • Loading branch information
bkamins committed Jun 30, 2017
1 parent ea110b5 commit 7664f0a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Breaking changes

This section lists changes that do not have deprecation warnings.

* `getindex(s::String, r::UnitRange{Int})` now throws `UnicodeError` if `last(r)`
is not a valid index into `s` ([#22572]).

* `ntuple(f, n::Integer)` throws `ArgumentError` if `n` is negative.
Previously an empty tuple was returned ([#21697]).

Expand Down
2 changes: 1 addition & 1 deletion base/repl/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function refresh_multi_line(termbuf::TerminalBuffer, terminal::UnixTerminal, buf
# in this case, we haven't yet written the cursor position
line_pos -= slength # '\n' gets an extra pos
if line_pos < 0 || !moreinput
num_chars = (line_pos >= 0 ? llength : strwidth(l[1:prevind(l, line_pos + slength+1)]))
num_chars = (line_pos >= 0 ? llength : strwidth(l[1:prevind(l, line_pos + slength + 1)]))
curs_row, curs_pos = divrem(lindent + num_chars - 1, cols)
curs_row += cur_row
curs_pos += 1
Expand Down
2 changes: 1 addition & 1 deletion base/repl/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ function setup_interface(
end
# Check if input line starts with "julia> ", remove it if we are in prompt paste mode
jl_prompt_len = 7
if (firstline || isprompt_paste) && (oldpos + jl_prompt_len <= sizeof(input) && input[oldpos:prevind(input, oldpos+jl_prompt_len)] == JULIA_PROMPT)
if (firstline || isprompt_paste) && startswith(SubString(input, oldpos), JULIA_PROMPT)
isprompt_paste = true
oldpos += jl_prompt_len
# If we are prompt pasting and current statement does not begin with julia> , skip to next line
Expand Down
8 changes: 6 additions & 2 deletions base/strings/string.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,17 @@ function getindex(s::String, r::UnitRange{Int})
isempty(r) && return ""
l = sizeof(s)
i = first(r)
(i < 1 || i > l) && throw(BoundsError(s, i))
if i < 1 || i > l
throw(BoundsError(s, i))
end
@inbounds si = codeunit(s, i)
if is_valid_continuation(si)
throw(UnicodeError(UTF_ERR_INVALID_INDEX, i, si))
end
j = last(r)
j > l && throw(BoundsError(s, j))
if j > l
throw(BoundsError(s, j))
end
@inbounds sj = codeunit(s, j)
if is_valid_continuation(sj)
throw(UnicodeError(UTF_ERR_INVALID_INDEX, j, sj))
Expand Down

0 comments on commit 7664f0a

Please sign in to comment.