Skip to content
Open
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
23 changes: 20 additions & 3 deletions unicode/norm/forminfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,18 @@ func compInfo(v uint16, sz int) Properties {
return p
}
// has decomposition
h := decomps[v]
h, ok := decompsVal(v)
if !ok {
return Properties{size: uint8(sz)}
}
f := (qcInfo(h&headerFlagsMask) >> 2) | 0x4
p := Properties{size: uint8(sz), flags: f, index: v}
if v >= firstCCC {
v += uint16(h&headerLenMask) + 1
c := decomps[v]
c, ok := decompsVal(v)
if !ok {
return Properties{size: uint8(sz)}
}
p.tccc = c >> 2
p.flags |= qcInfo(c & 0x3)
if v >= firstLeadingCCC {
Expand All @@ -272,8 +278,19 @@ func compInfo(v uint16, sz int) Properties {
p.index = 0
return p
}
p.ccc = decomps[v+1]
ccc, ok := decompsVal(v + 1)
if !ok {
return Properties{size: uint8(sz)}
}
p.ccc = ccc
}
}
return p
}

func decompsVal(v uint16) (byte, bool) {
if int(v) >= len(decomps) {
return 0, false
}
return decomps[v], true
}