diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-02-10 06:02:38 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-02-10 06:02:38 +0000 |
commit | d54fc074734ea7467a0861c861b145c8ef740bf4 (patch) | |
tree | fe1dad02b57206be8eeb4f61819b2f677ea99ee4 /libgo/go/regexp/syntax | |
parent | 8e29a61c2dc3d591cba39c4f4e8933a76493b22f (diff) | |
download | gcc-d54fc074734ea7467a0861c861b145c8ef740bf4.zip gcc-d54fc074734ea7467a0861c861b145c8ef740bf4.tar.gz gcc-d54fc074734ea7467a0861c861b145c8ef740bf4.tar.bz2 |
compiler, libgo: Permit testing package when test imports it circularly.
From-SVN: r195931
Diffstat (limited to 'libgo/go/regexp/syntax')
-rw-r--r-- | libgo/go/regexp/syntax/parse.go | 66 | ||||
-rw-r--r-- | libgo/go/regexp/syntax/parse_test.go | 17 | ||||
-rw-r--r-- | libgo/go/regexp/syntax/prog_test.go | 3 | ||||
-rw-r--r-- | libgo/go/regexp/syntax/simplify_test.go | 3 |
4 files changed, 43 insertions, 46 deletions
diff --git a/libgo/go/regexp/syntax/parse.go b/libgo/go/regexp/syntax/parse.go index 335f739..30e0e8b 100644 --- a/libgo/go/regexp/syntax/parse.go +++ b/libgo/go/regexp/syntax/parse.go @@ -191,7 +191,7 @@ func (p *parser) newLiteral(r rune, flags Flags) *Regexp { // minFoldRune returns the minimum rune fold-equivalent to r. func minFoldRune(r rune) rune { - if r < MinFold || r > MaxFold { + if r < minFold || r > maxFold { return r } min := r @@ -1553,7 +1553,7 @@ func (p *parser) parseClass(s string) (rest string, err error) { } } if p.flags&FoldCase == 0 { - class = AppendRange(class, lo, hi) + class = appendRange(class, lo, hi) } else { class = appendFoldedRange(class, lo, hi) } @@ -1608,11 +1608,11 @@ func appendLiteral(r []rune, x rune, flags Flags) []rune { if flags&FoldCase != 0 { return appendFoldedRange(r, x, x) } - return AppendRange(r, x, x) + return appendRange(r, x, x) } // appendRange returns the result of appending the range lo-hi to the class r. -func AppendRange(r []rune, lo, hi rune) []rune { +func appendRange(r []rune, lo, hi rune) []rune { // Expand last range or next to last range if it overlaps or abuts. // Checking two ranges helps when appending case-folded // alphabets, so that one range can be expanding A-Z and the @@ -1639,39 +1639,39 @@ func AppendRange(r []rune, lo, hi rune) []rune { const ( // minimum and maximum runes involved in folding. // checked during test. - MinFold = 0x0041 - MaxFold = 0x1044f + minFold = 0x0041 + maxFold = 0x1044f ) // appendFoldedRange returns the result of appending the range lo-hi // and its case folding-equivalent runes to the class r. func appendFoldedRange(r []rune, lo, hi rune) []rune { // Optimizations. - if lo <= MinFold && hi >= MaxFold { + if lo <= minFold && hi >= maxFold { // Range is full: folding can't add more. - return AppendRange(r, lo, hi) + return appendRange(r, lo, hi) } - if hi < MinFold || lo > MaxFold { + if hi < minFold || lo > maxFold { // Range is outside folding possibilities. - return AppendRange(r, lo, hi) + return appendRange(r, lo, hi) } - if lo < MinFold { - // [lo, MinFold-1] needs no folding. - r = AppendRange(r, lo, MinFold-1) - lo = MinFold + if lo < minFold { + // [lo, minFold-1] needs no folding. + r = appendRange(r, lo, minFold-1) + lo = minFold } - if hi > MaxFold { - // [MaxFold+1, hi] needs no folding. - r = AppendRange(r, MaxFold+1, hi) - hi = MaxFold + if hi > maxFold { + // [maxFold+1, hi] needs no folding. + r = appendRange(r, maxFold+1, hi) + hi = maxFold } - // Brute force. Depend on AppendRange to coalesce ranges on the fly. + // Brute force. Depend on appendRange to coalesce ranges on the fly. for c := lo; c <= hi; c++ { - r = AppendRange(r, c, c) + r = appendRange(r, c, c) f := unicode.SimpleFold(c) for f != c { - r = AppendRange(r, f, f) + r = appendRange(r, f, f) f = unicode.SimpleFold(f) } } @@ -1682,7 +1682,7 @@ func appendFoldedRange(r []rune, lo, hi rune) []rune { // It assume x is clean. func appendClass(r []rune, x []rune) []rune { for i := 0; i < len(x); i += 2 { - r = AppendRange(r, x[i], x[i+1]) + r = appendRange(r, x[i], x[i+1]) } return r } @@ -1702,12 +1702,12 @@ func appendNegatedClass(r []rune, x []rune) []rune { for i := 0; i < len(x); i += 2 { lo, hi := x[i], x[i+1] if nextLo <= lo-1 { - r = AppendRange(r, nextLo, lo-1) + r = appendRange(r, nextLo, lo-1) } nextLo = hi + 1 } if nextLo <= unicode.MaxRune { - r = AppendRange(r, nextLo, unicode.MaxRune) + r = appendRange(r, nextLo, unicode.MaxRune) } return r } @@ -1717,21 +1717,21 @@ func appendTable(r []rune, x *unicode.RangeTable) []rune { for _, xr := range x.R16 { lo, hi, stride := rune(xr.Lo), rune(xr.Hi), rune(xr.Stride) if stride == 1 { - r = AppendRange(r, lo, hi) + r = appendRange(r, lo, hi) continue } for c := lo; c <= hi; c += stride { - r = AppendRange(r, c, c) + r = appendRange(r, c, c) } } for _, xr := range x.R32 { lo, hi, stride := rune(xr.Lo), rune(xr.Hi), rune(xr.Stride) if stride == 1 { - r = AppendRange(r, lo, hi) + r = appendRange(r, lo, hi) continue } for c := lo; c <= hi; c += stride { - r = AppendRange(r, c, c) + r = appendRange(r, c, c) } } return r @@ -1744,14 +1744,14 @@ func appendNegatedTable(r []rune, x *unicode.RangeTable) []rune { lo, hi, stride := rune(xr.Lo), rune(xr.Hi), rune(xr.Stride) if stride == 1 { if nextLo <= lo-1 { - r = AppendRange(r, nextLo, lo-1) + r = appendRange(r, nextLo, lo-1) } nextLo = hi + 1 continue } for c := lo; c <= hi; c += stride { if nextLo <= c-1 { - r = AppendRange(r, nextLo, c-1) + r = appendRange(r, nextLo, c-1) } nextLo = c + 1 } @@ -1760,20 +1760,20 @@ func appendNegatedTable(r []rune, x *unicode.RangeTable) []rune { lo, hi, stride := rune(xr.Lo), rune(xr.Hi), rune(xr.Stride) if stride == 1 { if nextLo <= lo-1 { - r = AppendRange(r, nextLo, lo-1) + r = appendRange(r, nextLo, lo-1) } nextLo = hi + 1 continue } for c := lo; c <= hi; c += stride { if nextLo <= c-1 { - r = AppendRange(r, nextLo, c-1) + r = appendRange(r, nextLo, c-1) } nextLo = c + 1 } } if nextLo <= unicode.MaxRune { - r = AppendRange(r, nextLo, unicode.MaxRune) + r = appendRange(r, nextLo, unicode.MaxRune) } return r } diff --git a/libgo/go/regexp/syntax/parse_test.go b/libgo/go/regexp/syntax/parse_test.go index e247cf2..81fd9dc 100644 --- a/libgo/go/regexp/syntax/parse_test.go +++ b/libgo/go/regexp/syntax/parse_test.go @@ -2,12 +2,11 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package syntax_test +package syntax import ( "bytes" "fmt" - . "regexp/syntax" "testing" "unicode" ) @@ -413,13 +412,13 @@ func TestFoldConstants(t *testing.T) { if unicode.SimpleFold(i) == i { continue } - if last == -1 && MinFold != i { - t.Errorf("MinFold=%#U should be %#U", MinFold, i) + if last == -1 && minFold != i { + t.Errorf("minFold=%#U should be %#U", minFold, i) } last = i } - if MaxFold != last { - t.Errorf("MaxFold=%#U should be %#U", MaxFold, last) + if maxFold != last { + t.Errorf("maxFold=%#U should be %#U", maxFold, last) } } @@ -430,11 +429,11 @@ func TestAppendRangeCollapse(t *testing.T) { // Note that we are not calling cleanClass. var r []rune for i := rune('A'); i <= 'Z'; i++ { - r = AppendRange(r, i, i) - r = AppendRange(r, i+'a'-'A', i+'a'-'A') + r = appendRange(r, i, i) + r = appendRange(r, i+'a'-'A', i+'a'-'A') } if string(r) != "AZaz" { - t.Errorf("AppendRange interlaced A-Z a-z = %s, want AZaz", string(r)) + t.Errorf("appendRange interlaced A-Z a-z = %s, want AZaz", string(r)) } } diff --git a/libgo/go/regexp/syntax/prog_test.go b/libgo/go/regexp/syntax/prog_test.go index 0d96507..663d5a8 100644 --- a/libgo/go/regexp/syntax/prog_test.go +++ b/libgo/go/regexp/syntax/prog_test.go @@ -2,10 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package syntax_test +package syntax import ( - . "regexp/syntax" "testing" ) diff --git a/libgo/go/regexp/syntax/simplify_test.go b/libgo/go/regexp/syntax/simplify_test.go index 92a9d3d..879eff5 100644 --- a/libgo/go/regexp/syntax/simplify_test.go +++ b/libgo/go/regexp/syntax/simplify_test.go @@ -2,9 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package syntax_test +package syntax -import . "regexp/syntax" import "testing" var simplifyTests = []struct { |