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
This commit is contained in:
rfm 2011-10-11 21:43:00 +00:00
parent ccbd4060d9
commit 3cc9fb2c50
3 changed files with 16 additions and 4 deletions

View file

@ -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;