mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
More user defaults modification.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11359 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
01c5c95a40
commit
8cd9e00585
16 changed files with 205 additions and 162 deletions
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
||||||
|
2001-11-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Documentation/gsdoc/Base.gsdoc:
|
||||||
|
* Source/GSCompatibility.m:
|
||||||
|
* Source/GSMime.m:
|
||||||
|
* Source/GSUserDefaults.h:
|
||||||
|
* Source/NSArray.m:
|
||||||
|
* Source/NSCalendarDate.m:
|
||||||
|
* Source/NSDate.m:
|
||||||
|
* Source/NSDecimalNumber.m:
|
||||||
|
* Source/NSDictionary.m:
|
||||||
|
* Source/NSFileHandle.m:
|
||||||
|
* Source/NSGeometry.m:
|
||||||
|
* Source/NSLog.m:
|
||||||
|
* Source/NSScanner.m:
|
||||||
|
* Source/NSString.m:
|
||||||
|
* Source/NSUserDefaults.m: Modify user defaults usage to cache some
|
||||||
|
defaults used internally and provide private accessors for speed.
|
||||||
|
Add default to force logging to be done via syslog since logging
|
||||||
|
to stderr within code called via JIGS from a servlet engine may
|
||||||
|
cause severe problems if the servlet engine is using descriptor 2
|
||||||
|
for other purposes.
|
||||||
|
|
||||||
2001-11-09 Richard Frith-Macdonald <rfm@gnu.org>
|
2001-11-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSMime.m: modifications made to support HTTP continuation
|
* Source/GSMime.m: modifications made to support HTTP continuation
|
||||||
|
|
|
@ -61,15 +61,32 @@
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
<h4><a name ="cont-3">User defaults</a></h4>
|
<h4><a name ="cont-3">User defaults</a></h4>
|
||||||
<p>
|
|
||||||
|
|
||||||
Setting the user default <code>GSMacOSXCompatible</code> to
|
|
||||||
<code>YES</code> will cause MacOS compatible behavior to be
|
|
||||||
the default at runtime. This default may however be overridden
|
|
||||||
to provide more fine grained control of system behavior.
|
|
||||||
</p>
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt>GSMacOSXCompatibleGeometry
|
<dt>GSLogSyslog
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
Setting the user default <code>GSLogSyslog</code> to
|
||||||
|
<code>YES</code> will cause log/debug output to be sent to
|
||||||
|
the syslog facility (on systems which support it), rather
|
||||||
|
than to the standard error stream. This is useful in
|
||||||
|
environments where stderr has been re-used strangely for
|
||||||
|
some reason.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<dt>GSMacOSXCompatible
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
Setting the user default <code>GSMacOSXCompatible</code> to
|
||||||
|
<code>YES</code> will cause MacOS compatible behavior to be
|
||||||
|
the default at runtime. This default may however be overridden
|
||||||
|
to provide more fine grained control of system behavior.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<dt>GSOldStyleGeometry
|
||||||
<dd>
|
<dd>
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
|
@ -82,7 +99,7 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<dt>GSMacOSXCompatiblePropertyLists
|
<dt>NSWriteOldStylePropertyLists
|
||||||
<dd>
|
<dd>
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
|
@ -110,29 +127,6 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<dt>NSWriteOldStylePropertyLists
|
|
||||||
<dd>
|
|
||||||
<p>
|
|
||||||
|
|
||||||
Specifies whether text property-list output should be in
|
|
||||||
the default MacOS-X format (XML), or in the more human
|
|
||||||
readable (but less powerful) original OpenStep format.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
|
|
||||||
If, GSMacOSXCompatible is YES, this default is treated
|
|
||||||
as being NO if it is not set, otherwise, this default
|
|
||||||
is treated as YES.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
|
|
||||||
This default is <em>NOT</em> used if
|
|
||||||
GSMacOSXCompatiblePropertyLists is specified.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
<h4><a name ="cont-4">Environment variables</a></h4>
|
<h4><a name ="cont-4">Environment variables</a></h4>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <Foundation/Foundation.h>
|
#include <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#include "GSUserDefaults.h"
|
||||||
|
|
||||||
#ifndef HAVE_RINT
|
#ifndef HAVE_RINT
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
static double rint(double a)
|
static double rint(double a)
|
||||||
|
@ -35,98 +37,19 @@ static double rint(double a)
|
||||||
/*
|
/*
|
||||||
* Runtime MacOS-X compatibility flags.
|
* Runtime MacOS-X compatibility flags.
|
||||||
*/
|
*/
|
||||||
static BOOL setupDone = NO;
|
|
||||||
|
|
||||||
static BOOL MacOSXCompatible = NO;
|
|
||||||
static BOOL MacOSXCompatibleGeometry = NO;
|
|
||||||
static BOOL MacOSXCompatiblePropertyLists = NO;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A trivial class to monitor user defaults to see how we should be
|
|
||||||
* producing strings describing geometry structures.
|
|
||||||
*/
|
|
||||||
@interface GSBaseDefaultObserver : NSObject
|
|
||||||
+ (void) defaultsChanged: (NSNotification*)aNotification;
|
|
||||||
@end
|
|
||||||
@implementation GSBaseDefaultObserver
|
|
||||||
+ (void) defaultsChanged: (NSNotification*)aNotification
|
|
||||||
{
|
|
||||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
||||||
id def;
|
|
||||||
Class sClass = [NSString class];
|
|
||||||
|
|
||||||
MacOSXCompatible = [defaults boolForKey: @"GSMacOSXCompatible"];
|
|
||||||
|
|
||||||
def = [defaults objectForKey: @"GSMacOSXCompatibleGeometry"];
|
|
||||||
if (def != nil && [def isKindOfClass: sClass] == YES)
|
|
||||||
{
|
|
||||||
MacOSXCompatibleGeometry = [def boolValue];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MacOSXCompatibleGeometry = MacOSXCompatible;
|
|
||||||
}
|
|
||||||
def = [defaults objectForKey: @"GSMacOSXCompatiblePropertyLists"];
|
|
||||||
if (def != nil && [def isKindOfClass: sClass] == YES)
|
|
||||||
{
|
|
||||||
MacOSXCompatiblePropertyLists = [def boolValue];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
def = [defaults objectForKey: @"NSWriteOldStylePropertyLists"];
|
|
||||||
if (def != nil && [def isKindOfClass: sClass] == YES)
|
|
||||||
{
|
|
||||||
if ([def boolValue] == YES)
|
|
||||||
{
|
|
||||||
MacOSXCompatiblePropertyLists = NO;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MacOSXCompatiblePropertyLists = YES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MacOSXCompatiblePropertyLists = MacOSXCompatible;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
static void
|
|
||||||
compatibilitySetup()
|
|
||||||
{
|
|
||||||
if (setupDone == NO)
|
|
||||||
{
|
|
||||||
setupDone = YES;
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
|
||||||
addObserver: [GSBaseDefaultObserver class]
|
|
||||||
selector: @selector(defaultsChanged:)
|
|
||||||
name: NSUserDefaultsDidChangeNotification
|
|
||||||
object: nil];
|
|
||||||
[[GSBaseDefaultObserver class] defaultsChanged: nil];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL GSMacOSXCompatible()
|
|
||||||
{
|
|
||||||
if (setupDone == NO)
|
|
||||||
compatibilitySetup();
|
|
||||||
return MacOSXCompatible;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL GSMacOSXCompatibleGeometry()
|
BOOL GSMacOSXCompatibleGeometry()
|
||||||
{
|
{
|
||||||
if (setupDone == NO)
|
if (GSUserDefaultsFlag(GSOldStyleGeometry) == YES)
|
||||||
compatibilitySetup();
|
return NO;
|
||||||
return MacOSXCompatibleGeometry;
|
return GSUserDefaultsFlag(GSMacOSXCompatible);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL GSMacOSXCompatiblePropertyLists()
|
BOOL GSMacOSXCompatiblePropertyLists()
|
||||||
{
|
{
|
||||||
if (setupDone == NO)
|
if (GSUserDefaultsFlag(NSWriteOldStylePropertyLists) == YES)
|
||||||
compatibilitySetup();
|
return NO;
|
||||||
return MacOSXCompatiblePropertyLists;
|
return GSUserDefaultsFlag(GSMacOSXCompatible);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <Foundation/NSDictionary.h>
|
#include <Foundation/NSDictionary.h>
|
||||||
#include <Foundation/NSScanner.h>
|
#include <Foundation/NSScanner.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSUserDefaults.h>
|
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSValue.h>
|
#include <Foundation/NSValue.h>
|
||||||
#include <Foundation/NSURL.h>
|
#include <Foundation/NSURL.h>
|
||||||
|
@ -37,6 +36,7 @@
|
||||||
#include <Foundation/GSMime.h>
|
#include <Foundation/GSMime.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include "GSUserDefaults.h"
|
||||||
|
|
||||||
static NSCharacterSet *specials = nil;
|
static NSCharacterSet *specials = nil;
|
||||||
|
|
||||||
|
@ -1992,7 +1992,7 @@ parseCharacterSet(NSString *token)
|
||||||
NSDictionary *locale;
|
NSDictionary *locale;
|
||||||
|
|
||||||
desc = [NSMutableString stringWithFormat: @"GSMimeDocument <%0x> -\n", self];
|
desc = [NSMutableString stringWithFormat: @"GSMimeDocument <%0x> -\n", self];
|
||||||
locale = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
locale = GSUserDefaultsDictionaryRepresentation();
|
||||||
[desc appendString: [headers descriptionWithLocale: locale]];
|
[desc appendString: [headers descriptionWithLocale: locale]];
|
||||||
[desc appendFormat: @"\nDocument content -\n%@", content];
|
[desc appendFormat: @"\nDocument content -\n%@", content];
|
||||||
return desc;
|
return desc;
|
||||||
|
|
50
Source/GSUserDefaults.h
Normal file
50
Source/GSUserDefaults.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/* GSUserDefaults
|
||||||
|
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
This file is part of the GNUstep Base Library.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GSUserDefaults_h_
|
||||||
|
#define __GSUserDefaults_h_
|
||||||
|
|
||||||
|
#include <Foundation/NSUserDefaults.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For efficiency, we save defaults information which is used by the
|
||||||
|
* base library.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
GSMacOSXCompatible, // General behavior flag.
|
||||||
|
GSOldStyleGeometry, // Control geometry string output.
|
||||||
|
GSLogSyslog, // Force logging to go to syslog.
|
||||||
|
NSWriteOldStylePropertyLists, // Control PList output.
|
||||||
|
GSUserDefaultMaxFlag // End marker.
|
||||||
|
} GSUserDefaultFlagType;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the dictionary representation.
|
||||||
|
*/
|
||||||
|
NSDictionary *GSUserDefaultsDictionaryRepresentation();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get one of several potentially useful flags.
|
||||||
|
*/
|
||||||
|
BOOL GSUserDefaultsFlag(GSUserDefaultFlagType type);
|
||||||
|
|
||||||
|
#endif /* __GSUserDefaults_h_ */
|
|
@ -36,11 +36,11 @@
|
||||||
#include <Foundation/NSUtilities.h>
|
#include <Foundation/NSUtilities.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSAutoreleasePool.h>
|
#include <Foundation/NSAutoreleasePool.h>
|
||||||
#include <Foundation/NSUserDefaults.h>
|
|
||||||
#include <Foundation/NSThread.h>
|
#include <Foundation/NSThread.h>
|
||||||
#include <Foundation/NSMapTable.h>
|
#include <Foundation/NSMapTable.h>
|
||||||
#include <Foundation/NSLock.h>
|
#include <Foundation/NSLock.h>
|
||||||
#include <Foundation/NSDebug.h>
|
#include <Foundation/NSDebug.h>
|
||||||
|
#include "GSUserDefaults.h"
|
||||||
|
|
||||||
@class NSArrayEnumerator;
|
@class NSArrayEnumerator;
|
||||||
@class NSArrayEnumeratorReverse;
|
@class NSArrayEnumeratorReverse;
|
||||||
|
@ -834,7 +834,7 @@ static NSString *indentStrings[] = {
|
||||||
NSDictionary *loc;
|
NSDictionary *loc;
|
||||||
NSString *desc;
|
NSString *desc;
|
||||||
|
|
||||||
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
loc = GSUserDefaultsDictionaryRepresentation();
|
||||||
|
|
||||||
if (GSMacOSXCompatiblePropertyLists() == YES)
|
if (GSMacOSXCompatiblePropertyLists() == YES)
|
||||||
{
|
{
|
||||||
|
@ -863,7 +863,7 @@ static NSString *indentStrings[] = {
|
||||||
NSDictionary *loc;
|
NSDictionary *loc;
|
||||||
NSString *desc;
|
NSString *desc;
|
||||||
|
|
||||||
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
loc = GSUserDefaultsDictionaryRepresentation();
|
||||||
|
|
||||||
if (GSMacOSXCompatiblePropertyLists() == YES)
|
if (GSMacOSXCompatiblePropertyLists() == YES)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,11 +32,11 @@
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSCoder.h>
|
#include <Foundation/NSCoder.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSUserDefaults.h>
|
|
||||||
#include <base/behavior.h>
|
#include <base/behavior.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include "GSUserDefaults.h"
|
||||||
|
|
||||||
// Absolute Gregorian date for NSDate reference date Jan 01 2001
|
// Absolute Gregorian date for NSDate reference date Jan 01 2001
|
||||||
//
|
//
|
||||||
|
@ -314,8 +314,7 @@ static inline int getDigits(const char *from, char *to, int limit)
|
||||||
|
|
||||||
if (locale == nil)
|
if (locale == nil)
|
||||||
{
|
{
|
||||||
locale
|
locale = GSUserDefaultsDictionaryRepresentation();
|
||||||
= [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
|
||||||
}
|
}
|
||||||
if (fmt == nil)
|
if (fmt == nil)
|
||||||
{
|
{
|
||||||
|
@ -1222,7 +1221,7 @@ static inline int getDigits(const char *from, char *to, int limit)
|
||||||
int i, j, k, z;
|
int i, j, k, z;
|
||||||
|
|
||||||
if (locale == nil)
|
if (locale == nil)
|
||||||
locale = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
locale = GSUserDefaultsDictionaryRepresentation();
|
||||||
if (format == nil)
|
if (format == nil)
|
||||||
format = [locale objectForKey: NSTimeDateFormatString];
|
format = [locale objectForKey: NSTimeDateFormatString];
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSCoder.h>
|
#include <Foundation/NSCoder.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSUserDefaults.h>
|
|
||||||
#include <Foundation/NSCharacterSet.h>
|
#include <Foundation/NSCharacterSet.h>
|
||||||
#include <Foundation/NSScanner.h>
|
#include <Foundation/NSScanner.h>
|
||||||
#include <Foundation/NSObjCRuntime.h>
|
#include <Foundation/NSObjCRuntime.h>
|
||||||
|
@ -45,6 +44,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "GSUserDefaults.h"
|
||||||
|
|
||||||
/* The number of seconds between 1/1/2001 and 1/1/1970 = -978307200. */
|
/* The number of seconds between 1/1/2001 and 1/1/1970 = -978307200. */
|
||||||
/* This number comes from:
|
/* This number comes from:
|
||||||
|
@ -239,7 +239,7 @@ GSTimeNow()
|
||||||
unsigned dtoIndex;
|
unsigned dtoIndex;
|
||||||
|
|
||||||
if (locale == nil)
|
if (locale == nil)
|
||||||
locale = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
locale = GSUserDefaultsDictionaryRepresentation();
|
||||||
|
|
||||||
ws = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
ws = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
||||||
digits = [NSCharacterSet decimalDigitCharacterSet];
|
digits = [NSCharacterSet decimalDigitCharacterSet];
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSDecimal.h>
|
#include <Foundation/NSDecimal.h>
|
||||||
#include <Foundation/NSDecimalNumber.h>
|
#include <Foundation/NSDecimalNumber.h>
|
||||||
#include <Foundation/NSUserDefaults.h>
|
#include "GSUserDefaults.h"
|
||||||
|
|
||||||
static NSDecimalNumberHandler *handler;
|
static NSDecimalNumberHandler *handler;
|
||||||
|
|
||||||
|
@ -224,9 +224,9 @@ static NSDecimalNumber *one;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithMantissa:(unsigned long long)mantissa
|
- (id) initWithMantissa: (unsigned long long)mantissa
|
||||||
exponent:(short)exponent
|
exponent: (short)exponent
|
||||||
isNegative:(BOOL)flag
|
isNegative: (BOOL)flag
|
||||||
{
|
{
|
||||||
NSDecimal decimal;
|
NSDecimal decimal;
|
||||||
|
|
||||||
|
@ -234,16 +234,14 @@ static NSDecimalNumber *one;
|
||||||
return [self initWithDecimal: decimal];
|
return [self initWithDecimal: decimal];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithString:(NSString *)numberValue
|
- (id) initWithString: (NSString*)numberValue
|
||||||
{
|
{
|
||||||
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
|
||||||
|
|
||||||
return [self initWithString: numberValue
|
return [self initWithString: numberValue
|
||||||
locale: [defs dictionaryRepresentation]];
|
locale: GSUserDefaultsDictionaryRepresentation()];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithString:(NSString *)numberValue
|
- (id) initWithString: (NSString*)numberValue
|
||||||
locale:(NSDictionary *)locale;
|
locale: (NSDictionary*)locale;
|
||||||
{
|
{
|
||||||
NSDecimal decimal;
|
NSDecimal decimal;
|
||||||
|
|
||||||
|
@ -251,7 +249,7 @@ static NSDecimalNumber *one;
|
||||||
return [self initWithDecimal: decimal];
|
return [self initWithDecimal: decimal];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)descriptionWithLocale:(NSDictionary *)locale
|
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
|
||||||
{
|
{
|
||||||
return NSDecimalString(&data, locale);
|
return NSDecimalString(&data, locale);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,10 @@
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSAutoreleasePool.h>
|
#include <Foundation/NSAutoreleasePool.h>
|
||||||
#include <Foundation/NSFileManager.h>
|
#include <Foundation/NSFileManager.h>
|
||||||
#include <Foundation/NSUserDefaults.h>
|
|
||||||
#include <Foundation/NSCoder.h>
|
#include <Foundation/NSCoder.h>
|
||||||
#include <Foundation/NSDebug.h>
|
#include <Foundation/NSDebug.h>
|
||||||
#include <Foundation/NSObjCRuntime.h>
|
#include <Foundation/NSObjCRuntime.h>
|
||||||
|
#include "GSUserDefaults.h"
|
||||||
|
|
||||||
@implementation NSDictionary
|
@implementation NSDictionary
|
||||||
|
|
||||||
|
@ -626,7 +626,7 @@ compareIt(id o1, id o2, void* context)
|
||||||
NSDictionary *loc;
|
NSDictionary *loc;
|
||||||
NSString *desc;
|
NSString *desc;
|
||||||
|
|
||||||
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
loc = GSUserDefaultsDictionaryRepresentation();
|
||||||
|
|
||||||
if (GSMacOSXCompatiblePropertyLists() == YES)
|
if (GSMacOSXCompatiblePropertyLists() == YES)
|
||||||
{
|
{
|
||||||
|
@ -655,7 +655,7 @@ compareIt(id o1, id o2, void* context)
|
||||||
NSDictionary *loc;
|
NSDictionary *loc;
|
||||||
NSString *desc;
|
NSString *desc;
|
||||||
|
|
||||||
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
loc = GSUserDefaultsDictionaryRepresentation();
|
||||||
|
|
||||||
if (GSMacOSXCompatiblePropertyLists() == YES)
|
if (GSMacOSXCompatiblePropertyLists() == YES)
|
||||||
{
|
{
|
||||||
|
|
|
@ -359,6 +359,11 @@ NSString* NSFileHandleOperationException =
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) useCompression
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) writeInBackgroundAndNotify: (NSData*)item forModes: (NSArray*)modes
|
- (void) writeInBackgroundAndNotify: (NSData*)item forModes: (NSArray*)modes
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
[self subclassResponsibility: _cmd];
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
#include <Foundation/NSGeometry.h>
|
#include <Foundation/NSGeometry.h>
|
||||||
#include <Foundation/NSScanner.h>
|
#include <Foundation/NSScanner.h>
|
||||||
#include <Foundation/NSNotification.h>
|
#include <Foundation/NSNotification.h>
|
||||||
#include <Foundation/NSUserDefaults.h>
|
|
||||||
|
|
||||||
extern BOOL GSMacOSXCompatibleGeometry(); // Compatibility mode
|
extern BOOL GSMacOSXCompatibleGeometry(); // Compatibility mode
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "GSUserDefaults.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_NSLog_standard_printf_handler (NSString* message)
|
_NSLog_standard_printf_handler (NSString* message)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +69,7 @@ _NSLog_standard_printf_handler (NSString* message)
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG
|
#ifdef HAVE_SYSLOG
|
||||||
|
|
||||||
if (write(2, buf, len) != len)
|
if (GSUserDefaultsFlag(GSLogSyslog) == YES || write(2, buf, len) != len)
|
||||||
{
|
{
|
||||||
int mask;
|
int mask;
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,12 @@
|
||||||
#include <base/Unicode.h>
|
#include <base/Unicode.h>
|
||||||
#include <Foundation/NSScanner.h>
|
#include <Foundation/NSScanner.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSUserDefaults.h>
|
|
||||||
#include <Foundation/NSObjCRuntime.h>
|
#include <Foundation/NSObjCRuntime.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <ctype.h> /* FIXME: May go away once I figure out Unicode */
|
#include <ctype.h> /* FIXME: May go away once I figure out Unicode */
|
||||||
|
#include "GSUserDefaults.h"
|
||||||
|
|
||||||
/* BSD and Solaris have this */
|
/* BSD and Solaris have this */
|
||||||
#if defined(HANDLE_LLONG_MAX) && !defined(HANDLE_LONG_LONG_MAX)
|
#if defined(HANDLE_LLONG_MAX) && !defined(HANDLE_LONG_LONG_MAX)
|
||||||
|
@ -110,9 +110,7 @@ typedef struct {
|
||||||
|
|
||||||
if (scanner != nil)
|
if (scanner != nil)
|
||||||
{
|
{
|
||||||
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
[scanner setLocale: GSUserDefaultsDictionaryRepresentation()];
|
||||||
|
|
||||||
[scanner setLocale: [defs dictionaryRepresentation]];
|
|
||||||
}
|
}
|
||||||
return scanner;
|
return scanner;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSValue.h>
|
#include <Foundation/NSValue.h>
|
||||||
#include <Foundation/NSDictionary.h>
|
#include <Foundation/NSDictionary.h>
|
||||||
#include <Foundation/NSUserDefaults.h>
|
|
||||||
#include <Foundation/NSFileManager.h>
|
#include <Foundation/NSFileManager.h>
|
||||||
#include <Foundation/NSPortCoder.h>
|
#include <Foundation/NSPortCoder.h>
|
||||||
#include <Foundation/NSPathUtilities.h>
|
#include <Foundation/NSPathUtilities.h>
|
||||||
|
@ -74,6 +73,8 @@
|
||||||
|
|
||||||
#include <base/Unicode.h>
|
#include <base/Unicode.h>
|
||||||
|
|
||||||
|
#include "GSUserDefaults.h"
|
||||||
|
|
||||||
@class GSString;
|
@class GSString;
|
||||||
@class GSMutableString;
|
@class GSMutableString;
|
||||||
@class GSPlaceholderString;
|
@class GSPlaceholderString;
|
||||||
|
@ -3097,7 +3098,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dict = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
dict = GSUserDefaultsDictionaryRepresentation();
|
||||||
ret = AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
|
ret = AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
|
||||||
initWithFormat: format locale: dict arguments: ap]);
|
initWithFormat: format locale: dict arguments: ap]);
|
||||||
}
|
}
|
||||||
|
@ -3125,8 +3126,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
|
|
||||||
- (NSComparisonResult) localizedCompare: (NSString *)string
|
- (NSComparisonResult) localizedCompare: (NSString *)string
|
||||||
{
|
{
|
||||||
NSDictionary *dict =
|
NSDictionary *dict = GSUserDefaultsDictionaryRepresentation();
|
||||||
[[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
|
||||||
|
|
||||||
return [self compare: string
|
return [self compare: string
|
||||||
options: 0
|
options: 0
|
||||||
|
@ -3136,8 +3136,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
|
|
||||||
- (NSComparisonResult) localizedCaseInsensitiveCompare: (NSString *)string
|
- (NSComparisonResult) localizedCaseInsensitiveCompare: (NSString *)string
|
||||||
{
|
{
|
||||||
NSDictionary *dict =
|
NSDictionary *dict = GSUserDefaultsDictionaryRepresentation();
|
||||||
[[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
|
||||||
|
|
||||||
return [self compare: string
|
return [self compare: string
|
||||||
options: NSCaseInsensitiveSearch
|
options: NSCaseInsensitiveSearch
|
||||||
|
|
|
@ -47,9 +47,14 @@
|
||||||
#include <Foundation/NSLock.h>
|
#include <Foundation/NSLock.h>
|
||||||
#include <base/GSLocale.h>
|
#include <base/GSLocale.h>
|
||||||
|
|
||||||
|
#include "GSUserDefaults.h"
|
||||||
|
|
||||||
/* Wait for access */
|
/* Wait for access */
|
||||||
#define _MAX_COUNT 5 /* Max 10 sec. */
|
#define _MAX_COUNT 5 /* Max 10 sec. */
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
*** Class variables
|
||||||
|
*************************************************************************/
|
||||||
static SEL nextObjectSel;
|
static SEL nextObjectSel;
|
||||||
static SEL objectForKeySel;
|
static SEL objectForKeySel;
|
||||||
static SEL addSel;
|
static SEL addSel;
|
||||||
|
@ -65,8 +70,31 @@ static Class NSDictionaryClass;
|
||||||
static Class NSMutableDictionaryClass;
|
static Class NSMutableDictionaryClass;
|
||||||
static Class NSStringClass;
|
static Class NSStringClass;
|
||||||
|
|
||||||
|
static NSUserDefaults *sharedDefaults = nil;
|
||||||
|
static NSMutableString *processName = nil;
|
||||||
|
static NSMutableArray *userLanguages = nil;
|
||||||
static NSRecursiveLock *classLock = nil;
|
static NSRecursiveLock *classLock = nil;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Caching some defaults.
|
||||||
|
*/
|
||||||
|
static BOOL flags[GSUserDefaultMaxFlag] = { 0 };
|
||||||
|
|
||||||
|
static void updateCache(NSUserDefaults *self)
|
||||||
|
{
|
||||||
|
if (self == sharedDefaults)
|
||||||
|
{
|
||||||
|
flags[GSMacOSXCompatible]
|
||||||
|
= [self boolForKey: @"GSMacOSXCompatible"];
|
||||||
|
flags[GSOldStyleGeometry]
|
||||||
|
= [self boolForKey: @"GSOldStyleGeometry"];
|
||||||
|
flags[GSLogSyslog]
|
||||||
|
= [self boolForKey: @"GSLogSyslog"];
|
||||||
|
flags[NSWriteOldStylePropertyLists]
|
||||||
|
= [self boolForKey: @"NSWriteOldStylePropertyLists"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
*** Local method definitions
|
*** Local method definitions
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
@ -78,13 +106,6 @@ static NSRecursiveLock *classLock = nil;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSUserDefaults: NSObject
|
@implementation NSUserDefaults: NSObject
|
||||||
/*************************************************************************
|
|
||||||
*** Class variables
|
|
||||||
*************************************************************************/
|
|
||||||
static NSUserDefaults *sharedDefaults = nil;
|
|
||||||
static NSMutableString *processName = nil;
|
|
||||||
static NSMutableArray *userLanguages = nil;
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
*** Getting the Shared Instance
|
*** Getting the Shared Instance
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
@ -1072,6 +1093,7 @@ static NSString *pathForUser(NSString *user)
|
||||||
{
|
{
|
||||||
RELEASE(_persDomains);
|
RELEASE(_persDomains);
|
||||||
_persDomains = newDict;
|
_persDomains = newDict;
|
||||||
|
updateCache(self);
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
postNotificationName: NSUserDefaultsDidChangeNotification
|
postNotificationName: NSUserDefaultsDidChangeNotification
|
||||||
object: nil];
|
object: nil];
|
||||||
|
@ -1336,8 +1358,10 @@ static NSString *pathForUser(NSString *user)
|
||||||
if (!_changedDomains)
|
if (!_changedDomains)
|
||||||
{
|
{
|
||||||
_changedDomains = [[NSMutableArray alloc] initWithCapacity: 5];
|
_changedDomains = [[NSMutableArray alloc] initWithCapacity: 5];
|
||||||
|
updateCache(self);
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
postNotificationName: NSUserDefaultsDidChangeNotification object: nil];
|
postNotificationName: NSUserDefaultsDidChangeNotification
|
||||||
|
object: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
enumerator = [_changedDomains objectEnumerator];
|
enumerator = [_changedDomains objectEnumerator];
|
||||||
|
@ -1363,3 +1387,32 @@ static NSString *pathForUser(NSString *user)
|
||||||
[self synchronize];
|
[self synchronize];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NSDictionary*
|
||||||
|
GSUserDefaultsDictionaryRepresentation()
|
||||||
|
{
|
||||||
|
NSDictionary *defs;
|
||||||
|
|
||||||
|
[classLock lock];
|
||||||
|
if (sharedDefaults == nil)
|
||||||
|
{
|
||||||
|
[NSUserDefaults standardUserDefaults];
|
||||||
|
}
|
||||||
|
defs = [sharedDefaults dictionaryRepresentation];
|
||||||
|
[classLock unlock];
|
||||||
|
return defs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get one of several potentially useful flags.
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
GSUserDefaultsFlag(GSUserDefaultFlagType type)
|
||||||
|
{
|
||||||
|
if (sharedDefaults == nil)
|
||||||
|
{
|
||||||
|
[NSUserDefaults standardUserDefaults];
|
||||||
|
}
|
||||||
|
return flags[type];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue