From 3cc9fb2c508fc90a3a08a753f03a2e3a2f241e92 Mon Sep 17 00:00:00 2001 From: rfm Date: Tue, 11 Oct 2011 21:43:00 +0000 Subject: [PATCH] Fix check for operation on nonblocking socket git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33967 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 1 + Source/GSNetwork.h | 3 ++- Source/NSString.m | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b30075fdb..83961588f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ * Source/NSString.m: Fix boundary error when getting cString into a buffer. Fix floatValue and doubleValue to support arbitrary length of leading white space. + * Source/GSNetwork.h: Check for EAGAIN on nonblocking socket. 2011-10-08 Niels Grewe diff --git a/Source/GSNetwork.h b/Source/GSNetwork.h index ef261bfe7..cd7709b3c 100644 --- a/Source/GSNetwork.h +++ b/Source/GSNetwork.h @@ -70,7 +70,8 @@ #define INVALID_SOCKET -1 #define BADSOCKET(X) ((X) < 0) #define GSNETERROR errno -#define GSWOULDBLOCK (errno == EINPROGRESS || errno == EALREADY) +#define GSWOULDBLOCK (EINPROGRESS == GSNETERROR\ + || EALREADY == GSNETERROR || EAGAIN == errno) #endif /* __MINGW__ */ diff --git a/Source/NSString.m b/Source/NSString.m index 230a58423..cce93d67b 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -136,6 +136,17 @@ static NSData *whitespaceBitmap; static unsigned const char *whitespaceBitmapRep = NULL; #define GS_IS_WHITESPACE(X) IS_BIT_SET(whitespaceBitmapRep[(X)/8], (X) % 8) +static void setupNonspace(void) +{ + if (nil == nonspace) + { + NSCharacterSet *whitespace; + + whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet]; + nonspace = [[whitespace invertedSet] retain]; + } +} + static void setupWhitespace(void) { if (whitespaceBitmapRep == NULL) @@ -149,7 +160,6 @@ static void setupWhitespace(void) */ whitespace = [NSCharacterSet characterSetWithCharactersInString: @" \t\r\n\f\b"]; - nonspace = [[whitespace invertedSet] retain]; whitespaceBitmap = RETAIN([whitespace bitmapRepresentation]); whitespaceBitmapRep = [whitespaceBitmap bytes]; } @@ -3112,7 +3122,7 @@ handle_printf_atsign (FILE *stream, double d = 0.0; NSRange r; - setupWhitespace(); + setupNonspace(); r = [self rangeOfCharacterFromSet: nonspace]; if (NSNotFound == r.location) return 0.0; r.length = [self length] - r.location; @@ -3133,7 +3143,7 @@ handle_printf_atsign (FILE *stream, double d = 0.0; NSRange r; - setupWhitespace(); + setupNonspace(); r = [self rangeOfCharacterFromSet: nonspace]; if (NSNotFound == r.location) return 0.0; r.length = [self length] - r.location;