mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Remove some of the compiler warnings on system without clang or ICU.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33680 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
86edfd0c2b
commit
00c8832228
4 changed files with 84 additions and 53 deletions
28
ChangeLog
28
ChangeLog
|
@ -1,3 +1,11 @@
|
|||
2011-08-02 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSThread.m (GSCurrentThread): Use C string in assert, not
|
||||
ObjC string.
|
||||
* Headers/Foundation/NSRegularExpression.h: Add the pattern as ivar.
|
||||
* Source/NSRegularExpression.m: Rewrite to compile with less
|
||||
warnings on systems not supporting ICU.
|
||||
|
||||
2011-07-31 16:19 David Chisnall <theraven@gna.org>
|
||||
|
||||
* libs/base/trunk/Headers/Foundation/NSObject.h: Remove the
|
||||
|
@ -36,7 +44,7 @@
|
|||
- (oneway void)release;
|
||||
so everything implementing -release actually implements the one
|
||||
declared in the NSObject protocol.
|
||||
|
||||
|
||||
Start marking things that are unavailable in ARC mode as
|
||||
unavailable in ARC mode.
|
||||
|
||||
|
@ -59,7 +67,7 @@
|
|||
* Headers/Foundation/NSObject.h:
|
||||
* Headers/Foundation/NSProxy.h:
|
||||
* Source/NSProxy.m:
|
||||
Fixed missing oneway qualifier on -release return type. Recent Clang
|
||||
Fixed missing oneway qualifier on -release return type. Recent Clang
|
||||
trunk complains about it.
|
||||
|
||||
2011-07-25 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
@ -133,25 +141,25 @@
|
|||
Tests/base/NSPointerArray/weak.m: Lots of little
|
||||
fixes to make -base compile with -Werror (now builds without
|
||||
warnings).
|
||||
|
||||
|
||||
Richard: I'm unsure about three of these, which were fixes in
|
||||
memset() calls in:
|
||||
- NSConcreteMapTable.m
|
||||
- NSConcreteHashTable.m
|
||||
- Additions/NSData+GNUstepBase.m
|
||||
|
||||
|
||||
Please can you check them? I think they are intended to zero the
|
||||
entire object
|
||||
(rather than the first word), but the lack of comments makes me
|
||||
unsure.
|
||||
|
||||
|
||||
Most changes were just tweaks to variable types. I've also
|
||||
removed some dead code from NSInvocation. This was small group of
|
||||
things that were marked for internal use only, but not actually
|
||||
referenced in the code anywhere.
|
||||
|
||||
|
||||
Other improvements:
|
||||
|
||||
|
||||
- NSArray / NSDictionary fixed up to use the 10.7 (ARC-friendly)
|
||||
prototypes.
|
||||
- getObjects:andKeys: implemented for NSDictionary (10.5 method)
|
||||
|
@ -175,7 +183,7 @@
|
|||
objects. Now we always query the zones to find the relevant
|
||||
pointer. Zones are still supported, but we now optimise for the
|
||||
case where they are not used.
|
||||
|
||||
|
||||
To disable zone support completely, NSAllocateObject() should
|
||||
ignore the zone and NSDeallocateObject() should skip the zone
|
||||
lookup.
|
||||
|
@ -195,7 +203,7 @@
|
|||
|
||||
2011-07-20 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSNumberFormatter.m
|
||||
* Source/NSNumberFormatter.m
|
||||
(-attributedStringForObjectValue:withDefaultAttributes:):
|
||||
Guard against initializing an NSAttributedString with a nil string.
|
||||
|
||||
|
@ -264,7 +272,7 @@
|
|||
threads, matching OS X behaviour and stopping us from crashing
|
||||
when calling autorelease from a thread that was not previously
|
||||
registered explicitly (yuck!)
|
||||
|
||||
|
||||
Also do some quite hacky (and not totally correct) things to try
|
||||
to make sure that we aren't confused into thinking that the first
|
||||
NSThread is the main thread, if it's created on a separate
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
@class NSTextCheckingResult;
|
||||
@class NSString, NSTextCheckingResult;
|
||||
|
||||
typedef NSUInteger NSRegularExpressionOptions;
|
||||
static const NSRegularExpressionOptions
|
||||
|
@ -76,6 +76,7 @@ DEFINE_BLOCK_TYPE(GSRegexBlock, void, NSTextCheckingResult*, NSMatchingFlags, BO
|
|||
#if GS_EXPOSE(NSRegularExpression)
|
||||
@private
|
||||
GSREGEXTYPE *regex;
|
||||
NSString *pattern;
|
||||
NSRegularExpressionOptions options;
|
||||
#endif
|
||||
#if GS_NONFRAGILE
|
||||
|
@ -113,8 +114,8 @@ DEFINE_BLOCK_TYPE(GSRegexBlock, void, NSTextCheckingResult*, NSMatchingFlags, BO
|
|||
options: (NSMatchingOptions)options
|
||||
range: (NSRange)range;
|
||||
- (NSArray*)matchesInString: (NSString*)string
|
||||
options:(NSMatchingOptions)options
|
||||
range:(NSRange)range;
|
||||
options: (NSMatchingOptions)options
|
||||
range: (NSRange)range;
|
||||
- (NSRange)rangeOfFirstMatchInString: (NSString*)string
|
||||
options: (NSMatchingOptions)options
|
||||
range: (NSRange)range;
|
||||
|
|
|
@ -27,17 +27,19 @@
|
|||
#if GS_USE_ICU == 1
|
||||
#include "unicode/uregex.h"
|
||||
#if (U_ICU_VERSION_MAJOR_NUM > 4 || (U_ICU_VERSION_MAJOR_NUM == 4 && U_ICU_VERSION_MINOR_NUM >= 4))
|
||||
|
||||
#define NSRegularExpressionWorks
|
||||
|
||||
#define GSREGEXTYPE URegularExpression
|
||||
#import "GSICUString.h"
|
||||
#import "Foundation/NSRegularExpression.h"
|
||||
#import "Foundation/NSTextCheckingResult.h"
|
||||
#endif //U_ICU_VERSION_MAJOR_NUM > 4 || (U_ICU_VERSION_MAJOR_NUM == 4 && U_ICU_VERSION_MINOR_NUM >= 4))
|
||||
#endif //HAV_ICU
|
||||
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSRegularExpression.h"
|
||||
#import "Foundation/NSTextCheckingResult.h"
|
||||
|
||||
|
||||
#ifdef NSRegularExpressionWorks
|
||||
/**
|
||||
* To be helpful, Apple decided to define a set of flags that mean exactly the
|
||||
* same thing as the URegexpFlags enum in libicu, but have different values.
|
||||
|
@ -80,6 +82,7 @@ NSRegularExpressionOptionsToURegexpFlags(NSRegularExpressionOptions opts)
|
|||
}
|
||||
return flags;
|
||||
}
|
||||
#endif
|
||||
|
||||
@implementation NSRegularExpression
|
||||
|
||||
|
@ -96,6 +99,7 @@ NSRegularExpressionOptionsToURegexpFlags(NSRegularExpressionOptions opts)
|
|||
options: (NSRegularExpressionOptions)opts
|
||||
error: (NSError**)e
|
||||
{
|
||||
#ifdef NSRegularExpressionWorks
|
||||
uint32_t flags = NSRegularExpressionOptionsToURegexpFlags(opts);
|
||||
UText p = UTEXT_INITIALIZER;
|
||||
UParseError pe = {0};
|
||||
|
@ -110,26 +114,18 @@ NSRegularExpressionOptionsToURegexpFlags(NSRegularExpressionOptions opts)
|
|||
[self release];
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
ASSIGN(pattern, aPattern);
|
||||
options = opts;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString*) pattern
|
||||
{
|
||||
UErrorCode s = 0;
|
||||
UText *t = uregex_patternUText(regex, &s);
|
||||
GSUTextString *str = NULL;
|
||||
|
||||
if (U_FAILURE(s))
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
str = [GSUTextString new];
|
||||
utext_clone(&str->txt, t, FALSE, TRUE, &s);
|
||||
utext_close(t);
|
||||
return [str autorelease];
|
||||
return pattern;
|
||||
}
|
||||
|
||||
#ifdef NSRegularExpressionWorks
|
||||
static UBool
|
||||
callback(const void *context, int32_t steps)
|
||||
{
|
||||
|
@ -217,12 +213,14 @@ prepareResult(NSRegularExpression *regex,
|
|||
}
|
||||
return flags;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void) enumerateMatchesInString: (NSString*)string
|
||||
options: (NSMatchingOptions)opts
|
||||
range: (NSRange)range
|
||||
usingBlock: (GSRegexBlock)block
|
||||
{
|
||||
#ifdef NSRegularExpressionWorks
|
||||
UErrorCode s = 0;
|
||||
UText txt = UTEXT_INITIALIZER;
|
||||
BOOL stop = NO;
|
||||
|
@ -272,6 +270,11 @@ prepareResult(NSRegularExpression *regex,
|
|||
}
|
||||
utext_close(&txt);
|
||||
uregex_close(r);
|
||||
#else
|
||||
//FIXME
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"NSRegularExpression requires ICU 4.4 or later"];
|
||||
#endif
|
||||
}
|
||||
|
||||
/* The remaining methods are all meant to be wrappers around the primitive
|
||||
|
@ -371,6 +374,8 @@ prepareResult(NSRegularExpression *regex,
|
|||
# ifdef __clang__
|
||||
# warning Your compiler would support blocks if you added -fblocks to your OBJCFLAGS
|
||||
# endif
|
||||
|
||||
#ifdef NSRegularExpressionWorks
|
||||
#define FAKE_BLOCK_HACK(failRet, code) \
|
||||
UErrorCode s = 0;\
|
||||
UText txt = UTEXT_INITIALIZER;\
|
||||
|
@ -393,6 +398,11 @@ prepareResult(NSRegularExpression *regex,
|
|||
}\
|
||||
utext_close(&txt);\
|
||||
uregex_close(r);
|
||||
#else
|
||||
#define FAKE_BLOCK_HACK(failRet, code) \
|
||||
[NSException raise: NSInvalidArgumentException \
|
||||
format: @"NSRegularExpression requires ICU 4.4 or later"]
|
||||
#endif
|
||||
|
||||
- (NSUInteger) numberOfMatchesInString: (NSString*)string
|
||||
options: (NSMatchingOptions)opts
|
||||
|
@ -476,6 +486,7 @@ prepareResult(NSRegularExpression *regex,
|
|||
NSInteger results = [self numberOfMatchesInString: string
|
||||
options: opts
|
||||
range: range];
|
||||
#ifdef NSRegularExpressionWorks
|
||||
UErrorCode s = 0;
|
||||
UText txt = UTEXT_INITIALIZER;
|
||||
UText replacement = UTEXT_INITIALIZER;
|
||||
|
@ -494,6 +505,7 @@ prepareResult(NSRegularExpression *regex,
|
|||
utext_close(&txt);
|
||||
utext_close(output);
|
||||
utext_close(&replacement);
|
||||
#endif
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@ -502,6 +514,7 @@ prepareResult(NSRegularExpression *regex,
|
|||
range: (NSRange)range
|
||||
withTemplate: (NSString*)template
|
||||
{
|
||||
#ifdef NSRegularExpressionWorks
|
||||
UErrorCode s = 0;
|
||||
UText txt = UTEXT_INITIALIZER;
|
||||
UText replacement = UTEXT_INITIALIZER;
|
||||
|
@ -519,6 +532,10 @@ prepareResult(NSRegularExpression *regex,
|
|||
utext_close(output);
|
||||
utext_close(&replacement);
|
||||
return ret;
|
||||
#else
|
||||
// FIXME
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSString*) replacementStringForResult: (NSTextCheckingResult*)result
|
||||
|
@ -526,6 +543,7 @@ prepareResult(NSRegularExpression *regex,
|
|||
offset: (NSInteger)offset
|
||||
template: (NSString*)template
|
||||
{
|
||||
#ifdef NSRegularExpressionWorks
|
||||
UErrorCode s = 0;
|
||||
UText txt = UTEXT_INITIALIZER;
|
||||
UText replacement = UTEXT_INITIALIZER;
|
||||
|
@ -549,6 +567,10 @@ prepareResult(NSRegularExpression *regex,
|
|||
utext_close(output);
|
||||
utext_close(&replacement);
|
||||
return ret;
|
||||
#else
|
||||
//FIXME
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSRegularExpressionOptions) options
|
||||
|
@ -558,13 +580,21 @@ prepareResult(NSRegularExpression *regex,
|
|||
|
||||
- (NSUInteger) numberOfCaptureGroups
|
||||
{
|
||||
#ifdef NSRegularExpressionWorks
|
||||
UErrorCode s = 0;
|
||||
return uregex_groupCount(regex, &s);
|
||||
#else
|
||||
// FIXME
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
#ifdef NSRegularExpressionWorks
|
||||
uregex_close(regex);
|
||||
#endif
|
||||
RELEASE(pattern);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -585,24 +615,26 @@ prepareResult(NSRegularExpression *regex,
|
|||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
NSString *pattern;
|
||||
NSString *aPattern;
|
||||
NSRegularExpressionOptions opts;
|
||||
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
options = [aCoder decodeIntegerForKey: @"options"];
|
||||
pattern = [aCoder decodeObjectForKey: @"pattern"];
|
||||
opts = [aCoder decodeIntegerForKey: @"options"];
|
||||
aPattern = [aCoder decodeObjectForKey: @"pattern"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder decodeValueOfObjCType: @encode(NSRegularExpressionOptions)
|
||||
at: &options];
|
||||
pattern = [aCoder decodeObject];
|
||||
at: &opts];
|
||||
aPattern = [aCoder decodeObject];
|
||||
}
|
||||
return [self initWithPattern: pattern options: options error: NULL];
|
||||
return [self initWithPattern: aPattern options: opts error: NULL];
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone*)aZone
|
||||
{
|
||||
#ifdef NSRegularExpressionWorks
|
||||
NSRegularExpressionOptions opts = options;
|
||||
UErrorCode s = 0;
|
||||
URegularExpression *r = uregex_clone(regex, &s);
|
||||
|
@ -620,20 +652,10 @@ prepareResult(NSRegularExpression *regex,
|
|||
options = opts;
|
||||
regex = r;
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
#endif //U_ICU_VERSION_MAJOR_NUM > 4 || (U_ICU_VERSION_MAJOR_NUM == 4 && U_ICU_VERSION_MINOR_NUM >= 4))
|
||||
#endif //HAV_ICU
|
||||
|
||||
#ifndef NSRegularExpressionWorks
|
||||
#import "Foundation/NSRegularExpression.h"
|
||||
#import "Foundation/NSZone.h"
|
||||
#import "Foundation/NSException.h"
|
||||
@implementation NSRegularExpression
|
||||
+ (id)allocWithZone: (NSZone*)aZone
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"NSRegularExpression requires ICU 4.4 or later"];
|
||||
}
|
||||
@end
|
||||
#else
|
||||
return [[[self class] allocWithZone: aZone] initWithPattern: [self pattern]
|
||||
options: [self options]
|
||||
error: NULL];
|
||||
#endif
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -336,7 +336,7 @@ GSCurrentThread(void)
|
|||
defaultThread = [thr retain];
|
||||
}
|
||||
}
|
||||
assert(nil != thr && @"No main thread");
|
||||
assert(nil != thr && "No main thread");
|
||||
return thr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue