Permalink
Browse files

refactoring

  • Loading branch information...
1 parent bf81d0c commit c76487d7e22857815ceeb40c0cd04ba1ab03dba6 @psychs psychs committed Jun 3, 2010
Showing with 6 additions and 2 deletions.
  1. +6 −2 Classes/Library/TCPClient.m
@@ -4,6 +4,10 @@
#import "TCPClient.h"
+#define LF 0xa
+#define CR 0xd
+
+
@interface TCPClient (Private)
- (BOOL)checkTag:(AsyncSocket*)sock;
- (void)waitRead;
@@ -108,13 +112,13 @@ - (NSData*)readLine
if (!len) return nil;
const char* bytes = [buffer bytes];
- char* p = memchr(bytes, 0xa, len);
+ char* p = memchr(bytes, LF, len);
if (!p) return nil;
int n = p - bytes;
if (n > 0) {
char prev = *(p - 1);
- if (prev == 0xd) {
+ if (prev == CR) {
--n;
}
}

0 comments on commit c76487d

Please sign in to comment.