From: Fazlul Shahriar Date: Thu, 16 Sep 2010 17:37:35 +0000 (-0400) Subject: net/dict: parse response correctly + typo X-Git-Tag: weekly.2010-09-22~58 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=dd0dec62901a7d1cfa1c44d89e94e793a78db049;p=gostls13.git net/dict: parse response correctly + typo * SHOW DB responds with a "110 n databases present - text follows" -- parse it. * Doing a Define() on a non-existing word gives error "invalid definition count: no", when we really want "552 no match". R=rsc CC=golang-dev https://golang.org/cl/2211041 --- diff --git a/src/pkg/net/dict/dict.go b/src/pkg/net/dict/dict.go index 474c48373a..42f6553ad3 100644 --- a/src/pkg/net/dict/dict.go +++ b/src/pkg/net/dict/dict.go @@ -55,6 +55,10 @@ func (c *Client) Dicts() ([]Dict, os.Error) { c.text.StartResponse(id) defer c.text.EndResponse(id) + _, _, err = c.text.ReadCodeLine(110) + if err != nil { + return nil, err + } lines, err := c.text.ReadDotLines() if err != nil { return nil, err @@ -85,9 +89,9 @@ type Defn struct { // The argument dict names the dictionary to use, // the Name field of a Dict returned by Dicts. // -// The special dictionary name "!" means to look in all the -// server's dictionaries. // The special dictionary name "*" means to look in all the +// server's dictionaries. +// The special dictionary name "!" means to look in all the // server's dictionaries in turn, stopping after finding the word // in one of them. func (c *Client) Define(dict, word string) ([]*Defn, os.Error) { @@ -100,6 +104,9 @@ func (c *Client) Define(dict, word string) ([]*Defn, os.Error) { defer c.text.EndResponse(id) _, line, err := c.text.ReadCodeLine(150) + if err != nil { + return nil, err + } a, _ := fields(line) if len(a) < 1 { return nil, textproto.ProtocolError("malformed response: " + line)