Skip to content

Commit

Permalink
Revert "updated to utf8proc v2.0.1, gives support for Unicode 9"
Browse files Browse the repository at this point in the history
This reverts commit 10359ec.

MSVC doesn't understand -Wmissing-prototypes
  • Loading branch information
tkelman committed Nov 25, 2016
1 parent 5fb8b13 commit cd3c970
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
20 changes: 6 additions & 14 deletions base/strings/utf8proc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,6 @@ end
isgraphemebreak(c1::Char, c2::Char) =
ccall(:utf8proc_grapheme_break, Bool, (UInt32, UInt32), c1, c2)

# 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}) =
ccall(:utf8proc_grapheme_break_stateful, Bool, (UInt32, UInt32, Ref{Int32}), c1, c2, state)

immutable GraphemeIterator{S<:AbstractString}
s::S # original string (for generation of SubStrings)
end
Expand All @@ -200,30 +194,28 @@ eltype{S}(::Type{GraphemeIterator{S}}) = SubString{S}
function length(g::GraphemeIterator)
c0 = Char(0x00ad) # soft hyphen (grapheme break always allowed after this)
n = 0
state = Ref{Int32}(0)
for c in g.s
n += isgraphemebreak(c0, c, state)
n += isgraphemebreak(c0, c)
c0 = c
end
return n
end

start(g::GraphemeIterator) = (start(g.s), Ref{Int32}(0))
done(g::GraphemeIterator, i) = done(g.s, i[1])
start(g::GraphemeIterator) = start(g.s)
done(g::GraphemeIterator, i) = done(g.s, i)

function next(g::GraphemeIterator, i_)
function next(g::GraphemeIterator, i)
s = g.s
i, state = i_
j = 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(c0, c) && break
j = k
k =
c0 = c
end
return (SubString(s, i, j), (k, state))
return (SubString(s, i, j), k)
end

==(g1::GraphemeIterator, g2::GraphemeIterator) = g1.s == g2.s
Expand Down
4 changes: 2 additions & 2 deletions deps/utf8proc.version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
UTF8PROC_BRANCH=v2.0.2
UTF8PROC_SHA1=e3a5ed7b8bb5d0c6bb313d3e1f4d072c04113c4b
UTF8PROC_BRANCH=v1.3
UTF8PROC_SHA1=85789180158ac7fff85b9f008828d6ac44f072ea

0 comments on commit cd3c970

Please sign in to comment.