Index: src/IRCConnection.m ================================================================== --- src/IRCConnection.m +++ src/IRCConnection.m @@ -143,10 +143,12 @@ OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *line; OFArray *split; for (;;) { + OFString *action = nil; + @try { line = [sock readLine]; } @catch (OFInvalidEncodingException *e) { [e dealloc]; line = [sock readLineWithEncoding: @@ -171,23 +173,23 @@ [self sendLine: s]; continue; } + action = [[split objectAtIndex: 1] uppercaseString]; + /* Connected */ - if (split.count >= 4 && - [[split objectAtIndex: 1] isEqual: @"001"]) { + if ([action isEqual: @"001"] && split.count >= 4) { if ([delegate respondsToSelector: @selector(connectionWasEstablished:)]) [delegate connectionWasEstablished: self]; continue; } /* JOIN */ - if (split.count == 3 && - [[split objectAtIndex: 1] isEqual: @"JOIN"]) { + if ([action isEqual: @"JOIN"] && split.count == 3) { OFString *who = [split objectAtIndex: 0]; OFString *where = [split objectAtIndex: 2]; IRCUser *user; IRCChannel *channel; @@ -213,12 +215,11 @@ continue; } /* PART */ - if (split.count >= 3 && - [[split objectAtIndex: 1] isEqual: @"PART"]) { + if ([action isEqual: @"part"] && split.count >= 3) { OFString *who = [split objectAtIndex: 0]; OFString *where = [split objectAtIndex: 2]; IRCUser *user; IRCChannel *channel; OFString *reason = nil; @@ -245,12 +246,11 @@ continue; } /* QUIT */ - if (split.count >= 2 && - [[split objectAtIndex: 1] isEqual: @"QUIT"]) { + if ([action isEqual: @"QUIT"] && split.count >= 2) { OFString *who = [split objectAtIndex: 0]; IRCUser *user; OFString *reason = nil; size_t pos = who.length + 1 + [[split objectAtIndex: 1] length]; @@ -271,12 +271,11 @@ continue; } /* PRIVMSG */ - if (split.count >= 4 && - [[split objectAtIndex: 1] isEqual: @"PRIVMSG"]) { + if ([action isEqual: @"PRIVMSG"] && split.count >= 4) { OFString *from = [split objectAtIndex: 0]; OFString *to = [split objectAtIndex: 2]; IRCUser *user; OFString *msg; size_t pos = from.length + 1 +