internal/number: rename Format to Pattern

Format is too overloaded and consists of more than
a pattern.

Change-Id: I92c08ca82930ef870e619c8fb7ebc6ef1b59bb69
Reviewed-on: https://go-review.googlesource.com/36278
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
diff --git a/internal/number/gen.go b/internal/number/gen.go
index 59a982b..0d5f592 100644
--- a/internal/number/gen.go
+++ b/internal/number/gen.go
@@ -364,7 +364,7 @@
 	}
 
 	// Fill the first slot with a dummy so we can identify unspecified tags.
-	formats := []number.Format{{}}
+	formats := []number.Pattern{{}}
 	patterns := map[string]int{}
 
 	// TODO: It would be possible to eliminate two of these slices by having
diff --git a/internal/number/number.go b/internal/number/number.go
index db8ad67..d412194 100644
--- a/internal/number/number.go
+++ b/internal/number/number.go
@@ -136,7 +136,7 @@
 	return symData.Elem(int(symIndex[n.symIndex][t]))
 }
 
-func formatForLang(t language.Tag, index []byte) *Format {
+func formatForLang(t language.Tag, index []byte) *Pattern {
 	for ; ; t = t.Parent() {
 		if x, ok := language.CompactIndex(t); ok {
 			return &formats[index[x]]
diff --git a/internal/number/pattern.go b/internal/number/pattern.go
index 2714b73..018cf02 100644
--- a/internal/number/pattern.go
+++ b/internal/number/pattern.go
@@ -31,14 +31,14 @@
 
 // TODO: replace special characters in affixes (-, +, ¤) with control codes.
 
-// Format holds information for formatting numbers. It is designed to hold
+// Pattern holds information for formatting numbers. It is designed to hold
 // information from CLDR number patterns.
 //
 // This pattern is precompiled  for all patterns for all languages. Even though
 // the number of patterns is not very large, we want to keep this small.
 //
 // This type is only intended for internal use.
-type Format struct {
+type Pattern struct {
 	// TODO: this struct can be packed a lot better than it is now. Should be
 	// possible to make it 32 bytes.
 
@@ -53,7 +53,7 @@
 	FormatWidth uint16
 
 	GroupingSize [2]uint8
-	Flags        FormatFlag
+	Flags        PatternFlag
 
 	// Number of digits.
 	MinIntegerDigits     uint8
@@ -65,11 +65,11 @@
 	MinExponentDigits    uint8
 }
 
-// A FormatFlag is a bit mask for the flag field of a Format.
-type FormatFlag uint8
+// A PatternFlag is a bit mask for the flag field of a Format.
+type PatternFlag uint8
 
 const (
-	AlwaysSign FormatFlag = 1 << iota
+	AlwaysSign PatternFlag = 1 << iota
 	AlwaysExpSign
 	AlwaysDecimalSeparator
 	ParenthesisForNegative // Common pattern. Saves space.
@@ -85,7 +85,7 @@
 )
 
 type parser struct {
-	*Format
+	*Pattern
 
 	leadingSharps int
 
@@ -126,8 +126,8 @@
 // ParsePattern extracts formatting information from a CLDR number pattern.
 //
 // See http://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns.
-func ParsePattern(s string) (f *Format, err error) {
-	p := parser{Format: &Format{}}
+func ParsePattern(s string) (f *Pattern, err error) {
+	p := parser{Pattern: &Pattern{}}
 
 	s = p.parseSubPattern(s)
 
@@ -137,7 +137,7 @@
 			p.setError(errors.New("format: error parsing first sub pattern"))
 			return nil, p.err
 		}
-		neg := parser{Format: &Format{}} // just for extracting the affixes.
+		neg := parser{Pattern: &Pattern{}} // just for extracting the affixes.
 		s = neg.parseSubPattern(s[len(";"):])
 		p.NegOffset = uint16(len(p.buf))
 		p.buf = append(p.buf, neg.buf...)
@@ -154,7 +154,7 @@
 	} else {
 		p.Affix = affix
 	}
-	return p.Format, nil
+	return p.Pattern, nil
 }
 
 func (p *parser) parseSubPattern(s string) string {
@@ -170,7 +170,7 @@
 	return s
 }
 
-func (p *parser) parsePad(s string, f FormatFlag) (tail string) {
+func (p *parser) parsePad(s string, f PatternFlag) (tail string) {
 	if len(s) >= 2 && s[0] == '*' {
 		r, sz := utf8.DecodeRuneInString(s[1:])
 		if p.PadRune != 0 {
diff --git a/internal/number/pattern_test.go b/internal/number/pattern_test.go
index f2ad55d..810b5a8 100644
--- a/internal/number/pattern_test.go
+++ b/internal/number/pattern_test.go
@@ -12,48 +12,48 @@
 
 var testCases = []struct {
 	pat  string
-	want *Format
+	want *Pattern
 }{{
 	"#",
-	&Format{
+	&Pattern{
 		FormatWidth: 1,
 		// TODO: Should MinIntegerDigits be 1?
 	},
 }, {
 	"0",
-	&Format{
+	&Pattern{
 		FormatWidth:      1,
 		MinIntegerDigits: 1,
 	},
 }, {
 	"0000",
-	&Format{
+	&Pattern{
 		FormatWidth:      4,
 		MinIntegerDigits: 4,
 	},
 }, {
 	".#",
-	&Format{
+	&Pattern{
 		FormatWidth:       2,
 		MaxFractionDigits: 1,
 	},
 }, {
 	"#0.###",
-	&Format{
+	&Pattern{
 		FormatWidth:       6,
 		MinIntegerDigits:  1,
 		MaxFractionDigits: 3,
 	},
 }, {
 	"#0.######",
-	&Format{
+	&Pattern{
 		FormatWidth:       9,
 		MinIntegerDigits:  1,
 		MaxFractionDigits: 6,
 	},
 }, {
 	"#,##0.###",
-	&Format{
+	&Pattern{
 		FormatWidth:       9,
 		GroupingSize:      [2]uint8{3, 0},
 		MinIntegerDigits:  1,
@@ -61,7 +61,7 @@
 	},
 }, {
 	"#,##,##0.###",
-	&Format{
+	&Pattern{
 		FormatWidth:       12,
 		GroupingSize:      [2]uint8{3, 2},
 		MinIntegerDigits:  1,
@@ -70,7 +70,7 @@
 }, {
 	// Ignore additional separators.
 	"#,####,##,##0.###",
-	&Format{
+	&Pattern{
 		FormatWidth:       17,
 		GroupingSize:      [2]uint8{3, 2},
 		MinIntegerDigits:  1,
@@ -78,21 +78,21 @@
 	},
 }, {
 	"#E0",
-	&Format{
+	&Pattern{
 		FormatWidth:       3,
 		MaxIntegerDigits:  1,
 		MinExponentDigits: 1,
 	},
 }, {
 	"0E0",
-	&Format{
+	&Pattern{
 		FormatWidth:       3,
 		MinIntegerDigits:  1,
 		MinExponentDigits: 1,
 	},
 }, {
 	"##00.0#E0",
-	&Format{
+	&Pattern{
 		FormatWidth:       9,
 		MinIntegerDigits:  2,
 		MaxIntegerDigits:  4,
@@ -102,7 +102,7 @@
 	},
 }, {
 	"#00.0E+0",
-	&Format{
+	&Pattern{
 		FormatWidth:       8,
 		Flags:             AlwaysExpSign,
 		MinIntegerDigits:  2,
@@ -120,7 +120,7 @@
 }, {
 	// significant digits
 	"@",
-	&Format{
+	&Pattern{
 		FormatWidth:          1,
 		MinSignificantDigits: 1,
 		MaxSignificantDigits: 1,
@@ -128,14 +128,14 @@
 }, {
 	// significant digits
 	"@@@@",
-	&Format{
+	&Pattern{
 		FormatWidth:          4,
 		MinSignificantDigits: 4,
 		MaxSignificantDigits: 4,
 	},
 }, {
 	"@###",
-	&Format{
+	&Pattern{
 		FormatWidth:          4,
 		MinSignificantDigits: 1,
 		MaxSignificantDigits: 4,
@@ -143,7 +143,7 @@
 }, {
 	// Exponents in significant digits mode gets normalized.
 	"@@E0",
-	&Format{
+	&Pattern{
 		FormatWidth:       4,
 		MinIntegerDigits:  1,
 		MaxIntegerDigits:  1,
@@ -153,7 +153,7 @@
 	},
 }, {
 	"@###E00",
-	&Format{
+	&Pattern{
 		FormatWidth:       7,
 		MinIntegerDigits:  1,
 		MaxIntegerDigits:  1,
@@ -168,7 +168,7 @@
 }, {
 	//alternative negative pattern
 	"#0.###;(#0.###)",
-	&Format{
+	&Pattern{
 		Affix:             "\x00\x00\x01(\x01)",
 		NegOffset:         2,
 		FormatWidth:       6,
@@ -178,7 +178,7 @@
 }, {
 	// Rounding increments
 	"1.05",
-	&Format{
+	&Pattern{
 		RoundIncrement:    105,
 		FormatWidth:       4,
 		MinIntegerDigits:  1,
@@ -187,7 +187,7 @@
 	},
 }, {
 	"0.0%",
-	&Format{
+	&Pattern{
 		Affix:             "\x00\x01%",
 		Multiplier:        100,
 		FormatWidth:       4,
@@ -197,7 +197,7 @@
 	},
 }, {
 	"0.0‰",
-	&Format{
+	&Pattern{
 		Affix:             "\x00\x03‰",
 		Multiplier:        1000,
 		FormatWidth:       4,
@@ -207,7 +207,7 @@
 	},
 }, {
 	"#,##0.00¤",
-	&Format{
+	&Pattern{
 		Affix:             "\x00\x02¤",
 		FormatWidth:       9,
 		GroupingSize:      [2]uint8{3, 0},
@@ -217,7 +217,7 @@
 	},
 }, {
 	"#,##0.00 ¤;(#,##0.00 ¤)",
-	&Format{Affix: "\x00\x04\u00a0¤\x01(\x05\u00a0¤)",
+	&Pattern{Affix: "\x00\x04\u00a0¤\x01(\x05\u00a0¤)",
 		NegOffset:         6,
 		Multiplier:        0,
 		FormatWidth:       10,
@@ -229,28 +229,28 @@
 }, {
 	// padding
 	"*x#",
-	&Format{
+	&Pattern{
 		PadRune:     'x',
 		FormatWidth: 1,
 	},
 }, {
 	// padding
 	"#*x",
-	&Format{
+	&Pattern{
 		PadRune:     'x',
 		FormatWidth: 1,
 		Flags:       PadBeforeSuffix,
 	},
 }, {
 	"*xpre#suf",
-	&Format{
+	&Pattern{
 		Affix:       "\x03pre\x03suf",
 		PadRune:     'x',
 		FormatWidth: 7,
 	},
 }, {
 	"pre*x#suf",
-	&Format{
+	&Pattern{
 		Affix:       "\x03pre\x03suf",
 		PadRune:     'x',
 		FormatWidth: 7,
@@ -258,7 +258,7 @@
 	},
 }, {
 	"pre#*xsuf",
-	&Format{
+	&Pattern{
 		Affix:       "\x03pre\x03suf",
 		PadRune:     'x',
 		FormatWidth: 7,
@@ -266,7 +266,7 @@
 	},
 }, {
 	"pre#suf*x",
-	&Format{
+	&Pattern{
 		Affix:       "\x03pre\x03suf",
 		PadRune:     'x',
 		FormatWidth: 7,
@@ -293,7 +293,7 @@
 }
 
 func TestPatternSize(t *testing.T) {
-	if sz := unsafe.Sizeof(Format{}); sz > 48 {
+	if sz := unsafe.Sizeof(Pattern{}); sz > 48 {
 		t.Errorf("got %d; want 48", sz)
 	}
 
diff --git a/internal/number/tables.go b/internal/number/tables.go
index 245535a..845e0b1 100644
--- a/internal/number/tables.go
+++ b/internal/number/tables.go
@@ -1376,7 +1376,7 @@
 	0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
 } // Size: 776 bytes
 
-var formats = []Format{Format{Affix: "",
+var formats = []Pattern{Pattern{Affix: "",
 	Offset:         0x0,
 	NegOffset:      0x0,
 	Multiplier:     0x0,
@@ -1393,7 +1393,7 @@
 	MinSignificantDigits: 0x0,
 	MaxSignificantDigits: 0x0,
 	MinExponentDigits:    0x0},
-	Format{Affix: "",
+	Pattern{Affix: "",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x0,
@@ -1410,7 +1410,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x0},
-	Format{Affix: "",
+	Pattern{Affix: "",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x0,
@@ -1427,7 +1427,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x1},
-	Format{Affix: "\x00\x03\u00a0%",
+	Pattern{Affix: "\x00\x03\u00a0%",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x64,
@@ -1444,7 +1444,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x0},
-	Format{Affix: "\x00\x01%",
+	Pattern{Affix: "\x00\x01%",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x64,
@@ -1461,7 +1461,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x0},
-	Format{Affix: "",
+	Pattern{Affix: "",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x0,
@@ -1478,7 +1478,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x0},
-	Format{Affix: "\x00\x01%",
+	Pattern{Affix: "\x00\x01%",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x64,
@@ -1495,7 +1495,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x0},
-	Format{Affix: "\x00\x03\u00a0%",
+	Pattern{Affix: "\x00\x03\u00a0%",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x64,
@@ -1512,7 +1512,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x0},
-	Format{Affix: "",
+	Pattern{Affix: "",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x0,
@@ -1529,7 +1529,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x0},
-	Format{Affix: "",
+	Pattern{Affix: "",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x0,
@@ -1546,7 +1546,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x3},
-	Format{Affix: "\x00\x01%",
+	Pattern{Affix: "\x00\x01%",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x64,
@@ -1563,7 +1563,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x0},
-	Format{Affix: "\x03%\u00a0\x00",
+	Pattern{Affix: "\x03%\u00a0\x00",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x64,
@@ -1580,7 +1580,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x0},
-	Format{Affix: "\x03%\u00a0\x00\x04%\u00a0-\x00",
+	Pattern{Affix: "\x03%\u00a0\x00\x04%\u00a0-\x00",
 		Offset:         0x0,
 		NegOffset:      0x5,
 		Multiplier:     0x64,
@@ -1597,7 +1597,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x0},
-	Format{Affix: "\x01[\x01]",
+	Pattern{Affix: "\x01[\x01]",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x0,
@@ -1614,7 +1614,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x1},
-	Format{Affix: "",
+	Pattern{Affix: "",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x0,
@@ -1631,7 +1631,7 @@
 		MinSignificantDigits: 0x0,
 		MaxSignificantDigits: 0x0,
 		MinExponentDigits:    0x0},
-	Format{Affix: "\x01%\x00",
+	Pattern{Affix: "\x01%\x00",
 		Offset:         0x0,
 		NegOffset:      0x0,
 		Multiplier:     0x64,