Merge branch 'master' of github.com:gnustep/libs-base

This commit is contained in:
Gregory Casamento 2020-01-20 23:25:41 -05:00
commit 4cbf07b4ae
8 changed files with 106 additions and 33 deletions

View file

@ -1,3 +1,23 @@
2020-01-20 Fred Kiefer <fredkiefer@gmx.de>
* Source/NSPredicate.m: Allow simple predicates on NSDate.
2020-01-20 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSTLS.m: remove certificate key password from hash key of
credentials since it's unnecessary there and we don't want it to be
logged when debug is on (for security, passwords shouldn't appear
in logs).
2020-01-12 Fred Kiefer <fredkiefer@gmx.de>
* Source/NSPredicate.m: Add support for NSDate constants.
2020-01-12 Fred Kiefer <fredkiefer@gmx.de>
* Source/NSKeyValueObserving.m: Implement two missing KVO methods
on NSArray.
2019-12-15 Fred Kiefer <fredkiefer@gmx.de>
* Headers/GNUstepBase/GSIMap.h: Use GSI_MAP_NODE_IS_EMPTY macros

View file

@ -50,9 +50,9 @@ typedef uint8_t gsuuid_t[16];
gsuuid_t uuid;
}
+ (id)UUID;
- (id)initWithUUIDString:(NSString *)string;
- (id)initWithUUIDBytes:(gsuuid_t)bytes;
+ (instancetype)UUID;
- (instancetype)initWithUUIDString:(NSString *)string;
- (instancetype)initWithUUIDBytes:(gsuuid_t)bytes;
- (NSString *)UUIDString;
- (void)getUUIDBytes:(gsuuid_t)bytes;

View file

@ -52,7 +52,7 @@
format: @"method %@ not implemented in %@(class)",
selector ? (id)NSStringFromSelector(selector) : (id)@"(null)",
NSStringFromClass(self)];
while (0) ; // Does not return
while (1) ; // Does not return
}
- (NSComparisonResult) compare: (id)anObject
@ -116,7 +116,7 @@
format: @"[%@%c%@] not implemented",
NSStringFromClass([self class]), c,
aSel ? (id)NSStringFromSelector(aSel) : (id)@"(null)"];
while (0) ; // Does not return
while (1) ; // Does not return
}
- (id) shouldNotImplement: (SEL)aSel
@ -128,7 +128,7 @@
format: @"[%@%c%@] should not be implemented",
NSStringFromClass([self class]), c,
aSel ? (id)NSStringFromSelector(aSel) : (id)@"(null)"];
while (0) ; // Does not return
while (1) ; // Does not return
}
- (id) subclassResponsibility: (SEL)aSel
@ -139,7 +139,7 @@
format: @"[%@%c%@] should be overridden by subclass",
NSStringFromClass([self class]), c,
aSel ? (id)NSStringFromSelector(aSel) : (id)@"(null)"];
while (0) ; // Does not return
while (1) ; // Does not return
}
@end

View file

@ -1117,7 +1117,8 @@ static NSMutableDictionary *credentialsCache = nil;
NSMutableString *k;
/* Build a unique key for the credentials based on all the
* information (file names and password) used to build them.
* information used to build them (apart from password used
* to load the key).
*/
k = [NSMutableString stringWithCapacity: 1024];
ca = standardizedPath(ca);
@ -1133,8 +1134,6 @@ static NSMutableDictionary *credentialsCache = nil;
if (nil != cf) [k appendString: cf];
[k appendString: @":"];
if (nil != ck) [k appendString: ck];
[k appendString: @":"];
if (nil != cp) [k appendString: cp];
[credentialsLock lock];
c = [credentialsCache objectForKey: k];

View file

@ -30,6 +30,7 @@
#import "Foundation/NSEnumerator.h"
#import "Foundation/NSException.h"
#import "Foundation/NSHashTable.h"
#import "Foundation/NSIndexSet.h"
#import "Foundation/NSKeyValueCoding.h"
#import "Foundation/NSKeyValueObserving.h"
#import "Foundation/NSLock.h"
@ -1579,7 +1580,19 @@ cifframe_callback(ffi_cif *cif, void *retp, void **args, void *user)
options: (NSKeyValueObservingOptions)options
context: (void*)aContext
{
[self notImplemented: _cmd];
NSUInteger i = [indexes firstIndex];
while (i != NSNotFound)
{
NSObject *elem = [self objectAtIndex: i];
[elem addObserver: anObserver
forKeyPath: aPath
options: options
context: aContext];
i = [indexes indexGreaterThanIndex: i];
}
}
- (void) removeObserver: (NSObject*)anObserver forKeyPath: (NSString*)aPath
@ -1593,7 +1606,17 @@ cifframe_callback(ffi_cif *cif, void *retp, void **args, void *user)
fromObjectsAtIndexes: (NSIndexSet*)indexes
forKeyPath: (NSString*)aPath
{
[self notImplemented: _cmd];
NSUInteger i = [indexes firstIndex];
while (i != NSNotFound)
{
NSObject *elem = [self objectAtIndex: i];
[elem removeObserver: anObserver
forKeyPath: aPath];
i = [indexes indexGreaterThanIndex: i];
}
}
@end

View file

@ -38,6 +38,7 @@
#import "Foundation/NSPredicate.h"
#import "Foundation/NSArray.h"
#import "Foundation/NSDate.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSEnumerator.h"
#import "Foundation/NSException.h"
@ -890,6 +891,18 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
}
#endif
- (double) doubleValueFor: (id)value
{
if ([value isKindOfClass: [NSDate class]])
{
return [(NSDate*)value timeIntervalSinceReferenceDate];
}
else
{
return [value doubleValue];
}
}
- (BOOL) _evaluateLeftValue: (id)leftResult
rightValue: (id)rightResult
object: (id)object
@ -941,26 +954,26 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
{
case NSLessThanPredicateOperatorType:
{
double ld = [leftResult doubleValue];
double rd = [rightResult doubleValue];
double ld = [self doubleValueFor: leftResult];
double rd = [self doubleValueFor: rightResult];
return (ld < rd) ? YES : NO;
}
case NSLessThanOrEqualToPredicateOperatorType:
{
double ld = [leftResult doubleValue];
double rd = [rightResult doubleValue];
double ld = [self doubleValueFor: leftResult];
double rd = [self doubleValueFor: rightResult];
return (ld <= rd) ? YES : NO;
}
case NSGreaterThanPredicateOperatorType:
{
double ld = [leftResult doubleValue];
double rd = [rightResult doubleValue];
double ld = [self doubleValueFor: leftResult];
double rd = [self doubleValueFor: rightResult];
return (ld > rd) ? YES : NO;
}
case NSGreaterThanOrEqualToPredicateOperatorType:
{
double ld = [leftResult doubleValue];
double rd = [rightResult doubleValue];
double ld = [self doubleValueFor: leftResult];
double rd = [self doubleValueFor: rightResult];
return (ld >= rd) ? YES : NO;
}
case NSEqualToPredicateOperatorType:
@ -1313,6 +1326,11 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
GSPropertyListMake(_obj, nil, NO, YES, 2, &result);
return result;
}
else if ([_obj isKindOfClass: [NSDate class]])
{
return [NSString stringWithFormat: @"CAST(%15.6f, \"NSDate\")",
[(NSDate*)_obj timeIntervalSinceReferenceDate]];
}
return [_obj description];
}
@ -1720,6 +1738,20 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
return [NSNumber numberWithDouble: sum];
}
- (id) _eval_CAST: (NSArray *)expressions
{
id left = [expressions objectAtIndex: 0];
id right = [expressions objectAtIndex: 1];
if ([right isEqualToString: @"NSDate"])
{
return [[NSDate alloc] initWithTimeIntervalSinceReferenceDate: [left doubleValue]];
}
NSLog(@"Cast to unknown type %@", right);
return nil;
}
// add arithmetic functions: average, median, mode, stddev, sqrt, log, ln, exp, floor, ceiling, abs, trunc, random, randomn, now
@end

View file

@ -116,7 +116,6 @@ static Class NSDate_class;
userInfo: (id)info
repeats: (BOOL)f
{
_block = nil;
if (ti <= 0.0)
{
ti = 0.0001;
@ -146,18 +145,18 @@ static Class NSDate_class;
return self;
}
- (instancetype) initWithFireDate: (NSDate *)date
interval: (NSTimeInterval)interval
repeats: (BOOL)repeats
- (instancetype) initWithFireDate: (NSDate *)date
interval: (NSTimeInterval)interval
repeats: (BOOL)repeats
block: (GSTimerBlock)block
{
ASSIGN(_block, block);
return [self initWithFireDate: date
interval: interval
target: nil
selector: NULL
userInfo: nil
repeats: repeats];
ASSIGN(_block, block);
}
/**
@ -254,7 +253,7 @@ static Class NSDate_class;
block: block];
[[NSRunLoop currentRunLoop] addTimer: t forMode: NSDefaultRunLoopMode];
RELEASE(t);
return t;
return t;
}
- (void) dealloc
@ -286,12 +285,12 @@ static Class NSDate_class;
else
{
id target;
/* We retain the target so it won't be deallocated while we are using
* it (if this timer gets invalidated while we are firing).
*/
target = RETAIN(_target);
if (_selector == 0)
{
NS_DURING
@ -328,7 +327,7 @@ static Class NSDate_class;
}
RELEASE(target);
}
if (_repeats == NO)
{
[self invalidate];

View file

@ -43,7 +43,7 @@ static const int kUUIDByteCount = 16;
*/
@implementation NSUUID
+ (id) UUID
+ (instancetype) UUID
{
id u;
@ -51,7 +51,7 @@ static const int kUUIDByteCount = 16;
return AUTORELEASE(u);
}
- (id) init
- (instancetype) init
{
gsuuid_t localUUID;
int result;
@ -65,7 +65,7 @@ static const int kUUIDByteCount = 16;
return [self initWithUUIDBytes: localUUID];
}
- (id) initWithUUIDString: (NSString *)string
- (instancetype) initWithUUIDString: (NSString *)string
{
gsuuid_t localUUID;
const char *cString;
@ -81,7 +81,7 @@ static const int kUUIDByteCount = 16;
return [self initWithUUIDBytes: localUUID];
}
- (id) initWithUUIDBytes: (gsuuid_t)bytes
- (instancetype) initWithUUIDBytes: (gsuuid_t)bytes
{
if (nil != (self = [super init]))
{