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

Update utf8proc.jl #18327

Merged
merged 1 commit into from
Sep 3, 2016
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
Update utf8proc.jl
add ! suffix to isgraphemebreak! to clarify that the state is changed
  • Loading branch information
matthieugomez authored Sep 1, 2016
commit aa6ec96828267bfe8c4f6e6ef8708090b382491c
6 changes: 3 additions & 3 deletions base/strings/utf8proc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ isgraphemebreak(c1::Char, c2::Char) =
# Stateful grapheme break required by Unicode-9 rules: the string
# must be processed in sequence, with state initialized to Ref{Int32}(0).
# Requires utf8proc v2.0 or later.
isgraphemebreak(c1::Char, c2::Char, state::Ref{Int32}) =
isgraphemebreak!(state::Ref{Int32}, c1::Char, c2::Char) =
ccall(:utf8proc_grapheme_break_stateful, Bool, (UInt32, UInt32, Ref{Int32}), c1, c2, state)

immutable GraphemeIterator{S<:AbstractString}
Expand All @@ -202,7 +202,7 @@ function length(g::GraphemeIterator)
n = 0
state = Ref{Int32}(0)
for c in g.s
n += isgraphemebreak(c0, c, state)
n += isgraphemebreak!(state, c0, c)
c0 = c
end
return n
Expand All @@ -218,7 +218,7 @@ function next(g::GraphemeIterator, i_)
c0, k = next(s, i)
while !done(s, k) # loop until next grapheme is s[i:j]
c, ℓ = next(s, k)
isgraphemebreak(c0, c, state) && break
isgraphemebreak!(state, c0, c) && break
j = k
k = ℓ
c0 = c
Expand Down