Author: mlytwyn
Date: Wed Sep 14 16:40:34 2016
New Revision: 40083
URL: http://svn.gna.org/viewcvs/gnustep?rev=40083&view=rev
Log:
Merges with base trunk revision 40072
Modified:
libs/base/branches/gnustep_testplant_branch/Source/GSFileHandle.h
libs/base/branches/gnustep_testplant_branch/Source/GSFileHandle.m
libs/base/branches/gnustep_testplant_branch/Source/GSFormat.m
libs/base/branches/gnustep_testplant_branch/Source/GSHTTPAuthentication.m
libs/base/branches/gnustep_testplant_branch/Source/GSHTTPURLHandle.m
libs/base/branches/gnustep_testplant_branch/Source/GSICUString.m
Modified: libs/base/branches/gnustep_testplant_branch/Source/GSFileHandle.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/branches/gnustep_testplant_branch/Source/GSFileHandle.h?rev=40083&r1=40082&r2=40083&view=diff
==============================================================================
--- libs/base/branches/gnustep_testplant_branch/Source/GSFileHandle.h
(original)
+++ libs/base/branches/gnustep_testplant_branch/Source/GSFileHandle.h Wed Sep
14 16:40:34 2016
@@ -30,9 +30,8 @@
#import "Foundation/NSDictionary.h"
#import "Foundation/NSRunLoop.h"
-#import <GNUstepBase/GSConfig.h>
-#if defined(__MINGW__) && defined(__clang__)
+#if defined(_WIN32) && defined(__clang__)
#import <winsock2.h>
#endif
@@ -71,7 +70,7 @@
#if USE_ZLIB
gzFile gzDescriptor;
#endif
-#if defined(__MINGW__)
+#if defined(_WIN32)
WSAEVENT event;
#endif
#endif
@@ -110,7 +109,9 @@
type: (RunLoopEventType)type
extra: (void*)extra
forMode: (NSString*)mode;
+
- (void) setAddr: (struct sockaddr *)sin;
+
- (BOOL) useCompression;
- (void) watchReadDescriptorForModes: (NSArray*)modes;
- (void) watchWriteDescriptor;
Modified: libs/base/branches/gnustep_testplant_branch/Source/GSFileHandle.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/branches/gnustep_testplant_branch/Source/GSFileHandle.m?rev=40083&r1=40082&r2=40083&view=diff
==============================================================================
--- libs/base/branches/gnustep_testplant_branch/Source/GSFileHandle.m
(original)
+++ libs/base/branches/gnustep_testplant_branch/Source/GSFileHandle.m Wed Sep
14 16:40:34 2016
@@ -96,9 +96,9 @@
#define NETBUF_SIZE (1024 * 16)
#define READ_SIZE NETBUF_SIZE*10
-static GSFileHandle* fh_stdin = nil;
-static GSFileHandle* fh_stdout = nil;
-static GSFileHandle* fh_stderr = nil;
+static GSFileHandle *fh_stdin = nil;
+static GSFileHandle *fh_stdout = nil;
+static GSFileHandle *fh_stderr = nil;
@interface GSTcpTune : NSObject
- (int) delay;
@@ -382,19 +382,19 @@
else
{
#if USE_ZLIB
- /*
- * The gzDescriptor should always be closed when we have done with it.
- */
- if (gzDescriptor != 0)
- {
- gzclose(gzDescriptor);
- gzDescriptor = 0;
- }
+ /*
+ * The gzDescriptor should always be closed when we have done with it.
+ */
+ if (gzDescriptor != 0)
+ {
+ gzclose(gzDescriptor);
+ gzDescriptor = 0;
+ }
#endif
- if (descriptor != -1)
- {
- [self setNonBlocking: wasNonBlocking];
- }
+ if (descriptor != -1)
+ {
+ [self setNonBlocking: wasNonBlocking];
+ }
}
}
@@ -1208,7 +1208,7 @@
if (fstat(desc, &sbuf) < 0)
{
-#if defined(__MINGW__)
+#if defined(_WIN32)
/* On windows, an fstat will fail if the descriptor is a pipe
* or socket, so we simply mark the descriptor as not being a
* standard file.
@@ -2082,9 +2082,9 @@
unsigned int size = sizeof(sin);
[tune tune: (void*)(intptr_t)desc];
-
+
h = [[[self class] alloc] initWithFileDescriptor: desc
- closeOnDealloc: YES];
+ closeOnDealloc: YES];
h->isSocket = YES;
getpeername(desc, &sin, &size);
[h setAddr: &sin];
@@ -2205,7 +2205,7 @@
int written;
written = [self write: (char*)ptr+writePos
- length: length-writePos];
+ length: length-writePos];
if (written <= 0)
{
if (written < 0 && errno != EAGAIN && errno != EINTR)
Modified: libs/base/branches/gnustep_testplant_branch/Source/GSFormat.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/branches/gnustep_testplant_branch/Source/GSFormat.m?rev=40083&r1=40082&r2=40083&view=diff
==============================================================================
--- libs/base/branches/gnustep_testplant_branch/Source/GSFormat.m
(original)
+++ libs/base/branches/gnustep_testplant_branch/Source/GSFormat.m Wed Sep
14 16:40:34 2016
@@ -1152,7 +1152,7 @@
{
workend = (unichar *)malloc(want);
workend_malloced = 1;
- }
+ }
else
{
workend = (unichar *)alloca(want);
@@ -1749,7 +1749,14 @@
}
else
{
+#if 1 // Testplant-MAL-09142016: merge with trunk revision 40072.
+ // Not sure which version to choose here, setting to a static char *
+ // is dangerous practice. Deciding on Testplant branch code for now...
string = (unichar *) {'\0'};
+#else
+ static unichar empty = 0;
+ string = ∅
+#endif
len = 0;
}
}
Modified:
libs/base/branches/gnustep_testplant_branch/Source/GSHTTPAuthentication.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/branches/gnustep_testplant_branch/Source/GSHTTPAuthentication.m?rev=40083&r1=40082&r2=40083&view=diff
==============================================================================
--- libs/base/branches/gnustep_testplant_branch/Source/GSHTTPAuthentication.m
(original)
+++ libs/base/branches/gnustep_testplant_branch/Source/GSHTTPAuthentication.m
Wed Sep 14 16:40:34 2016
@@ -56,11 +56,7 @@
NSData *data;
NSString *string;
-#if GS_WITH_GC
- dst = (char*)NSAllocateCollectable(dlen, 0);
-#else
dst = (char*)NSZoneMalloc(NSDefaultMallocZone(), dlen);
-#endif
while (spos < slen)
{
unsigned char c = src[spos++];
Modified: libs/base/branches/gnustep_testplant_branch/Source/GSHTTPURLHandle.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/branches/gnustep_testplant_branch/Source/GSHTTPURLHandle.m?rev=40083&r1=40082&r2=40083&view=diff
==============================================================================
--- libs/base/branches/gnustep_testplant_branch/Source/GSHTTPURLHandle.m
(original)
+++ libs/base/branches/gnustep_testplant_branch/Source/GSHTTPURLHandle.m
Wed Sep 14 16:40:34 2016
@@ -43,6 +43,7 @@
#import "Foundation/NSValue.h"
#import "GNUstepBase/GSMime.h"
#import "GNUstepBase/GSLock.h"
+#import "GNUstepBase/NSData+GNUstepBase.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
#import "GNUstepBase/NSURL+GNUstepBase.h"
#import "NSCallBacks.h"
@@ -127,7 +128,7 @@
reading,
} connectionState;
}
-- (void) setDebug: (BOOL)flag;
+- (int) setDebug: (int)flag;
- (void) _tryLoadInBackground: (NSURL*)fromURL;
@end
@@ -230,36 +231,62 @@
static void
debugRead(GSHTTPURLHandle *handle, NSData *data)
{
- int len = (int)[data length];
- const char *ptr = (const char*)[data bytes];
+ int len = (int)[data length];
+ const uint8_t *ptr = (const uint8_t*)[data bytes];
+ uint8_t *hex;
+ NSUInteger hl;
int pos;
+ hl = ((len + 2) / 3) * 4;
+ hex = malloc(hl + 1);
+ hex[hl] = '\0';
+ GSPrivateEncodeBase64(ptr, (NSUInteger)len, hex);
for (pos = 0; pos < len; pos++)
{
if (0 == ptr[pos])
{
- NSLog(@"Read for %p of %d bytes - %@", handle, len, data);
+ char *esc = [data escapedRepresentation: 0];
+
+ NSLog(@"Read for %p of %d bytes (escaped) - '%s'\n<[%s]>",
+ handle, len, esc, hex);
+ free(esc);
+ free(hex);
return;
}
}
- NSLog(@"Read for %p of %d bytes -'%*.*s'", handle, len, len, len, ptr);
+ NSLog(@"Read for %p of %d bytes - '%*.*s'\n<[%s]>",
+ handle, len, len, len, ptr, hex);
+ free(hex);
}
static void
debugWrite(GSHTTPURLHandle *handle, NSData *data)
{
- int len = (int)[data length];
- const char *ptr = (const char*)[data bytes];
- int pos = len;
-
+ int len = (int)[data length];
+ const uint8_t *ptr = (const uint8_t*)[data bytes];
+ uint8_t *hex;
+ NSUInteger hl;
+ int pos;
+
+ hl = ((len + 2) / 3) * 4;
+ hex = malloc(hl + 1);
+ hex[hl] = '\0';
+ GSPrivateEncodeBase64(ptr, (NSUInteger)len, hex);
for (pos = 0; pos < len; pos++)
{
if (0 == ptr[pos])
{
- NSLog(@"Write for %p of %d bytes - %@", handle, len, data);
+ char *esc = [data escapedRepresentation: 0];
+
+ NSLog(@"Write for %p of %d bytes (escaped) - '%s'\n<[%s]>",
+ handle, len, esc, hex);
+ free(esc);
+ free(hex);
return;
}
}
- NSLog(@"Write for %p of %d bytes -'%*.*s'", handle, len, len, len, ptr);
+ NSLog(@"Write for %p of %d bytes - '%*.*s'\n<[%s]>",
+ handle, len, len, len, ptr, hex);
+ free(hex);
}
+ (NSURLHandle*) cachedHandleForURL: (NSURL*)newUrl
@@ -295,7 +322,7 @@
[[NSObject leakAt: &urlOrder] release];
urlLock = [GSLazyLock new];
[[NSObject leakAt: &urlLock] release];
-#if !defined(__MINGW__)
+#if !defined(_WIN32)
sslClass = [NSFileHandle sslClass];
#endif
}
@@ -417,7 +444,7 @@
}
if (([s isEqualToString: @"http"] && [p intValue] == 80)
|| ([s isEqualToString: @"https"] && [p intValue] == 443))
- {
+ {
/* Some buggy systems object to the port being in the Host
* header when it's the default (optional) value. To keep
* them happy let's omit it in those cases.
@@ -520,15 +547,20 @@
}
}
+ buf = [[s dataUsingEncoding: NSISOLatin1StringEncoding] mutableCopy];
+
enumerator = NSEnumerateMapTable(wProperties);
while (NSNextMapEnumeratorPair(&enumerator, (void **)(&key), (void**)&val))
{
- [s appendFormat: @"%@: %@\r\n", key, val];
+ GSMimeHeader *h;
+
+ h = [[GSMimeHeader alloc] initWithName: key value: val parameters: nil];
+ [buf appendData: [h rawMimeDataPreservingCase: YES foldedAt: 0]];
+ RELEASE(h);
}
NSEndMapTableEnumeration(&enumerator);
- [s appendString: @"\r\n"];
- buf = [[s dataUsingEncoding: NSASCIIStringEncoding] mutableCopy];
+ [buf appendBytes: "\r\n" length: 2];
/*
* Append any data to be sent
@@ -1277,9 +1309,12 @@
return result;
}
-- (void) setDebug: (BOOL)flag
-{
- debug = flag;
+- (int) setDebug: (int)flag
+{
+ int old = debug;
+
+ debug = flag ? YES : NO;
+ return old;
}
- (void) setReturnAll: (BOOL)flag
@@ -1353,7 +1388,7 @@
*/
if (sock != nil)
{
-#if defined(__MINGW__)
+#if defined(_WIN32)
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSRunLoop *loop = [NSRunLoop currentRunLoop];
NSFileHandle *test = RETAIN(sock);
@@ -1612,6 +1647,9 @@
* to 8080 for <code>http</code> and 4430 for <code>https</code>.
* </item>
* <item>
+ * Any GSTLS... key to control TLS behavior
+ * </item>
+ * <item>
* Any NSHTTPProperty... key
* </item>
* </list>
@@ -1625,6 +1663,7 @@
format: @"%@ %p with invalid key", NSStringFromSelector(_cmd), self];
}
if ([propertyKey hasPrefix: @"GSHTTPProperty"]
+ || [propertyKey hasPrefix: @"GSTLS"]
|| [propertyKey hasPrefix: @"NSHTTPProperty"])
{
if (property == nil)
Modified: libs/base/branches/gnustep_testplant_branch/Source/GSICUString.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/branches/gnustep_testplant_branch/Source/GSICUString.m?rev=40083&r1=40082&r2=40083&view=diff
==============================================================================
--- libs/base/branches/gnustep_testplant_branch/Source/GSICUString.m
(original)
+++ libs/base/branches/gnustep_testplant_branch/Source/GSICUString.m Wed Sep
14 16:40:34 2016
@@ -40,7 +40,10 @@
static int64_t
UTextNSStringNativeLength(UText *ut)
{
- return [(NSString*)ut->p length];
+ /* For constant strings the length is stored in ut->c, but for mutable
+ * strings this is set to -1 and we must check the length every time.
+ */
+ return (-1 == ut->c) ? [(NSString*)ut->p length] : ut->c;
}
@@ -52,49 +55,82 @@
UTextNSStringAccess(UText *ut, int64_t nativeIndex, UBool forward)
{
NSString *str = (NSString*)ut->p;
- NSUInteger length = [str length];
+ NSInteger length = (-1 == ut->c) ? (NSInteger)[str length] : ut->c;
+ NSInteger nativeStart = ut->chunkNativeStart;
+ NSInteger nativeLimit = ut->chunkNativeLimit;
NSRange r;
- if (nativeIndex >= length)
- {
- return FALSE;
- }
-
- /* Special case if the chunk already contains this index
- */
- if (nativeIndex >= ut->chunkNativeStart
- && nativeIndex < (ut->chunkNativeStart + ut->chunkLength))
- {
- ut->chunkOffset = nativeIndex - ut->chunkNativeStart;
- return TRUE;
- }
- r = NSMakeRange(nativeIndex, chunkSize);
- forward = TRUE;
if (forward)
{
- if (nativeIndex + chunkSize > length)
- {
- r.length = length - nativeIndex;
- }
+ if (nativeIndex < nativeLimit && nativeIndex >= nativeStart)
+ {
+ /* The chunk already contains the index, set the offset
+ * to match it.
+ */
+ ut->chunkOffset = nativeIndex - nativeStart;
+ return TRUE;
+ }
+
+ if (nativeIndex >= length && nativeLimit >= length)
+ {
+ /* Asking for a position beyond the end of the string;
+ * Limit it to point just after the last character.
+ */
+ ut->chunkOffset = ut->chunkLength;
+ return FALSE;
+ }
+
+ /* Set up to fill the chunk with characters from the string
+ * and to start at the beginning of that buffer.
+ */
+ nativeStart = nativeIndex;
+ nativeLimit = nativeIndex + chunkSize;
+ if (nativeLimit > length)
+ {
+ nativeLimit = length;
+ }
+ r.location = nativeIndex;
+ r.length = nativeLimit - nativeIndex;
+ ut->chunkOffset = 0;
}
else
{
- if (nativeIndex - chunkSize > 0)
- {
- r.location = nativeIndex - chunkSize;
- r.length = chunkSize;
- }
- else
- {
- r.location = 0;
- r.length = chunkSize - nativeIndex;
- }
+ if (nativeIndex <= nativeLimit && nativeIndex > nativeStart)
+ {
+ /* The chunk already contains the index, set the offset
+ * to match it.
+ */
+ ut->chunkOffset = nativeIndex - nativeStart;
+ return TRUE;
+ }
+
+ if (nativeIndex <= 0 && nativeStart <= 0)
+ {
+ /* Asking for a position beyond the start of the string;
+ * Limit it to position of the first character.
+ */
+ ut->chunkOffset = 0;
+ return FALSE;
+ }
+
+ nativeLimit = nativeIndex;
+ if (nativeLimit > length)
+ {
+ nativeLimit = length;
+ }
+ nativeStart = nativeLimit - chunkSize;
+ if (nativeStart < 0)
+ {
+ nativeStart = 0;
+ }
+ r.location = nativeStart;
+ r.length = nativeLimit - nativeStart;
+ ut->chunkOffset = r.length;
}
[str getCharacters: ut->pExtra range: r];
- ut->chunkNativeStart = r.location;
- ut->chunkNativeLimit = r.location + r.length;
+ ut->chunkNativeLimit = nativeLimit;
+ ut->chunkNativeStart = nativeStart;
ut->chunkLength = r.length;
- ut->chunkOffset = 0;
return TRUE;
}
@@ -120,9 +156,10 @@
}
else
{
- replacement = [replacement initWithCharactersNoCopy:
(unichar*)replacementText
- length: replacmentLength
- freeWhenDone: NO];
+ replacement = [replacement
+ initWithCharactersNoCopy: (unichar*)replacementText
+ length: replacmentLength
+ freeWhenDone: NO];
}
[str replaceCharactersInRange: r withString: replacement];
@@ -152,34 +189,35 @@
int32_t destCapacity,
UErrorCode *status)
{
- NSString *str;
- NSUInteger length;
- NSRange r;
-
/* If we're loading no characters, we are expected to return the number of
* characters that we could load if requested.
*/
- if (destCapacity == 0)
+ if (destCapacity <= 0)
{
return nativeLimit - nativeStart;
}
- str = (NSString*)ut->p;
- length = [str length];
- if (nativeLimit > length)
- {
- nativeLimit = length;
- }
- r = NSMakeRange(nativeStart, nativeLimit - nativeStart );
- if (destCapacity < r.length)
- {
- r.length = destCapacity;
- }
- [str getCharacters: dest range: r];
- if (destCapacity > r.length)
- {
- dest[r.length] = 0;
- }
- return r.length;
+ else
+ {
+ NSString *str = (NSString*)ut->p;
+ NSUInteger length = (-1 == ut->c) ? [str length] : ut->c;
+ NSRange r;
+
+ if (nativeLimit > length)
+ {
+ nativeLimit = length;
+ }
+ r = NSMakeRange(nativeStart, nativeLimit - nativeStart );
+ if (destCapacity < r.length)
+ {
+ r.length = destCapacity;
+ }
+ [str getCharacters: dest range: r];
+ if (destCapacity > r.length)
+ {
+ dest[r.length] = 0;
+ }
+ return r.length;
+ }
}
/**
@@ -193,7 +231,7 @@
UErrorCode *status)
{
NSMutableString *str = (NSMutableString*)ut->p;
- NSUInteger length = [str length];
+ NSUInteger length = (-1 == ut->c) ? [str length] : ut->c;
NSRange r;
NSString *substr;
@@ -341,7 +379,7 @@
txt->pFuncs = &NSMutableStringFuncs;
txt->chunkContents = txt->pExtra;
txt->nativeIndexingLimit = INT32_MAX;
-
+ txt->c = -1; // Need to fetch length every time
txt->providerProperties = 1<<UTEXT_PROVIDER_WRITABLE;
return txt;
@@ -362,6 +400,7 @@
txt->pFuncs = &NSStringFuncs;
txt->chunkContents = txt->pExtra;
txt->nativeIndexingLimit = INT32_MAX;
+ txt->c = [str length];
return txt;
}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs