]> Cypherpunks repositories - gostls13.git/commitdiff
rearrange some constants. unicode package now defines MaxRune and ReplacementChar.
authorRob Pike <r@golang.org>
Mon, 31 Aug 2009 20:01:25 +0000 (13:01 -0700)
committerRob Pike <r@golang.org>
Mon, 31 Aug 2009 20:01:25 +0000 (13:01 -0700)
utf8 package imports unicode to get those definitions.
regenerate dependencies.

R=rsc
DELTA=41  (19 added, 3 deleted, 19 changed)
OCL=34123
CL=34129

src/pkg/Make.deps
src/pkg/strconv/quote.go
src/pkg/strings/strings_test.go
src/pkg/unicode/digit_test.go
src/pkg/unicode/letter.go
src/pkg/unicode/letter_test.go
src/pkg/unicode/script_test.go
src/pkg/utf8/utf8.go

index 0ae5ddf32e4de1f82f9e796a90b0205dec1cc278..b77974f47c8de2b4e29be26c4b43f3443eed1cb9 100644 (file)
@@ -48,14 +48,14 @@ regexp.install: bytes.install container/vector.install io.install os.install run
 rpc.install: bufio.install fmt.install gob.install http.install io.install log.install net.install os.install reflect.install sort.install strconv.install strings.install sync.install template.install unicode.install utf8.install
 runtime.install:
 sort.install:
-strconv.install: bytes.install math.install os.install utf8.install
+strconv.install: bytes.install math.install os.install unicode.install utf8.install
 strings.install: utf8.install
 sync.install:
 syscall.install: sync.install
 tabwriter.install: bytes.install container/vector.install io.install os.install utf8.install
 template.install: bytes.install container/vector.install fmt.install io.install os.install reflect.install runtime.install strings.install
 testing.install: flag.install fmt.install os.install runtime.install utf8.install
-testing/iotest.install: io.install log.install os.install
+testing/iotest.install: bytes.install io.install log.install os.install
 time.install: io.install once.install os.install syscall.install
 unicode.install:
-utf8.install:
+utf8.install: unicode.install
index f970ef518920e3355a11587291dbe56e4b684744..e343f670cd6ea851c4ce7b3c9a27674fab140ee4 100644 (file)
@@ -6,6 +6,7 @@ package strconv
 
 import (
        "os";
+       "unicode";
        "utf8";
 )
 
@@ -175,7 +176,7 @@ func UnquoteChar(s string, quote byte) (value int, multibyte bool, tail string,
                        value = v;
                        break;
                }
-               if v > utf8.RuneMax {
+               if v > unicode.MaxRune {
                        err = os.EINVAL;
                        return;
                }
index 714507b6d9bbd0e30795c0bc384d3e5cbf75c5fd..cd9679e94805626bba2a3114f1540ab04c0ba2e3 100644 (file)
@@ -2,9 +2,10 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package strings
+package strings_test
 
 import (
+       . "strings";
        "testing";
 )
 
@@ -92,7 +93,7 @@ var explodetests = []ExplodeTest {
 }
 func TestExplode(t *testing.T) {
        for _, tt := range explodetests {
-               a := explode(tt.s, tt.n);
+               a := Split(tt.s, "", tt.n);
                if !eq(a, tt.a) {
                        t.Errorf("explode(%q, %d) = %v; want %v", tt.s, tt.n, a, tt.a);
                        continue;
index 19a55bb673567c7b3ae5c376102b7e447bb98256..a63404ebd800ec14cf77412d0a0581aca751af21 100644 (file)
@@ -2,9 +2,12 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package unicode
+package unicode_test
 
-import "testing"
+import (
+       "testing";
+       . "unicode";
+)
 
 var testDigit = []int {
        0x0030,
index c68ec47e368c315cca7195761d7b1a8247b80589..f67b7e5cf0f9cbb63019c7abd74b4353cb4fc28a 100644 (file)
@@ -3,9 +3,14 @@
 // license that can be found in the LICENSE file.
 
 // This package provides data and functions to test some properties of Unicode code points.
-// It is rudimentary but will improve.
 package unicode
 
+const (
+       MaxRune = 0x10FFFF;     // Maximum valid Unicode code point.
+       ReplacementChar = 0xFFFD;       // Represents invalid code points.
+)
+
+
 // The representation of a range of Unicode code points.  The range runs from Lo to Hi
 // inclusive and has the specified stride.
 type Range struct {
@@ -42,8 +47,7 @@ type d [MaxCase]int32 // to make the CaseRanges text shorter
 // this CaseRange represents a sequence of the form (say)
 // Upper Lower Upper Lower.
 const (
-       MaxChar         = 0x10FFFF;     // Maximum valid Unicode character value.
-       UpperLower      = MaxChar + 1;  // (Cannot be a valid delta.)
+       UpperLower      = MaxRune + 1;  // (Cannot be a valid delta.)
 )
 
 // Is tests whether rune is in the specified table of ranges.
@@ -113,10 +117,10 @@ func IsLetter(rune int) bool {
        return Is(Letter, rune);
 }
 
-// To maps the rune to the specified case, UpperCase, LowerCase, or TitleCase
+// To maps the rune to the specified case: UpperCase, LowerCase, or TitleCase
 func To(_case int, rune int) int {
        if _case < 0 || MaxCase <= _case {
-               return 0xFFFD   // as reasonable an error as any
+               return ReplacementChar  // as reasonable an error as any
        }
        // binary search over ranges
        lo := 0;
@@ -126,7 +130,7 @@ func To(_case int, rune int) int {
                r := CaseRanges[m];
                if r.Lo <= rune && rune <= r.Hi {
                        delta := int(r.Delta[_case]);
-                       if delta > MaxChar {
+                       if delta > MaxRune {
                                // In an Upper-Lower sequence, which always starts with
                                // an UpperCase letter, the real deltas always look like:
                                //      {0, 1, 0}    UpperCase (Lower is next)
index 13daa0342201d23c4da23970e3bcafd0ef187a1f..0ccb29f0a20d04f909f47338f49958b74cd9c71d 100644 (file)
@@ -2,9 +2,12 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package unicode
+package unicode_test
 
-import "testing"
+import (
+       "testing";
+       . "unicode";
+)
 
 var upperTest = []int{
        0x41,
index 390e47b36066aaaf33f3dbc00f9085dc7bb505e8..da525c541885825d9ea4fb41a69f4e574afc567c 100644 (file)
@@ -2,9 +2,12 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package unicode
+package unicode_test
 
-import "testing"
+import (
+       "testing";
+       . "unicode";
+)
 
 type T struct {
        rune    int;
index 9c2ac790d0cdc24f8d5e176a989ab4c7b3d8ceaf..62adcd9e01534c246c7e3d635ed3778572f1c0c6 100644 (file)
@@ -6,11 +6,12 @@
 // This package calls a Unicode character a rune for brevity.
 package utf8
 
+import "unicode"       // only needed for a couple of constants
+
 // Numbers fundamental to the encoding.
 const (
-       RuneError = 0xFFFD;     // the "error" Rune or "replacement character".
+       RuneError = unicode.ReplacementChar;    // the "error" Rune or "replacement character".
        RuneSelf = 0x80;        // characters below Runeself are represented as themselves in a single byte.
-       RuneMax = 0x10FFFF;     // maximum Unicode code point.
        UTFMax = 4;     // maximum number of bytes of a UTF-8 encoded Unicode character.
 )
 
@@ -239,7 +240,7 @@ func EncodeRune(rune int, p []byte) int {
                return 2;
        }
 
-       if rune > RuneMax {
+       if rune > unicode.MaxRune {
                rune = RuneError
        }