]> Cypherpunks repositories - gostls13.git/commitdiff
exp/locale/collate/build: fixed bug that was exposed by experimenting
authorMarcel van Lohuizen <mpvl@golang.org>
Mon, 20 Aug 2012 08:56:41 +0000 (10:56 +0200)
committerMarcel van Lohuizen <mpvl@golang.org>
Mon, 20 Aug 2012 08:56:41 +0000 (10:56 +0200)
with table changes.
NOTE: there is no test for this, but 1) the code has now the same
control flow as scan in exp/locale/collate/contract.go, which is
tested and 2) Builder verifies the generated table so bugs in this
code are quickly and easily found (which is how this bug was discovered).

R=r
CC=golang-dev
https://golang.org/cl/6461082

src/pkg/exp/locale/collate/build/contract.go

index 45d8f74b9b09c2d9755c4f23324969366a4e4f11..f7cf64a7309b35a9e9cb0423fe5494ffa502b54d 100644 (file)
@@ -241,8 +241,8 @@ func (ct *contractTrieSet) lookup(h ctHandle, str []byte) (index, ns int) {
                e := states[i]
                c := str[p]
                if c >= e.l {
-                       p++
                        if e.l == c {
+                               p++
                                if e.i != noIndex {
                                        index, ns = int(e.i), p
                                }
@@ -252,12 +252,13 @@ func (ct *contractTrieSet) lookup(h ctHandle, str []byte) (index, ns int) {
                                } else {
                                        return
                                }
+                               continue
                        } else if e.n == final && c <= e.h {
+                               p++
                                return int(c-e.l) + int(e.i), p
                        }
-               } else {
-                       i++
                }
+               i++
        }
        return
 }