diff options
Diffstat (limited to 'vendor/golang.org/x/text/internal/catmsg')
-rw-r--r-- | vendor/golang.org/x/text/internal/catmsg/catmsg.go | 43 | ||||
-rw-r--r-- | vendor/golang.org/x/text/internal/catmsg/catmsg_test.go | 13 |
2 files changed, 3 insertions, 53 deletions
diff --git a/vendor/golang.org/x/text/internal/catmsg/catmsg.go b/vendor/golang.org/x/text/internal/catmsg/catmsg.go index c0bf86f..32d6c20 100644 --- a/vendor/golang.org/x/text/internal/catmsg/catmsg.go +++ b/vendor/golang.org/x/text/internal/catmsg/catmsg.go @@ -104,24 +104,20 @@ const ( msgFirst msgRaw msgString - msgAffix - // Leave some arbitrary room for future expansion: 20 should suffice. - numInternal = 20 + numFixed ) const prefix = "golang.org/x/text/internal/catmsg." var ( - // TODO: find a more stable way to link handles to message types. mutex sync.Mutex names = map[string]Handle{ prefix + "Vars": msgVars, prefix + "First": msgFirst, prefix + "Raw": msgRaw, prefix + "String": msgString, - prefix + "Affix": msgAffix, } - handlers = make([]Handler, numInternal) + handlers = make([]Handler, numFixed) ) func init() { @@ -165,20 +161,6 @@ func init() { } return true } - - handlers[msgAffix] = func(d *Decoder) bool { - // TODO: use an alternative method for common cases. - prefix := d.DecodeString() - suffix := d.DecodeString() - if prefix != "" { - d.Render(prefix) - } - ret := d.ExecuteMessage() - if suffix != "" { - d.Render(suffix) - } - return ret - } } var ( @@ -392,24 +374,3 @@ func (s String) Compile(e *Encoder) (err error) { } return err } - -// Affix is a message that adds a prefix and suffix to another message. -// This is mostly used add back whitespace to a translation that was stripped -// before sending it out. -type Affix struct { - Message Message - Prefix string - Suffix string -} - -// Compile implements Message. -func (a Affix) Compile(e *Encoder) (err error) { - // TODO: consider adding a special message type that just adds a single - // return. This is probably common enough to handle the majority of cases. - // Get some stats first, though. - e.EncodeMessageType(msgAffix) - e.EncodeString(a.Prefix) - e.EncodeString(a.Suffix) - e.EncodeMessage(a.Message) - return nil -} diff --git a/vendor/golang.org/x/text/internal/catmsg/catmsg_test.go b/vendor/golang.org/x/text/internal/catmsg/catmsg_test.go index b2a7a9e..485d19c 100644 --- a/vendor/golang.org/x/text/internal/catmsg/catmsg_test.go +++ b/vendor/golang.org/x/text/internal/catmsg/catmsg_test.go @@ -71,10 +71,6 @@ func TestCodec(t *testing.T) { m: String("foo"), tests: single("foo", ""), }, { - desc: "affix", - m: &Affix{String("foo"), "\t", "\n"}, - tests: single("\t|foo|\n", ""), - }, { desc: "missing var", m: String("foo${bar}"), enc: "\x03\x03foo\x02\x03bar", @@ -105,13 +101,6 @@ func TestCodec(t *testing.T) { }, tests: single("foo|baz", ""), }, { - desc: "affix with substitution", - m: &Affix{seq{ - &Var{"bar", String("baz")}, - String("foo${bar}"), - }, "\t", "\n"}, - tests: single("\t|foo|baz|\n", ""), - }, { desc: "shadowed variable", m: seq{ &Var{"bar", String("baz")}, @@ -151,7 +140,7 @@ func TestCodec(t *testing.T) { &Var{"bar", incomplete{}}, String("${bar}"), }, - enc: "\x00\t\b\x01\x01\x14\x04\x02bar\x03\x00\x00\x00", + enc: "\x00\t\b\x01\x01\x04\x04\x02bar\x03\x00\x00\x00", // TODO: recognize that it is cheaper to substitute bar. tests: single("bar", ""), }, { |