mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +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
784b1aef82
commit
bdb33706fe
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>
|
||||
|
||||
* Source/GSMime.m: modifications made to support HTTP continuation
|
||||
|
|
|
@ -61,15 +61,32 @@
|
|||
|
||||
</dl>
|
||||
<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>
|
||||
<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>
|
||||
<p>
|
||||
|
||||
|
@ -82,7 +99,7 @@
|
|||
</p>
|
||||
|
||||
|
||||
<dt>GSMacOSXCompatiblePropertyLists
|
||||
<dt>NSWriteOldStylePropertyLists
|
||||
<dd>
|
||||
<p>
|
||||
|
||||
|
@ -110,29 +127,6 @@
|
|||
</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>
|
||||
<h4><a name ="cont-4">Environment variables</a></h4>
|
||||
<p>
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <config.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#include "GSUserDefaults.h"
|
||||
|
||||
#ifndef HAVE_RINT
|
||||
#include <math.h>
|
||||
static double rint(double a)
|
||||
|
@ -35,98 +37,19 @@ static double rint(double a)
|
|||
/*
|
||||
* 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()
|
||||
{
|
||||
if (setupDone == NO)
|
||||
compatibilitySetup();
|
||||
return MacOSXCompatibleGeometry;
|
||||
if (GSUserDefaultsFlag(GSOldStyleGeometry) == YES)
|
||||
return NO;
|
||||
return GSUserDefaultsFlag(GSMacOSXCompatible);
|
||||
}
|
||||
|
||||
BOOL GSMacOSXCompatiblePropertyLists()
|
||||
{
|
||||
if (setupDone == NO)
|
||||
compatibilitySetup();
|
||||
return MacOSXCompatiblePropertyLists;
|
||||
if (GSUserDefaultsFlag(NSWriteOldStylePropertyLists) == YES)
|
||||
return NO;
|
||||
return GSUserDefaultsFlag(GSMacOSXCompatible);
|
||||
}
|
||||
|
||||
#include <math.h>
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSScanner.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSURL.h>
|
||||
|
@ -37,6 +36,7 @@
|
|||
#include <Foundation/GSMime.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "GSUserDefaults.h"
|
||||
|
||||
static NSCharacterSet *specials = nil;
|
||||
|
||||
|
@ -1992,7 +1992,7 @@ parseCharacterSet(NSString *token)
|
|||
NSDictionary *locale;
|
||||
|
||||
desc = [NSMutableString stringWithFormat: @"GSMimeDocument <%0x> -\n", self];
|
||||
locale = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
locale = GSUserDefaultsDictionaryRepresentation();
|
||||
[desc appendString: [headers descriptionWithLocale: locale]];
|
||||
[desc appendFormat: @"\nDocument content -\n%@", content];
|
||||
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/NSException.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSThread.h>
|
||||
#include <Foundation/NSMapTable.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include "GSUserDefaults.h"
|
||||
|
||||
@class NSArrayEnumerator;
|
||||
@class NSArrayEnumeratorReverse;
|
||||
|
@ -834,7 +834,7 @@ static NSString *indentStrings[] = {
|
|||
NSDictionary *loc;
|
||||
NSString *desc;
|
||||
|
||||
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
loc = GSUserDefaultsDictionaryRepresentation();
|
||||
|
||||
if (GSMacOSXCompatiblePropertyLists() == YES)
|
||||
{
|
||||
|
@ -863,7 +863,7 @@ static NSString *indentStrings[] = {
|
|||
NSDictionary *loc;
|
||||
NSString *desc;
|
||||
|
||||
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
loc = GSUserDefaultsDictionaryRepresentation();
|
||||
|
||||
if (GSMacOSXCompatiblePropertyLists() == YES)
|
||||
{
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSCoder.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <base/behavior.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "GSUserDefaults.h"
|
||||
|
||||
// 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)
|
||||
{
|
||||
locale
|
||||
= [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
locale = GSUserDefaultsDictionaryRepresentation();
|
||||
}
|
||||
if (fmt == nil)
|
||||
{
|
||||
|
@ -1222,7 +1221,7 @@ static inline int getDigits(const char *from, char *to, int limit)
|
|||
int i, j, k, z;
|
||||
|
||||
if (locale == nil)
|
||||
locale = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
locale = GSUserDefaultsDictionaryRepresentation();
|
||||
if (format == nil)
|
||||
format = [locale objectForKey: NSTimeDateFormatString];
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSCoder.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSCharacterSet.h>
|
||||
#include <Foundation/NSScanner.h>
|
||||
#include <Foundation/NSObjCRuntime.h>
|
||||
|
@ -45,6 +44,7 @@
|
|||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "GSUserDefaults.h"
|
||||
|
||||
/* The number of seconds between 1/1/2001 and 1/1/1970 = -978307200. */
|
||||
/* This number comes from:
|
||||
|
@ -239,7 +239,7 @@ GSTimeNow()
|
|||
unsigned dtoIndex;
|
||||
|
||||
if (locale == nil)
|
||||
locale = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
locale = GSUserDefaultsDictionaryRepresentation();
|
||||
|
||||
ws = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
||||
digits = [NSCharacterSet decimalDigitCharacterSet];
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSDecimal.h>
|
||||
#include <Foundation/NSDecimalNumber.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include "GSUserDefaults.h"
|
||||
|
||||
static NSDecimalNumberHandler *handler;
|
||||
|
||||
|
@ -224,9 +224,9 @@ static NSDecimalNumber *one;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithMantissa:(unsigned long long)mantissa
|
||||
exponent:(short)exponent
|
||||
isNegative:(BOOL)flag
|
||||
- (id) initWithMantissa: (unsigned long long)mantissa
|
||||
exponent: (short)exponent
|
||||
isNegative: (BOOL)flag
|
||||
{
|
||||
NSDecimal decimal;
|
||||
|
||||
|
@ -234,16 +234,14 @@ static NSDecimalNumber *one;
|
|||
return [self initWithDecimal: decimal];
|
||||
}
|
||||
|
||||
- (id)initWithString:(NSString *)numberValue
|
||||
- (id) initWithString: (NSString*)numberValue
|
||||
{
|
||||
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
return [self initWithString: numberValue
|
||||
locale: [defs dictionaryRepresentation]];
|
||||
locale: GSUserDefaultsDictionaryRepresentation()];
|
||||
}
|
||||
|
||||
- (id)initWithString:(NSString *)numberValue
|
||||
locale:(NSDictionary *)locale;
|
||||
- (id) initWithString: (NSString*)numberValue
|
||||
locale: (NSDictionary*)locale;
|
||||
{
|
||||
NSDecimal decimal;
|
||||
|
||||
|
@ -251,7 +249,7 @@ static NSDecimalNumber *one;
|
|||
return [self initWithDecimal: decimal];
|
||||
}
|
||||
|
||||
- (NSString *)descriptionWithLocale:(NSDictionary *)locale
|
||||
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
|
||||
{
|
||||
return NSDecimalString(&data, locale);
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSFileManager.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSCoder.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSObjCRuntime.h>
|
||||
#include "GSUserDefaults.h"
|
||||
|
||||
@implementation NSDictionary
|
||||
|
||||
|
@ -626,7 +626,7 @@ compareIt(id o1, id o2, void* context)
|
|||
NSDictionary *loc;
|
||||
NSString *desc;
|
||||
|
||||
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
loc = GSUserDefaultsDictionaryRepresentation();
|
||||
|
||||
if (GSMacOSXCompatiblePropertyLists() == YES)
|
||||
{
|
||||
|
@ -655,7 +655,7 @@ compareIt(id o1, id o2, void* context)
|
|||
NSDictionary *loc;
|
||||
NSString *desc;
|
||||
|
||||
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
loc = GSUserDefaultsDictionaryRepresentation();
|
||||
|
||||
if (GSMacOSXCompatiblePropertyLists() == YES)
|
||||
{
|
||||
|
|
|
@ -359,6 +359,11 @@ NSString* NSFileHandleOperationException =
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL) useCompression
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) writeInBackgroundAndNotify: (NSData*)item forModes: (NSArray*)modes
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include <Foundation/NSGeometry.h>
|
||||
#include <Foundation/NSScanner.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
|
||||
extern BOOL GSMacOSXCompatibleGeometry(); // Compatibility mode
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "GSUserDefaults.h"
|
||||
|
||||
static void
|
||||
_NSLog_standard_printf_handler (NSString* message)
|
||||
{
|
||||
|
@ -67,7 +69,7 @@ _NSLog_standard_printf_handler (NSString* message)
|
|||
|
||||
#ifdef HAVE_SYSLOG
|
||||
|
||||
if (write(2, buf, len) != len)
|
||||
if (GSUserDefaultsFlag(GSLogSyslog) == YES || write(2, buf, len) != len)
|
||||
{
|
||||
int mask;
|
||||
|
||||
|
|
|
@ -25,12 +25,12 @@
|
|||
#include <base/Unicode.h>
|
||||
#include <Foundation/NSScanner.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSObjCRuntime.h>
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <ctype.h> /* FIXME: May go away once I figure out Unicode */
|
||||
#include "GSUserDefaults.h"
|
||||
|
||||
/* BSD and Solaris have this */
|
||||
#if defined(HANDLE_LLONG_MAX) && !defined(HANDLE_LONG_LONG_MAX)
|
||||
|
@ -110,9 +110,7 @@ typedef struct {
|
|||
|
||||
if (scanner != nil)
|
||||
{
|
||||
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
[scanner setLocale: [defs dictionaryRepresentation]];
|
||||
[scanner setLocale: GSUserDefaultsDictionaryRepresentation()];
|
||||
}
|
||||
return scanner;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSFileManager.h>
|
||||
#include <Foundation/NSPortCoder.h>
|
||||
#include <Foundation/NSPathUtilities.h>
|
||||
|
@ -74,6 +73,8 @@
|
|||
|
||||
#include <base/Unicode.h>
|
||||
|
||||
#include "GSUserDefaults.h"
|
||||
|
||||
@class GSString;
|
||||
@class GSMutableString;
|
||||
@class GSPlaceholderString;
|
||||
|
@ -3097,7 +3098,7 @@ handle_printf_atsign (FILE *stream,
|
|||
}
|
||||
else
|
||||
{
|
||||
dict = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
dict = GSUserDefaultsDictionaryRepresentation();
|
||||
ret = AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithFormat: format locale: dict arguments: ap]);
|
||||
}
|
||||
|
@ -3125,8 +3126,7 @@ handle_printf_atsign (FILE *stream,
|
|||
|
||||
- (NSComparisonResult) localizedCompare: (NSString *)string
|
||||
{
|
||||
NSDictionary *dict =
|
||||
[[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
NSDictionary *dict = GSUserDefaultsDictionaryRepresentation();
|
||||
|
||||
return [self compare: string
|
||||
options: 0
|
||||
|
@ -3136,8 +3136,7 @@ handle_printf_atsign (FILE *stream,
|
|||
|
||||
- (NSComparisonResult) localizedCaseInsensitiveCompare: (NSString *)string
|
||||
{
|
||||
NSDictionary *dict =
|
||||
[[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
|
||||
NSDictionary *dict = GSUserDefaultsDictionaryRepresentation();
|
||||
|
||||
return [self compare: string
|
||||
options: NSCaseInsensitiveSearch
|
||||
|
|
|
@ -47,9 +47,14 @@
|
|||
#include <Foundation/NSLock.h>
|
||||
#include <base/GSLocale.h>
|
||||
|
||||
#include "GSUserDefaults.h"
|
||||
|
||||
/* Wait for access */
|
||||
#define _MAX_COUNT 5 /* Max 10 sec. */
|
||||
|
||||
/*************************************************************************
|
||||
*** Class variables
|
||||
*************************************************************************/
|
||||
static SEL nextObjectSel;
|
||||
static SEL objectForKeySel;
|
||||
static SEL addSel;
|
||||
|
@ -65,8 +70,31 @@ static Class NSDictionaryClass;
|
|||
static Class NSMutableDictionaryClass;
|
||||
static Class NSStringClass;
|
||||
|
||||
static NSUserDefaults *sharedDefaults = nil;
|
||||
static NSMutableString *processName = nil;
|
||||
static NSMutableArray *userLanguages = 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
|
||||
*************************************************************************/
|
||||
|
@ -78,13 +106,6 @@ static NSRecursiveLock *classLock = nil;
|
|||
@end
|
||||
|
||||
@implementation NSUserDefaults: NSObject
|
||||
/*************************************************************************
|
||||
*** Class variables
|
||||
*************************************************************************/
|
||||
static NSUserDefaults *sharedDefaults = nil;
|
||||
static NSMutableString *processName = nil;
|
||||
static NSMutableArray *userLanguages = nil;
|
||||
|
||||
/*************************************************************************
|
||||
*** Getting the Shared Instance
|
||||
*************************************************************************/
|
||||
|
@ -1072,6 +1093,7 @@ static NSString *pathForUser(NSString *user)
|
|||
{
|
||||
RELEASE(_persDomains);
|
||||
_persDomains = newDict;
|
||||
updateCache(self);
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSUserDefaultsDidChangeNotification
|
||||
object: nil];
|
||||
|
@ -1336,8 +1358,10 @@ static NSString *pathForUser(NSString *user)
|
|||
if (!_changedDomains)
|
||||
{
|
||||
_changedDomains = [[NSMutableArray alloc] initWithCapacity: 5];
|
||||
updateCache(self);
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSUserDefaultsDidChangeNotification object: nil];
|
||||
postNotificationName: NSUserDefaultsDidChangeNotification
|
||||
object: nil];
|
||||
}
|
||||
|
||||
enumerator = [_changedDomains objectEnumerator];
|
||||
|
@ -1363,3 +1387,32 @@ static NSString *pathForUser(NSString *user)
|
|||
[self synchronize];
|
||||
}
|
||||
@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