@@ -148,7 +148,7 @@ func (f Form) IsNormalString(s string) bool {
148148// patched buffer and whether the decomposition is still in progress.
149149func patchTail (rb * reorderBuffer ) bool {
150150 info , p := lastRuneStart (& rb .f , rb .out )
151- if p == - 1 || info .size == 0 {
151+ if p == - 1 || info .isInvalid () {
152152 return true
153153 }
154154 end := p + int (info .size )
@@ -225,7 +225,7 @@ func doAppend(rb *reorderBuffer, out []byte, p int) []byte {
225225 }
226226 fd := & rb .f
227227 if doMerge {
228- var info Properties
228+ info := Properties { flags : 0x80 , size : 1 } // invalid rune
229229 if p < n {
230230 info = fd .info (src , p )
231231 if ! info .BoundaryBefore () || info .nLeadingNonStarters () > 0 {
@@ -235,7 +235,7 @@ func doAppend(rb *reorderBuffer, out []byte, p int) []byte {
235235 p = decomposeSegment (rb , p , true )
236236 }
237237 }
238- if info .size == 0 {
238+ if info .isInvalid () {
239239 rb .doFlush ()
240240 // Append incomplete UTF-8 encoding.
241241 return src .appendSlice (rb .out , p , n )
@@ -314,7 +314,7 @@ func (f *formInfo) quickSpan(src input, i, end int, atEOF bool) (n int, ok bool)
314314 continue
315315 }
316316 info := f .info (src , i )
317- if info .size == 0 {
317+ if info .isInvalid () {
318318 if atEOF {
319319 // include incomplete runes
320320 return n , true
@@ -379,7 +379,7 @@ func (f Form) firstBoundary(src input, nsrc int) int {
379379 // CGJ insertion points correctly. Luckily it doesn't have to.
380380 for {
381381 info := fd .info (src , i )
382- if info .size == 0 {
382+ if info .isInvalid () {
383383 return - 1
384384 }
385385 if s := ss .next (info ); s != ssSuccess {
@@ -424,7 +424,7 @@ func (f Form) nextBoundary(src input, nsrc int, atEOF bool) int {
424424 }
425425 fd := formTable [f ]
426426 info := fd .info (src , 0 )
427- if info .size == 0 {
427+ if info .isInvalid () {
428428 if atEOF {
429429 return 1
430430 }
@@ -435,7 +435,7 @@ func (f Form) nextBoundary(src input, nsrc int, atEOF bool) int {
435435
436436 for i := int (info .size ); i < nsrc ; i += int (info .size ) {
437437 info = fd .info (src , i )
438- if info .size == 0 {
438+ if info .isInvalid () {
439439 if atEOF {
440440 return i
441441 }
@@ -465,7 +465,7 @@ func lastBoundary(fd *formInfo, b []byte) int {
465465 if p == - 1 {
466466 return - 1
467467 }
468- if info .size == 0 { // ends with incomplete rune
468+ if info .isInvalid () { // ends with incomplete rune
469469 if p == 0 { // starts with incomplete rune
470470 return - 1
471471 }
@@ -504,7 +504,7 @@ func lastBoundary(fd *formInfo, b []byte) int {
504504func decomposeSegment (rb * reorderBuffer , sp int , atEOF bool ) int {
505505 // Force one character to be consumed.
506506 info := rb .f .info (rb .src , sp )
507- if info .size == 0 {
507+ if info .isInvalid () {
508508 return 0
509509 }
510510 if s := rb .ss .next (info ); s == ssStarter {
@@ -528,7 +528,7 @@ func decomposeSegment(rb *reorderBuffer, sp int, atEOF bool) int {
528528 break
529529 }
530530 info = rb .f .info (rb .src , sp )
531- if info .size == 0 {
531+ if info .isInvalid () {
532532 if ! atEOF {
533533 return int (iShortSrc )
534534 }
0 commit comments