From 47d4587ca33b8adc110f28836e6bb2ea233207fc Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Thu, 28 Jul 2011 12:14:51 +0100 Subject: [PATCH 1/4] Revert "Weekly commits shouldn't be on release branch" This reverts commit 934ee04fcfe075406a655363126ab6d33273cf3e. --- client/handlers.go | 4 ++-- client/line.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/handlers.go b/client/handlers.go index f0a582e..89d6312 100644 --- a/client/handlers.go +++ b/client/handlers.go @@ -220,7 +220,7 @@ func (conn *Conn) h_352(line *Line) { // XXX: do we care about the actual server the nick is on? // or the hop count to this server? // last arg contains " " - a := strings.Split(line.Args[len(line.Args)-1], " ", 2) + a := strings.SplitN(line.Args[len(line.Args)-1], " ", 2) n.Name = a[1] if idx := strings.Index(line.Args[6], "*"); idx != -1 { n.Modes.Oper = true @@ -236,7 +236,7 @@ func (conn *Conn) h_352(line *Line) { // Handle 353 names reply func (conn *Conn) h_353(line *Line) { if ch := conn.GetChannel(line.Args[2]); ch != nil { - nicks := strings.Split(line.Args[len(line.Args)-1], " ", -1) + nicks := strings.Split(line.Args[len(line.Args)-1], " ") for _, nick := range nicks { // UnrealIRCd's coders are lazy and leave a trailing space if nick == "" { diff --git a/client/line.go b/client/line.go index 313d542..5934e65 100644 --- a/client/line.go +++ b/client/line.go @@ -41,7 +41,7 @@ func parseLine(s string) *Line { // now we're here, we've parsed a :nick!user@host or :server off // s should contain "cmd args[] :text" - args := strings.Split(s, " :", 2) + args := strings.SplitN(s, " :", 2) if len(args) > 1 { args = append(strings.Fields(args[0]), args[1]) } else { From 364c6da7ae5caeeb78346d8ae77ddf5a6bd37602 Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Thu, 28 Jul 2011 17:56:14 +0100 Subject: [PATCH 2/4] Add a function to make a copy of a *Line (bar the Time field). --- client/line.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/line.go b/client/line.go index 5934e65..48bbdab 100644 --- a/client/line.go +++ b/client/line.go @@ -17,6 +17,14 @@ type Line struct { Time *time.Time } +// NOTE: this doesn't copy l.Time (this should be read-only anyway) +func (l *Line) Copy() *Line { + nl := *line + nl.Args = make([]string, len(line.Args)) + copy(nl.Args, line.Args) + return &nl +} + func parseLine(s string) *Line { line := &Line{Raw: s} if s[0] == ':' { From 2f31ca5dcfd621a5820fead022b7f75bce9b225c Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Thu, 28 Jul 2011 18:01:46 +0100 Subject: [PATCH 3/4] Oh, god damnit. Should at least *try* to build things to make sure they work. --- client/line.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/line.go b/client/line.go index 48bbdab..cf77b3d 100644 --- a/client/line.go +++ b/client/line.go @@ -19,9 +19,9 @@ type Line struct { // NOTE: this doesn't copy l.Time (this should be read-only anyway) func (l *Line) Copy() *Line { - nl := *line - nl.Args = make([]string, len(line.Args)) - copy(nl.Args, line.Args) + nl := *l + nl.Args = make([]string, len(l.Args)) + copy(nl.Args, l.Args) return &nl } From 49942637739423ccfd14dda07864d3ab18a4de6a Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Fri, 29 Jul 2011 23:11:05 +0100 Subject: [PATCH 4/4] Fix SerialDispatcher test. --- event/registry_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event/registry_test.go b/event/registry_test.go index abc1744..921c145 100644 --- a/event/registry_test.go +++ b/event/registry_test.go @@ -66,7 +66,7 @@ func TestParallelDispatch(t *testing.T) { func TestSerialDispatch(t *testing.T) { r := NewRegistry() - r.Serial() + r.(*registry).Serial() // ensure we have enough of a buffer that all sends complete out := make(chan int, 5) // handler factory :-)