mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Adding using correct revision number.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/testplant_1@28486 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
commit
b0ebefc2db
92 changed files with 1916 additions and 4699 deletions
15
ANNOUNCE
15
ANNOUNCE
|
@ -1,7 +1,7 @@
|
|||
1 Announcement
|
||||
**************
|
||||
|
||||
The GNUstep Base Library, version 1.19.1, is now available.
|
||||
The GNUstep Base Library, version 1.18.0, is now available.
|
||||
|
||||
1.1 What is the GNUstep Base Library?
|
||||
=====================================
|
||||
|
@ -18,22 +18,19 @@ portion of the OpenStep standard (the Foundation library).
|
|||
There is more information available at the GNUstep homepage at
|
||||
`http://www.gnustep.org'.
|
||||
|
||||
1.2 Noteworthy changes in version `1.19.1'
|
||||
1.2 Noteworthy changes in version `1.18.0'
|
||||
==========================================
|
||||
|
||||
* New Mac OS X methods for writing data in NSData
|
||||
* Many new OSX 10.5 methods and stubs and general 10.5 compatibility
|
||||
|
||||
* New classes NSHashTable and NSMapTable
|
||||
* Changes to build on 64bit Windows
|
||||
|
||||
* Garbage collection now works again and is much improved.
|
||||
|
||||
* Method return types and arguments have been changed for Mac OS X
|
||||
10.5
|
||||
* Support for @synchronize
|
||||
|
||||
1.3 Where can you get it? How can you compile it?
|
||||
==================================================
|
||||
|
||||
The gnustep-base-1.19.1.tar.gz distribution file has been placed at
|
||||
The gnustep-base-1.18.0.tar.gz distribution file has been placed at
|
||||
`ftp://ftp.gnustep.org/pub/gnustep/core'.
|
||||
|
||||
Please log bug reports on the GNUstep project page
|
||||
|
|
400
ChangeLog
400
ChangeLog
|
@ -1,401 +1,3 @@
|
|||
2009-08-19 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/Additions/GSObjCRuntime.m:
|
||||
Behave consistently with MacOS-X when a getter or setter method
|
||||
returns a type of data which is not supported by KVC.
|
||||
|
||||
2009-08-15 David Chisnall <theraven@gna.org>
|
||||
|
||||
* Source/NSObject:
|
||||
- Tweaked NSObject to use atomic ops with LLVM as well as gcc (this
|
||||
probably isn't actually needed)
|
||||
- Fixed SIGFPE problem on FreeBSD using proper interfaces instead of
|
||||
an asm hack.
|
||||
* Removes various mframe things from being compiled when ffcall/libffi
|
||||
is used (mframe.m, NSConnection.m, NSInvocation.m)
|
||||
* Turned a nested function in make_strings.m into a macro.
|
||||
|
||||
2009-08-12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSData.m: Remove some redundant methods and add checks for
|
||||
attempts to use a null pointer to set bytes in the data.
|
||||
* Source/NSCharacterSet.m: Save mem with index set rather than
|
||||
bitmap set
|
||||
|
||||
2009-08-11 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSAttributedString.m: Fix keyeded encodgin decoding for
|
||||
both NSAttributedString and NSMutableAttributedString.
|
||||
|
||||
2009-08-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSData.m: Fix memory leak introduced with GC changes.
|
||||
* Source/Additions/GSMime.m: Use memmove() as fix for bug #27224
|
||||
|
||||
2009-08-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSData.m: Fix memory leak introduced with GC changes.
|
||||
|
||||
2009-08-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSFileManager.m:
|
||||
* Headers/Foundation/NSFileManager.h:
|
||||
Updated comments/documentation to say that directory enumeration order
|
||||
is undefined.
|
||||
|
||||
2009-08-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Tools/AGSHtml.m: Escape non-ascii characters etc in author.
|
||||
|
||||
2009-08-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSPropertyList.m: Fix for handling empty key values in
|
||||
XML property lists.
|
||||
|
||||
2009-08-03 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSObject.m: Fix error in memory allocation debug when
|
||||
swizzling a class.
|
||||
|
||||
2009-07-30 Quentin Mathe <qmathe@club-internet.fr>
|
||||
|
||||
* Headers/Foundation/Foundation.h: Included NSKeyValueObserving.h.
|
||||
|
||||
2009-07-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSConnection.m: Correct the text in exception when attempting
|
||||
to read a response on an invalidated connection.
|
||||
* Source/Additions/GSMime.m:
|
||||
Fixup incorrect declaration of method in wrong class implementation.
|
||||
|
||||
2009-07-27 David Ayers <ayers@fsfe.org>
|
||||
|
||||
* Source/Additions/GSCompatibility.m ([-boolValue]): Only compile
|
||||
for OS X Versions below 10.5 and sync implementation with -base.
|
||||
Reported by: Georg Fleischmann
|
||||
|
||||
2009-07-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* GSHTTPURLHandle.m:
|
||||
* NSURLProtocol.m:
|
||||
Include the port in the 'Host' header if it's specified in the URL.
|
||||
|
||||
2009-07-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSInternal.h: New macros for CLANG/non-fragile ivar compat.
|
||||
* Source/NSOperation.m: Use new macros.
|
||||
|
||||
2009-07-17 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSOperation.m: Fix includes and text of comments at start
|
||||
of document.
|
||||
|
||||
2009-07-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSOperation.h:
|
||||
* Source/NSOperation.m:
|
||||
Various changes for maintainability and coding standards ... nothing
|
||||
which should effect functionality.
|
||||
|
||||
2009-07-14 20:02-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Headers/Foundation/NSOperation.h
|
||||
* Source/NSOperation.m: Added initial implementation of
|
||||
NSOperationQueue.
|
||||
|
||||
2009-07-13 14:15-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Headers/Foundation/Foundation.h
|
||||
* Headers/Foundation/NSOperation.h
|
||||
* Source/GNUmakefile
|
||||
* Source/NSOperation.m: Initial implementation of NSOperation
|
||||
class.
|
||||
|
||||
2009-07-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSConcreteMapTable.m: Add some comments.
|
||||
* Source/NSConcreteHashTable.m: Dito
|
||||
* Headers/Additions/GNUstepBase/GSIMap.h: Make explicit that fields in
|
||||
enumerator are all big enough to hold pointers.
|
||||
|
||||
2009-07-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSProcessInfo.m: Add daignostic check.
|
||||
* Source/NSSocketPort.m: Make sure socklen_t is defined.
|
||||
Shoudl fix bug #26856
|
||||
|
||||
2009-06-30 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* configure.ac:
|
||||
* configure:
|
||||
* config/config.poll-dev.c: Add test to configure to avoid using
|
||||
the broken poll implementation on Mac OS X 10.4 and later, which
|
||||
does not support devices.
|
||||
|
||||
2009-06-24 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSXMLParser.m: ([-parse]) don't split whitespace strings
|
||||
at newline.
|
||||
|
||||
2009-06-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/win32/GSRunLoopCtxt.m: Fix error sending received event
|
||||
handle to watcher. Had broken TCP/IP ports.
|
||||
|
||||
2009-06-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/Unicode.m: Fix incorrect attempt to free memory
|
||||
we shouldn't. Should fix bug #26843
|
||||
|
||||
2009-06-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/win32/NSMessagePort.m: Don't use NSLog() to report error
|
||||
when writing to mailslot ... it's usually just that the remote
|
||||
end has terminated, so invalidating the port silently is better.
|
||||
* Source/GSFileHandle.m: Adjust code to deal with fstat() returning
|
||||
a failure on windows if the descriptor is a pipe/socket.
|
||||
|
||||
2009-06-13 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSKeyedArchiver.h:
|
||||
* Headers/Foundation/NSArchiver.h:
|
||||
Fix error cleaning up a define.
|
||||
|
||||
2009-06-12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSDistributedNotificationCenter.m: add explicit size casts
|
||||
to avoid compiler warnings.
|
||||
* Source/NSUserDefaults.m: Save defaults in xml format and add some
|
||||
error checking.
|
||||
* Source/NSPropertyList.m: tolerate NSNumber values used as dictionary
|
||||
keys, by using their string representation.
|
||||
|
||||
2009-06-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* SSL/Source/GSSSLHandle.m: Disable v2 by default due to
|
||||
security issues. GSPermitSSLv2 user default can enable it again.
|
||||
|
||||
2009-06-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/Unicode.m: Optimise somewhat for converting
|
||||
from unicode (UTF-2) to UTF-8
|
||||
* Source/GSString.m: Optimise 8 bit string equality tests a little.
|
||||
|
||||
2009-06-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/Unicode.m: Optimise case where we are converting
|
||||
from unicode to latin1 or ascii.
|
||||
* Source/GSString.m: Optimise -hash method of NXConstantString too.
|
||||
|
||||
2009-06-06 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/GSFFIInvocation.m
|
||||
(-initWithCallback:returnp:values:frame:signature:): Fix bug
|
||||
#26419 by removing bogus code which was used on targets where
|
||||
MFRAME_STRUCT_BYREF is defined.
|
||||
|
||||
2009-06-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/Unicode.m: When converting from a characterset
|
||||
to unicode, and we know that there is a one to one correspondence
|
||||
between the characterset values and unicode values, shift the
|
||||
buffer sizing outsize the loop through the characters to avoid
|
||||
unnecessary checks for the end of the buffer in each iteration.
|
||||
Optimisation suggested by Fred Kiefer
|
||||
|
||||
2009-06-05 18:12-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/NSDistantObject.m: NSProxy subclasses must override -init
|
||||
or an exception will be thrown. This change calls the forwarding
|
||||
mechanism to invoke -init on the remote object.
|
||||
Patch by David Chisnall <theraven@sucs.org>
|
||||
|
||||
2009-06-04 Georg Fleischmann <G.Fleischmann@vhf.de>
|
||||
|
||||
* Source/Additions/unicode/nextstep.h: Fixups for encoding mapping.
|
||||
|
||||
2009-06-02 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSUndoManager.m (-undo, -redo): Call -_begin instead of
|
||||
-beginUndoGrouping to avoid creation of a spurious top-level group
|
||||
while performing undo or redo operations, which was causing the
|
||||
recorded actions to be dropped silently.
|
||||
|
||||
* Source/NSUndoManager.m (-beginUndoGrouping): Post
|
||||
NSUndoManagerCheckpointNotification also during undo as on OS X.
|
||||
|
||||
* Source/NSUndoManager.m (-endUndoGrouping): Post
|
||||
NSUndoManagerWillCloseUndoGroupNotification before changing the
|
||||
group so that clients see the same grouping level as on OS X.
|
||||
|
||||
2009-05-29 Riccardo Mottola <rmottola@users.sf.net>
|
||||
|
||||
* Source/NSObject.m: Atomic increment and decrement functions for m68k
|
||||
|
||||
2009-05-29 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||
|
||||
* GNUmakefile: Use $(warning ...) instead of $(info ...) since
|
||||
$(info ...) exists only in GNU make >= 3.81.
|
||||
* NSCharacterSets/GNUmakefile: Same change.
|
||||
* Source/GNUmakefile: Same change.
|
||||
* SSL/GNUmakefile: Same change.
|
||||
* Documentation/GNUmakefile: Same change.
|
||||
* Resources/GNUmakefile: Same change.
|
||||
* NSTimeZones/GNUmakefile: Same change.
|
||||
* Examples/GNUmakefile: Same change.
|
||||
* Tools/GNUmakefile: Same change.
|
||||
|
||||
2009-05-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSRunLoop.m: Updates to match latest MacOS-X behavior.
|
||||
The +new and -init methods now return nil.
|
||||
Timers are now treated like input sources for purposes of deciding
|
||||
whether the loop will block and whether performerds will execute.
|
||||
* Source/NSTimer.m: Updates to match latest MacOS-X behavior.
|
||||
The +new and -init methods now return nil.
|
||||
|
||||
2009-05-24 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSThread.m: Use lock to prevent race condition setting up
|
||||
runloop info for thread.
|
||||
|
||||
2009-05-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSKeyValueObserving.m:
|
||||
Permit setters which return values.
|
||||
|
||||
2009-05-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSFileManager.m:
|
||||
* Source/NSBundle.m:
|
||||
Try to get the path right for loading dynamic library code on windows
|
||||
when NSExecutable doesn't have the .dll path extension.
|
||||
|
||||
2009-05-16 Doug Simons <doug@riverrock.org>
|
||||
|
||||
* Source/NSCalendarDate.m:
|
||||
Implement field widths for numeric fields in a date format for
|
||||
MacOS-X compatibility.
|
||||
|
||||
2009-05-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSURL.m: Add support for file URLs on mswindows. The path
|
||||
may be of the form C:\... rather than /... (and the colon might be
|
||||
a vertical bar).
|
||||
Also makefile fixes for bug #26446
|
||||
|
||||
2009-05-11 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/NSXMLParser.m: Fix include location
|
||||
|
||||
2009-05-10 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Version 1.19.1
|
||||
|
||||
2009-05-06 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Documentation/news.texi, Documentation/releasenotes.texi: Update.
|
||||
|
||||
2009-05-04 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSObject.m: Correct asm for PPC.
|
||||
Patch by Eric Wasylishen <ewasylishen@gmail.com>
|
||||
* Source/NSObject.m: Add support for new gcc atomic build
|
||||
ins. Currently still disabled.
|
||||
Patch by David Chisnall <theraven@sucs.org>
|
||||
|
||||
2009-05-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* NSCharacterSets/GNUmakefile:
|
||||
* Source/GNUmakefile:
|
||||
* SSL/GNUmakefile:
|
||||
* Documentation/GNUmakefile:
|
||||
* Resources/GNUmakefile:
|
||||
* Examples/GNUmakefile:
|
||||
* NSTimeZones/GNUmakefile:
|
||||
* GNUmakefile:
|
||||
* Tools/GNUmakefile:
|
||||
Add help info for the case when gnustep-config can't tell us the
|
||||
location of the makefiles.
|
||||
|
||||
2009-05-03 Riccardo Mottola <rmottola@users.sf.net>
|
||||
|
||||
* Source/NSURLProtocol.m: Removed c99-ism
|
||||
|
||||
2009-05-03 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GNUmakefile.postamble: remove generated files from pathconfig
|
||||
subdirectory on distclean.
|
||||
|
||||
2009-04-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSCalendarDate.m: Fix bug #26360 plus optimise a little.
|
||||
* Source/NSURL.m: Send over DO bycopy as default.
|
||||
|
||||
2009-04-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSData.h:
|
||||
* Source/NSData.m:
|
||||
Implement new MacOS-X methods for writing data (no support for
|
||||
returning NSError objects yet).
|
||||
|
||||
2009-04-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSFTPURLHandle.m: Implement full support for multiline
|
||||
responses. Fix for bug #26348
|
||||
|
||||
2009-04-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSTimeZone.h:
|
||||
* Headers/Foundation/NSPropertyList.h:
|
||||
* Headers/Foundation/NSZone.h:
|
||||
* Source/NSHashTable.m:
|
||||
* Source/NSZone.m:
|
||||
* Source/NSDecimal.m:
|
||||
Fix errors generating documentation.
|
||||
|
||||
2009-04-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSFileManager.m: ([changeFileAttributes:atPath:]) optimise
|
||||
to avoid unnecessary creation of NSNumber objects as suggested by
|
||||
Greg.
|
||||
|
||||
2009-04-25 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSFileManager.m: Reinstate incorrectly reverted changes.
|
||||
Fix actual bug in Fred's patched version ... some code incorrectly
|
||||
returning an integer when it should return an NSNumber.
|
||||
|
||||
2009-04-25 08:35-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/NSFileManager.m: Partial reversion of previous patch.
|
||||
The calls in the method changeAttribues:atPath: to the GSAttrDictionary
|
||||
which is used there were erroneously changed to assume an NSNumber.
|
||||
This was causing a crash in various applications.
|
||||
|
||||
2009-04-24 Fred Morcos <fred.morcos"gmail.com>
|
||||
|
||||
* Headers/Foundation/NSFileManager.h:
|
||||
* Source/NSFileManager.m:
|
||||
Fix -fileOwnerAccountID and -fileGroupOwnerAccountID to return the
|
||||
correct type. Also fix return type of HFS methods (though these are
|
||||
Apple filesystem specific and do nothing in GNUstep).
|
||||
|
||||
2009-04-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSHashTable.m:
|
||||
* Source/NSConcreteHashTable.m:
|
||||
* Source/NSMapTable.m:
|
||||
* Source/NSConcreteMapTable.m:
|
||||
* Headers/Additions/GNUstepBase/GSIMap.h:
|
||||
Changes for GC zeroing weak pointers. Implement enumeration stuff for
|
||||
new classes. Add code to support subclassing.
|
||||
|
||||
2009-04-18 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSArray.m: Implement the
|
||||
([countByEnumeratingWithState:objects:count:]) method.
|
||||
|
||||
2009-04-18 10:15-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/GSURLPrivate.h: Addition of private method to NSURLProtocol
|
||||
|
@ -1526,7 +1128,7 @@
|
|||
|
||||
2008-12-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Version 1.19.0
|
||||
* Version:
|
||||
* Documentation/news.texi:
|
||||
* Documentation/ReleaseNotes.gsdoc:
|
||||
Update for new release.
|
||||
|
|
|
@ -23,15 +23,6 @@
|
|||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(warning )
|
||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
||||
$(warning Perhaps gnustep-make is not properly installed,)
|
||||
$(warning so gnustep-config is not in your PATH.)
|
||||
$(warning )
|
||||
$(warning Your PATH is currently $(PATH))
|
||||
$(warning )
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
|
@ -43,9 +34,9 @@ GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../base.make
|
|||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
-include ../Version
|
||||
-include ../config.mak
|
||||
-include ../Source/pathconfig/pathconfig.mak
|
||||
include ../Version
|
||||
include ../config.mak
|
||||
include ../Source/pathconfig/pathconfig.mak
|
||||
|
||||
# The documents to be generated
|
||||
DOCUMENT_NAME = coding-standards
|
||||
|
@ -57,7 +48,7 @@ SUBPROJECTS = manual General
|
|||
|
||||
# The text documents to be generated
|
||||
DOCUMENT_TEXT_NAME = \
|
||||
INSTALL NEWS README ANNOUNCE
|
||||
INSTALL NEWS CODING-STANDARDS README ANNOUNCE
|
||||
|
||||
TOP_DOC_FILES = INSTALL NEWS README ANNOUNCE
|
||||
|
||||
|
|
|
@ -28,47 +28,6 @@ notice and this notice are preserved.
|
|||
changes and other information that might help developers and users
|
||||
migrate to using a newer version of the library.
|
||||
</p>
|
||||
<section>
|
||||
<heading>Version 1.19.1</heading>
|
||||
<p>A great deal of improvements have occured recently. This includes
|
||||
many improvements in garbage collection (first to get it working again).
|
||||
Also many Mac OS X 10.5 methods and classes have been added, as well
|
||||
as compatibility improvements.
|
||||
</p>
|
||||
Highlights:
|
||||
<deflist>
|
||||
<term>NSData</term>
|
||||
<desc>
|
||||
Implemented new Mac OS X methods for writing data.
|
||||
</desc>
|
||||
<term>NSFileManager</term>
|
||||
<desc>
|
||||
Fix -fileOwnerAccountID and -fileGroupOwnerAccountID to
|
||||
return the correct type.
|
||||
</desc>
|
||||
<term>NSHashTable, NSMapTable</term>
|
||||
<desc>
|
||||
New Mac OS X 10.5 API classes.
|
||||
</desc>
|
||||
<term>Garbage Collection</term>
|
||||
<desc>
|
||||
Get GC working again. Fixes in various classes to work better with GC.
|
||||
</desc>
|
||||
<term>Mac OS X 10.5 Return Types</term>
|
||||
<desc>
|
||||
Methods have been converted to use return types and
|
||||
arguments of NSInteger, NSUInteger and CGFloat. For now,
|
||||
these types are equivalent to the old types. This can be
|
||||
changed in NSObjCRuntime.h so that integer tpyes are the
|
||||
same size as a pointer, and the float type is actually a
|
||||
double on 64bit processors.
|
||||
</desc>
|
||||
<term>NSArray</term>
|
||||
<desc>
|
||||
New methods for inserting objects with NSIndexSet
|
||||
</desc>
|
||||
</deflist>
|
||||
</section>
|
||||
<section>
|
||||
<heading>Version 1.19.0</heading>
|
||||
<p>
|
||||
|
|
|
@ -11,17 +11,6 @@ The currently released version of the library is
|
|||
See the @url{ReleaseNotes.html} document for more information.
|
||||
@end ifclear
|
||||
|
||||
@section Noteworthy changes in version @samp{1.19.1}
|
||||
|
||||
@itemize @bullet
|
||||
@item New Mac OS X methods for writing data in NSData
|
||||
@item New classes NSHashTable and NSMapTable
|
||||
@item Garbage collection now works again and is much improved.
|
||||
@item Method return types and arguments have been changed for Mac OS X 10.5
|
||||
@end itemize
|
||||
|
||||
@ifclear ANNOUNCE-ONLY
|
||||
|
||||
@section Noteworthy changes in version @samp{1.19.0}
|
||||
|
||||
@itemize @bullet
|
||||
|
@ -32,6 +21,8 @@ See the @url{ReleaseNotes.html} document for more information.
|
|||
@item Support for @@synchronize
|
||||
@end itemize
|
||||
|
||||
@ifclear ANNOUNCE-ONLY
|
||||
|
||||
@section Noteworthy changes in version @samp{1.15.3}
|
||||
|
||||
@itemize @bullet
|
||||
|
|
|
@ -25,15 +25,6 @@
|
|||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(warning )
|
||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
||||
$(warning Perhaps gnustep-make is not properly installed,)
|
||||
$(warning so gnustep-config is not in your PATH.)
|
||||
$(warning )
|
||||
$(warning Your PATH is currently $(PATH))
|
||||
$(warning )
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
|
@ -47,17 +38,10 @@ include $(GNUSTEP_MAKEFILES)/common.make
|
|||
|
||||
# The tools to be created
|
||||
TEST_TOOL_NAME = \
|
||||
dictionary \
|
||||
nsconnection \
|
||||
nsconnection_client \
|
||||
nsconnection_server \
|
||||
|
||||
dictionary
|
||||
|
||||
# The Objective-C source files to be compiled to create each tool
|
||||
dictionary_OBJC_FILES = dictionary.m
|
||||
nsconnection_OBJC_FILES = nsconnection.m
|
||||
nsconnection_client_OBJC_FILES = nsconnection_client.m
|
||||
nsconnection_server_OBJC_FILES = nsconnection_server.m
|
||||
|
||||
include Makefile.preamble
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
This file is part of the GNUstep Base Library.
|
||||
*/
|
||||
|
||||
#define STRICT_OPENSTEP 1
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
id myServer;
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include <stdio.h>
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSConnection.h>
|
||||
#include <Foundation/NSPort.h>
|
||||
#include <Foundation/NSPortNameServer.h>
|
||||
#include <Foundation/NSDistantObject.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
@ -93,6 +91,8 @@ int con_data (id prx)
|
|||
id obj;
|
||||
small_struct small = {12};
|
||||
foo ffoo = {'Z', 1234.5678, 99, "cow", 9876543};
|
||||
int a3[3] = {66,77,88};
|
||||
struct myarray ma = {{55,66,77}};
|
||||
|
||||
printf("Testing data sending\n");
|
||||
|
||||
|
@ -502,7 +502,6 @@ int main (int argc, char *argv[], char **env)
|
|||
id cobj, prx;
|
||||
unsigned connect_attempts;
|
||||
NSAutoreleasePool *arp;
|
||||
NSPortNameServer *ns;
|
||||
Auth *auth;
|
||||
#ifndef __MINGW32__
|
||||
extern int optind;
|
||||
|
@ -518,7 +517,7 @@ int main (int argc, char *argv[], char **env)
|
|||
debug = 0;
|
||||
type_test = 0;
|
||||
stats = 0;
|
||||
while ((c = wgetopt(argc, argv, "hdtbmslocr")) != EOF)
|
||||
while ((c = getopt(argc, argv, "hdtbmslocr")) != EOF)
|
||||
switch (c)
|
||||
{
|
||||
case 'd':
|
||||
|
@ -574,7 +573,6 @@ int main (int argc, char *argv[], char **env)
|
|||
[NSObject enableDoubleReleaseCheck: YES];
|
||||
}
|
||||
|
||||
ns = [NSSocketPortNameServer sharedInstance];
|
||||
while (connect_attempts-- > 0)
|
||||
{
|
||||
if (optind < argc)
|
||||
|
@ -582,18 +580,15 @@ int main (int argc, char *argv[], char **env)
|
|||
if (optind+1 < argc)
|
||||
prx = [NSConnection rootProxyForConnectionWithRegisteredName:
|
||||
[NSString stringWithCString: argv[optind+1]]
|
||||
host: [NSString stringWithCString:argv[optind]]
|
||||
usingNameServer: ns];
|
||||
host: [NSString stringWithCString:argv[optind]]];
|
||||
else
|
||||
prx = [NSConnection rootProxyForConnectionWithRegisteredName:
|
||||
@"test2server"
|
||||
host:[NSString stringWithCString:argv[optind]]
|
||||
usingNameServer: ns];
|
||||
host:[NSString stringWithCString:argv[optind]]];
|
||||
}
|
||||
else
|
||||
prx = [NSConnection rootProxyForConnectionWithRegisteredName:
|
||||
@"test2server" host: @""
|
||||
usingNameServer: ns];
|
||||
@"test2server" host: @""];
|
||||
if (prx == nil)
|
||||
{
|
||||
printf("ERROR: Failed to connect to server\n");
|
||||
|
@ -610,19 +605,7 @@ int main (int argc, char *argv[], char **env)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Check that we can retain the connection, release the proxy,
|
||||
* and then regain the proxy from the connection.
|
||||
*/
|
||||
cobj = RETAIN([prx connectionForProxy]);
|
||||
RELEASE(arp);
|
||||
arp = [NSAutoreleasePool new];
|
||||
prx = [cobj rootObject];
|
||||
AUTORELEASE(cobj);
|
||||
#else
|
||||
cobj = [prx connectionForProxy];
|
||||
#endif
|
||||
|
||||
[cobj setDelegate:auth];
|
||||
[cobj setRequestTimeout:180.0];
|
||||
[cobj setReplyTimeout:180.0];
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*/
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSConnection.h>
|
||||
#include <Foundation/NSPort.h>
|
||||
#include <Foundation/NSPortNameServer.h>
|
||||
#include <Foundation/NSDistantObject.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
|
@ -477,8 +475,6 @@ int main(int argc, char *argv[], char **env)
|
|||
id l;
|
||||
id o = [[NSObject alloc] init];
|
||||
NSConnection *c;
|
||||
NSPortNameServer *ns;
|
||||
NSPort *port;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
#ifndef __MINGW32__
|
||||
extern int optind;
|
||||
|
@ -491,7 +487,7 @@ int main(int argc, char *argv[], char **env)
|
|||
[NSProcessInfo initializeWithArguments: argv count: argc environment: env];
|
||||
debug = 0;
|
||||
timeout = 0;
|
||||
while ((i = wgetopt(argc, argv, "hdt:")) != EOF)
|
||||
while ((i = getopt(argc, argv, "hdt:")) != EOF)
|
||||
switch (i)
|
||||
{
|
||||
case 'd':
|
||||
|
@ -522,16 +518,13 @@ int main(int argc, char *argv[], char **env)
|
|||
[NSConnection setDebug: debug];
|
||||
[NSObject enableDoubleReleaseCheck: YES];
|
||||
}
|
||||
ns = [NSSocketPortNameServer sharedInstance];
|
||||
port = [NSSocketPort port];
|
||||
c = [NSConnection connectionWithReceivePort: port sendPort: port];
|
||||
c = [NSConnection defaultConnection];
|
||||
[c setRootObject: l];
|
||||
|
||||
if (optind < argc)
|
||||
[c registerName: [NSString stringWithUTF8String: argv[optind]]
|
||||
withNameServer: ns];
|
||||
[c registerName: [NSString stringWithUTF8String: argv[optind]]];
|
||||
else
|
||||
[c registerName: @"test2server" withNameServer: ns];
|
||||
[c registerName: @"test2server"];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: s
|
||||
|
|
|
@ -1,126 +0,0 @@
|
|||
/* Test/example program for the base library
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved.
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
*/
|
||||
#ifndef _server_h
|
||||
#define _server_h
|
||||
|
||||
#include <Foundation/NSConnection.h>
|
||||
|
||||
@interface NSConnection (Debug)
|
||||
+ (void) setDebug: (BOOL)aFlag;
|
||||
@end
|
||||
@interface NSDistantObject (Debug)
|
||||
+ (void) setDebug: (BOOL)aFlag;
|
||||
@end
|
||||
|
||||
typedef struct _small_struct {
|
||||
unsigned char z;
|
||||
} small_struct;
|
||||
|
||||
typedef struct _foo {
|
||||
char c;
|
||||
double d;
|
||||
int i;
|
||||
char *s;
|
||||
unsigned long l;
|
||||
} foo;
|
||||
|
||||
struct myarray {
|
||||
int a[3];
|
||||
};
|
||||
|
||||
#define ADD_CONST 47
|
||||
|
||||
@protocol ClientProtocol
|
||||
- (BOOL) callback;
|
||||
@end
|
||||
|
||||
@protocol ServerProtocol
|
||||
- (void) addObject: (id)o;
|
||||
- (BOOL) sendBoolean: (BOOL)b;
|
||||
- (void) getBoolean: (BOOL*)bp;
|
||||
- (unsigned char) sendUChar: (unsigned char)uc;
|
||||
- (void) getUChar: (unsigned char *)ucp;
|
||||
- (char) sendChar: (char)uc;
|
||||
- (void) getChar: (char *)ucp;
|
||||
- (short) sendShort: (short)num;
|
||||
- (void) getShort: (short *)num;
|
||||
- (int) sendInt: (int)num;
|
||||
- (void) getInt: (int *)num;
|
||||
- (long) sendLong: (long)num;
|
||||
- (void) getLong: (long *)num;
|
||||
- (float) sendFloat: (float)num;
|
||||
- (void) getFloat: (float *)num;
|
||||
- (double) sendDouble: (double)num;
|
||||
- (void) getDouble: (double *)num;
|
||||
- sendDouble: (double)dbl andFloat: (float)flt;
|
||||
|
||||
- (small_struct) sendSmallStruct: (small_struct)str;
|
||||
- (void) getSmallStruct: (small_struct *)str;
|
||||
- (foo) sendStruct: (foo)str;
|
||||
- (void) getStruct: (foo *)str;
|
||||
- (id) sendObject: (id)str;
|
||||
- (void) getObject: (id *)str;
|
||||
- (char *) sendString: (char *)str;
|
||||
- (void) getString: (char **)str;
|
||||
|
||||
- print: (const char *)str;
|
||||
|
||||
- objectAt: (unsigned)i;
|
||||
- (unsigned) count;
|
||||
- echoObject: obj;
|
||||
|
||||
- (oneway void) shout;
|
||||
- bounce: sender count: (int)c;
|
||||
- (oneway void) outputStats:obj;
|
||||
|
||||
- sendArray: (int[3])a;
|
||||
- sendStructArray: (struct myarray)ma;
|
||||
|
||||
- sendBycopy: (bycopy id)o;
|
||||
#ifdef _F_BYREF
|
||||
- sendByref: (byref id)o;
|
||||
- modifyByref: (byref NSMutableString *)o;
|
||||
#endif
|
||||
- manyArgs: (int)i1 : (int)i2 : (int)i3 : (int)i4 : (int)i5 : (int)i6
|
||||
: (int)i7 : (int)i8 : (int)i9 : (int)i10 : (int)i11 : (int)i12;
|
||||
- (int) exceptionTest1;
|
||||
- (void) exceptionTest2;
|
||||
- (oneway void) exceptionTest3;
|
||||
|
||||
- (oneway void) registerClient: (id<ClientProtocol>)client;
|
||||
- (oneway void) unregisterClient: (id<ClientProtocol>)client;
|
||||
- (BOOL) tryClientCallback;
|
||||
@end
|
||||
|
||||
#ifdef IN_SERVER
|
||||
/*
|
||||
* We don't want the client to know about some methods, so we can
|
||||
* check that they work when it doesn't know them.
|
||||
*/
|
||||
@protocol privateServer
|
||||
- quietBycopy: (bycopy id)o;
|
||||
@end
|
||||
@interface Server : NSObject <ServerProtocol,privateServer>
|
||||
{
|
||||
id the_array;
|
||||
id<ClientProtocol> registered_client;
|
||||
}
|
||||
@end
|
||||
#else
|
||||
@interface Server : NSObject <ServerProtocol>
|
||||
{
|
||||
id the_array;
|
||||
id<ClientProtocol> registered_client;
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
||||
#endif /* _server_h */
|
|
@ -1,74 +0,0 @@
|
|||
/* Test/example program for the base library
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved.
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
*/
|
||||
|
||||
/* A simple implementation of getopt() */
|
||||
static int
|
||||
indexof(char c, char *string)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < strlen(string); i++)
|
||||
{
|
||||
if (string[i] == c)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char *optarg;
|
||||
static int optind;
|
||||
static char
|
||||
wgetopt(int argc, char **argv, char *options)
|
||||
{
|
||||
static char *arg;
|
||||
int index;
|
||||
char retval = '\0';
|
||||
|
||||
optarg = NULL;
|
||||
if (optind == 0)
|
||||
{
|
||||
optind = 1;
|
||||
}
|
||||
while (optind < argc)
|
||||
{
|
||||
arg = argv[optind];
|
||||
if (strlen(arg) == 2)
|
||||
{
|
||||
if (arg[0] == '-')
|
||||
{
|
||||
if ((index = indexof(arg[1], options)) != -1)
|
||||
{
|
||||
retval = arg[1];
|
||||
if (index < strlen(options))
|
||||
{
|
||||
if (options[index+1] == ':')
|
||||
{
|
||||
if (optind < argc-1)
|
||||
{
|
||||
optind++;
|
||||
optarg = argv[optind];
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1; /* ':' given, but argv exhausted */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
optind++;
|
||||
return retval;
|
||||
}
|
||||
return -1;
|
||||
}
|
|
@ -25,15 +25,6 @@
|
|||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(warning )
|
||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
||||
$(warning Perhaps gnustep-make is not properly installed,)
|
||||
$(warning so gnustep-config is not in your PATH.)
|
||||
$(warning )
|
||||
$(warning Your PATH is currently $(PATH))
|
||||
$(warning )
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
|
|
|
@ -49,11 +49,6 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/*
|
||||
* NB. This file is intended for internal use by the GNUstep libraries
|
||||
* and may change siugnificantly between releases.
|
||||
* While it is unlikley to be removed from the distributiuon any time
|
||||
* soon, its use by other software is not officially supported.
|
||||
*
|
||||
* This file should be INCLUDED in files wanting to use the GSIArray
|
||||
* functions - these are all declared inline for maximum performance.
|
||||
*
|
||||
|
|
|
@ -41,11 +41,6 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/*
|
||||
* NB. This file is intended for internal use by the GNUstep libraries
|
||||
* and may change siugnificantly between releases.
|
||||
* While it is unlikley to be removed from the distributiuon any time
|
||||
* soon, its use by other software is not officially supported.
|
||||
*
|
||||
* This file should be INCLUDED in files wanting to use the GSIMap
|
||||
* functions - these are all declared inline for maximum performance.
|
||||
*
|
||||
|
@ -89,10 +84,6 @@ extern "C" {
|
|||
* GSI_MAP_NODES()
|
||||
* Define this macro to allocate nodes for the map using typed
|
||||
* memory when working with garbage collection.
|
||||
*
|
||||
* GSI_MAP_ZEROED()
|
||||
* Define this macro to check whether a map uses keys which may
|
||||
* be zeroed weak pointers. This is only used when GC is enabled.
|
||||
*/
|
||||
|
||||
#ifndef GSI_MAP_HAS_VALUE
|
||||
|
@ -121,9 +112,6 @@ extern "C" {
|
|||
#define GSI_MAP_NODES(M, X) \
|
||||
(GSIMapNode)NSAllocateCollectable(X*sizeof(GSIMapNode_t), NSScannedOption)
|
||||
#endif
|
||||
#ifndef GSI_MAP_ZEROED
|
||||
#define GSI_MAP_ZEROED(M) 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If there is no bitmask defined to supply the types that
|
||||
|
@ -307,7 +295,7 @@ struct _GSIMapNode {
|
|||
};
|
||||
|
||||
struct _GSIMapBucket {
|
||||
uintptr_t nodeCount; /* Number of nodes in bucket. */
|
||||
size_t nodeCount; /* Number of nodes in bucket. */
|
||||
GSIMapNode firstNode; /* The linked list of nodes. */
|
||||
};
|
||||
|
||||
|
@ -319,13 +307,13 @@ typedef GSIMapTable_t *GSIMapTable;
|
|||
|
||||
struct _GSIMapTable {
|
||||
NSZone *zone;
|
||||
uintptr_t nodeCount; /* Number of used nodes in map. */
|
||||
uintptr_t bucketCount; /* Number of buckets in map. */
|
||||
size_t nodeCount; /* Number of used nodes in map. */
|
||||
size_t bucketCount; /* Number of buckets in map. */
|
||||
GSIMapBucket buckets; /* Array of buckets. */
|
||||
GSIMapNode freeNodes; /* List of unused nodes. */
|
||||
uintptr_t chunkCount; /* Number of chunks in array. */
|
||||
size_t chunkCount; /* Number of chunks in array. */
|
||||
GSIMapNode *nodeChunks; /* Chunks of allocated memory. */
|
||||
uintptr_t increment;
|
||||
size_t increment;
|
||||
#ifdef GSI_MAP_EXTRA
|
||||
GSI_MAP_EXTRA extra;
|
||||
#endif
|
||||
|
@ -335,7 +323,7 @@ struct _GSIMapTable {
|
|||
typedef struct _GSIMapEnumerator {
|
||||
GSIMapTable map; /* the map being enumerated. */
|
||||
GSIMapNode node; /* The next node to use. */
|
||||
uintptr_t bucket; /* The next bucket to use. */
|
||||
size_t bucket; /* The next bucket to use. */
|
||||
} *_GSIE;
|
||||
|
||||
#ifdef GSI_MAP_ENUMERATOR
|
||||
|
@ -346,7 +334,7 @@ typedef struct _GSIMapEnumerator GSIMapEnumerator_t;
|
|||
typedef GSIMapEnumerator_t *GSIMapEnumerator;
|
||||
|
||||
static INLINE GSIMapBucket
|
||||
GSIMapPickBucket(unsigned hash, GSIMapBucket buckets, uintptr_t bucketCount)
|
||||
GSIMapPickBucket(unsigned hash, GSIMapBucket buckets, size_t bucketCount)
|
||||
{
|
||||
return buckets + hash % bucketCount;
|
||||
}
|
||||
|
@ -416,63 +404,11 @@ GSIMapRemoveNodeFromMap(GSIMapTable map, GSIMapBucket bkt, GSIMapNode node)
|
|||
GSIMapRemoveNodeFromBucket(bkt, node);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
GSIMapFreeNode(GSIMapTable map, GSIMapNode node)
|
||||
{
|
||||
GSI_MAP_RELEASE_KEY(map, node->key);
|
||||
GSI_MAP_CLEAR_KEY(node);
|
||||
#if GSI_MAP_HAS_VALUE
|
||||
GSI_MAP_RELEASE_VAL(map, node->value);
|
||||
GSI_MAP_CLEAR_VAL(node);
|
||||
#endif
|
||||
|
||||
node->nextInBucket = map->freeNodes;
|
||||
map->freeNodes = node;
|
||||
}
|
||||
|
||||
static INLINE GSIMapNode
|
||||
GSIMapRemoveAndFreeNode(GSIMapTable map, uintptr_t bkt, GSIMapNode node)
|
||||
{
|
||||
GSIMapNode next = node->nextInBucket;
|
||||
GSIMapRemoveNodeFromMap(map, &(map->buckets[bkt]), node);
|
||||
GSIMapFreeNode(map, node);
|
||||
return next;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
GSIMapRemangleBuckets(GSIMapTable map,
|
||||
GSIMapBucket old_buckets, uintptr_t old_bucketCount,
|
||||
GSIMapBucket new_buckets, uintptr_t new_bucketCount)
|
||||
GSIMapBucket old_buckets, size_t old_bucketCount,
|
||||
GSIMapBucket new_buckets, size_t new_bucketCount)
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
if (GSI_MAP_ZEROED(map))
|
||||
{
|
||||
while (old_bucketCount-- > 0)
|
||||
{
|
||||
GSIMapNode node;
|
||||
|
||||
while ((node = old_buckets->firstNode) != 0)
|
||||
{
|
||||
if (node->key.addr == 0)
|
||||
{
|
||||
GSIMapRemoveNodeFromMap(map, old_buckets, node);
|
||||
GSIMapFreeNode(map, node);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSIMapBucket bkt;
|
||||
|
||||
GSIMapRemoveNodeFromBucket(old_buckets, node);
|
||||
bkt = GSIMapPickBucket(GSI_MAP_HASH(map, node->key),
|
||||
new_buckets, new_bucketCount);
|
||||
GSIMapAddNodeToBucket(bkt, node);
|
||||
}
|
||||
}
|
||||
old_buckets++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
while (old_bucketCount-- > 0)
|
||||
{
|
||||
GSIMapNode node;
|
||||
|
@ -494,7 +430,7 @@ static INLINE void
|
|||
GSIMapMoreNodes(GSIMapTable map, unsigned required)
|
||||
{
|
||||
GSIMapNode *newArray;
|
||||
uintptr_t arraySize = (map->chunkCount+1)*sizeof(GSIMapNode);
|
||||
size_t arraySize = (map->chunkCount+1)*sizeof(GSIMapNode);
|
||||
|
||||
#if GS_WITH_GC
|
||||
/* We don't want our nodes collected before we have finished with them,
|
||||
|
@ -507,7 +443,7 @@ GSIMapMoreNodes(GSIMapTable map, unsigned required)
|
|||
if (newArray)
|
||||
{
|
||||
GSIMapNode newNodes;
|
||||
uintptr_t chunkCount;
|
||||
size_t chunkCount;
|
||||
|
||||
if (map->nodeChunks != 0)
|
||||
{
|
||||
|
@ -553,28 +489,25 @@ GSIMapMoreNodes(GSIMapTable map, unsigned required)
|
|||
}
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
GSIMapFreeNode(GSIMapTable map, GSIMapNode node)
|
||||
{
|
||||
GSI_MAP_RELEASE_KEY(map, node->key);
|
||||
GSI_MAP_CLEAR_KEY(node);
|
||||
#if GSI_MAP_HAS_VALUE
|
||||
GSI_MAP_RELEASE_VAL(map, node->value);
|
||||
GSI_MAP_CLEAR_VAL(node);
|
||||
#endif
|
||||
|
||||
node->nextInBucket = map->freeNodes;
|
||||
map->freeNodes = node;
|
||||
}
|
||||
|
||||
static INLINE GSIMapNode
|
||||
GSIMapNodeForKeyInBucket(GSIMapTable map, GSIMapBucket bucket, GSIMapKey key)
|
||||
{
|
||||
GSIMapNode node = bucket->firstNode;
|
||||
|
||||
#if GS_WITH_GC
|
||||
if (GSI_MAP_ZEROED(map))
|
||||
{
|
||||
while ((node != 0) && GSI_MAP_EQUAL(map, node->key, key) == NO)
|
||||
{
|
||||
GSIMapNode tmp = node->nextInBucket;
|
||||
|
||||
if (node->key.addr == 0)
|
||||
{
|
||||
GSIMapRemoveNodeFromMap(map, bucket, node);
|
||||
GSIMapFreeNode(map, node);
|
||||
}
|
||||
node = tmp;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
#endif
|
||||
while ((node != 0) && GSI_MAP_EQUAL(map, node->key, key) == NO)
|
||||
{
|
||||
node = node->nextInBucket;
|
||||
|
@ -597,51 +530,6 @@ GSIMapNodeForKey(GSIMapTable map, GSIMapKey key)
|
|||
return node;
|
||||
}
|
||||
|
||||
static INLINE GSIMapNode
|
||||
GSIMapFirstNode(GSIMapTable map)
|
||||
{
|
||||
if (map->nodeCount > 0)
|
||||
{
|
||||
uintptr_t count = map->bucketCount;
|
||||
uintptr_t bucket = 0;
|
||||
GSIMapNode node = 0;
|
||||
|
||||
#if GS_WITH_GC
|
||||
if (GSI_MAP_ZEROED(map))
|
||||
{
|
||||
while (bucket < count)
|
||||
{
|
||||
node = map->buckets[bucket].firstNode;
|
||||
while (node != 0 && node->key.addr == 0)
|
||||
{
|
||||
node = GSIMapRemoveAndFreeNode(map, bucket, node);
|
||||
}
|
||||
if (node != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
bucket++;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
#endif
|
||||
while (bucket < count)
|
||||
{
|
||||
node = map->buckets[bucket].firstNode;
|
||||
if (node != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
bucket++;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if (GSI_MAP_KTYPES & GSUNION_INT)
|
||||
/*
|
||||
* Specialized lookup for the case where keys are known to be simple integer
|
||||
|
@ -660,23 +548,6 @@ GSIMapNodeForSimpleKey(GSIMapTable map, GSIMapKey key)
|
|||
}
|
||||
bucket = map->buckets + ((unsigned)key.addr) % map->bucketCount;
|
||||
node = bucket->firstNode;
|
||||
#if GS_WITH_GC
|
||||
if (GSI_MAP_ZEROED(map))
|
||||
{
|
||||
while ((node != 0) && node->key.addr != key.addr)
|
||||
{
|
||||
GSIMapNode tmp = node->nextInBucket;
|
||||
|
||||
if (node->key.addr == 0)
|
||||
{
|
||||
GSIMapRemoveNodeFromMap(map, bucket, node);
|
||||
GSIMapFreeNode(map, node);
|
||||
}
|
||||
node = tmp;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
#endif
|
||||
while ((node != 0) && node->key.addr != key.addr)
|
||||
{
|
||||
node = node->nextInBucket;
|
||||
|
@ -686,18 +557,18 @@ GSIMapNodeForSimpleKey(GSIMapTable map, GSIMapKey key)
|
|||
#endif
|
||||
|
||||
static INLINE void
|
||||
GSIMapResize(GSIMapTable map, uintptr_t new_capacity)
|
||||
GSIMapResize(GSIMapTable map, size_t new_capacity)
|
||||
{
|
||||
GSIMapBucket new_buckets;
|
||||
uintptr_t size = 1;
|
||||
uintptr_t old = 1;
|
||||
size_t size = 1;
|
||||
size_t old = 1;
|
||||
|
||||
/*
|
||||
* Find next size up in the fibonacci series
|
||||
*/
|
||||
while (size < new_capacity)
|
||||
{
|
||||
uintptr_t tmp = old;
|
||||
size_t tmp = old;
|
||||
|
||||
old = size;
|
||||
size += tmp;
|
||||
|
@ -742,7 +613,7 @@ GSIMapResize(GSIMapTable map, uintptr_t new_capacity)
|
|||
}
|
||||
|
||||
static INLINE void
|
||||
GSIMapRightSizeMap(GSIMapTable map, uintptr_t capacity)
|
||||
GSIMapRightSizeMap(GSIMapTable map, size_t capacity)
|
||||
{
|
||||
/* FIXME: Now, this is a guess, based solely on my intuition. If anyone
|
||||
* knows of a better ratio (or other test, for that matter) and can
|
||||
|
@ -786,31 +657,12 @@ GSIMapEnumeratorForMap(GSIMapTable map)
|
|||
/*
|
||||
* Locate next bucket and node to be returned.
|
||||
*/
|
||||
#if GS_WITH_GC
|
||||
if (GSI_MAP_ZEROED(map))
|
||||
{
|
||||
while (enumerator.bucket < map->bucketCount)
|
||||
{
|
||||
GSIMapNode node = map->buckets[enumerator.bucket].firstNode;
|
||||
|
||||
while (node != 0 && node->key.addr == 0)
|
||||
{
|
||||
node = GSIMapRemoveAndFreeNode(map, enumerator.bucket, node);
|
||||
}
|
||||
if ((enumerator.node = node) != 0)
|
||||
{
|
||||
return enumerator;
|
||||
}
|
||||
enumerator.bucket++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
while (enumerator.bucket < map->bucketCount)
|
||||
{
|
||||
enumerator.node = map->buckets[enumerator.bucket].firstNode;
|
||||
if (enumerator.node != 0)
|
||||
{
|
||||
return enumerator; // Got first node, and recorded its bucket.
|
||||
break; // Got first node, and recorded its bucket.
|
||||
}
|
||||
enumerator.bucket++;
|
||||
}
|
||||
|
@ -854,70 +706,17 @@ static INLINE GSIMapNode
|
|||
GSIMapEnumeratorNextNode(GSIMapEnumerator enumerator)
|
||||
{
|
||||
GSIMapNode node = ((_GSIE)enumerator)->node;
|
||||
GSIMapTable map = ((_GSIE)enumerator)->map;
|
||||
|
||||
#if GS_WITH_GC
|
||||
/* Find the frst available non-zeroed node.
|
||||
*/
|
||||
if (node != 0 && GSI_MAP_ZEROED(map) && node->key.addr == 0)
|
||||
{
|
||||
uintptr_t bucketCount = map->bucketCount;
|
||||
uintptr_t bucket = ((_GSIE)enumerator)->bucket;
|
||||
|
||||
while (node != 0 && node->key.addr == 0)
|
||||
{
|
||||
node = GSIMapRemoveAndFreeNode(map, bucket, node);
|
||||
while (node == 0 && ++bucket < bucketCount)
|
||||
{
|
||||
node = (map->buckets[bucket]).firstNode;
|
||||
while (node != 0 && node->key.addr == 0)
|
||||
{
|
||||
node = GSIMapRemoveAndFreeNode(map, bucket, node);
|
||||
}
|
||||
}
|
||||
((_GSIE)enumerator)->bucket = bucket;
|
||||
((_GSIE)enumerator)->node = node;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
GSIMapNode next = node->nextInBucket;
|
||||
|
||||
#if GS_WITH_GC
|
||||
if (GSI_MAP_ZEROED(map))
|
||||
{
|
||||
uintptr_t bucket = ((_GSIE)enumerator)->bucket;
|
||||
|
||||
while (next != 0 && next->key.addr == 0)
|
||||
{
|
||||
next = GSIMapRemoveAndFreeNode(map, bucket, next);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (next == 0)
|
||||
{
|
||||
uintptr_t bucketCount = map->bucketCount;
|
||||
uintptr_t bucket = ((_GSIE)enumerator)->bucket;
|
||||
GSIMapTable map = ((_GSIE)enumerator)->map;
|
||||
size_t bucketCount = map->bucketCount;
|
||||
size_t bucket = ((_GSIE)enumerator)->bucket;
|
||||
|
||||
#if GS_WITH_GC
|
||||
if (GSI_MAP_ZEROED(map))
|
||||
{
|
||||
while (next == 0 && ++bucket < bucketCount)
|
||||
{
|
||||
next = (map->buckets[bucket]).firstNode;
|
||||
while (next != 0 && next->key.addr == 0)
|
||||
{
|
||||
next = GSIMapRemoveAndFreeNode(map, bucket, next);
|
||||
}
|
||||
}
|
||||
((_GSIE)enumerator)->bucket = bucket;
|
||||
((_GSIE)enumerator)->node = next;
|
||||
return node;
|
||||
}
|
||||
#endif
|
||||
while (next == 0 && ++bucket < bucketCount)
|
||||
{
|
||||
next = (map->buckets[bucket]).firstNode;
|
||||
|
@ -1129,7 +928,7 @@ GSIMapEmptyMap(GSIMapTable map)
|
|||
}
|
||||
|
||||
static INLINE void
|
||||
GSIMapInitWithZoneAndCapacity(GSIMapTable map, NSZone *zone, uintptr_t capacity)
|
||||
GSIMapInitWithZoneAndCapacity(GSIMapTable map, NSZone *zone, size_t capacity)
|
||||
{
|
||||
map->zone = zone;
|
||||
map->nodeCount = 0;
|
||||
|
|
|
@ -76,7 +76,6 @@
|
|||
#import <Foundation/NSInvocation.h>
|
||||
#import <Foundation/NSKeyedArchiver.h>
|
||||
#import <Foundation/NSKeyValueCoding.h>
|
||||
#import <Foundation/NSKeyValueObserving.h>
|
||||
#import <Foundation/NSLock.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
#import <Foundation/NSMethodSignature.h>
|
||||
|
@ -85,7 +84,6 @@
|
|||
#import <Foundation/NSNetServices.h>
|
||||
#import <Foundation/NSNull.h>
|
||||
#import <Foundation/NSNumberFormatter.h>
|
||||
#import <Foundation/NSOperation.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
#import <Foundation/NSPointerArray.h>
|
||||
#import <Foundation/NSPointerFunctions.h>
|
||||
|
|
|
@ -164,7 +164,7 @@ extern "C" {
|
|||
GSIArray objMap; /* Object crossreference map. */
|
||||
GSIArray ptrMap; /* Pointer crossreference map. */
|
||||
#ifndef _IN_NSUNARCHIVER_M
|
||||
#undef GSIArray
|
||||
#undef GSUnarchiverArray
|
||||
#endif
|
||||
unsigned cursor; /* Position in data buffer. */
|
||||
unsigned version; /* Version of archiver used. */
|
||||
|
|
|
@ -80,18 +80,7 @@ extern "C" {
|
|||
- (NSInteger) secondOfMinute;
|
||||
- (NSInteger) yearOfCommonEra;
|
||||
|
||||
/**
|
||||
* <p>Returns a calendar date formed by adding the specified offsets to the
|
||||
* receiver. The offsets are added in order, years, then months, then
|
||||
* days, then hours then minutes then seconds, so if you add 1 month and
|
||||
* forty days to 20th September, the result will be 9th November.
|
||||
* </p>
|
||||
* <p>This method understands leap years and tries to adjust for daylight
|
||||
* savings time changes so that it preserves expected clock time.
|
||||
* </p>
|
||||
* <p>The returned date has the calendar format and timezone of the receiver.
|
||||
* </p>
|
||||
*/
|
||||
// Providing Adjusted Dates
|
||||
- (NSCalendarDate*) addYear: (NSInteger)year
|
||||
month: (NSInteger)month
|
||||
day: (NSInteger)day
|
||||
|
|
|
@ -102,23 +102,12 @@ enum {
|
|||
- (BOOL) isEqualToData: (NSData*)other;
|
||||
- (NSUInteger) length;
|
||||
|
||||
/**
|
||||
* <p>Writes a copy of the data encapsulated by the receiver to a file
|
||||
* at path. If the useAuxiliaryFile flag is YES, this writes to a
|
||||
* temporary file and then renames that to the file at path, thus
|
||||
* ensuring that path exists and does not contain partially written
|
||||
* data at any point.
|
||||
* </p>
|
||||
* <p>On success returns YES, on failure returns NO.
|
||||
* </p>
|
||||
*/
|
||||
// Storing Data
|
||||
|
||||
- (BOOL) writeToFile: (NSString*)path
|
||||
atomically: (BOOL)useAuxiliaryFile;
|
||||
|
||||
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
||||
/**
|
||||
* Writes a copy of the contents of the receiver to the specified URL.
|
||||
*/
|
||||
- (BOOL) writeToURL: (NSURL*)anURL atomically: (BOOL)flag;
|
||||
#endif
|
||||
|
||||
|
@ -142,23 +131,11 @@ enum {
|
|||
atIndex: (unsigned int)index;
|
||||
|
||||
#if OS_API_VERSION(100400,GS_API_LATEST)
|
||||
/**
|
||||
* <p>Writes a copy of the data encapsulated by the receiver to a file
|
||||
* at path. If the NSAtomicWrite option is set, this writes to a
|
||||
* temporary file and then renames that to the file at path, thus
|
||||
* ensuring that path exists and does not contain partially written
|
||||
* data at any point.
|
||||
* </p>
|
||||
* <p>On success returns YES, on failure returns NO.
|
||||
* </p>
|
||||
*/
|
||||
/** Not implemented */
|
||||
- (BOOL) writeToFile: (NSString *)path
|
||||
options: (NSUInteger)writeOptionsMask
|
||||
error: (NSError **)errorPtr;
|
||||
|
||||
/**
|
||||
* Writes a copy of the contents of the receiver to the specified URL.
|
||||
*/
|
||||
/** Not implemented */
|
||||
- (BOOL) writeToURL: (NSURL *)url
|
||||
options: (NSUInteger)writeOptionsMask
|
||||
error: (NSError **)errorPtr;
|
||||
|
|
|
@ -190,10 +190,6 @@ extern "C" {
|
|||
@class NSDirectoryEnumerator;
|
||||
@class NSError;
|
||||
|
||||
/* MacOS-X defines OSType as a 32bit unsigned integer.
|
||||
*/
|
||||
typedef uint32_t OSType;
|
||||
|
||||
@interface NSFileManager : NSObject
|
||||
{
|
||||
NSString *_lastError;
|
||||
|
@ -225,17 +221,6 @@ typedef uint32_t OSType;
|
|||
- (NSString*) currentDirectoryPath;
|
||||
- (NSArray*) directoryContentsAtPath: (NSString*)path;
|
||||
- (NSString*) displayNameAtPath: (NSString*)path;
|
||||
/**
|
||||
* <p>Returns an enumerator which can be used to return each item with
|
||||
* the directory at path in turn.
|
||||
* </p>
|
||||
* <p>The enumeration is recursive ... following all nested subdirectories.
|
||||
* </p>
|
||||
* <p>The order in which directory contents are enumerated is undefined,
|
||||
* and in the current implementation the natural order of the underlying
|
||||
* filesystem is used.
|
||||
* </p>
|
||||
*/
|
||||
- (NSDirectoryEnumerator*) enumeratorAtPath: (NSString*)path;
|
||||
- (NSDictionary*) fileAttributesAtPath: (NSString*)path
|
||||
traverseLink: (BOOL)flag;
|
||||
|
@ -346,19 +331,6 @@ typedef uint32_t OSType;
|
|||
@end
|
||||
|
||||
|
||||
/**
|
||||
* <p>This is a subclass of <code>NSEnumerator</code> which provides a full
|
||||
* listing of all the files beneath a directory and its subdirectories.
|
||||
* Instances can be obtained through [NSFileManager-enumeratorAtPath:].
|
||||
* </p>
|
||||
*
|
||||
* <p>This implementation is optimized and performance should be comparable
|
||||
* to the speed of standard Unix tools for large directories.</p>
|
||||
*
|
||||
* <p>The order in which directory contents are enumerated is undefined,
|
||||
* and in the current implementation the natural order of the underlying
|
||||
* filesystem is used.</p>
|
||||
*/
|
||||
@interface NSDirectoryEnumerator : NSEnumerator
|
||||
{
|
||||
@private
|
||||
|
@ -482,15 +454,15 @@ GS_EXPORT NSString* const NSFileSystemFreeNodes;
|
|||
@interface NSDictionary(NSFileAttributes)
|
||||
- (NSDate*) fileCreationDate;
|
||||
- (BOOL) fileExtensionHidden;
|
||||
- (OSType) fileHFSCreatorCode;
|
||||
- (OSType) fileHFSTypeCode;
|
||||
- (int) fileHFSCreatorCode;
|
||||
- (int) fileHFSTypeCode;
|
||||
- (BOOL) fileIsAppendOnly;
|
||||
- (BOOL) fileIsImmutable;
|
||||
- (unsigned long long) fileSize;
|
||||
- (NSString*) fileType;
|
||||
- (NSNumber*) fileOwnerAccountID;
|
||||
- (unsigned long) fileOwnerAccountID;
|
||||
- (NSString*) fileOwnerAccountName;
|
||||
- (NSNumber*) fileGroupOwnerAccountID;
|
||||
- (unsigned long) fileGroupOwnerAccountID;
|
||||
- (NSString*) fileGroupOwnerAccountName;
|
||||
- (NSDate*) fileModificationDate;
|
||||
- (NSUInteger) filePosixPermissions;
|
||||
|
|
|
@ -230,7 +230,7 @@ extern "C" {
|
|||
#endif
|
||||
GSIArray _objMap; /* Decoded objects. */
|
||||
#ifndef _IN_NSKEYEDUNARCHIVER_M
|
||||
#undef GSIArray
|
||||
#undef GSUnarchiverArray
|
||||
#endif
|
||||
NSZone *_zone; /* Zone for allocating objs. */
|
||||
}
|
||||
|
|
|
@ -1,118 +0,0 @@
|
|||
/**Interface for NSOperation for GNUStep
|
||||
Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Gregory Casamento <greg.casamento@gmail.com>
|
||||
Date: 2009
|
||||
|
||||
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 Lesser 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 Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __NSOperation_h_GNUSTEP_BASE_INCLUDE
|
||||
#define __NSOperation_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
#if OS_API_VERSION(100500, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@class NSMutableArray;
|
||||
|
||||
enum {
|
||||
NSOperationQueuePriorityVeryLow = -8,
|
||||
NSOperationQueuePriorityLow = -4,
|
||||
NSOperationQueuePriorityNormal = 0,
|
||||
NSOperationQueuePriorityHigh = 4,
|
||||
NSOperationQueuePriorityVeryHigh = 8
|
||||
};
|
||||
|
||||
typedef NSInteger NSOperationQueuePriority;
|
||||
|
||||
@interface NSOperation : NSObject
|
||||
{
|
||||
@private
|
||||
id _internal;
|
||||
}
|
||||
|
||||
// Initialization
|
||||
- (id) init;
|
||||
|
||||
// Executing the operation
|
||||
- (void) start;
|
||||
- (void) main;
|
||||
|
||||
// Cancelling the operation
|
||||
- (void) cancel;
|
||||
|
||||
// Getting the operation status
|
||||
- (BOOL) isCancelled;
|
||||
- (BOOL) isExecuting;
|
||||
- (BOOL) isFinished;
|
||||
- (BOOL) isConcurrent;
|
||||
- (BOOL) isReady;
|
||||
|
||||
// Managing dependencies
|
||||
- (void) addDependency: (NSOperation *)op;
|
||||
- (void) removeDependency: (NSOperation *)op;
|
||||
- (NSArray *)dependencies;
|
||||
|
||||
// Prioritization
|
||||
- (NSOperationQueuePriority) queuePriority;
|
||||
- (void) setQueuePriority: (NSOperationQueuePriority)priority;
|
||||
@end
|
||||
|
||||
|
||||
/**
|
||||
* NSOperationQueue
|
||||
*/
|
||||
|
||||
// Enumerated type for default operation count.
|
||||
enum {
|
||||
NSOperationQueueDefaultMaxConcurrentOperationCount = -1
|
||||
};
|
||||
|
||||
// NSOperationQueue
|
||||
@interface NSOperationQueue : NSObject
|
||||
{
|
||||
@private
|
||||
id _internal;
|
||||
}
|
||||
|
||||
// status
|
||||
- (BOOL) isSuspended;
|
||||
- (void) setSuspended: (BOOL)flag;
|
||||
- (NSInteger) maxConcurrentOperationCount;
|
||||
- (void) setMaxConcurrentOperationCount: (NSInteger)cnt;
|
||||
|
||||
// operations
|
||||
- (void) addOperation: (NSOperation *) op;
|
||||
- (NSArray *) operations;
|
||||
- (void) cancelAllOperations;
|
||||
- (void) waitUntilAllOperationsAreFinished;
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __NSOperation_h_GNUSTEP_BASE_INCLUDE */
|
|
@ -47,12 +47,12 @@ enum {
|
|||
/**
|
||||
* Describes the mutability to use when generating objects during
|
||||
* deserialisation of a property list.
|
||||
* <list>
|
||||
* <item><strong>NSPropertyListImmutable</strong>
|
||||
* all objects in created list are immutable</item>
|
||||
* <item><strong>NSPropertyListMutableContainers</strong>
|
||||
* dictionaries, arrays, strings and data objects are mutable</item>
|
||||
* </list>
|
||||
* <example>
|
||||
* <strong>NSPropertyListImmutable</strong>
|
||||
* all objects in created list are immutable
|
||||
* <strong>NSPropertyListMutableContainers</strong>
|
||||
* dictionaries, arrays, strings and data objects are mutable
|
||||
* </example>
|
||||
*/
|
||||
typedef NSUInteger NSPropertyListMutabilityOptions;
|
||||
|
||||
|
@ -66,18 +66,18 @@ enum {
|
|||
};
|
||||
/**
|
||||
* Specifies the serialisation format for a serialised property list.
|
||||
* <list>
|
||||
* <item><strong>NSPropertyListOpenStepFormat</strong>
|
||||
* the most human-readable format</item>
|
||||
* <item><strong>NSPropertyListXMLFormat_v1_0</strong>
|
||||
* portable and readable</item>
|
||||
* <item><strong>NSPropertyListBinaryFormat_v1_0</strong>
|
||||
* the standard format on macos-x</item>
|
||||
* <item><strong>NSPropertyListGNUstepFormat</strong>
|
||||
* extension of OpenStep format</item>
|
||||
* <item><strong>NSPropertyListGNUstepBinaryFormat</strong>
|
||||
* efficient, hardware independent</item>
|
||||
* </list>
|
||||
* <example>
|
||||
* <strong>NSPropertyListOpenStepFormat</strong>
|
||||
* the most human-readable format
|
||||
* <strong>NSPropertyListXMLFormat_v1_0</strong>
|
||||
* portable and readable
|
||||
* <strong>NSPropertyListBinaryFormat_v1_0</strong>
|
||||
* the standard format on macos-x
|
||||
* <strong>NSPropertyListGNUstepFormat</strong>
|
||||
* extension of OpenStep format
|
||||
* <strong>NSPropertyListGNUstepBinaryFormat</strong>
|
||||
* efficient, hardware independent
|
||||
* </example>
|
||||
*/
|
||||
typedef NSUInteger NSPropertyListFormat;
|
||||
|
||||
|
|
|
@ -133,17 +133,6 @@ typedef enum {
|
|||
#endif
|
||||
} RunLoopEventType;
|
||||
@protocol RunLoopEvents
|
||||
/* This is the message sent back to a watcher when an event is observed
|
||||
* by the run loop.
|
||||
* The 'data', 'type' and 'mode' arguments are the same as the arguments
|
||||
* passed to the -addEvent:type:watcher:forMode: method.
|
||||
* The 'extra' argument varies. For an ET_TRIGGER event, it is the same
|
||||
* as the 'data' argument. For other events on unix it is the file
|
||||
* descriptor associated with the event (which may be the same as the
|
||||
* 'data' argument, but is not in the case of ET_RPORT).
|
||||
* For windows it will be the handle or the windows message assciated
|
||||
* with the event.
|
||||
*/
|
||||
- (void) receivedEvent: (void*)data
|
||||
type: (RunLoopEventType)type
|
||||
extra: (void*)extra
|
||||
|
|
|
@ -35,16 +35,6 @@ extern "C" {
|
|||
@class NSLocale;
|
||||
@class NSString;
|
||||
|
||||
#if OS_API_VERSION(100500,GS_API_LATEST)
|
||||
enum {
|
||||
NSTimeZoneNameStyleStandard,
|
||||
NSTimeZoneNameStyleShortStandard,
|
||||
NSTimeZoneNameStyleDaylightSaving,
|
||||
NSTimeZoneNameStyleShortDaylightSaving
|
||||
};
|
||||
typedef NSInteger NSTimeZoneNameStyle;
|
||||
#endif
|
||||
|
||||
@interface NSTimeZone : NSObject
|
||||
|
||||
//Creating and Initializing an NSTimeZone
|
||||
|
@ -96,6 +86,13 @@ typedef NSInteger NSTimeZoneNameStyle;
|
|||
/** Not implemented */
|
||||
- (NSDate *) nextDaylightSavingTimeTransition;
|
||||
|
||||
enum {
|
||||
NSTimeZoneNameStyleStandard,
|
||||
NSTimeZoneNameStyleShortStandard,
|
||||
NSTimeZoneNameStyleDaylightSaving,
|
||||
NSTimeZoneNameStyleShortDaylightSaving
|
||||
};
|
||||
typedef NSInteger NSTimeZoneNameStyle;
|
||||
- (NSString *)localizedName: (NSTimeZoneNameStyle)style
|
||||
locale: (NSLocale *)locale;
|
||||
GS_EXPORT NSString * const NSSystemTimeZoneDidChangeNotification;
|
||||
|
|
|
@ -112,7 +112,7 @@ NSZoneFromPointer (void *ptr);
|
|||
* given zone. Returns NULL if allocation of size 0 requested. Raises
|
||||
* <code>NSMallocException</code> if not enough free memory in zone to
|
||||
* allocate and no more can be obtained from system, unless using the
|
||||
* default zone, in which case NULL is returned.<br />
|
||||
* default zone, in which case NULL is returned.<br \>
|
||||
* If Garbage Collection is enabled, this function always allocates
|
||||
* non-scanned, non-collectable memory in the NSDefaultMallocZone() and
|
||||
* the zone argument is ignored.
|
||||
|
|
146
NEWS
146
NEWS
|
@ -1,36 +1,20 @@
|
|||
1 News
|
||||
******
|
||||
|
||||
The currently released version of the library is `1.19.1'.
|
||||
The currently released version of the library is `1.18.0'.
|
||||
|
||||
See the `ReleaseNotes.html' document for more information.
|
||||
|
||||
1.1 Noteworthy changes in version `1.19.1'
|
||||
1.1 Noteworthy changes in version `1.18.0'
|
||||
==========================================
|
||||
|
||||
* New Mac OS X methods for writing data in NSData
|
||||
* Many new OSX 10.5 methods and stubs and general 10.5 compatibility
|
||||
|
||||
* New classes NSHashTable and NSMapTable
|
||||
|
||||
* Garbage collection now works again and is much improved.
|
||||
|
||||
* Method return types and arguments have been changed for Mac OS X
|
||||
10.5
|
||||
|
||||
1.2 Noteworthy changes in version `1.19.0'
|
||||
==========================================
|
||||
|
||||
* Support for native objective-c exceptions
|
||||
|
||||
* Connection keepalive for ms-windows
|
||||
|
||||
* Path utitlites fix for ms-windows
|
||||
|
||||
* Changes to build on 64bit ms-windows
|
||||
* Changes to build on 64bit Windows
|
||||
|
||||
* Support for @synchronize
|
||||
|
||||
1.3 Noteworthy changes in version `1.15.3'
|
||||
1.2 Noteworthy changes in version `1.15.3'
|
||||
==========================================
|
||||
|
||||
* Extended NSUserDefaults so it recognizes ../ as a relative path.
|
||||
|
@ -42,13 +26,13 @@ See the `ReleaseNotes.html' document for more information.
|
|||
|
||||
* Fixed various problems with and added new options to KVO.
|
||||
|
||||
1.4 Noteworthy changes in version `1.15.2'
|
||||
1.3 Noteworthy changes in version `1.15.2'
|
||||
==========================================
|
||||
|
||||
Bug fixes include improved thread safety (and a change to the NSThread
|
||||
class structure) and Key-Value observing.
|
||||
|
||||
1.5 Noteworthy changes in version `1.15.1'
|
||||
1.4 Noteworthy changes in version `1.15.1'
|
||||
==========================================
|
||||
|
||||
This is an unstable release. There may be API and ABI changes from
|
||||
|
@ -56,14 +40,14 @@ previous releases. The licesne hase changed to GPLv3 and LGPLv3.
|
|||
Mostly bug fixes, but a few improvements in NSPredicates and Key-Value
|
||||
coding have been added.
|
||||
|
||||
1.6 Noteworthy changes in version `1.15.0'
|
||||
1.5 Noteworthy changes in version `1.15.0'
|
||||
==========================================
|
||||
|
||||
This is an unstable release from 1.14.0. It is otherwise identical to
|
||||
the 1.14.0 release. Releases in the 1.15 series may not be forward
|
||||
compatible with previous 1.15 releases.
|
||||
|
||||
1.7 Noteworthy changes in version `1.14.0'
|
||||
1.6 Noteworthy changes in version `1.14.0'
|
||||
==========================================
|
||||
|
||||
Many portability (particularly for ms-windows) and MacOS-X
|
||||
|
@ -71,7 +55,7 @@ compatibility fixes. New MacOS-X classes and incorporation of
|
|||
NSAffineTransform and NSSpellServer which were formerly in the gui
|
||||
library. Improved performance of amssively multithreaded programs.
|
||||
|
||||
1.8 Noteworthy changes in version `1.13.1'
|
||||
1.7 Noteworthy changes in version `1.13.1'
|
||||
==========================================
|
||||
|
||||
Various minor bugs and MacOS-X incompatibilities fixed. One important
|
||||
|
@ -80,14 +64,14 @@ objects from strings. One fix for a serious (crash) bug when
|
|||
initialising the bundles system in an application which has a lot of
|
||||
frameworks linked to it. See the release notes for more details.
|
||||
|
||||
1.9 Noteworthy changes in version `1.13.0'
|
||||
1.8 Noteworthy changes in version `1.13.0'
|
||||
==========================================
|
||||
|
||||
Several sets of classes have been added for dealing with urls and
|
||||
predicates. A few minor api changes have occured as well.
|
||||
|
||||
1.10 Noteworthy changes in version `1.12.0'
|
||||
===========================================
|
||||
1.9 Noteworthy changes in version `1.12.0'
|
||||
==========================================
|
||||
|
||||
There have been a number of API changes and several methods have been
|
||||
depreciated in this release. Although current GNUstep programs that use
|
||||
|
@ -102,7 +86,7 @@ can be set to not write to an external file at all, for developers who
|
|||
wish to use the library as a stand-alone library or in other situations
|
||||
where using external resources is not desired.
|
||||
|
||||
1.11 Noteworthy changes in version `1.11.2'
|
||||
1.10 Noteworthy changes in version `1.11.2'
|
||||
===========================================
|
||||
|
||||
* Support for GNUstep.conf and relocation of the filesystem is much
|
||||
|
@ -119,7 +103,7 @@ where using external resources is not desired.
|
|||
* Some support for keeping user defaults in the Windows registry
|
||||
implemented.
|
||||
|
||||
1.12 Noteworthy changes in version `1.11.1'
|
||||
1.11 Noteworthy changes in version `1.11.1'
|
||||
===========================================
|
||||
|
||||
* New Cocoa class NSSortDescriptor
|
||||
|
@ -131,7 +115,7 @@ where using external resources is not desired.
|
|||
* More support for debugging on mingw, including writing logs to
|
||||
debugger and event viewer.
|
||||
|
||||
1.13 Noteworthy changes in version `1.11.0'
|
||||
1.12 Noteworthy changes in version `1.11.0'
|
||||
===========================================
|
||||
|
||||
This release is binary incompatible with previous releases. The
|
||||
|
@ -150,12 +134,12 @@ new version.
|
|||
* NSRunLoop and related classes use natvie win32 event handling on
|
||||
Windows machines.
|
||||
|
||||
1.14 Noteworthy changes in version `1.10.3'
|
||||
1.13 Noteworthy changes in version `1.10.3'
|
||||
===========================================
|
||||
|
||||
This version includes a few minor bug fixes.
|
||||
|
||||
1.15 Noteworthy changes in version `1.10.2'
|
||||
1.14 Noteworthy changes in version `1.10.2'
|
||||
===========================================
|
||||
|
||||
This version mostly includes minor fixes and updates.
|
||||
|
@ -169,7 +153,7 @@ This version mostly includes minor fixes and updates.
|
|||
|
||||
* Use a proper one-to-one abbreviation dictionary for NSTimeZone.
|
||||
|
||||
1.16 Noteworthy changes in version `1.10.1'
|
||||
1.15 Noteworthy changes in version `1.10.1'
|
||||
===========================================
|
||||
|
||||
This version mostly includes minor fixes and updates.
|
||||
|
@ -184,7 +168,7 @@ This version mostly includes minor fixes and updates.
|
|||
* Designated initializers for NSArray, NSDictionary, NSSet, and
|
||||
NSString have been changed for MacOS X compatibility.
|
||||
|
||||
1.17 Noteworthy changes in version `1.10.0'
|
||||
1.16 Noteworthy changes in version `1.10.0'
|
||||
===========================================
|
||||
|
||||
Note the interface version of the library has changed so that apps,
|
||||
|
@ -198,7 +182,7 @@ use it.
|
|||
|
||||
* Mac OSX XML compatibility fixes.
|
||||
|
||||
1.18 Noteworthy changes in version `1.9.2'
|
||||
1.17 Noteworthy changes in version `1.9.2'
|
||||
==========================================
|
||||
|
||||
* GSMime parsing ignores extraneous data
|
||||
|
@ -216,7 +200,7 @@ use it.
|
|||
* Binary incompatibility: NSUnarchiver, GSIMapTable have new ivars
|
||||
added
|
||||
|
||||
1.19 Noteworthy changes in version `1.9.1'
|
||||
1.18 Noteworthy changes in version `1.9.1'
|
||||
==========================================
|
||||
|
||||
* Default string encoding taken from system nl_langinfo if not set
|
||||
|
@ -227,7 +211,7 @@ use it.
|
|||
* NSPropertyLists class added, also decodes Mac OS X binary propery
|
||||
lists.
|
||||
|
||||
1.20 Noteworthy changes in version `1.9.0'
|
||||
1.19 Noteworthy changes in version `1.9.0'
|
||||
==========================================
|
||||
|
||||
* Lazy locking implemented (see GSLock documentation)
|
||||
|
@ -244,7 +228,7 @@ use it.
|
|||
* NSString subclass heirarchy reorganized to fix problems with
|
||||
copying and ownership of data.
|
||||
|
||||
1.21 Noteworthy changes in version `1.8.0'
|
||||
1.20 Noteworthy changes in version `1.8.0'
|
||||
==========================================
|
||||
|
||||
Read the NEWS file for a complete list of changes since the last stable
|
||||
|
@ -254,14 +238,14 @@ changes in gnustep-make, several components of gnustep-base are located
|
|||
in different locations. Generally this should not affect the
|
||||
compilation or running of applications and tools.
|
||||
|
||||
1.22 Noteworthy changes in version `1.7.4'
|
||||
1.21 Noteworthy changes in version `1.7.4'
|
||||
==========================================
|
||||
|
||||
* Added Korean encoding
|
||||
|
||||
* Updated use of ObjCRuntime functions.
|
||||
|
||||
1.23 Noteworthy changes in version `1.7.3'
|
||||
1.22 Noteworthy changes in version `1.7.3'
|
||||
==========================================
|
||||
|
||||
Note in this version there have been large changes to the location of
|
||||
|
@ -273,7 +257,7 @@ specific headers may not compile because of this.
|
|||
|
||||
* New TraditionalChinese language.
|
||||
|
||||
1.24 Noteworthy changes in version `1.7.2'
|
||||
1.23 Noteworthy changes in version `1.7.2'
|
||||
==========================================
|
||||
|
||||
* NSUndoManager improvements
|
||||
|
@ -284,12 +268,12 @@ specific headers may not compile because of this.
|
|||
|
||||
* Improvements to handle selectors better over remote connections.
|
||||
|
||||
1.25 Noteworthy changes in version `1.7.1'
|
||||
1.24 Noteworthy changes in version `1.7.1'
|
||||
==========================================
|
||||
|
||||
Bug fixes.
|
||||
|
||||
1.26 Noteworthy changes in version `1.7.0'
|
||||
1.25 Noteworthy changes in version `1.7.0'
|
||||
==========================================
|
||||
|
||||
See gnustep-make for comments on the filesystem change. Some components
|
||||
|
@ -306,7 +290,7 @@ changes:
|
|||
|
||||
* Added man page for gdomap
|
||||
|
||||
1.27 Noteworthy changes in version `1.6.0'
|
||||
1.26 Noteworthy changes in version `1.6.0'
|
||||
==========================================
|
||||
|
||||
* More MinGW support
|
||||
|
@ -321,7 +305,7 @@ changes:
|
|||
|
||||
* Any many many bug fixes and minor improvements.
|
||||
|
||||
1.28 Noteworthy changes in version `1.5.1'
|
||||
1.27 Noteworthy changes in version `1.5.1'
|
||||
==========================================
|
||||
|
||||
* Port NSThread to MingW
|
||||
|
@ -340,7 +324,7 @@ changes:
|
|||
|
||||
* NSTimeZone code rewritten for speed.
|
||||
|
||||
1.29 Noteworthy changes in version `1.5.0'
|
||||
1.28 Noteworthy changes in version `1.5.0'
|
||||
==========================================
|
||||
|
||||
* New MacOSX methods implemented (NSString, NSArray, NSObject)
|
||||
|
@ -349,12 +333,12 @@ changes:
|
|||
|
||||
* Tcp connections use runloop in NSConnectionReplyMode.
|
||||
|
||||
1.30 Noteworthy changes in version `1.4.0'
|
||||
1.29 Noteworthy changes in version `1.4.0'
|
||||
==========================================
|
||||
|
||||
* gdomap - security bug fixes.
|
||||
|
||||
1.31 Noteworthy changes in version `1.3.4'
|
||||
1.30 Noteworthy changes in version `1.3.4'
|
||||
==========================================
|
||||
|
||||
This is a first pre-release version for 1.4.
|
||||
|
@ -366,7 +350,7 @@ users are urged to upgrade to this version as soon as possible.
|
|||
|
||||
* New combined Unix/Windows version of NSFileHandle
|
||||
|
||||
1.32 Noteworthy changes in version `1.3.3'
|
||||
1.31 Noteworthy changes in version `1.3.3'
|
||||
==========================================
|
||||
|
||||
Note there are interface and binary changes in this release that
|
||||
|
@ -387,7 +371,7 @@ gnustep-base.
|
|||
|
||||
* Support for system-wide .GNUsteprc
|
||||
|
||||
1.33 Noteworthy changes in version `1.3.2'
|
||||
1.32 Noteworthy changes in version `1.3.2'
|
||||
==========================================
|
||||
|
||||
* Corrections for handling Windows file paths, etc
|
||||
|
@ -405,7 +389,7 @@ gnustep-base.
|
|||
|
||||
* Unicode and UTF8 handling improvements.
|
||||
|
||||
1.34 Noteworthy changes in version `1.3.0'
|
||||
1.33 Noteworthy changes in version `1.3.0'
|
||||
==========================================
|
||||
|
||||
* Moved additional classes into subprojects and/or bundles to make it
|
||||
|
@ -421,7 +405,7 @@ gnustep-base.
|
|||
|
||||
* New, partially finished Objective-C/Foundation programming manual.
|
||||
|
||||
1.35 Noteworthy changes in version `1.1.0'
|
||||
1.34 Noteworthy changes in version `1.1.0'
|
||||
==========================================
|
||||
|
||||
* Removed use of distributed lock to sync defaults file.
|
||||
|
@ -443,7 +427,7 @@ gnustep-base.
|
|||
|
||||
* XML property lists
|
||||
|
||||
1.36 Noteworthy changes in version `1.0.2'
|
||||
1.35 Noteworthy changes in version `1.0.2'
|
||||
==========================================
|
||||
|
||||
Mostly a bug fix release to work with the new gcc 3.0.
|
||||
|
@ -451,7 +435,7 @@ Mostly a bug fix release to work with the new gcc 3.0.
|
|||
* Added support for special gcc 3.0 options (constant string
|
||||
support).
|
||||
|
||||
1.37 Noteworthy changes in version `1.0.1'
|
||||
1.36 Noteworthy changes in version `1.0.1'
|
||||
==========================================
|
||||
|
||||
* Many fixes to work better with Darwin (still not there).
|
||||
|
@ -467,7 +451,7 @@ Mostly a bug fix release to work with the new gcc 3.0.
|
|||
|
||||
* More memory debugging support.
|
||||
|
||||
1.38 Noteworthy changes in version `1.0.0'
|
||||
1.37 Noteworthy changes in version `1.0.0'
|
||||
==========================================
|
||||
|
||||
* Fix parsing of arguments for new linux kernels.
|
||||
|
@ -478,7 +462,7 @@ Mostly a bug fix release to work with the new gcc 3.0.
|
|||
|
||||
* Update unicode support and fixes
|
||||
|
||||
1.39 Noteworthy changes in version `0.9.1'
|
||||
1.38 Noteworthy changes in version `0.9.1'
|
||||
==========================================
|
||||
|
||||
* New MacOSX compatible files for NSCalendarDate, NSTimeZone
|
||||
|
@ -491,7 +475,7 @@ Mostly a bug fix release to work with the new gcc 3.0.
|
|||
|
||||
* Added some gettext compatible localization macros.
|
||||
|
||||
1.40 Noteworthy changes in version `0.9.1'
|
||||
1.39 Noteworthy changes in version `0.9.1'
|
||||
==========================================
|
||||
|
||||
* Fixes for building on FreeBSD
|
||||
|
@ -502,7 +486,7 @@ Mostly a bug fix release to work with the new gcc 3.0.
|
|||
|
||||
* Updated for Makefile package changes.
|
||||
|
||||
1.41 Noteworthy changes in version `0.9.0'
|
||||
1.40 Noteworthy changes in version `0.9.0'
|
||||
==========================================
|
||||
|
||||
* Workaround when no host IP set.
|
||||
|
@ -540,7 +524,7 @@ Mostly a bug fix release to work with the new gcc 3.0.
|
|||
|
||||
* Removed obsolete classes.
|
||||
|
||||
1.42 Noteworthy changes in version `0.6.6'
|
||||
1.41 Noteworthy changes in version `0.6.6'
|
||||
==========================================
|
||||
|
||||
* Lots of new documentation.
|
||||
|
@ -557,7 +541,7 @@ Mostly a bug fix release to work with the new gcc 3.0.
|
|||
|
||||
* More optimization of classes.
|
||||
|
||||
1.43 Noteworthy changes in version `0.6.5'
|
||||
1.42 Noteworthy changes in version `0.6.5'
|
||||
==========================================
|
||||
|
||||
* Better debugging information.
|
||||
|
@ -571,7 +555,7 @@ Mostly a bug fix release to work with the new gcc 3.0.
|
|||
|
||||
* Lots of optimizations and bug fixes.
|
||||
|
||||
1.44 Noteworthy changes in version `0.6.0'
|
||||
1.43 Noteworthy changes in version `0.6.0'
|
||||
==========================================
|
||||
|
||||
Most of the changes to the Base Library are bug fixes and updates to
|
||||
|
@ -587,7 +571,7 @@ and installations, and is considered to be fairly stable.
|
|||
* Performance boosts in many classes.
|
||||
|
||||
|
||||
1.45 Noteworthy changes in version `0.5.5'
|
||||
1.44 Noteworthy changes in version `0.5.5'
|
||||
==========================================
|
||||
|
||||
Too many changes to mention in detail, but here is a list of a few:
|
||||
|
@ -606,14 +590,14 @@ Too many changes to mention in detail, but here is a list of a few:
|
|||
pasteboards.
|
||||
|
||||
|
||||
1.46 Noteworthy changes in version `0.5.1'
|
||||
1.45 Noteworthy changes in version `0.5.1'
|
||||
==========================================
|
||||
|
||||
* Additional runtime functions for interaction with Guile and
|
||||
ObjC-Guile library.
|
||||
|
||||
|
||||
1.47 Noteworthy changes in version `0.5.0'
|
||||
1.46 Noteworthy changes in version `0.5.0'
|
||||
==========================================
|
||||
|
||||
* Improvements to the NSInvocation class, from Masatake Yamato
|
||||
|
@ -628,7 +612,7 @@ Too many changes to mention in detail, but here is a list of a few:
|
|||
<richard@brainstorm.co.uk>.
|
||||
|
||||
|
||||
1.48 Noteworthy changes in version `0.4.0'
|
||||
1.47 Noteworthy changes in version `0.4.0'
|
||||
==========================================
|
||||
|
||||
* New tools for maintaining the defaults database.
|
||||
|
@ -663,7 +647,7 @@ Too many changes to mention in detail, but here is a list of a few:
|
|||
* Many, many, many, many bug fixes and new classes.
|
||||
|
||||
|
||||
1.49 Noteworthy changes since version `0.1.19'
|
||||
1.48 Noteworthy changes since version `0.1.19'
|
||||
==============================================
|
||||
|
||||
* The library has changed its name from `libobjects' to
|
||||
|
@ -765,7 +749,7 @@ Too many changes to mention in detail, but here is a list of a few:
|
|||
* ...and many bug fixes.
|
||||
|
||||
|
||||
1.50 Noteworthy changes since version `0.1.14'
|
||||
1.49 Noteworthy changes since version `0.1.14'
|
||||
==============================================
|
||||
|
||||
* Can be made as a shared library by passing `--enabled-shared' to
|
||||
|
@ -800,7 +784,7 @@ Too many changes to mention in detail, but here is a list of a few:
|
|||
places.
|
||||
|
||||
|
||||
1.51 Noteworthy changes since version `0.1.13'
|
||||
1.50 Noteworthy changes since version `0.1.13'
|
||||
==============================================
|
||||
|
||||
* NSProcessInfo class, thanks to Georg Tuparev.
|
||||
|
@ -815,7 +799,7 @@ Too many changes to mention in detail, but here is a list of a few:
|
|||
* Many bug fixes.
|
||||
|
||||
|
||||
1.52 Noteworthy changes since version `0.1.12'
|
||||
1.51 Noteworthy changes since version `0.1.12'
|
||||
==============================================
|
||||
|
||||
* Bug fixes: installation; NSArray and NSDictionary copying;
|
||||
|
@ -824,7 +808,7 @@ Too many changes to mention in detail, but here is a list of a few:
|
|||
ChangeLog for more details.
|
||||
|
||||
|
||||
1.53 Noteworthy changes since version `0.1.10'
|
||||
1.52 Noteworthy changes since version `0.1.10'
|
||||
==============================================
|
||||
|
||||
* Now using `src', `config' and `doc' directories to un-clutter the
|
||||
|
@ -842,7 +826,7 @@ Too many changes to mention in detail, but here is a list of a few:
|
|||
* And several bug fixes. See the ChangeLog for details.
|
||||
|
||||
|
||||
1.54 Noteworthy changes since version `0.1.9'
|
||||
1.53 Noteworthy changes since version `0.1.9'
|
||||
=============================================
|
||||
|
||||
* Renamed "foundation" include file directory to "Foundation", in
|
||||
|
@ -852,7 +836,7 @@ Too many changes to mention in detail, but here is a list of a few:
|
|||
0.1.9.
|
||||
|
||||
|
||||
1.55 Noteworthy changes since version `0.1.8'
|
||||
1.54 Noteworthy changes since version `0.1.8'
|
||||
=============================================
|
||||
|
||||
* Many new GNUStep classes: NSEnumerator, NSArrayEnumerator, NSCoder,
|
||||
|
@ -889,7 +873,7 @@ Too many changes to mention in detail, but here is a list of a few:
|
|||
implementations back in Collection.m.
|
||||
|
||||
|
||||
1.56 Noteworthy changes since version `0.1.7'
|
||||
1.55 Noteworthy changes since version `0.1.7'
|
||||
=============================================
|
||||
|
||||
* Thanks to Adam Fedor <fedor@boulder.colorado.edu>, classes
|
||||
|
@ -911,7 +895,7 @@ Too many changes to mention in detail, but here is a list of a few:
|
|||
deallocation and behavior adding. See the ChangeLog for details.
|
||||
|
||||
|
||||
1.57 Noteworthy changes since version `0.1.5'
|
||||
1.56 Noteworthy changes since version `0.1.5'
|
||||
=============================================
|
||||
|
||||
* Better string handling. NSString is now fleshed out, and I've
|
||||
|
@ -939,7 +923,7 @@ Too many changes to mention in detail, but here is a list of a few:
|
|||
are in the ChangeLog.
|
||||
|
||||
|
||||
1.58 Noteworthy changes since version `0.1.3'
|
||||
1.57 Noteworthy changes since version `0.1.3'
|
||||
=============================================
|
||||
|
||||
This release not well tested at all. We desperately need someone to
|
||||
|
@ -966,7 +950,7 @@ made on GNUSTEP.
|
|||
`autorelease', `dealloc' instead of `free'.
|
||||
|
||||
|
||||
1.59 Noteworthy changes since version `0.1.0'
|
||||
1.58 Noteworthy changes since version `0.1.0'
|
||||
=============================================
|
||||
|
||||
* New category: ObjectRetaining. New classes: AutoreleasePool,
|
||||
|
@ -976,7 +960,7 @@ made on GNUSTEP.
|
|||
README.ULTRIX. Time.m patched for Solaris 2.4. test12.m free fix.
|
||||
|
||||
|
||||
1.60 Noteworthy changes in version `0.1.0'
|
||||
1.59 Noteworthy changes in version `0.1.0'
|
||||
==========================================
|
||||
|
||||
* Renamed the library from `libcoll' to `libgnustep-base'. (See the
|
||||
|
@ -1010,7 +994,7 @@ made on GNUSTEP.
|
|||
for NeXT-compatible zone functions.
|
||||
|
||||
|
||||
1.61 Noteworthy changes in verion `940524'
|
||||
1.60 Noteworthy changes in verion `940524'
|
||||
==========================================
|
||||
|
||||
* A NeXT-compatible NXStringTable object, thanks to Adam Fedor
|
||||
|
@ -1037,7 +1021,7 @@ made on GNUSTEP.
|
|||
for better NeXT-compability. And more.
|
||||
|
||||
|
||||
1.62 Noteworthy changes in version `931026'
|
||||
1.61 Noteworthy changes in version `931026'
|
||||
===========================================
|
||||
|
||||
* Installation using `./configure' and `autoconf'
|
||||
|
|
|
@ -23,15 +23,6 @@
|
|||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(warning )
|
||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
||||
$(warning Perhaps gnustep-make is not properly installed,)
|
||||
$(warning so gnustep-config is not in your PATH.)
|
||||
$(warning )
|
||||
$(warning Your PATH is currently $(PATH))
|
||||
$(warning )
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
|
|
|
@ -23,15 +23,6 @@
|
|||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(warning )
|
||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
||||
$(warning Perhaps gnustep-make is not properly installed,)
|
||||
$(warning so gnustep-config is not in your PATH.)
|
||||
$(warning )
|
||||
$(warning Your PATH is currently $(PATH))
|
||||
$(warning )
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
|
@ -43,9 +34,9 @@ GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../base.make
|
|||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
-include ../Version
|
||||
-include ../config.mak
|
||||
-include ../Source/pathconfig/pathconfig.mak
|
||||
include ../Version
|
||||
include ../config.mak
|
||||
include ../Source/pathconfig/pathconfig.mak
|
||||
|
||||
libgnustep-base_INTERFACE_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)
|
||||
|
||||
|
|
10
README
10
README
|
@ -10,6 +10,12 @@ remote object messaging support (distributed objects), and event loops.
|
|||
It provides functionality that aims to implement the non-graphical
|
||||
portion of the OpenStep standard (the Foundation library).
|
||||
|
||||
Regression testing is available in the GNUstep testsuite.
|
||||
You can check this out using subversion with the following command:
|
||||
svn co svn://svn.gna.org/gnustep/tests/testsuite/trunk testsuite
|
||||
or view it in a web browser at
|
||||
http://svn.gna.org/viewcvs/gnustep/tests/testsuite/trunk
|
||||
|
||||
1.1 Initial reading
|
||||
===================
|
||||
|
||||
|
@ -34,8 +40,8 @@ and subdirectories under this are covered under the GLPL.
|
|||
GNU Public License. This means if you make changes to these programs,
|
||||
you cannot charge a fee, other than distribution fees, for others to
|
||||
use the program. You should read the COPYING file for more information.
|
||||
All files in the `Documentation', `Examples', `Tools', `config', and
|
||||
`macosx' directories are covered under the GPL.
|
||||
All files in the `Documentation', `Examples', `Tools',
|
||||
`config', and `macosx' directories are covered under the GPL.
|
||||
|
||||
With GNUstep-Base, we strongly recommend the use of the ffcall
|
||||
libraries, which provides stack frame handling for NSInvocation and
|
||||
|
|
|
@ -24,15 +24,6 @@
|
|||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(warning )
|
||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
||||
$(warning Perhaps gnustep-make is not properly installed,)
|
||||
$(warning so gnustep-config is not in your PATH.)
|
||||
$(warning )
|
||||
$(warning Your PATH is currently $(PATH))
|
||||
$(warning )
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
|
|
|
@ -25,15 +25,6 @@
|
|||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(warning )
|
||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
||||
$(warning Perhaps gnustep-make is not properly installed,)
|
||||
$(warning so gnustep-config is not in your PATH.)
|
||||
$(warning )
|
||||
$(warning Your PATH is currently $(PATH))
|
||||
$(warning )
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
|
|
|
@ -122,21 +122,11 @@ sslError(int err)
|
|||
PEMpasswd: (NSString*)PEMpasswd;
|
||||
@end
|
||||
|
||||
static BOOL permitSSLv2 = NO;
|
||||
|
||||
@implementation GSSSLHandle
|
||||
+ (void) _defaultsChanged: (NSNotification*)n
|
||||
{
|
||||
permitSSLv2
|
||||
= [[NSUserDefaults standardUserDefaults] boolForKey: @"GSPermitSSLv2"];
|
||||
}
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSSSLHandle class])
|
||||
{
|
||||
NSUserDefaults *defs;
|
||||
|
||||
SSL_library_init();
|
||||
|
||||
/*
|
||||
|
@ -150,13 +140,6 @@ static BOOL permitSSLv2 = NO;
|
|||
inf = [[[NSProcessInfo processInfo] globallyUniqueString] UTF8String];
|
||||
RAND_seed(inf, strlen(inf));
|
||||
}
|
||||
defs = [NSUserDefaults standardUserDefaults];
|
||||
permitSSLv2 = [defs boolForKey: @"GSPermitSSLv2"];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_defaultsChanged:)
|
||||
name: NSUserDefaultsDidChangeNotification
|
||||
object: nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,10 +186,6 @@ static BOOL permitSSLv2 = NO;
|
|||
if (ctx == 0)
|
||||
{
|
||||
ctx = SSL_CTX_new(SSLv23_server_method());
|
||||
if (permitSSLv2 == NO)
|
||||
{
|
||||
SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2);
|
||||
}
|
||||
}
|
||||
if (ssl == 0)
|
||||
{
|
||||
|
@ -309,10 +288,6 @@ static BOOL permitSSLv2 = NO;
|
|||
if (ctx == 0)
|
||||
{
|
||||
ctx = SSL_CTX_new(SSLv23_client_method());
|
||||
if (permitSSLv2 == NO)
|
||||
{
|
||||
SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2);
|
||||
}
|
||||
}
|
||||
if (ssl == 0)
|
||||
{
|
||||
|
@ -430,10 +405,6 @@ static BOOL permitSSLv2 = NO;
|
|||
if (ctx == 0)
|
||||
{
|
||||
ctx = SSL_CTX_new(SSLv23_method());
|
||||
if (permitSSLv2 == NO)
|
||||
{
|
||||
SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2);
|
||||
}
|
||||
}
|
||||
if ([PEMpasswd length] > 0)
|
||||
{
|
||||
|
|
|
@ -349,23 +349,23 @@ static NSMutableSet *_debug_set = nil;
|
|||
BOOL GSDebugSet(NSString *level)
|
||||
// From GNUStep's
|
||||
{
|
||||
static IMP debugImp = 0;
|
||||
static SEL debugSel;
|
||||
static IMP debugImp = 0;
|
||||
static SEL debugSel;
|
||||
|
||||
if (debugImp == 0)
|
||||
if (debugImp == 0)
|
||||
{
|
||||
debugSel = @selector(member:);
|
||||
if (_debug_set == nil)
|
||||
{
|
||||
[[NSProcessInfo processInfo] debugSet];
|
||||
}
|
||||
debugImp = [_debug_set methodForSelector: debugSel];
|
||||
debugSel = @selector(member:);
|
||||
if (_debug_set == nil)
|
||||
{
|
||||
[[NSProcessInfo processInfo] debugSet];
|
||||
}
|
||||
debugImp = [_debug_set methodForSelector: debugSel];
|
||||
}
|
||||
if ((*debugImp)(_debug_set, debugSel, level) == nil)
|
||||
if ((*debugImp)(_debug_set, debugSel, level) == nil)
|
||||
{
|
||||
return NO;
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSMutableSet *) debugSet
|
||||
|
@ -373,9 +373,9 @@ BOOL GSDebugSet(NSString *level)
|
|||
{
|
||||
if (_debug_set == nil)
|
||||
{
|
||||
int argc = [[self arguments] count];
|
||||
int argc = [[self arguments] count];
|
||||
NSMutableSet *mySet;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
mySet = [NSMutableSet new];
|
||||
for (i = 0; i < argc; i++)
|
||||
|
@ -394,30 +394,24 @@ BOOL GSDebugSet(NSString *level)
|
|||
|
||||
@implementation NSString(GSCompatibility)
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_5
|
||||
// From GNUStep
|
||||
/**
|
||||
* Returns YES when scanning the receiver's text from left to right finds a
|
||||
* digit in the range 1-9 or a letter in the set ('Y', 'y', 'T', 't').<br />
|
||||
* Any trailing characters are ignored.<br />
|
||||
* Any leading whitespace or zeros or signs are also ignored.<br />
|
||||
* Returns NO if the above conditions are not met.
|
||||
* If the string consists of the words 'true' or 'yes' (case insensitive)
|
||||
* or begins with a non-zero numeric value, return YES, otherwise return
|
||||
* NO.
|
||||
*/
|
||||
- (BOOL) boolValue
|
||||
{
|
||||
static NSCharacterSet *yes = nil;
|
||||
|
||||
if (yes == nil)
|
||||
if ([self caseInsensitiveCompare: @"YES"] == NSOrderedSame)
|
||||
{
|
||||
yes = RETAIN([NSCharacterSet characterSetWithCharactersInString:
|
||||
@"123456789yYtT"]);
|
||||
return YES;
|
||||
}
|
||||
if ([self rangeOfCharacterFromSet: yes].length > 0)
|
||||
if ([self caseInsensitiveCompare: @"true"] == NSOrderedSame)
|
||||
{
|
||||
return YES;
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
return [self intValue] != 0 ? YES : NO;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (NSString*) substringFromRange:(NSRange)range
|
||||
{
|
||||
|
|
|
@ -716,6 +716,164 @@ wordData(NSString *word)
|
|||
return AUTORELEASE([[self alloc] init]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Examine xml data to find out the characterset needed to convert from
|
||||
* binary data to an NSString object.
|
||||
*/
|
||||
+ (NSString*) charsetForXml: (NSData*)xml
|
||||
{
|
||||
unsigned int length = [xml length];
|
||||
const unsigned char *ptr = (const unsigned char*)[xml bytes];
|
||||
const unsigned char *end = ptr + length;
|
||||
unsigned int offset = 0;
|
||||
unsigned int size = 1;
|
||||
unsigned char quote = 0;
|
||||
unsigned char buffer[30];
|
||||
unsigned int buflen = 0;
|
||||
BOOL found = NO;
|
||||
|
||||
if (length < 4)
|
||||
{
|
||||
// Not long enough to determine an encoding
|
||||
return nil;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine encoding using byte-order-mark if present
|
||||
*/
|
||||
if ((ptr[0] == 0xFE && ptr[1] == 0xFF)
|
||||
|| (ptr[0] == 0xFF && ptr[1] == 0xFE))
|
||||
{
|
||||
return @"utf-16";
|
||||
}
|
||||
if (ptr[0] == 0xEF && ptr[1] == 0xBB && ptr[2] == 0xBF)
|
||||
{
|
||||
return @"utf-8";
|
||||
}
|
||||
if ((ptr[0] == 0x00 && ptr[1] == 0x00)
|
||||
&& ((ptr[2] == 0xFE && ptr[3] == 0xFF)
|
||||
|| (ptr[2] == 0xFF && ptr[3] == 0xFE)))
|
||||
{
|
||||
return @"ucs-4";
|
||||
}
|
||||
|
||||
/*
|
||||
* Look for nul bytes to determine whether this is a four byte
|
||||
* encoding or a two byte encoding (or the default).
|
||||
*/
|
||||
if (ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0)
|
||||
{
|
||||
offset = 3;
|
||||
size = 4;
|
||||
}
|
||||
else if (ptr[0] == 0 && ptr[1] == 0 && ptr[3] == 0)
|
||||
{
|
||||
offset = 2;
|
||||
size = 4;
|
||||
}
|
||||
else if (ptr[0] == 0 && ptr[2] == 0 && ptr[3] == 0)
|
||||
{
|
||||
offset = 1;
|
||||
size = 4;
|
||||
}
|
||||
else if (ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0)
|
||||
{
|
||||
offset = 0;
|
||||
size = 4;
|
||||
}
|
||||
else if (ptr[0] == 0)
|
||||
{
|
||||
offset = 1;
|
||||
size = 2;
|
||||
}
|
||||
else if (ptr[1] == 0)
|
||||
{
|
||||
offset = 0;
|
||||
size = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now look for the xml encoding declaration ...
|
||||
*/
|
||||
|
||||
// Tolerate leading whitespace
|
||||
while (ptr + size <= end && isspace(ptr[offset])) ptr += size;
|
||||
|
||||
if (ptr + (size * 20) >= end || ptr[offset] != '<' || ptr[offset+size] != '?')
|
||||
{
|
||||
if (size == 1)
|
||||
{
|
||||
return @"utf-8";
|
||||
}
|
||||
else if (size == 2)
|
||||
{
|
||||
return @"utf-16";
|
||||
}
|
||||
else
|
||||
{
|
||||
return @"ucs-4";
|
||||
}
|
||||
}
|
||||
ptr += size * 5; // Step past '<?xml' prefix
|
||||
|
||||
while (ptr + size <= end)
|
||||
{
|
||||
unsigned char c = ptr[offset];
|
||||
|
||||
ptr += size;
|
||||
if (quote == 0)
|
||||
{
|
||||
if (c == '\'' || c == '"')
|
||||
{
|
||||
buflen = 0;
|
||||
quote = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isspace(c) || c == '=')
|
||||
{
|
||||
if (buflen == 8)
|
||||
{
|
||||
buffer[8] = '\0';
|
||||
if (strcasecmp((char*)buffer, "encoding") == 0)
|
||||
{
|
||||
found = YES;
|
||||
}
|
||||
}
|
||||
buflen = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buflen == sizeof(buffer)) buflen = 0;
|
||||
buffer[buflen++] = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c == quote)
|
||||
{
|
||||
if (found == YES)
|
||||
{
|
||||
NSString *tmp;
|
||||
|
||||
tmp = [[NSString alloc] initWithBytes: buffer
|
||||
length: buflen
|
||||
encoding: NSASCIIStringEncoding];
|
||||
IF_NO_GC([tmp autorelease];)
|
||||
return [tmp lowercaseString];
|
||||
}
|
||||
buflen = 0;
|
||||
quote = 0; // End of quoted section
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buflen == sizeof(buffer)) buflen = 0;
|
||||
buffer[buflen++] = c;
|
||||
}
|
||||
}
|
||||
|
||||
return @"utf-8";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a coding context object to be used for decoding data
|
||||
* according to the scheme specified in the header.
|
||||
|
@ -1709,22 +1867,22 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
|||
|
||||
if ([scanner scanInt: &major] == NO || major < 0)
|
||||
{
|
||||
NSLog(@"Bad value for http major version in %@", [scanner string]);
|
||||
NSLog(@"Bad value for http major version");
|
||||
return NO;
|
||||
}
|
||||
if ([scanner scanString: @"." intoString: 0] == NO)
|
||||
{
|
||||
NSLog(@"Bad format for http version in %@", [scanner string]);
|
||||
NSLog(@"Bad format for http version");
|
||||
return NO;
|
||||
}
|
||||
if ([scanner scanInt: &minor] == NO || minor < 0)
|
||||
{
|
||||
NSLog(@"Bad value for http minor version in %@", [scanner string]);
|
||||
NSLog(@"Bad value for http minor version");
|
||||
return NO;
|
||||
}
|
||||
if ([scanner scanInt: &status] == NO || status < 0)
|
||||
{
|
||||
NSLog(@"Bad value for http status in %@", [scanner string]);
|
||||
NSLog(@"Bad value for http status");
|
||||
return NO;
|
||||
}
|
||||
[info setObject: [NSStringClass stringWithFormat: @"%d", minor]
|
||||
|
@ -1761,8 +1919,7 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
|||
value = [self scanToken: scanner];
|
||||
if ([value length] == 0)
|
||||
{
|
||||
NSLog(@"Bad value for content-transfer-encoding header in %@",
|
||||
[scanner string]);
|
||||
NSLog(@"Bad value for content-transfer-encoding header");
|
||||
return NO;
|
||||
}
|
||||
value = [value lowercaseString];
|
||||
|
@ -1775,7 +1932,7 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
|||
type = [self scanName: scanner];
|
||||
if ([type length] == 0)
|
||||
{
|
||||
NSLog(@"Invalid Mime content-type in %@", [scanner string]);
|
||||
NSLog(@"Invalid Mime content-type");
|
||||
return NO;
|
||||
}
|
||||
type = [type lowercaseString];
|
||||
|
@ -1785,8 +1942,7 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
|||
subtype = [self scanName: scanner];
|
||||
if ([subtype length] == 0)
|
||||
{
|
||||
NSLog(@"Invalid Mime content-type (subtype) in %@",
|
||||
[scanner string]);
|
||||
NSLog(@"Invalid Mime content-type (subtype)");
|
||||
return NO;
|
||||
}
|
||||
subtype = [subtype lowercaseString];
|
||||
|
@ -2679,7 +2835,7 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
|||
*/
|
||||
lineStart += bLength;
|
||||
sectionStart = lineStart;
|
||||
memmove(bytes, &bytes[sectionStart], dataEnd - sectionStart);
|
||||
memcpy(bytes, &bytes[sectionStart], dataEnd - sectionStart);
|
||||
dataEnd -= sectionStart;
|
||||
[data setLength: dataEnd];
|
||||
bytes = (unsigned char*)[data mutableBytes];
|
||||
|
@ -2745,7 +2901,6 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
|||
{
|
||||
unsigned diff = input - lineEnd;
|
||||
|
||||
bytes[input] = ' ';
|
||||
memmove(&bytes[lineStart + diff], &bytes[lineStart], length);
|
||||
lineStart += diff;
|
||||
lineEnd += diff;
|
||||
|
@ -2772,7 +2927,7 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
|||
lengthRemaining = dataEnd - input;
|
||||
if (lengthRemaining > 0)
|
||||
{
|
||||
memmove(bytes, &bytes[input], lengthRemaining);
|
||||
memcpy(bytes, &bytes[input], lengthRemaining);
|
||||
}
|
||||
dataEnd = lengthRemaining;
|
||||
[data setLength: lengthRemaining];
|
||||
|
@ -3192,7 +3347,7 @@ appendBytes(NSMutableData *m, unsigned offset, unsigned fold,
|
|||
* If we already have space at the end of the line,
|
||||
* we remove it because the wrapping counts as a space.
|
||||
*/
|
||||
if (len > 0 && isspace(((unsigned char*)[m bytes])[len - 1]))
|
||||
if (len > 0 && ((unsigned char*)[m bytes])[len - 1] == ' ')
|
||||
{
|
||||
[m setLength: --len];
|
||||
}
|
||||
|
@ -3549,164 +3704,6 @@ appendString(NSMutableData *m, unsigned offset, unsigned fold,
|
|||
*/
|
||||
@implementation GSMimeDocument
|
||||
|
||||
/*
|
||||
* Examine xml data to find out the characterset needed to convert from
|
||||
* binary data to an NSString object.
|
||||
*/
|
||||
+ (NSString*) charsetForXml: (NSData*)xml
|
||||
{
|
||||
unsigned int length = [xml length];
|
||||
const unsigned char *ptr = (const unsigned char*)[xml bytes];
|
||||
const unsigned char *end = ptr + length;
|
||||
unsigned int offset = 0;
|
||||
unsigned int size = 1;
|
||||
unsigned char quote = 0;
|
||||
unsigned char buffer[30];
|
||||
unsigned int buflen = 0;
|
||||
BOOL found = NO;
|
||||
|
||||
if (length < 4)
|
||||
{
|
||||
// Not long enough to determine an encoding
|
||||
return nil;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine encoding using byte-order-mark if present
|
||||
*/
|
||||
if ((ptr[0] == 0xFE && ptr[1] == 0xFF)
|
||||
|| (ptr[0] == 0xFF && ptr[1] == 0xFE))
|
||||
{
|
||||
return @"utf-16";
|
||||
}
|
||||
if (ptr[0] == 0xEF && ptr[1] == 0xBB && ptr[2] == 0xBF)
|
||||
{
|
||||
return @"utf-8";
|
||||
}
|
||||
if ((ptr[0] == 0x00 && ptr[1] == 0x00)
|
||||
&& ((ptr[2] == 0xFE && ptr[3] == 0xFF)
|
||||
|| (ptr[2] == 0xFF && ptr[3] == 0xFE)))
|
||||
{
|
||||
return @"ucs-4";
|
||||
}
|
||||
|
||||
/*
|
||||
* Look for nul bytes to determine whether this is a four byte
|
||||
* encoding or a two byte encoding (or the default).
|
||||
*/
|
||||
if (ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0)
|
||||
{
|
||||
offset = 3;
|
||||
size = 4;
|
||||
}
|
||||
else if (ptr[0] == 0 && ptr[1] == 0 && ptr[3] == 0)
|
||||
{
|
||||
offset = 2;
|
||||
size = 4;
|
||||
}
|
||||
else if (ptr[0] == 0 && ptr[2] == 0 && ptr[3] == 0)
|
||||
{
|
||||
offset = 1;
|
||||
size = 4;
|
||||
}
|
||||
else if (ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0)
|
||||
{
|
||||
offset = 0;
|
||||
size = 4;
|
||||
}
|
||||
else if (ptr[0] == 0)
|
||||
{
|
||||
offset = 1;
|
||||
size = 2;
|
||||
}
|
||||
else if (ptr[1] == 0)
|
||||
{
|
||||
offset = 0;
|
||||
size = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now look for the xml encoding declaration ...
|
||||
*/
|
||||
|
||||
// Tolerate leading whitespace
|
||||
while (ptr + size <= end && isspace(ptr[offset])) ptr += size;
|
||||
|
||||
if (ptr + (size * 20) >= end || ptr[offset] != '<' || ptr[offset+size] != '?')
|
||||
{
|
||||
if (size == 1)
|
||||
{
|
||||
return @"utf-8";
|
||||
}
|
||||
else if (size == 2)
|
||||
{
|
||||
return @"utf-16";
|
||||
}
|
||||
else
|
||||
{
|
||||
return @"ucs-4";
|
||||
}
|
||||
}
|
||||
ptr += size * 5; // Step past '<?xml' prefix
|
||||
|
||||
while (ptr + size <= end)
|
||||
{
|
||||
unsigned char c = ptr[offset];
|
||||
|
||||
ptr += size;
|
||||
if (quote == 0)
|
||||
{
|
||||
if (c == '\'' || c == '"')
|
||||
{
|
||||
buflen = 0;
|
||||
quote = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isspace(c) || c == '=')
|
||||
{
|
||||
if (buflen == 8)
|
||||
{
|
||||
buffer[8] = '\0';
|
||||
if (strcasecmp((char*)buffer, "encoding") == 0)
|
||||
{
|
||||
found = YES;
|
||||
}
|
||||
}
|
||||
buflen = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buflen == sizeof(buffer)) buflen = 0;
|
||||
buffer[buflen++] = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c == quote)
|
||||
{
|
||||
if (found == YES)
|
||||
{
|
||||
NSString *tmp;
|
||||
|
||||
tmp = [[NSString alloc] initWithBytes: buffer
|
||||
length: buflen
|
||||
encoding: NSASCIIStringEncoding];
|
||||
IF_NO_GC([tmp autorelease];)
|
||||
return [tmp lowercaseString];
|
||||
}
|
||||
buflen = 0;
|
||||
quote = 0; // End of quoted section
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buflen == sizeof(buffer)) buflen = 0;
|
||||
buffer[buflen++] = c;
|
||||
}
|
||||
}
|
||||
|
||||
return @"utf-8";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the MIME characterset name corresponding to the
|
||||
* specified string encoding.<br />
|
||||
|
|
|
@ -1841,14 +1841,14 @@ GSObjCGetVal(NSObject *self, const char *key, SEL sel,
|
|||
}
|
||||
else
|
||||
{
|
||||
val = [self valueForUndefinedKey:
|
||||
[NSString stringWithUTF8String: key]];
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"key-value get method unsupported struct"];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
val = [self valueForUndefinedKey:
|
||||
[NSString stringWithUTF8String: key]];
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"key-value get method has unsupported type"];
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
@ -1897,8 +1897,8 @@ GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel,
|
|||
}
|
||||
if (type == NULL)
|
||||
{
|
||||
[self setValue: val forUndefinedKey:
|
||||
[NSString stringWithUTF8String: key]];
|
||||
[self setValue: val
|
||||
forUndefinedKey: [NSString stringWithUTF8String: key]];
|
||||
}
|
||||
else if ((val == nil || val == null) && *type != _C_ID && *type != _C_CLASS)
|
||||
{
|
||||
|
@ -2255,14 +2255,14 @@ GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel,
|
|||
}
|
||||
else
|
||||
{
|
||||
[self setValue: val forUndefinedKey:
|
||||
[NSString stringWithUTF8String: key]];
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"key-value set method unsupported struct"];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
[self setValue: val forUndefinedKey:
|
||||
[NSString stringWithUTF8String: key]];
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"key-value set method has unsupported type"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -820,7 +820,8 @@ else \
|
|||
} \
|
||||
if (ptr == 0) \
|
||||
{ \
|
||||
return NO; /* Not enough memory */ \
|
||||
result = NO; /* Not enough memory */ \
|
||||
break; \
|
||||
} \
|
||||
bsize = grow / sizeof(unichar); \
|
||||
}
|
||||
|
@ -874,7 +875,8 @@ else \
|
|||
} \
|
||||
if (ptr == 0) \
|
||||
{ \
|
||||
return NO; /* Not enough memory */ \
|
||||
result = NO; /* Not enough memory */ \
|
||||
break; \
|
||||
} \
|
||||
bsize = grow / sizeof(unichar); \
|
||||
}
|
||||
|
@ -1080,123 +1082,31 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
|
|||
|
||||
case NSNonLossyASCIIStringEncoding:
|
||||
case NSASCIIStringEncoding:
|
||||
if (dst == 0)
|
||||
while (spos < slen)
|
||||
{
|
||||
/* Just counting bytes, and we know there is exactly one
|
||||
* unicode codepoint needed for each ascii character.
|
||||
*/
|
||||
dpos += slen;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Because we know that each ascii chartacter is exactly
|
||||
* one unicode character, we can check the destination
|
||||
* buffer size and allocate more space in one go, before
|
||||
* entering the loop where we deal with each character.
|
||||
*/
|
||||
if (dpos + slen + (extra ? 1 : 0) > bsize)
|
||||
{
|
||||
if (zone == 0)
|
||||
{
|
||||
result = NO; /* No buffer growth possible ... fail. */
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned grow = (dpos + slen) * sizeof(unichar);
|
||||
unichar *tmp;
|
||||
unichar c = (unichar)((unc)src[spos++]);
|
||||
|
||||
#if GS_WITH_GC
|
||||
tmp = NSAllocateCollectable(grow + extra, 0);
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, grow + extra);
|
||||
#endif
|
||||
if ((ptr == buf || ptr == *dst) && (tmp != 0))
|
||||
{
|
||||
memcpy(tmp, ptr, bsize * sizeof(unichar));
|
||||
}
|
||||
#if !GS_WITH_GC
|
||||
if (ptr != buf && ptr != *dst)
|
||||
{
|
||||
NSZoneFree(zone, ptr);
|
||||
}
|
||||
#endif
|
||||
ptr = tmp;
|
||||
if (ptr == 0)
|
||||
{
|
||||
return NO; /* Not enough memory */
|
||||
}
|
||||
bsize = grow / sizeof(unichar);
|
||||
}
|
||||
}
|
||||
while (spos < slen)
|
||||
if (c > 127)
|
||||
{
|
||||
unichar c = (unichar)((unc)src[spos++]);
|
||||
|
||||
if (c > 127)
|
||||
{
|
||||
result = NO; // Non-ascii data found in input.
|
||||
goto done;
|
||||
}
|
||||
ptr[dpos++] = c;
|
||||
result = NO; // Non-ascii data found in input.
|
||||
goto done;
|
||||
}
|
||||
if (dpos >= bsize)
|
||||
{
|
||||
GROW();
|
||||
}
|
||||
ptr[dpos++] = c;
|
||||
}
|
||||
break;
|
||||
|
||||
case NSISOLatin1StringEncoding:
|
||||
if (dst == 0)
|
||||
while (spos < slen)
|
||||
{
|
||||
/* Just counting bytes, and we know there is exactly one
|
||||
* unicode codepoint needed for each latin1 character.
|
||||
*/
|
||||
dpos += slen;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Because we know that each latin1 chartacter is exactly
|
||||
* one unicode character, we can check the destination
|
||||
* buffer size and allocate more space in one go, before
|
||||
* entering the loop where we deal with each character.
|
||||
*/
|
||||
if (dpos + slen + (extra ? 1 : 0) > bsize)
|
||||
if (dpos >= bsize)
|
||||
{
|
||||
if (zone == 0)
|
||||
{
|
||||
result = NO; /* No buffer growth possible ... fail. */
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned grow = (dpos + slen) * sizeof(unichar);
|
||||
unichar *tmp;
|
||||
|
||||
#if GS_WITH_GC
|
||||
tmp = NSAllocateCollectable(grow + extra, 0);
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, grow + extra);
|
||||
#endif
|
||||
if ((ptr == buf || ptr == *dst) && (tmp != 0))
|
||||
{
|
||||
memcpy(tmp, ptr, bsize * sizeof(unichar));
|
||||
}
|
||||
#if !GS_WITH_GC
|
||||
if (ptr != buf && ptr != *dst)
|
||||
{
|
||||
NSZoneFree(zone, ptr);
|
||||
}
|
||||
#endif
|
||||
ptr = tmp;
|
||||
if (ptr == 0)
|
||||
{
|
||||
return NO; /* Not enough memory */
|
||||
}
|
||||
bsize = grow / sizeof(unichar);
|
||||
}
|
||||
}
|
||||
while (spos < slen)
|
||||
{
|
||||
ptr[dpos++] = (unichar)((unc)src[spos++]);
|
||||
GROW();
|
||||
}
|
||||
ptr[dpos++] = (unichar)((unc)src[spos++]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1233,69 +1143,23 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
|
|||
#endif
|
||||
|
||||
tables:
|
||||
if (dst == 0)
|
||||
while (spos < slen)
|
||||
{
|
||||
/* Just counting bytes, and we know there is exactly one
|
||||
* unicode codepoint needed for each character.
|
||||
*/
|
||||
dpos += slen;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Because we know that each character in the table is exactly
|
||||
* one unicode character, we can check the destination
|
||||
* buffer size and allocate more space in one go, before
|
||||
* entering the loop where we deal with each character.
|
||||
*/
|
||||
if (dpos + slen + (extra ? 1 : 0) > bsize)
|
||||
{
|
||||
if (zone == 0)
|
||||
{
|
||||
result = NO; /* No buffer growth possible ... fail. */
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned grow = (dpos + slen) * sizeof(unichar);
|
||||
unichar *tmp;
|
||||
unc c = (unc)src[spos];
|
||||
|
||||
#if GS_WITH_GC
|
||||
tmp = NSAllocateCollectable(grow + extra, 0);
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, grow + extra);
|
||||
#endif
|
||||
if ((ptr == buf || ptr == *dst) && (tmp != 0))
|
||||
{
|
||||
memcpy(tmp, ptr, bsize * sizeof(unichar));
|
||||
}
|
||||
#if !GS_WITH_GC
|
||||
if (ptr != buf && ptr != *dst)
|
||||
{
|
||||
NSZoneFree(zone, ptr);
|
||||
}
|
||||
#endif
|
||||
ptr = tmp;
|
||||
if (ptr == 0)
|
||||
{
|
||||
return NO; /* Not enough memory */
|
||||
}
|
||||
bsize = grow / sizeof(unichar);
|
||||
}
|
||||
}
|
||||
while (spos < slen)
|
||||
if (dpos >= bsize)
|
||||
{
|
||||
unc c = (unc)src[spos];
|
||||
|
||||
if (c < base)
|
||||
{
|
||||
ptr[dpos++] = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr[dpos++] = table[c - base];
|
||||
}
|
||||
spos++;
|
||||
GROW();
|
||||
}
|
||||
if (c < base)
|
||||
{
|
||||
ptr[dpos++] = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr[dpos++] = table[c - base];
|
||||
}
|
||||
spos++;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1308,6 +1172,7 @@ tables:
|
|||
{
|
||||
GROW();
|
||||
}
|
||||
|
||||
ptr[dpos] = GSM0338_char_to_uni_table[c];
|
||||
if (c == 0x1b && spos < slen)
|
||||
{
|
||||
|
@ -1414,9 +1279,9 @@ tables:
|
|||
done:
|
||||
|
||||
/*
|
||||
* Post conversion ... terminate if needed, and set output values.
|
||||
* Post conversion ... set output values.
|
||||
*/
|
||||
if (extra != 0 && dst != 0)
|
||||
if (extra != 0)
|
||||
{
|
||||
ptr[dpos] = (unichar)0;
|
||||
}
|
||||
|
@ -1437,7 +1302,7 @@ done:
|
|||
#else
|
||||
r = GSAutoreleasedBuffer(bytes);
|
||||
memcpy(r, ptr, bytes);
|
||||
if (ptr != buf && ptr != *dst)
|
||||
if (ptr != buf && (dst == 0 || ptr != *dst))
|
||||
{
|
||||
NSZoneFree(zone, ptr);
|
||||
}
|
||||
|
@ -1489,7 +1354,7 @@ done:
|
|||
}
|
||||
}
|
||||
#if !GS_WITH_GC
|
||||
else if (ptr != buf && ptr != *dst)
|
||||
else if (ptr != buf && dst != 0 && ptr != *dst)
|
||||
{
|
||||
NSZoneFree(zone, ptr);
|
||||
}
|
||||
|
@ -1552,7 +1417,8 @@ else \
|
|||
} \
|
||||
if (ptr == 0) \
|
||||
{ \
|
||||
return NO; /* Not enough memory */ \
|
||||
result = NO; /* Not enough memory */ \
|
||||
break; \
|
||||
} \
|
||||
bsize = grow; \
|
||||
}
|
||||
|
@ -1605,7 +1471,8 @@ else \
|
|||
} \
|
||||
if (ptr == 0) \
|
||||
{ \
|
||||
return NO; /* Not enough memory */ \
|
||||
result = NO; /* Not enough memory */ \
|
||||
break; \
|
||||
} \
|
||||
bsize = grow; \
|
||||
}
|
||||
|
@ -1779,249 +1646,127 @@ GSFromUnicode(unsigned char **dst, unsigned int *size, const unichar *src,
|
|||
{
|
||||
case NSUTF8StringEncoding:
|
||||
{
|
||||
if (swapped == YES)
|
||||
while (spos < slen)
|
||||
{
|
||||
while (spos < slen)
|
||||
{
|
||||
unichar u1, u2;
|
||||
unsigned char reversed[8];
|
||||
unsigned long u;
|
||||
int sl;
|
||||
int i;
|
||||
unichar u1, u2;
|
||||
unsigned long u;
|
||||
int sl = 0;
|
||||
|
||||
/* get first unichar */
|
||||
u1 = src[spos++];
|
||||
/* get first unichar */
|
||||
u1 = src[spos++];
|
||||
if (swapped == YES)
|
||||
{
|
||||
u1 = (((u1 & 0xff00) >> 8) + ((u1 & 0x00ff) << 8));
|
||||
|
||||
/* Fast track ... if this is actually an ascii character
|
||||
* it just converts straight to utf-8
|
||||
*/
|
||||
if (u1 <= 0x7f)
|
||||
}
|
||||
// 0xfeff is a zero-width-no-break-space inside text (not a BOM).
|
||||
if (u1 == 0xfffe // unexpected BOM
|
||||
|| u1 == 0xffff // not a character
|
||||
|| (u1 >= 0xfdd0 && u1 <= 0xfdef) // invalid character
|
||||
|| (u1 >= 0xdc00 && u1 <= 0xdfff)) // bad pairing
|
||||
{
|
||||
if (strict)
|
||||
{
|
||||
if (dpos >= bsize)
|
||||
{
|
||||
GROW();
|
||||
}
|
||||
ptr[dpos++] = (unsigned char)u1;
|
||||
continue;
|
||||
}
|
||||
result = NO;
|
||||
goto done;
|
||||
}
|
||||
continue; // Skip invalid character.
|
||||
}
|
||||
|
||||
// 0xfeff is a zero-width-no-break-space inside text
|
||||
if (u1 == 0xfffe // unexpected BOM
|
||||
|| u1 == 0xffff // not a character
|
||||
|| (u1 >= 0xfdd0 && u1 <= 0xfdef) // invalid character
|
||||
|| (u1 >= 0xdc00 && u1 <= 0xdfff)) // bad pairing
|
||||
{
|
||||
/* possibly get second character and calculate 'u' */
|
||||
if ((u1 >= 0xd800) && (u1 < 0xdc00))
|
||||
{
|
||||
if (spos >= slen)
|
||||
{
|
||||
if (strict)
|
||||
{
|
||||
result = NO;
|
||||
goto done;
|
||||
}
|
||||
continue; // Skip invalid character.
|
||||
}
|
||||
continue; // At end.
|
||||
}
|
||||
|
||||
/* possibly get second character and calculate 'u' */
|
||||
if ((u1 >= 0xd800) && (u1 < 0xdc00))
|
||||
/* get second unichar */
|
||||
u2 = src[spos++];
|
||||
if (swapped == YES)
|
||||
{
|
||||
if (spos >= slen)
|
||||
{
|
||||
if (strict)
|
||||
{
|
||||
result = NO;
|
||||
goto done;
|
||||
}
|
||||
continue; // At end.
|
||||
}
|
||||
|
||||
/* get second unichar */
|
||||
u2 = src[spos++];
|
||||
u2 = (((u2 & 0xff00) >> 8) + ((u2 & 0x00ff) << 8));
|
||||
|
||||
if ((u2 < 0xdc00) && (u2 > 0xdfff))
|
||||
{
|
||||
spos--;
|
||||
if (strict)
|
||||
{
|
||||
result = NO;
|
||||
goto done;
|
||||
}
|
||||
continue; // Skip bad half of surrogate pair.
|
||||
}
|
||||
|
||||
/* make the full value */
|
||||
u = ((unsigned long)(u1 - 0xd800) * 0x400)
|
||||
+ (u2 - 0xdc00) + 0x10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
u = u1;
|
||||
}
|
||||
|
||||
/* calculate the sequence length
|
||||
* a length of 1 was dealt with earlier
|
||||
*/
|
||||
if (u <= 0x7ff)
|
||||
{
|
||||
sl = 2;
|
||||
}
|
||||
else if (u <= 0xffff)
|
||||
{
|
||||
sl = 3;
|
||||
}
|
||||
else if (u <= 0x1fffff)
|
||||
{
|
||||
sl = 4;
|
||||
}
|
||||
else if (u <= 0x3ffffff)
|
||||
{
|
||||
sl = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
sl = 6;
|
||||
}
|
||||
|
||||
/* make sure we have enough space for it */
|
||||
while (dpos + sl >= bsize)
|
||||
{
|
||||
GROW();
|
||||
}
|
||||
|
||||
/* split value into reversed array */
|
||||
for (i = 0; i < sl; i++)
|
||||
{
|
||||
reversed[i] = (u & 0x3f);
|
||||
u = u >> 6;
|
||||
}
|
||||
|
||||
ptr[dpos++] = reversed[sl-1] | ((0xff << (8-sl)) & 0xff);
|
||||
/* add bytes into the output sequence */
|
||||
for (i = sl - 2; i >= 0; i--)
|
||||
{
|
||||
ptr[dpos++] = reversed[i] | 0x80;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (spos < slen)
|
||||
{
|
||||
unichar u1, u2;
|
||||
unsigned char reversed[8];
|
||||
unsigned long u;
|
||||
int sl;
|
||||
int i;
|
||||
|
||||
/* get first unichar */
|
||||
u1 = src[spos++];
|
||||
|
||||
/* Fast track ... if this is actually an ascii character
|
||||
* it just converts straight to utf-8
|
||||
*/
|
||||
if (u1 <= 0x7f)
|
||||
{
|
||||
if (dpos >= bsize)
|
||||
{
|
||||
GROW();
|
||||
}
|
||||
ptr[dpos++] = (unsigned char)u1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 0xfeff is a zero-width-no-break-space inside text
|
||||
if (u1 == 0xfffe // unexpected BOM
|
||||
|| u1 == 0xffff // not a character
|
||||
|| (u1 >= 0xfdd0 && u1 <= 0xfdef) // invalid character
|
||||
|| (u1 >= 0xdc00 && u1 <= 0xdfff)) // bad pairing
|
||||
{
|
||||
if ((u2 < 0xdc00) && (u2 > 0xdfff))
|
||||
{
|
||||
spos--;
|
||||
if (strict)
|
||||
{
|
||||
result = NO;
|
||||
goto done;
|
||||
}
|
||||
continue; // Skip invalid character.
|
||||
}
|
||||
continue; // Skip bad half of surrogate pair.
|
||||
}
|
||||
|
||||
/* possibly get second character and calculate 'u' */
|
||||
if ((u1 >= 0xd800) && (u1 < 0xdc00))
|
||||
{
|
||||
if (spos >= slen)
|
||||
{
|
||||
if (strict)
|
||||
{
|
||||
result = NO;
|
||||
goto done;
|
||||
}
|
||||
continue; // At end.
|
||||
}
|
||||
/* make the full value */
|
||||
u = ((unsigned long)(u1 - 0xd800) * 0x400)
|
||||
+ (u2 - 0xdc00) + 0x10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
u = u1;
|
||||
}
|
||||
|
||||
/* get second unichar */
|
||||
u2 = src[spos++];
|
||||
/* calculate the sequence length */
|
||||
if (u <= 0x7f)
|
||||
{
|
||||
sl = 1;
|
||||
}
|
||||
else if (u <= 0x7ff)
|
||||
{
|
||||
sl = 2;
|
||||
}
|
||||
else if (u <= 0xffff)
|
||||
{
|
||||
sl = 3;
|
||||
}
|
||||
else if (u <= 0x1fffff)
|
||||
{
|
||||
sl = 4;
|
||||
}
|
||||
else if (u <= 0x3ffffff)
|
||||
{
|
||||
sl = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
sl = 6;
|
||||
}
|
||||
|
||||
if ((u2 < 0xdc00) && (u2 > 0xdfff))
|
||||
{
|
||||
spos--;
|
||||
if (strict)
|
||||
{
|
||||
result = NO;
|
||||
goto done;
|
||||
}
|
||||
continue; // Skip bad half of surrogate pair.
|
||||
}
|
||||
/* make sure we have enough space for it */
|
||||
while (dpos + sl >= bsize)
|
||||
{
|
||||
GROW();
|
||||
}
|
||||
|
||||
/* make the full value */
|
||||
u = ((unsigned long)(u1 - 0xd800) * 0x400)
|
||||
+ (u2 - 0xdc00) + 0x10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
u = u1;
|
||||
}
|
||||
if (sl == 1)
|
||||
{
|
||||
ptr[dpos++] = u & 0x7f;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
unsigned char reversed[8];
|
||||
|
||||
/* calculate the sequence length
|
||||
* a length of 1 was dealt with earlier
|
||||
*/
|
||||
if (u <= 0x7ff)
|
||||
{
|
||||
sl = 2;
|
||||
}
|
||||
else if (u <= 0xffff)
|
||||
{
|
||||
sl = 3;
|
||||
}
|
||||
else if (u <= 0x1fffff)
|
||||
{
|
||||
sl = 4;
|
||||
}
|
||||
else if (u <= 0x3ffffff)
|
||||
{
|
||||
sl = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
sl = 6;
|
||||
}
|
||||
/* split value into reversed array */
|
||||
for (i = 0; i < sl; i++)
|
||||
{
|
||||
reversed[i] = (u & 0x3f);
|
||||
u = u >> 6;
|
||||
}
|
||||
|
||||
/* make sure we have enough space for it */
|
||||
while (dpos + sl >= bsize)
|
||||
{
|
||||
GROW();
|
||||
}
|
||||
|
||||
/* split value into reversed array */
|
||||
for (i = 0; i < sl; i++)
|
||||
{
|
||||
reversed[i] = (u & 0x3f);
|
||||
u = u >> 6;
|
||||
}
|
||||
|
||||
ptr[dpos++] = reversed[sl-1] | ((0xff << (8-sl)) & 0xff);
|
||||
/* add bytes into the output sequence */
|
||||
for (i = sl - 2; i >= 0; i--)
|
||||
ptr[dpos++] = reversed[sl-1] | ((0xff << (8-sl)) & 0xff);
|
||||
/* add bytes into the output sequence */
|
||||
for (i = sl - 2; i >= 0; i--)
|
||||
{
|
||||
ptr[dpos++] = reversed[i] | 0x80;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2037,120 +1782,53 @@ GSFromUnicode(unsigned char **dst, unsigned int *size, const unichar *src,
|
|||
goto bases;
|
||||
|
||||
bases:
|
||||
if (dst == 0)
|
||||
if (strict == NO)
|
||||
{
|
||||
/* Just counting bytes, and we know there is exactly one
|
||||
* unicode codepoint needed for each character.
|
||||
*/
|
||||
dpos = slen;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Because we know that each ascii chartacter is exactly
|
||||
* one unicode character, we can check the destination
|
||||
* buffer size and allocate more space in one go, before
|
||||
* entering the loop where we deal with each character.
|
||||
*/
|
||||
if (slen > bsize)
|
||||
while (spos < slen)
|
||||
{
|
||||
if (zone == 0)
|
||||
unichar u = src[spos++];
|
||||
|
||||
if (swapped == YES)
|
||||
{
|
||||
result = NO; /* No buffer growth possible ... fail. */
|
||||
goto done;
|
||||
u = (((u & 0xff00) >> 8) + ((u & 0x00ff) << 8));
|
||||
}
|
||||
|
||||
if (dpos >= bsize)
|
||||
{
|
||||
GROW();
|
||||
}
|
||||
if (u < base)
|
||||
{
|
||||
ptr[dpos++] = (unsigned char)u;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t *tmp;
|
||||
|
||||
#if GS_WITH_GC
|
||||
tmp = NSAllocateCollectable(slen, 0);
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, slen);
|
||||
if (ptr != buf && ptr != *dst)
|
||||
{
|
||||
NSZoneFree(zone, ptr);
|
||||
}
|
||||
#endif
|
||||
ptr = tmp;
|
||||
if (ptr == 0)
|
||||
{
|
||||
return NO; /* Not enough memory */
|
||||
}
|
||||
bsize = slen;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strict == NO)
|
||||
{
|
||||
if (swapped == YES)
|
||||
{
|
||||
while (spos < slen)
|
||||
{
|
||||
unichar u = src[spos++];
|
||||
|
||||
u = (((u & 0xff00) >> 8) + ((u & 0x00ff) << 8));
|
||||
if (u < base)
|
||||
{
|
||||
ptr[dpos++] = (unsigned char)u;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr[dpos++] = '?';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (spos < slen)
|
||||
{
|
||||
unichar u = src[spos++];
|
||||
|
||||
if (u < base)
|
||||
{
|
||||
ptr[dpos++] = (unsigned char)u;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr[dpos++] = '?';
|
||||
}
|
||||
ptr[dpos++] = '?';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (swapped == YES)
|
||||
while (spos < slen)
|
||||
{
|
||||
while (spos < slen)
|
||||
{
|
||||
unichar u = src[spos++];
|
||||
unichar u = src[spos++];
|
||||
|
||||
if (swapped == YES)
|
||||
{
|
||||
u = (((u & 0xff00) >> 8) + ((u & 0x00ff) << 8));
|
||||
if (u < base)
|
||||
{
|
||||
ptr[dpos++] = (unsigned char)u;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = NO;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (spos < slen)
|
||||
if (dpos >= bsize)
|
||||
{
|
||||
unichar u = src[spos++];
|
||||
|
||||
if (u < base)
|
||||
{
|
||||
ptr[dpos++] = (unsigned char)u;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = NO;
|
||||
goto done;
|
||||
}
|
||||
GROW();
|
||||
}
|
||||
if (u < base)
|
||||
{
|
||||
ptr[dpos++] = (unsigned char)u;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = NO;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2434,7 +2112,7 @@ iconv_start:
|
|||
#else
|
||||
r = GSAutoreleasedBuffer(bytes);
|
||||
memcpy(r, ptr, bytes);
|
||||
if (ptr != buf && ptr != *dst)
|
||||
if (ptr != buf && (dst == 0 || ptr != *dst))
|
||||
{
|
||||
NSZoneFree(zone, ptr);
|
||||
}
|
||||
|
@ -2486,7 +2164,7 @@ iconv_start:
|
|||
}
|
||||
}
|
||||
#if !GS_WITH_GC
|
||||
else if (ptr != buf && ptr != *dst)
|
||||
else if (ptr != buf && dst != 0 && ptr != *dst)
|
||||
{
|
||||
NSZoneFree(zone, ptr);
|
||||
}
|
||||
|
|
|
@ -51,11 +51,8 @@ static unichar Next_char_to_uni_table[] =
|
|||
0x0192,
|
||||
0x00A7,
|
||||
0x00A4,
|
||||
0xFBA9,
|
||||
0x201C,
|
||||
0x00AB,
|
||||
0xFBAC,
|
||||
0xFBAD,
|
||||
0xFB01,
|
||||
0xFB02,
|
||||
0x00AE,
|
||||
|
@ -66,8 +63,6 @@ static unichar Next_char_to_uni_table[] =
|
|||
0x00A6,
|
||||
0x00B6,
|
||||
0x2022,
|
||||
0xFBB8,
|
||||
0xFBB9,
|
||||
0x201D,
|
||||
0x00BB,
|
||||
0x2026,
|
||||
|
|
|
@ -25,15 +25,6 @@
|
|||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(warning )
|
||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
||||
$(warning Perhaps gnustep-make is not properly installed,)
|
||||
$(warning so gnustep-config is not in your PATH.)
|
||||
$(warning )
|
||||
$(warning Your PATH is currently $(PATH))
|
||||
$(warning )
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
|
@ -47,7 +38,7 @@ include $(GNUSTEP_MAKEFILES)/common.make
|
|||
|
||||
include ../Version
|
||||
include ../config.mak
|
||||
-include pathconfig/pathconfig.mak
|
||||
include pathconfig/pathconfig.mak
|
||||
|
||||
# Interface version changes with each minor release
|
||||
libgnustep-base_INTERFACE_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)
|
||||
|
@ -231,7 +222,6 @@ NSNumberFormatter.m \
|
|||
NSObjCRuntime.m \
|
||||
NSObject.m \
|
||||
NSObject+NSComparisonMethods.m \
|
||||
NSOperation.m \
|
||||
NSPage.m \
|
||||
NSPathUtilities.m \
|
||||
NSPipe.m \
|
||||
|
@ -379,7 +369,6 @@ NSNull.h \
|
|||
NSNumberFormatter.h \
|
||||
NSObjCRuntime.h \
|
||||
NSObject.h \
|
||||
NSOperation.h \
|
||||
NSPathUtilities.h \
|
||||
NSPointerArray.h \
|
||||
NSPointerFunctions.h \
|
||||
|
|
|
@ -912,7 +912,7 @@ static Class GSInlineArrayClass;
|
|||
* get objects from after the end of the array. Don't pass negative values
|
||||
* to memcpy.
|
||||
*/
|
||||
if (count > 0)
|
||||
if (count >= 0)
|
||||
{
|
||||
memcpy(stackbuf, _contents_array + state->state, count * sizeof(id));
|
||||
state->state += count;
|
||||
|
|
|
@ -266,11 +266,32 @@ IMP gs_objc_msg_forward (SEL sel)
|
|||
* in the NSInvocation if the stack is changed before the
|
||||
* invocation is used.
|
||||
*/
|
||||
#if MFRAME_STRUCT_BYREF
|
||||
for (i = 0; i < ((cifframe_t *)_cframe)->nargs; i++)
|
||||
{
|
||||
const char *t = _info[i+1].type;
|
||||
|
||||
if (*t == _C_STRUCT_B || *t == _C_UNION_B || *t == _C_ARY_B)
|
||||
{
|
||||
/* Fix up some of the values. Do this on all processors that pass
|
||||
structs by reference.
|
||||
Is there an automatic way to determine this? */
|
||||
memcpy(((cifframe_t *)_cframe)->values[i], *(void **)vals[i],
|
||||
((cifframe_t *)_cframe)->arg_types[i]->size);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(((cifframe_t *)_cframe)->values[i], vals[i],
|
||||
((cifframe_t *)_cframe)->arg_types[i]->size);
|
||||
}
|
||||
}
|
||||
#else
|
||||
for (i = 0; i < ((cifframe_t *)_cframe)->nargs; i++)
|
||||
{
|
||||
memcpy(((cifframe_t *)_cframe)->values[i], vals[i],
|
||||
((cifframe_t *)_cframe)->arg_types[i]->size);
|
||||
}
|
||||
#endif
|
||||
_retval = retp;
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -485,7 +485,6 @@ NSString * const GSTelnetTextKey = @"GSTelnetTextKey";
|
|||
NSFileHandle *dHandle;
|
||||
NSURL *url;
|
||||
NSData *wData;
|
||||
NSString *term;
|
||||
enum {
|
||||
idle,
|
||||
cConnect, // Establishing control connection
|
||||
|
@ -554,7 +553,6 @@ static NSLock *urlLock = nil;
|
|||
}
|
||||
RELEASE(url);
|
||||
RELEASE(wData);
|
||||
RELEASE(term);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -600,46 +598,14 @@ static NSLock *urlLock = nil;
|
|||
|
||||
text = [info objectForKey: GSTelnetTextKey];
|
||||
// NSLog(@"Ctl: %@", text);
|
||||
/* Find first reply line which is not a continuation of another.
|
||||
/*
|
||||
* Find first reply line which is not a continuation of another.
|
||||
*/
|
||||
enumerator = [text objectEnumerator];
|
||||
while ((line = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if (term == nil)
|
||||
if ([line length] > 4 && [line characterAtIndex: 3] != '-')
|
||||
{
|
||||
if ([line length] > 4)
|
||||
{
|
||||
char buf[4];
|
||||
|
||||
buf[0] = (char)[line characterAtIndex: 0];
|
||||
buf[1] = (char)[line characterAtIndex: 1];
|
||||
buf[2] = (char)[line characterAtIndex: 2];
|
||||
buf[3] = (char)[line characterAtIndex: 3];
|
||||
if (isdigit(buf[0]) && isdigit(buf[1]) && isdigit(buf[2]))
|
||||
{
|
||||
if (buf[3] == '-')
|
||||
{
|
||||
/* Got start of a multiline block ...
|
||||
* set the terminator we need to look for.
|
||||
*/
|
||||
buf[3] = ' ';
|
||||
term = [[NSString alloc]
|
||||
initWithCString: buf length: 4];
|
||||
}
|
||||
else if (buf[3] == ' ')
|
||||
{
|
||||
/* Found single line response.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ([line hasPrefix: term] == YES)
|
||||
{
|
||||
/* Found end of a multiline response.
|
||||
*/
|
||||
DESTROY(term);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1096,20 +1096,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
|
||||
if (fstat(desc, &sbuf) < 0)
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
/* 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.
|
||||
*/
|
||||
isStandardFile = NO;
|
||||
#else
|
||||
/* This should never happen on unix. If it does, we have somehow
|
||||
* ended up with a bad descriptor.
|
||||
*/
|
||||
NSLog(@"unable to get status of descriptor %d - %@",
|
||||
desc, [NSError _last]);
|
||||
isStandardFile = NO;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -424,22 +424,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
|
||||
if ((id)NSMapGet(wProperties, (void*)@"Host") == nil)
|
||||
{
|
||||
id p = [u port];
|
||||
id h = [u host];
|
||||
|
||||
if (h == nil)
|
||||
{
|
||||
h = @""; // Must use an empty host header
|
||||
}
|
||||
if (p == nil)
|
||||
{
|
||||
NSMapInsert(wProperties, (void*)@"Host", (void*)h);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSMapInsert(wProperties, (void*)@"Host",
|
||||
(void*)[NSString stringWithFormat: @"%@:%@", h, p]);
|
||||
}
|
||||
NSMapInsert(wProperties, (void*)@"Host", (void*)[u host]);
|
||||
}
|
||||
|
||||
if ([wData length] > 0)
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
/* GSInternal
|
||||
Copyright (C) 2009 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 Lesser 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 Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02111 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* This file defines macros for managing internal (hidden) instance variables
|
||||
* of a public class so that users of the public class don't need to recompile
|
||||
* their code when the class implementation is changed in new versions of the
|
||||
* library.
|
||||
*
|
||||
* The public class MUST contain an instance variable 'id _internal;' to be
|
||||
* used as a pointer to a private class containing the ivars.
|
||||
*
|
||||
* Before including this file, you must define 'GSInternal' to be the name
|
||||
* of your public class with * 'Internal' appended.
|
||||
* eg. if your class is called 'MyClass' then use the following define:
|
||||
* #define GSInternal MyClassInternal
|
||||
*
|
||||
* After including this file you can use the GS_BEGIN_INTERNAL() and
|
||||
* GS_END_INTERNAL() macros to bracket the declaration of the instance
|
||||
* variables.
|
||||
*
|
||||
* You use GS_CREATE_INTERNAL() in your intialiser to create the object
|
||||
* holding the internal instance variables, and GS_DESTROY_INTERNAL() to
|
||||
* get rid of that object (only do this if '_internal' is not nil) in
|
||||
* your -dealloc method.
|
||||
*
|
||||
* Instance variables are referenced using the 'internal->ivar' suntax or
|
||||
* the GSIV(classname,object,ivar) macro.
|
||||
*
|
||||
* If built with CLANG (assumed to support non-fragile instance variables)
|
||||
* rather than GCC, the compiler/runtime can simply declare instance variables
|
||||
* within the implementation file so that they are not part of the public ABI,
|
||||
* in which case the macros here mostly reduce to nothing and the generated
|
||||
* code can be much more efficient.
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
|
||||
/* Code for GCC.
|
||||
*/
|
||||
|
||||
/* Start declaration of internal ivars.
|
||||
*/
|
||||
#define GS_BEGIN_INTERNAL(name) \
|
||||
@interface name ## Internal : NSObject \
|
||||
{ \
|
||||
@public
|
||||
|
||||
/* Finish declaration of internal ivars.
|
||||
*/
|
||||
#define GS_END_INTERNAL(name) \
|
||||
} \
|
||||
@end \
|
||||
@implementation name ## Internal \
|
||||
@end
|
||||
|
||||
/* Create holder for internal ivars.
|
||||
*/
|
||||
#define GS_CREATE_INTERNAL(name) \
|
||||
_internal = [name ## Internal new];
|
||||
|
||||
/* Create holder for internal ivars.
|
||||
*/
|
||||
#define GS_DESTROY_INTERNAL(name) \
|
||||
DESTROY(_internal);
|
||||
|
||||
#undef internal
|
||||
#define internal ((GSInternal*)_internal)
|
||||
#undef GSIVr
|
||||
#define GSIVar(X,Y) (((X ## Internal*)_internal)->Y)
|
||||
|
||||
#else /* defined(__GNUC__) */
|
||||
|
||||
/* Not GCC, so we assume this is CLANG with support for non-fragile ivars
|
||||
*/
|
||||
|
||||
#define GS_BEGIN_INTERNAL(name) \
|
||||
@interface name \
|
||||
{
|
||||
|
||||
/* Finish declaration of internal ivars.
|
||||
*/
|
||||
#define GS_END_INTERNAL(name) \
|
||||
} \
|
||||
@end
|
||||
|
||||
/* Create holder for internal ivars (nothing to do).
|
||||
*/
|
||||
#define GS_CREATE_INTERNAL(name)
|
||||
|
||||
#define GS_DESTROY_INTERNAL(name)
|
||||
|
||||
/* Define constant to reference internal ivars.
|
||||
*/
|
||||
#undef internal
|
||||
#define internal self
|
||||
#undef GSIVar
|
||||
#define GSIVar(X,Y) (self->Y)
|
||||
|
||||
#endif /* defined(__GNUC__) */
|
||||
|
||||
|
|
@ -409,14 +409,6 @@ static gnutls_anon_client_credentials_t anoncred;
|
|||
output: (GSSocketOutputStream*)o
|
||||
{
|
||||
NSString *proto = [i propertyForKey: NSStreamSocketSecurityLevelKey];
|
||||
BOOL server = NO;
|
||||
|
||||
/* FIXME
|
||||
if ([[o propertyForKey: NSStreamSocketCertificateServerKey] boolValue] == YES)
|
||||
{
|
||||
server = YES;
|
||||
}
|
||||
*/
|
||||
|
||||
if (GSDebugSet(@"NSStream") == YES)
|
||||
{
|
||||
|
@ -429,7 +421,6 @@ static gnutls_anon_client_credentials_t anoncred;
|
|||
|
||||
if ([[o propertyForKey: NSStreamSocketSecurityLevelKey] isEqual: proto] == NO)
|
||||
{
|
||||
NSLog(@"NSStreamSocketSecurityLevel on input stream does not match output stream");
|
||||
DESTROY(self);
|
||||
return nil;
|
||||
}
|
||||
|
@ -442,7 +433,7 @@ static gnutls_anon_client_credentials_t anoncred;
|
|||
else if ([proto isEqualToString: NSStreamSocketSecurityLevelSSLv2] == YES)
|
||||
{
|
||||
proto = NSStreamSocketSecurityLevelSSLv2;
|
||||
GSOnceMLog(@"NSStreamSocketSecurityLevelTLSv2 is insecure ..."
|
||||
GSOnceMLog(@"NSStreamSocketSecurityLevelTLSv1 is insecure ..."
|
||||
@" not implemented");
|
||||
DESTROY(self);
|
||||
return nil;
|
||||
|
@ -479,15 +470,7 @@ static gnutls_anon_client_credentials_t anoncred;
|
|||
|
||||
/* Initialise session and set default priorities foir key exchange.
|
||||
*/
|
||||
if (server)
|
||||
{
|
||||
gnutls_init (&session, GNUTLS_SERVER);
|
||||
/* FIXME ... need to set up DH information and key/certificate. */
|
||||
}
|
||||
else
|
||||
{
|
||||
gnutls_init (&session, GNUTLS_CLIENT);
|
||||
}
|
||||
gnutls_init (&session, GNUTLS_CLIENT);
|
||||
gnutls_set_default_priority (session);
|
||||
|
||||
if ([proto isEqualToString: NSStreamSocketSecurityLevelTLSv1] == YES)
|
||||
|
|
|
@ -2094,13 +2094,13 @@ isEqual_c(GSStr self, id anObject)
|
|||
if (c == NSConstantStringClass)
|
||||
{
|
||||
GSStr other = (GSStr)anObject;
|
||||
NSRange r = {0, self->_count};
|
||||
|
||||
if (other->_count == self->_count
|
||||
&& memcmp(other->_contents.c, self->_contents.c, self->_count) == 0)
|
||||
if (strCompCsCs((id)self, (id)other, 0, r) == NSOrderedSame)
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
else if (c == GSMutableStringClass)
|
||||
else if (GSObjCIsKindOf(c, GSStringClass) == YES || c == GSMutableStringClass)
|
||||
{
|
||||
GSStr other = (GSStr)anObject;
|
||||
NSRange r = {0, self->_count};
|
||||
|
@ -2125,32 +2125,11 @@ isEqual_c(GSStr self, id anObject)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (other->_count == self->_count
|
||||
&& memcmp(other->_contents.c, self->_contents.c, self->_count) == 0)
|
||||
if (strCompCsCs((id)self, (id)other, 0, r) == NSOrderedSame)
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
else if (GSObjCIsKindOf(c, GSStringClass) == YES)
|
||||
{
|
||||
GSStr other = (GSStr)anObject;
|
||||
|
||||
/*
|
||||
* First see if the hash is the same - if not, we can't be equal.
|
||||
*/
|
||||
if (self->_flags.hash == 0)
|
||||
self->_flags.hash = (*hashImp)((id)self, hashSel);
|
||||
if (other->_flags.hash == 0)
|
||||
other->_flags.hash = (*hashImp)((id)other, hashSel);
|
||||
if (self->_flags.hash != other->_flags.hash)
|
||||
return NO;
|
||||
|
||||
if (other->_count == self->_count
|
||||
&& memcmp(other->_contents.c, self->_contents.c, self->_count) == 0)
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
else if (GSObjCIsKindOf(c, NSStringClass))
|
||||
{
|
||||
return (*equalImp)((id)self, equalSel, anObject);
|
||||
|
@ -5074,33 +5053,23 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
|||
|
||||
if (len > 0)
|
||||
{
|
||||
register const unsigned char *p;
|
||||
register unsigned index = 0;
|
||||
const unsigned char *p;
|
||||
unsigned char_count = 0;
|
||||
|
||||
p = _self->_contents.c;
|
||||
if (internalEncoding == NSISOLatin1StringEncoding)
|
||||
while (char_count++ < len)
|
||||
{
|
||||
while (index < len)
|
||||
{
|
||||
ret = (ret << 5) + ret + p[index++];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (index < len)
|
||||
{
|
||||
unichar u = p[index++];
|
||||
unichar u = *p++;
|
||||
|
||||
if (u > 127)
|
||||
{
|
||||
unsigned char c = (unsigned char)u;
|
||||
unsigned int s = 1;
|
||||
unichar *d = &u;
|
||||
if (u > 127 && internalEncoding != NSISOLatin1StringEncoding)
|
||||
{
|
||||
unsigned char c = (unsigned char)u;
|
||||
unsigned int s = 1;
|
||||
unichar *d = &u;
|
||||
|
||||
GSToUnicode(&d, &s, &c, 1, internalEncoding, 0, 0);
|
||||
}
|
||||
ret = (ret << 5) + ret + u;
|
||||
GSToUnicode(&d, &s, &c, 1, internalEncoding, 0, 0);
|
||||
}
|
||||
ret = (ret << 5) + ret + u;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -379,12 +379,13 @@ GSEQ_STRCOMP(NSString *ss, NSString *os, unsigned mask, NSRange aRange)
|
|||
GSEQ_ST s = (GSEQ_ST)ss;
|
||||
GSEQ_OT o = (GSEQ_OT)os;
|
||||
unsigned oLength; /* Length of other. */
|
||||
unsigned sLength = GSEQ_SLEN;
|
||||
|
||||
#if 0
|
||||
/* Range should be checked in calling code */
|
||||
if (aRange.location > GSEQ_SLEN)
|
||||
if (aRange.location > sLength)
|
||||
[NSException raise: NSRangeException format: @"Invalid location."];
|
||||
if (aRange.length > (GSEQ_SLEN - aRange.location))
|
||||
if (aRange.length > (sLength - aRange.location))
|
||||
[NSException raise: NSRangeException format: @"Invalid location+length."];
|
||||
#endif
|
||||
|
||||
|
@ -461,13 +462,8 @@ GSEQ_STRCOMP(NSString *ss, NSString *os, unsigned mask, NSRange aRange)
|
|||
{
|
||||
for (i = 0; i < end; i++)
|
||||
{
|
||||
#if GSEQ_O == GSEQ_CS && GSEQ_S == GSEQ_CS
|
||||
char c1 = tolower(sBuf[i]);
|
||||
char c2 = tolower(oBuf[i]);
|
||||
#else
|
||||
unichar c1 = uni_tolower((unichar)sBuf[i]);
|
||||
unichar c2 = uni_tolower((unichar)oBuf[i]);
|
||||
#endif
|
||||
|
||||
if (c1 < c2)
|
||||
return NSOrderedAscending;
|
||||
|
@ -479,17 +475,10 @@ GSEQ_STRCOMP(NSString *ss, NSString *os, unsigned mask, NSRange aRange)
|
|||
{
|
||||
for (i = 0; i < end; i++)
|
||||
{
|
||||
#if GSEQ_O == GSEQ_CS && GSEQ_S == GSEQ_CS
|
||||
if (sBuf[i] < oBuf[i])
|
||||
return NSOrderedAscending;
|
||||
if (sBuf[i] > oBuf[i])
|
||||
return NSOrderedDescending;
|
||||
#else
|
||||
if ((unichar)sBuf[i] < (unichar)oBuf[i])
|
||||
return NSOrderedAscending;
|
||||
if ((unichar)sBuf[i] > (unichar)oBuf[i])
|
||||
return NSOrderedDescending;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (sLen > oLen)
|
||||
|
@ -503,7 +492,6 @@ GSEQ_STRCOMP(NSString *ss, NSString *os, unsigned mask, NSRange aRange)
|
|||
{
|
||||
unsigned start = aRange.location;
|
||||
unsigned end = start + aRange.length;
|
||||
unsigned sLength = GSEQ_SLEN;
|
||||
unsigned sCount = start;
|
||||
unsigned oCount = 0;
|
||||
NSComparisonResult result;
|
||||
|
|
|
@ -96,11 +96,7 @@ after-clean::
|
|||
# Things to do after distcleaning
|
||||
after-distclean::
|
||||
rm -f mframe/mframe.h Foundation \
|
||||
NSNumber[0-9]*.m GSValue[0-9]*.m \
|
||||
pathconfig/config.log \
|
||||
pathconfig/config.status \
|
||||
pathconfig/pathconfig.h \
|
||||
pathconfig/pathconfig.mak \
|
||||
NSNumber[0-9]*.m GSValue[0-9]*.m
|
||||
rm -rf $(GNUSTEP_TARGET_DIR)/GNUstepBase
|
||||
rm -rf $(GNUSTEP_TARGET_DIR)/mframe.h
|
||||
rm -rf $(GNUSTEP_TARGET_DIR)/mframe.h
|
||||
|
|
|
@ -57,9 +57,13 @@
|
|||
|
||||
static BOOL GSMacOSXCompatiblePropertyLists(void)
|
||||
{
|
||||
#if defined(HAVE_LIBXML)
|
||||
if (GSPrivateDefaultsFlag(NSWriteOldStylePropertyLists) == YES)
|
||||
return NO;
|
||||
return GSPrivateDefaultsFlag(GSMacOSXCompatible);
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern void GSPropertyListMake(id,NSDictionary*,BOOL,BOOL,unsigned,id*);
|
||||
|
@ -382,43 +386,6 @@ static SEL rlSel;
|
|||
return 0;
|
||||
}
|
||||
|
||||
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
|
||||
objects: (id*)stackbuf
|
||||
count: (NSUInteger)len
|
||||
{
|
||||
NSUInteger size = [self count];
|
||||
NSInteger count;
|
||||
|
||||
/* This is cached in the caller at the start and compared at each
|
||||
* iteration. If it changes during the iteration then
|
||||
* objc_enumerationMutation() will be called, throwing an exception.
|
||||
*/
|
||||
state->mutationsPtr = (unsigned long *)size;
|
||||
count = MIN(len, size - state->state);
|
||||
/* If a mutation has occurred then it's possible that we are being asked to
|
||||
* get objects from after the end of the array. Don't pass negative values
|
||||
* to memcpy.
|
||||
*/
|
||||
if (count > 0)
|
||||
{
|
||||
IMP imp = [self methodForSelector: @selector(objectAtIndex:)];
|
||||
int p = state->state;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++, p++)
|
||||
{
|
||||
stackbuf[i] = (*imp)(self, @selector(objectAtIndex:), p);
|
||||
}
|
||||
state->state += count;
|
||||
}
|
||||
else
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
state->itemsPtr = stackbuf;
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the receiver for storing to archive or sending over an
|
||||
* [NSConnection].
|
||||
|
|
|
@ -152,32 +152,19 @@ static Class GSMutableAttributedStringClass;
|
|||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
[aCoder encodeObject: [self string] forKey: @"NSString"];
|
||||
if ([self length] > 0)
|
||||
{
|
||||
NSDictionary* attrs = [self attributesAtIndex: 0 effectiveRange: NULL];
|
||||
NSRange r = NSMakeRange(0, 0);
|
||||
unsigned index = NSMaxRange(r);
|
||||
unsigned length = [self length];
|
||||
NSString *string = [self string];
|
||||
NSDictionary *attrs;
|
||||
|
||||
[aCoder encodeObject: attrs forKey: @"NSAttributes"];
|
||||
}
|
||||
}
|
||||
else
|
||||
[aCoder encodeObject: string];
|
||||
while (index < length)
|
||||
{
|
||||
NSRange r = NSMakeRange(0, 0);
|
||||
unsigned index = NSMaxRange(r);
|
||||
unsigned length = [self length];
|
||||
NSString *string = [self string];
|
||||
NSDictionary *attrs;
|
||||
|
||||
[aCoder encodeObject: string];
|
||||
while (index < length)
|
||||
{
|
||||
attrs = [self attributesAtIndex: index effectiveRange: &r];
|
||||
index = NSMaxRange(r);
|
||||
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &index];
|
||||
[aCoder encodeObject: attrs];
|
||||
}
|
||||
attrs = [self attributesAtIndex: index effectiveRange: &r];
|
||||
index = NSMaxRange(r);
|
||||
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &index];
|
||||
[aCoder encodeObject: attrs];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +188,7 @@ static Class GSMutableAttributedStringClass;
|
|||
}
|
||||
else
|
||||
{
|
||||
unsigned index;
|
||||
unsigned index;
|
||||
NSDictionary *attrs;
|
||||
|
||||
[aDecoder decodeValueOfObjCType: @encode(unsigned) at: &index];
|
||||
|
@ -640,53 +627,42 @@ static Class GSMutableAttributedStringClass;
|
|||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
if ([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
NSString *string = [aDecoder decodeObjectForKey: @"NSString"];
|
||||
NSDictionary *attributes = [aDecoder decodeObjectForKey: @"NSAttributes"];
|
||||
NSString *string = [aDecoder decodeObject];
|
||||
unsigned length = [string length];
|
||||
|
||||
self = [self initWithString: string attributes: attributes];
|
||||
if (length == 0)
|
||||
{
|
||||
self = [self initWithString: string attributes: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *string = [aDecoder decodeObject];
|
||||
unsigned length = [string length];
|
||||
unsigned index;
|
||||
NSDictionary *attrs;
|
||||
|
||||
if (length == 0)
|
||||
[aDecoder decodeValueOfObjCType: @encode(unsigned) at: &index];
|
||||
attrs = [aDecoder decodeObject];
|
||||
if (index == length)
|
||||
{
|
||||
self = [self initWithString: string attributes: nil];
|
||||
self = [self initWithString: string attributes: attrs];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned index;
|
||||
NSDictionary *attrs;
|
||||
NSRange r = NSMakeRange(0, index);
|
||||
unsigned last = index;
|
||||
|
||||
[aDecoder decodeValueOfObjCType: @encode(unsigned) at: &index];
|
||||
attrs = [aDecoder decodeObject];
|
||||
if (index == length)
|
||||
self = [self initWithString: string attributes: nil];
|
||||
[self setAttributes: attrs range: r];
|
||||
while (index < length)
|
||||
{
|
||||
self = [self initWithString: string attributes: attrs];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSRange r = NSMakeRange(0, index);
|
||||
unsigned last = index;
|
||||
|
||||
self = [self initWithString: string attributes: nil];
|
||||
[self setAttributes: attrs range: r];
|
||||
while (index < length)
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(unsigned)
|
||||
[aDecoder decodeValueOfObjCType: @encode(unsigned)
|
||||
at: &index];
|
||||
attrs = [aDecoder decodeObject];
|
||||
r = NSMakeRange(last, index - last);
|
||||
[self setAttributes: attrs range: r];
|
||||
last = index;
|
||||
}
|
||||
attrs = [aDecoder decodeObject];
|
||||
r = NSMakeRange(last, index - last);
|
||||
[self setAttributes: attrs range: r];
|
||||
last = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ bundle_object_name(NSString *path, NSString* executable)
|
|||
path = [path stringByAppendingPathComponent: gnustep_target_dir];
|
||||
path1 = [path stringByAppendingPathComponent: name];
|
||||
path = [path stringByAppendingPathComponent: library_combo];
|
||||
path2 = [path stringByAppendingPathComponent: name];
|
||||
path2 = [path stringByAppendingPathComponent: executable];
|
||||
|
||||
if ([mgr isReadableFileAtPath: path2] == YES)
|
||||
return path2;
|
||||
|
@ -328,24 +328,7 @@ bundle_object_name(NSString *path, NSString* executable)
|
|||
return path1;
|
||||
else if ([mgr isReadableFileAtPath: path0] == YES)
|
||||
return path0;
|
||||
#if defined(__MINGW32__)
|
||||
/* If we couldn't find the binary, and we are on windows, and the name
|
||||
* has no path extension, then let's try looking for a dll.
|
||||
*/
|
||||
if ([name pathExtension] == nil)
|
||||
{
|
||||
if ([mgr isReadableFileAtPath:
|
||||
[path2 stringByAppendingPathExtension: @"dll"]] == YES)
|
||||
return [path2 stringByAppendingPathExtension: @"dll"];
|
||||
else if ([mgr isReadableFileAtPath:
|
||||
[path1 stringByAppendingPathExtension: @"dll"]] == YES)
|
||||
return [path1 stringByAppendingPathExtension: @"dll"];
|
||||
else if ([mgr isReadableFileAtPath:
|
||||
[path0 stringByAppendingPathExtension: @"dll"]] == YES)
|
||||
return [path0 stringByAppendingPathExtension: @"dll"];
|
||||
}
|
||||
#endif
|
||||
return path0;
|
||||
return path2;
|
||||
}
|
||||
|
||||
/* Construct a path from components */
|
||||
|
|
|
@ -70,7 +70,6 @@ static NSString *cformat = @"%Y-%m-%d %H:%M:%S %z";
|
|||
|
||||
static NSTimeZone *localTZ = nil;
|
||||
|
||||
static Class NSCalendarDateClass;
|
||||
static Class absClass;
|
||||
static Class dstClass;
|
||||
|
||||
|
@ -322,7 +321,6 @@ GSTimeNow(void)
|
|||
{
|
||||
if (self == [NSCalendarDate class])
|
||||
{
|
||||
NSCalendarDateClass = self;
|
||||
[self setVersion: 1];
|
||||
localTZ = RETAIN([NSTimeZone localTimeZone]);
|
||||
|
||||
|
@ -1297,7 +1295,7 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
|
||||
if ((had & (hadY|hadw)) != (hadY|hadw))
|
||||
{
|
||||
NSCalendarDate *now = [[NSCalendarDateClass alloc] init];
|
||||
NSCalendarDate *now = [[NSCalendarDate alloc] init];
|
||||
|
||||
[now setTimeZone: gmtZone];
|
||||
if ((had & hadY) == 0)
|
||||
|
@ -1313,13 +1311,13 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
RELEASE(now);
|
||||
}
|
||||
|
||||
d = [[NSCalendarDateClass alloc] initWithYear: year
|
||||
month: 1
|
||||
day: 1
|
||||
hour: 0
|
||||
minute: 0
|
||||
second: 0
|
||||
timeZone: gmtZone];
|
||||
d = [[NSCalendarDate alloc] initWithYear: year
|
||||
month: 1
|
||||
day: 1
|
||||
hour: 0
|
||||
minute: 0
|
||||
second: 0
|
||||
timeZone: gmtZone];
|
||||
currDay = [d dayOfWeek];
|
||||
RELEASE(d);
|
||||
|
||||
|
@ -1349,7 +1347,7 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
*/
|
||||
if ((had & hadY) == 0)
|
||||
{
|
||||
NSCalendarDate *now = [[NSCalendarDateClass alloc] init];
|
||||
NSCalendarDate *now = [[NSCalendarDate alloc] init];
|
||||
|
||||
year = [now yearOfCommonEra];
|
||||
RELEASE(now);
|
||||
|
@ -1785,21 +1783,6 @@ static void Grow(DescriptionInfo *info, unsigned size)
|
|||
}
|
||||
}
|
||||
|
||||
#define MAX_FLD_WIDTH 99
|
||||
|
||||
static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
||||
{
|
||||
char cbuf[MAX_FLD_WIDTH + 1];
|
||||
int idx = 0;
|
||||
|
||||
sprintf((char*)cbuf, fldfmt, v);
|
||||
Grow(info, strlen((char*)cbuf));
|
||||
while (cbuf[idx] != '\0')
|
||||
{
|
||||
info->t[info->offset++] = cbuf[idx++];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _format: (NSString*)fmt
|
||||
locale: (NSDictionary*)locale
|
||||
info: (DescriptionInfo*)info
|
||||
|
@ -1831,27 +1814,11 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
BOOL mname = NO;
|
||||
BOOL dname = NO;
|
||||
BOOL twelve = NO;
|
||||
char fldfmt[8];
|
||||
int fmtlen = 0;
|
||||
int width = 0;
|
||||
|
||||
// Only care about a format specifier
|
||||
if (f[i] == '%')
|
||||
{
|
||||
i++;
|
||||
fldfmt[fmtlen++] = '%'; // start format with %
|
||||
while (fmtlen < 5 && f[i] >= '0' && f[i] <= '9') // field width specified
|
||||
{
|
||||
fldfmt[fmtlen++] = f[i];
|
||||
width = 10 * width + f[i] - '0';
|
||||
i++;
|
||||
}
|
||||
if (fmtlen >= 5 || width > MAX_FLD_WIDTH)
|
||||
{
|
||||
// ignore formats that specify field width greater than the max allowed
|
||||
i -= fmtlen; // set i back so all ignored characters will be copied
|
||||
}
|
||||
|
||||
// check the character that comes after
|
||||
switch (f[i++])
|
||||
{
|
||||
|
@ -1908,25 +1875,41 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
v = info->yd;
|
||||
if (ycent)
|
||||
{
|
||||
if (fmtlen == 1) // no format width specified; supply default
|
||||
if (v >= 0 && v <= 9999)
|
||||
{
|
||||
fldfmt[fmtlen++] = '0';
|
||||
fldfmt[fmtlen++] = '4';
|
||||
Grow(info, 4);
|
||||
info->t[info->offset+3] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+2] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char tmp[16];
|
||||
int idx = 0;
|
||||
|
||||
sprintf((char*)tmp, "%d", v);
|
||||
Grow(info, strlen((char*)tmp));
|
||||
while (tmp[idx] != '\0')
|
||||
{
|
||||
info->t[info->offset++] = tmp[idx++];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Grow(info, 2);
|
||||
if (v < 0) v = -v;
|
||||
v = v % 100;
|
||||
if (fmtlen == 1) // no format width specified; supply default
|
||||
{
|
||||
fldfmt[fmtlen++] = '0';
|
||||
fldfmt[fmtlen++] = '2';
|
||||
}
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 2;
|
||||
}
|
||||
fldfmt[fmtlen++] = 'd';
|
||||
fldfmt[fmtlen++] = 0;
|
||||
outputValueWithFormat(v, fldfmt, info);
|
||||
break;
|
||||
|
||||
// is it the month
|
||||
|
@ -1961,41 +1944,40 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
if (mtag == NO)
|
||||
{
|
||||
v = info->md;
|
||||
Grow(info, 2);
|
||||
v = v % 100;
|
||||
if (fmtlen == 1) // no format width specified; supply default
|
||||
{
|
||||
fldfmt[fmtlen++] = '0';
|
||||
fldfmt[fmtlen++] = '2';
|
||||
}
|
||||
fldfmt[fmtlen++] = 'd';
|
||||
fldfmt[fmtlen++] = 0;
|
||||
outputValueWithFormat(v, fldfmt, info);
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd': // day of month with leading zero
|
||||
v = info->dom;
|
||||
Grow(info, 2);
|
||||
v = v % 100;
|
||||
if (fmtlen == 1) // no format width specified; supply default
|
||||
{
|
||||
fldfmt[fmtlen++] = '0';
|
||||
fldfmt[fmtlen++] = '2';
|
||||
}
|
||||
fldfmt[fmtlen++] = 'd';
|
||||
fldfmt[fmtlen++] = 0;
|
||||
outputValueWithFormat(v, fldfmt, info);
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 2;
|
||||
break;
|
||||
|
||||
case 'e': // day of month with leading space
|
||||
v = info->dom;
|
||||
Grow(info, 2);
|
||||
v = v % 100;
|
||||
if (fmtlen == 1) // no format width specified; supply default
|
||||
{
|
||||
fldfmt[fmtlen++] = '1'; // no leading space, just like Cocoa
|
||||
}
|
||||
fldfmt[fmtlen++] = 'd';
|
||||
fldfmt[fmtlen++] = 0;
|
||||
outputValueWithFormat(v, fldfmt, info);
|
||||
if (v%10 == '0')
|
||||
{
|
||||
info->t[info->offset+1] = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
}
|
||||
v /= 10;
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 2;
|
||||
break;
|
||||
|
||||
case 'F': // milliseconds
|
||||
|
@ -2009,26 +1991,24 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
s *= 1000.0;
|
||||
v = (NSInteger)(s + 0.5);
|
||||
}
|
||||
if (fmtlen == 1) // no format width specified; supply default
|
||||
{
|
||||
fldfmt[fmtlen++] = '0';
|
||||
fldfmt[fmtlen++] = '3';
|
||||
}
|
||||
fldfmt[fmtlen++] = 'd';
|
||||
fldfmt[fmtlen++] = 0;
|
||||
outputValueWithFormat(v, fldfmt, info);
|
||||
Grow(info, 3);
|
||||
info->t[info->offset+2] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 3;
|
||||
break;
|
||||
|
||||
case 'j': // day of year
|
||||
v = [self dayOfYear];
|
||||
if (fmtlen == 1) // no format width specified; supply default
|
||||
{
|
||||
fldfmt[fmtlen++] = '0';
|
||||
fldfmt[fmtlen++] = '3';
|
||||
}
|
||||
fldfmt[fmtlen++] = 'd';
|
||||
fldfmt[fmtlen++] = 0;
|
||||
outputValueWithFormat(v, fldfmt, info);
|
||||
Grow(info, 3);
|
||||
info->t[info->offset+2] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 3;
|
||||
break;
|
||||
|
||||
// is it the week-day
|
||||
|
@ -2064,13 +2044,8 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
}
|
||||
if (dtag == NO)
|
||||
{
|
||||
if (fmtlen == 1) // no format width specified; supply default
|
||||
{
|
||||
fldfmt[fmtlen++] = '1';
|
||||
}
|
||||
fldfmt[fmtlen++] = 'd';
|
||||
fldfmt[fmtlen++] = 0;
|
||||
outputValueWithFormat(v, fldfmt, info);
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2091,40 +2066,31 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
v = v % 12;
|
||||
}
|
||||
}
|
||||
if (fmtlen == 1) // no format width specified; supply default
|
||||
{
|
||||
fldfmt[fmtlen++] = '0';
|
||||
fldfmt[fmtlen++] = '2';
|
||||
}
|
||||
fldfmt[fmtlen++] = 'd';
|
||||
fldfmt[fmtlen++] = 0;
|
||||
outputValueWithFormat(v, fldfmt, info);
|
||||
Grow(info, 2);
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 2;
|
||||
break;
|
||||
|
||||
// is it the minute
|
||||
case 'M':
|
||||
v = info->mnd;
|
||||
if (fmtlen == 1) // no format width specified; supply default
|
||||
{
|
||||
fldfmt[fmtlen++] = '0';
|
||||
fldfmt[fmtlen++] = '2';
|
||||
}
|
||||
fldfmt[fmtlen++] = 'd';
|
||||
fldfmt[fmtlen++] = 0;
|
||||
outputValueWithFormat(v, fldfmt, info);
|
||||
Grow(info, 2);
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 2;
|
||||
break;
|
||||
|
||||
// is it the second
|
||||
case 'S':
|
||||
v = info->sd;
|
||||
if (fmtlen == 1) // no format width specified; supply default
|
||||
{
|
||||
fldfmt[fmtlen++] = '0';
|
||||
fldfmt[fmtlen++] = '2';
|
||||
}
|
||||
fldfmt[fmtlen++] = 'd';
|
||||
fldfmt[fmtlen++] = 0;
|
||||
outputValueWithFormat(v, fldfmt, info);
|
||||
Grow(info, 2);
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 2;
|
||||
break;
|
||||
|
||||
// Is it the am/pm indicator
|
||||
|
@ -2477,6 +2443,16 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
*/
|
||||
@implementation NSCalendarDate (OPENSTEP)
|
||||
|
||||
/**
|
||||
* <p>Returns a calendar date formed by adding the specified offsets to the
|
||||
* receiver. The offsets are added in order, years, then months, then
|
||||
* days, then hours then minutes then seconds, so if you add 1 month and
|
||||
* forty days to 20th September, the result will be 9th November.
|
||||
* </p>
|
||||
* <p>This method understands leap years and tries to adjust for daylight
|
||||
* savings time changes so that it preserves expected clock time.
|
||||
* </p>
|
||||
*/
|
||||
- (NSCalendarDate*) dateByAddingYears: (NSInteger)years
|
||||
months: (NSInteger)months
|
||||
days: (NSInteger)days
|
||||
|
@ -2592,9 +2568,9 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
*/
|
||||
s = GSTime(day, month, year, hour, minute, second, mil);
|
||||
s -= oldOffset;
|
||||
c = [NSCalendarDateClass alloc];
|
||||
c->_calendar_format = [_calendar_format copy];
|
||||
c->_time_zone = [_time_zone copy];
|
||||
c = [NSCalendarDate alloc];
|
||||
c->_calendar_format = cformat;
|
||||
c->_time_zone = RETAIN([self timeZone]);
|
||||
c->_seconds_since_ref = s;
|
||||
|
||||
/*
|
||||
|
@ -2655,13 +2631,13 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
/* FIXME What if the two dates are in different time zones?
|
||||
How about daylight savings time?
|
||||
*/
|
||||
if ([date isKindOfClass: NSCalendarDateClass])
|
||||
if ([date isKindOfClass: [NSCalendarDate class]])
|
||||
{
|
||||
tmp = (NSCalendarDate*)RETAIN(date);
|
||||
}
|
||||
else if ([date isKindOfClass: [NSDate class]])
|
||||
{
|
||||
tmp = [[NSCalendarDateClass alloc] initWithTimeIntervalSinceReferenceDate:
|
||||
tmp = [[NSCalendarDate alloc] initWithTimeIntervalSinceReferenceDate:
|
||||
[date timeIntervalSinceReferenceDate]];
|
||||
}
|
||||
else
|
||||
|
|
|
@ -41,8 +41,8 @@
|
|||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
|
||||
#define GNUSTEP_INDEX_CHARSET 1
|
||||
//#undef GNUSTEP_INDEX_CHARSET
|
||||
//#define GNUSTEP_INDEX_CHARSET 1
|
||||
#undef GNUSTEP_INDEX_CHARSET
|
||||
|
||||
#include "NSCharacterSetData.h"
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
|
||||
#import "NSConcretePointerFunctions.h"
|
||||
#import "NSCallBacks.h"
|
||||
#import "GSPrivate.h"
|
||||
|
||||
static Class concreteClass = 0;
|
||||
|
||||
|
@ -63,7 +62,6 @@ typedef GSIMapNode_t *GSIMapNode;
|
|||
GSIMapNode *nodeChunks; /* Chunks of allocated memory. */
|
||||
size_t chunkCount; /* Number of chunks in array. */
|
||||
size_t increment; /* Amount to grow by. */
|
||||
unsigned long version; /* For fast enumeration. */
|
||||
BOOL legacy; /* old style callbacks? */
|
||||
union {
|
||||
PFInfo pf;
|
||||
|
@ -87,9 +85,6 @@ typedef GSIMapNode_t *GSIMapNode;
|
|||
#define GSI_MAP_RETAIN_KEY(M, X)\
|
||||
(M->legacy ? M->cb.old.retain(M, X.ptr) \
|
||||
: pointerFunctionsAcquire(&M->cb.pf, &X.ptr, X.ptr))
|
||||
#define GSI_MAP_ZEROED(M)\
|
||||
(M->legacy ? 0 \
|
||||
: ((M->cb.pf.options & NSPointerFunctionsZeroingWeakMemory) ? YES : NO))
|
||||
|
||||
#define GSI_MAP_ENUMERATOR NSHashEnumerator
|
||||
|
||||
|
@ -112,7 +107,29 @@ static GC_descr nodeW = 0;
|
|||
NSArray *
|
||||
NSAllHashTableObjects(NSHashTable *table)
|
||||
{
|
||||
return [table allObjects];
|
||||
NSMutableArray *array;
|
||||
NSHashEnumerator enumerator;
|
||||
id element;
|
||||
|
||||
if (table == nil)
|
||||
{
|
||||
NSWarnFLog(@"Null table argument supplied");
|
||||
return nil;
|
||||
}
|
||||
|
||||
/* Create our mutable key array. */
|
||||
array = [NSMutableArray arrayWithCapacity: NSCountHashTable(table)];
|
||||
|
||||
/* Get an enumerator for TABLE. */
|
||||
enumerator = NSEnumerateHashTable(table);
|
||||
|
||||
/* Step through TABLE... */
|
||||
while ((element = NSNextHashEnumeratorItem(&enumerator)) != nil)
|
||||
{
|
||||
[array addObject: element];
|
||||
}
|
||||
NSEndHashTableEnumeration(&enumerator);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -263,7 +280,12 @@ NSCopyHashTableWithZone(NSHashTable *table, NSZone *zone)
|
|||
unsigned int
|
||||
NSCountHashTable(NSHashTable *table)
|
||||
{
|
||||
return [table count];
|
||||
if (table == nil)
|
||||
{
|
||||
NSWarnFLog(@"Null table argument supplied");
|
||||
return 0;
|
||||
}
|
||||
return ((GSIMapTable)table)->nodeCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -339,22 +361,7 @@ NSEndHashTableEnumeration(NSHashEnumerator *enumerator)
|
|||
NSWarnFLog(@"Null enumerator argument supplied");
|
||||
return;
|
||||
}
|
||||
if (enumerator->map != 0)
|
||||
{
|
||||
/* The 'map' field is non-null, so this NSHashEnumerator is actually
|
||||
* a GSIMapEnumerator.
|
||||
*/
|
||||
GSIMapEndEnumerator((GSIMapEnumerator)enumerator);
|
||||
}
|
||||
else if (enumerator->node != 0)
|
||||
{
|
||||
/* The 'map' field is null but the 'node' field is not, so the
|
||||
* NSHashEnumerator structure actually contains an NSEnumerator
|
||||
* in the 'node' field.
|
||||
*/
|
||||
[(id)enumerator->node release];
|
||||
memset(enumerator, '\0', sizeof(GSIMapEnumerator));
|
||||
}
|
||||
GSIMapEndEnumerator((GSIMapEnumerator)enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -371,17 +378,7 @@ NSEnumerateHashTable(NSHashTable *table)
|
|||
NSWarnFLog(@"Null table argument supplied");
|
||||
return v;
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
{
|
||||
return GSIMapEnumeratorForMap((GSIMapTable)table);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSHashEnumerator v = {0, 0, 0};
|
||||
|
||||
v.node = (void*)[[table objectEnumerator] retain];
|
||||
return v;
|
||||
}
|
||||
return GSIMapEnumeratorForMap((GSIMapTable)table);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -393,7 +390,14 @@ NSEnumerateHashTable(NSHashTable *table)
|
|||
void
|
||||
NSFreeHashTable(NSHashTable *table)
|
||||
{
|
||||
[table release];
|
||||
if (table == nil)
|
||||
{
|
||||
NSWarnFLog(@"Null table argument supplied");
|
||||
}
|
||||
else
|
||||
{
|
||||
[table release];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -403,26 +407,22 @@ NSFreeHashTable(NSHashTable *table)
|
|||
void *
|
||||
NSHashGet(NSHashTable *table, const void *element)
|
||||
{
|
||||
GSIMapNode n;
|
||||
|
||||
if (table == nil)
|
||||
{
|
||||
NSWarnFLog(@"Null table argument supplied");
|
||||
return 0;
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
n = GSIMapNodeForKey((GSIMapTable)table, (GSIMapKey)element);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapNode n;
|
||||
|
||||
n = GSIMapNodeForKey((GSIMapTable)table, (GSIMapKey)element);
|
||||
if (n == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return n->key.ptr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return n->key.ptr;
|
||||
}
|
||||
return [table member: (id)element];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -433,6 +433,9 @@ NSHashGet(NSHashTable *table, const void *element)
|
|||
void
|
||||
NSHashInsert(NSHashTable *table, const void *element)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
GSIMapNode n;
|
||||
|
||||
if (table == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
|
@ -443,28 +446,16 @@ NSHashInsert(NSHashTable *table, const void *element)
|
|||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place null in hash table"];
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)element);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
GSIMapNode n;
|
||||
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)element);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapAddKey(t, (GSIMapKey)element);
|
||||
((NSConcreteHashTable*)table)->version++;
|
||||
}
|
||||
else if (element != n->key.ptr)
|
||||
{
|
||||
GSI_MAP_RELEASE_KEY(t, n->key);
|
||||
n->key = (GSIMapKey)element;
|
||||
GSI_MAP_RETAIN_KEY(t, n->key);
|
||||
((NSConcreteHashTable*)table)->version++;
|
||||
}
|
||||
GSIMapAddKey(t, (GSIMapKey)element);
|
||||
}
|
||||
else
|
||||
{
|
||||
[table addObject: (id)element];
|
||||
GSI_MAP_RELEASE_KEY(t, n->key);
|
||||
n->key = (GSIMapKey)element;
|
||||
GSI_MAP_RETAIN_KEY(t, n->key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -477,6 +468,9 @@ NSHashInsert(NSHashTable *table, const void *element)
|
|||
void *
|
||||
NSHashInsertIfAbsent(NSHashTable *table, const void *element)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
GSIMapNode n;
|
||||
|
||||
if (table == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
|
@ -487,36 +481,15 @@ NSHashInsertIfAbsent(NSHashTable *table, const void *element)
|
|||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place null in hash table"];
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)element);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
GSIMapNode n;
|
||||
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)element);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapAddKey(t, (GSIMapKey)element);
|
||||
((NSConcreteHashTable*)table)->version++;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return n->key.ptr;
|
||||
}
|
||||
GSIMapAddKey(t, (GSIMapKey)element);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
id old = [table member: (id)element];
|
||||
|
||||
if (old == nil)
|
||||
{
|
||||
[table addObject: (id)element];
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (void*)old;
|
||||
}
|
||||
return n->key.ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -528,6 +501,9 @@ NSHashInsertIfAbsent(NSHashTable *table, const void *element)
|
|||
void
|
||||
NSHashInsertKnownAbsent(NSHashTable *table, const void *element)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
GSIMapNode n;
|
||||
|
||||
if (table == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
|
@ -538,36 +514,15 @@ NSHashInsertKnownAbsent(NSHashTable *table, const void *element)
|
|||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place null in hash table"];
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)element);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
GSIMapNode n;
|
||||
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)element);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapAddKey(t, (GSIMapKey)element);
|
||||
((NSConcreteHashTable*)table)->version++;
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"NSHashInsertKnownAbsent ... item not absent"];
|
||||
}
|
||||
GSIMapAddKey(t, (GSIMapKey)element);
|
||||
}
|
||||
else
|
||||
{
|
||||
id old = [table member: (id)element];
|
||||
|
||||
if (old == nil)
|
||||
{
|
||||
[table addObject: (id)element];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"NSHashInsertKnownAbsent ... item not absent"];
|
||||
}
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"NSHashInsertKnownAbsent ... element not absent"];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -580,26 +535,10 @@ NSHashRemove(NSHashTable *table, const void *element)
|
|||
if (table == 0)
|
||||
{
|
||||
NSWarnFLog(@"Nul table argument supplied");
|
||||
return;
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
{
|
||||
GSIMapTable map = (GSIMapTable)table;
|
||||
GSIMapBucket bucket;
|
||||
GSIMapNode node;
|
||||
|
||||
bucket = GSIMapBucketForKey(map, (GSIMapKey)element);
|
||||
node = GSIMapNodeForKeyInBucket(map, bucket, (GSIMapKey)element);
|
||||
if (node != 0)
|
||||
{
|
||||
GSIMapRemoveNodeFromMap(map, bucket, node);
|
||||
GSIMapFreeNode(map, node);
|
||||
((NSConcreteHashTable*)table)->version++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[table removeObject: (id)element];
|
||||
GSIMapRemoveKey((GSIMapTable)table, (GSIMapKey)element);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,40 +549,21 @@ NSHashRemove(NSHashTable *table, const void *element)
|
|||
void *
|
||||
NSNextHashEnumeratorItem(NSHashEnumerator *enumerator)
|
||||
{
|
||||
GSIMapNode n;
|
||||
|
||||
if (enumerator == 0)
|
||||
{
|
||||
NSWarnFLog(@"Nul enumerator argument supplied");
|
||||
return 0;
|
||||
}
|
||||
if (enumerator->map != 0) // Got a GSIMapTable enumerator
|
||||
n = GSIMapEnumeratorNextNode((GSIMapEnumerator)enumerator);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapNode n;
|
||||
|
||||
/* The 'map' field is non-null, so this NSHashEnumerator is actually
|
||||
* a GSIMapEnumerator.
|
||||
*/
|
||||
n = GSIMapEnumeratorNextNode((GSIMapEnumerator)enumerator);
|
||||
if (n == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return n->key.ptr;
|
||||
}
|
||||
}
|
||||
else if (enumerator->node != 0) // Got an enumerator object
|
||||
{
|
||||
/* The 'map' field is null but the 'node' field is not, so the
|
||||
* NSHashEnumerator structure actually contains an NSEnumerator
|
||||
* in the 'node' field, and the map table being enumerated in the
|
||||
* 'bucket' field.
|
||||
*/
|
||||
return (void*)[(id)enumerator->node nextObject];
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
return n->key.ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -656,21 +576,10 @@ NSResetHashTable(NSHashTable *table)
|
|||
if (table == 0)
|
||||
{
|
||||
NSWarnFLog(@"Nul table argument supplied");
|
||||
return;
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
{
|
||||
NSConcreteHashTable *t = (NSConcreteHashTable*)table;
|
||||
|
||||
if (t->nodeCount > 0)
|
||||
{
|
||||
GSIMapCleanMap((GSIMapTable)table);
|
||||
t->version++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[table removeAllObjects];
|
||||
GSIMapCleanMap((GSIMapTable)table);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -795,14 +704,6 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
|
|||
|
||||
|
||||
|
||||
@interface NSConcreteHashTableEnumerator : NSEnumerator
|
||||
{
|
||||
NSConcreteHashTable *table;
|
||||
GSIMapEnumerator_t enumerator;
|
||||
}
|
||||
- (id) initWithHashTable: (NSConcreteHashTable*)t;
|
||||
@end
|
||||
|
||||
@implementation NSConcreteHashTable
|
||||
|
||||
+ (void) initialize
|
||||
|
@ -830,72 +731,19 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
|
|||
GSIMapTable t = (GSIMapTable)self;
|
||||
GSIMapNode n;
|
||||
|
||||
if (anObject == nil)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@:] given nil argument",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
}
|
||||
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)anObject);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapAddKey(t, (GSIMapKey)anObject);
|
||||
version++;
|
||||
}
|
||||
else if (n->key.obj != anObject)
|
||||
{
|
||||
GSI_MAP_RELEASE_KEY(t, n->key);
|
||||
n->key = (GSIMapKey)anObject;
|
||||
GSI_MAP_RETAIN_KEY(t, n->key);
|
||||
version++;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray*) allObjects
|
||||
{
|
||||
NSHashEnumerator enumerator;
|
||||
unsigned index;
|
||||
NSArray *a;
|
||||
GS_BEGINITEMBUF(objects, nodeCount, id);
|
||||
|
||||
enumerator = NSEnumerateHashTable(self);
|
||||
index = 0;
|
||||
while ((objects[index] = NSNextHashEnumeratorItem(&enumerator)) != nil)
|
||||
{
|
||||
index++;
|
||||
}
|
||||
NSEndHashTableEnumeration(&enumerator);
|
||||
a = [[[NSArray alloc] initWithObjects: objects count: nodeCount] autorelease];
|
||||
GS_ENDITEMBUF();
|
||||
return a;
|
||||
}
|
||||
|
||||
- (id) anyObject
|
||||
{
|
||||
GSIMapNode node = GSIMapFirstNode(self);
|
||||
|
||||
if (node == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return node->key.obj;
|
||||
}
|
||||
|
||||
- (BOOL) containsObject: (id)anObject
|
||||
{
|
||||
if (anObject != nil)
|
||||
{
|
||||
GSIMapNode node = GSIMapNodeForKey(self, (GSIMapKey)anObject);
|
||||
|
||||
if (node)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone*)aZone
|
||||
{
|
||||
return NSCopyHashTableWithZone(self, aZone);
|
||||
|
@ -910,37 +758,7 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
|
|||
objects: (id*)stackbuf
|
||||
count: (NSUInteger)len
|
||||
{
|
||||
NSInteger count;
|
||||
NSHashEnumerator enumerator;
|
||||
|
||||
state->mutationsPtr = (unsigned long *)version;
|
||||
if (state->state == 0 && state->extra[0] == 0)
|
||||
{
|
||||
enumerator = GSIMapEnumeratorForMap(self);
|
||||
}
|
||||
else
|
||||
{
|
||||
enumerator.map = self;
|
||||
enumerator.node = (GSIMapNode)(uintptr_t)state->state;
|
||||
enumerator.bucket = state->extra[0];
|
||||
}
|
||||
for (count = 0; count < len; count++)
|
||||
{
|
||||
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
|
||||
|
||||
if (node == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
stackbuf[count] = node->key.obj;
|
||||
}
|
||||
}
|
||||
state->state = (unsigned long)(uintptr_t)enumerator.node;
|
||||
state->extra[0] = enumerator.bucket;
|
||||
state->itemsPtr = stackbuf;
|
||||
return count;
|
||||
return (NSUInteger)[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
@ -1008,10 +826,7 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
|
|||
|
||||
- (NSEnumerator*) objectEnumerator
|
||||
{
|
||||
NSEnumerator *e;
|
||||
|
||||
e = [[NSConcreteHashTableEnumerator alloc] initWithHashTable: self];
|
||||
return [e autorelease];
|
||||
return [self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (id) member: (id)aKey
|
||||
|
@ -1038,64 +853,12 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
|
|||
|
||||
- (void) removeAllObjects
|
||||
{
|
||||
if (nodeCount > 0)
|
||||
{
|
||||
GSIMapCleanMap(self);
|
||||
version++;
|
||||
}
|
||||
GSIMapEmptyMap(self);
|
||||
}
|
||||
|
||||
- (void) removeObject: (id)anObject
|
||||
- (NSSet*) setRepresentation
|
||||
{
|
||||
if (anObject == nil)
|
||||
{
|
||||
NSWarnMLog(@"attempt to remove nil object from hash table %@", self);
|
||||
return;
|
||||
}
|
||||
if (nodeCount > 0)
|
||||
{
|
||||
GSIMapTable map = (GSIMapTable)self;
|
||||
GSIMapBucket bucket;
|
||||
GSIMapNode node;
|
||||
|
||||
bucket = GSIMapBucketForKey(map, (GSIMapKey)anObject);
|
||||
node = GSIMapNodeForKeyInBucket(map, bucket, (GSIMapKey)anObject);
|
||||
if (node != 0)
|
||||
{
|
||||
GSIMapRemoveNodeFromMap(map, bucket, node);
|
||||
GSIMapFreeNode(map, node);
|
||||
version++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSConcreteHashTableEnumerator
|
||||
|
||||
- (id) initWithHashTable: (NSConcreteHashTable*)t
|
||||
{
|
||||
table = RETAIN(t);
|
||||
enumerator = GSIMapEnumeratorForMap(table);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) nextObject
|
||||
{
|
||||
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
|
||||
|
||||
if (node == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return node->key.obj;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
GSIMapEndEnumerator(&enumerator);
|
||||
RELEASE(table);
|
||||
[super dealloc];
|
||||
return [self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -62,7 +62,6 @@ typedef GSIMapNode_t *GSIMapNode;
|
|||
GSIMapNode *nodeChunks; /* Chunks of allocated memory. */
|
||||
size_t chunkCount; /* Number of chunks in array. */
|
||||
size_t increment; /* Amount to grow by. */
|
||||
unsigned long version; /* For fast enumeration. */
|
||||
BOOL legacy; /* old style callbacks? */
|
||||
union {
|
||||
struct {
|
||||
|
@ -97,9 +96,6 @@ typedef GSIMapNode_t *GSIMapNode;
|
|||
#define GSI_MAP_RETAIN_VAL(M, X)\
|
||||
(M->legacy ? M->cb.old.v.retain(M, X.ptr) \
|
||||
: pointerFunctionsAcquire(&M->cb.pf.v, &X.ptr, X.ptr))
|
||||
#define GSI_MAP_ZEROED(M)\
|
||||
(M->legacy ? 0 \
|
||||
: ((M->cb.pf.k.options & NSPointerFunctionsZeroingWeakMemory) ? YES : NO))
|
||||
|
||||
#define GSI_MAP_ENUMERATOR NSMapEnumerator
|
||||
|
||||
|
@ -333,6 +329,7 @@ NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone)
|
|||
GSIMapTable o = (GSIMapTable)table;
|
||||
GSIMapTable t;
|
||||
GSIMapNode n;
|
||||
NSMapEnumerator enumerator;
|
||||
|
||||
if (table == nil)
|
||||
{
|
||||
|
@ -356,28 +353,12 @@ NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone)
|
|||
#endif
|
||||
GSIMapInitWithZoneAndCapacity(t, zone, ((GSIMapTable)table)->nodeCount);
|
||||
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
enumerator = GSIMapEnumeratorForMap((GSIMapTable)table);
|
||||
while ((n = GSIMapEnumeratorNextNode(&enumerator)) != 0)
|
||||
{
|
||||
NSMapEnumerator enumerator;
|
||||
|
||||
enumerator = GSIMapEnumeratorForMap((GSIMapTable)table);
|
||||
while ((n = GSIMapEnumeratorNextNode(&enumerator)) != 0)
|
||||
{
|
||||
GSIMapAddPair(t, n->key, n->value);
|
||||
}
|
||||
GSIMapEndEnumerator((GSIMapEnumerator)&enumerator);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id k;
|
||||
|
||||
enumerator = [table keyEnumerator];
|
||||
while ((k = [enumerator nextObject]) != nil)
|
||||
{
|
||||
GSIMapAddPair(t, (GSIMapKey)k, (GSIMapVal)[table objectForKey: k]);
|
||||
}
|
||||
GSIMapAddPair(t, n->key, n->value);
|
||||
}
|
||||
GSIMapEndEnumerator((GSIMapEnumerator)&enumerator);
|
||||
|
||||
return (NSMapTable*)t;
|
||||
}
|
||||
|
@ -393,11 +374,7 @@ NSCountMapTable(NSMapTable *table)
|
|||
NSWarnFLog(@"Null table argument supplied");
|
||||
return 0;
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
{
|
||||
return ((GSIMapTable)table)->nodeCount;
|
||||
}
|
||||
return [table count];
|
||||
return ((GSIMapTable)table)->nodeCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -484,23 +461,7 @@ NSEndMapTableEnumeration(NSMapEnumerator *enumerator)
|
|||
NSWarnFLog(@"Null enumerator argument supplied");
|
||||
return;
|
||||
}
|
||||
if (enumerator->map != 0)
|
||||
{
|
||||
/* The 'map' field is non-null, so this NSMapEnumerator is actually
|
||||
* a GSIMapEnumerator.
|
||||
*/
|
||||
GSIMapEndEnumerator((GSIMapEnumerator)enumerator);
|
||||
}
|
||||
else if (enumerator->node != 0)
|
||||
{
|
||||
/* The 'map' field is null but the 'node' field is not, so the
|
||||
* NSMapEnumerator structure actually contains an NSEnumerator
|
||||
* in the 'node' field, and the map table being enumerated in the
|
||||
* 'bucket' field.
|
||||
*/
|
||||
[(id)enumerator->node release];
|
||||
memset(enumerator, '\0', sizeof(GSIMapEnumerator));
|
||||
}
|
||||
GSIMapEndEnumerator((GSIMapEnumerator)enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -512,23 +473,12 @@ NSEnumerateMapTable(NSMapTable *table)
|
|||
{
|
||||
if (table == nil)
|
||||
{
|
||||
NSMapEnumerator v = {0, 0, 0};
|
||||
NSMapEnumerator v = {0, 0};
|
||||
|
||||
NSWarnFLog(@"Null table argument supplied");
|
||||
return v;
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
{
|
||||
return GSIMapEnumeratorForMap((GSIMapTable)table);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSMapEnumerator v = {0, 0, 0};
|
||||
|
||||
v.node = (void*)[[table keyEnumerator] retain];
|
||||
v.bucket = (unsigned long)(uintptr_t)table;
|
||||
return v;
|
||||
}
|
||||
return GSIMapEnumeratorForMap((GSIMapTable)table);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -557,28 +507,21 @@ NSFreeMapTable(NSMapTable *table)
|
|||
void *
|
||||
NSMapGet(NSMapTable *table, const void *key)
|
||||
{
|
||||
GSIMapNode n;
|
||||
|
||||
if (table == nil)
|
||||
{
|
||||
NSWarnFLog(@"Null table argument supplied");
|
||||
return 0;
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
n = GSIMapNodeForKey((GSIMapTable)table, (GSIMapKey)key);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapNode n;
|
||||
|
||||
n = GSIMapNodeForKey((GSIMapTable)table, (GSIMapKey)key);
|
||||
if (n == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return n->value.ptr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return [table objectForKey: (id)key];
|
||||
return n->value.ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -592,48 +535,31 @@ NSMapGet(NSMapTable *table, const void *key)
|
|||
void
|
||||
NSMapInsert(NSMapTable *table, const void *key, const void *value)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
GSIMapNode n;
|
||||
|
||||
if (table == nil)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place key-value in null table"];
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
if (key == t->cb.old.k.notAKeyMarker)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
GSIMapNode n;
|
||||
|
||||
if (t->legacy == YES)
|
||||
{
|
||||
if (key == t->cb.old.k.notAKeyMarker)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place notAKeyMarker in map"];
|
||||
}
|
||||
}
|
||||
else if (key == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place nil key in map"];
|
||||
}
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)key);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapAddPair(t, (GSIMapKey)key, (GSIMapVal)value);
|
||||
t->version++;
|
||||
}
|
||||
else if (n->value.ptr != value)
|
||||
{
|
||||
GSIMapVal tmp = n->value;
|
||||
|
||||
n->value = (GSIMapVal)value;
|
||||
GSI_MAP_RETAIN_VAL(t, n->value);
|
||||
GSI_MAP_RELEASE_VAL(t, tmp);
|
||||
t->version++;
|
||||
}
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place notAKeyMarker in map table"];
|
||||
}
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)key);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapAddPair(t, (GSIMapKey)key, (GSIMapVal)value);
|
||||
}
|
||||
else
|
||||
{
|
||||
[table setObject: (id)value forKey: (id)key];
|
||||
GSIMapVal tmp = n->value;
|
||||
|
||||
n->value = (GSIMapVal)value;
|
||||
GSI_MAP_RETAIN_VAL(t, n->value);
|
||||
GSI_MAP_RELEASE_VAL(t, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -647,51 +573,28 @@ NSMapInsert(NSMapTable *table, const void *key, const void *value)
|
|||
void *
|
||||
NSMapInsertIfAbsent(NSMapTable *table, const void *key, const void *value)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
GSIMapNode n;
|
||||
|
||||
if (table == nil)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place key-value in null table"];
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
if (key == t->cb.old.k.notAKeyMarker)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
GSIMapNode n;
|
||||
|
||||
if (t->legacy == YES)
|
||||
{
|
||||
if (key == t->cb.old.k.notAKeyMarker)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place notAKeyMarker in map table"];
|
||||
}
|
||||
}
|
||||
else if (key == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place nil key in map"];
|
||||
}
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)key);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapAddPair(t, (GSIMapKey)key, (GSIMapVal)value);
|
||||
t->version++;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return n->key.ptr;
|
||||
}
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place notAKeyMarker in map table"];
|
||||
}
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)key);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapAddPair(t, (GSIMapKey)key, (GSIMapVal)value);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
void *v = (void*)[table objectForKey: (id)key];
|
||||
|
||||
if (v == 0)
|
||||
{
|
||||
[table setObject: (id)value forKey: (id)v];
|
||||
return 0;
|
||||
}
|
||||
return v;
|
||||
return n->key.ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -704,54 +607,28 @@ NSMapInsertIfAbsent(NSMapTable *table, const void *key, const void *value)
|
|||
void
|
||||
NSMapInsertKnownAbsent(NSMapTable *table, const void *key, const void *value)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
GSIMapNode n;
|
||||
|
||||
if (table == nil)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place key-value in null table"];
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
if (key == t->cb.old.k.notAKeyMarker)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
GSIMapNode n;
|
||||
|
||||
if (t->legacy == YES)
|
||||
{
|
||||
if (key == t->cb.old.k.notAKeyMarker)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place notAKeyMarker in map table"];
|
||||
}
|
||||
}
|
||||
else if (key == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place nil key in map"];
|
||||
}
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)key);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapAddPair(t, (GSIMapKey)key, (GSIMapVal)value);
|
||||
t->version++;
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"NSMapInsertKnownAbsent ... key not absent"];
|
||||
}
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Attempt to place notAKeyMarker in map table"];
|
||||
}
|
||||
n = GSIMapNodeForKey(t, (GSIMapKey)key);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapAddPair(t, (GSIMapKey)key, (GSIMapVal)value);
|
||||
}
|
||||
else
|
||||
{
|
||||
void *v = (void*)[table objectForKey: (id)key];
|
||||
|
||||
if (v == 0)
|
||||
{
|
||||
[table setObject: (id)value forKey: (id)v];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"NSMapInsertKnownAbsent ... key not absent"];
|
||||
}
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"NSMapInsertKnownAbsent ... key not absent"];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -765,36 +642,29 @@ BOOL
|
|||
NSMapMember(NSMapTable *table, const void *key,
|
||||
void **originalKey, void **value)
|
||||
{
|
||||
GSIMapNode n;
|
||||
|
||||
if (table == nil)
|
||||
{
|
||||
NSWarnFLog(@"Null table argument supplied");
|
||||
return NO;
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
n = GSIMapNodeForKey((GSIMapTable)table, (GSIMapKey)key);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapNode n;
|
||||
|
||||
n = GSIMapNodeForKey((GSIMapTable)table, (GSIMapKey)key);
|
||||
if (n == 0)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (originalKey != 0)
|
||||
{
|
||||
*originalKey = n->key.ptr;
|
||||
}
|
||||
if (value != 0)
|
||||
{
|
||||
*value = n->value.ptr;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
return [table objectForKey: (id)key] ? YES : NO;
|
||||
if (originalKey != 0)
|
||||
{
|
||||
*originalKey = n->key.ptr;
|
||||
}
|
||||
if (value != 0)
|
||||
{
|
||||
*value = n->value.ptr;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -810,18 +680,7 @@ NSMapRemove(NSMapTable *table, const void *key)
|
|||
NSWarnFLog(@"Null table argument supplied");
|
||||
return;
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
{
|
||||
if (((GSIMapTable)table)->nodeCount > 0)
|
||||
{
|
||||
GSIMapRemoveKey((GSIMapTable)table, (GSIMapKey)key);
|
||||
((GSIMapTable)table)->version++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[table removeObjectForKey: (id)key];
|
||||
}
|
||||
GSIMapRemoveKey((GSIMapTable)table, (GSIMapKey)key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -837,71 +696,32 @@ BOOL
|
|||
NSNextMapEnumeratorPair(NSMapEnumerator *enumerator,
|
||||
void **key, void **value)
|
||||
{
|
||||
GSIMapNode n;
|
||||
|
||||
if (enumerator == 0)
|
||||
{
|
||||
NSWarnFLog(@"Null enumerator argument supplied");
|
||||
return NO;
|
||||
}
|
||||
if (enumerator->map != 0)
|
||||
n = GSIMapEnumeratorNextNode((GSIMapEnumerator)enumerator);
|
||||
if (n == 0)
|
||||
{
|
||||
GSIMapNode n;
|
||||
|
||||
/* The 'map' field is non-null, so this NSMapEnumerator is actually
|
||||
* a GSIMapEnumerator and we can use the GSIMap... functions to work
|
||||
* with it.
|
||||
*/
|
||||
n = GSIMapEnumeratorNextNode((GSIMapEnumerator)enumerator);
|
||||
if (n == 0)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key != 0)
|
||||
{
|
||||
*key = n->key.ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSWarnFLog(@"Null key return address");
|
||||
}
|
||||
|
||||
if (value != 0)
|
||||
{
|
||||
*value = n->value.ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSWarnFLog(@"Null value return address");
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
else if (enumerator->node != 0)
|
||||
else
|
||||
{
|
||||
id k;
|
||||
|
||||
/* The 'map' field is null but the 'node' field is not, so the
|
||||
* NSMapEnumerator structure actually contains an NSEnumerator
|
||||
* in the 'node' field, and the map table being enumerated in the
|
||||
* 'bucket' field.
|
||||
*/
|
||||
k = [(NSEnumerator*)enumerator->node nextObject];
|
||||
if (k == nil)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
if (key != 0)
|
||||
{
|
||||
*key = k;
|
||||
*key = n->key.ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSWarnFLog(@"Null key return address");
|
||||
}
|
||||
|
||||
if (value != 0)
|
||||
{
|
||||
*value = [(NSMapTable*)enumerator->bucket objectForKey: k];
|
||||
*value = n->value.ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -909,10 +729,6 @@ NSNextMapEnumeratorPair(NSMapEnumerator *enumerator,
|
|||
}
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -925,19 +741,10 @@ NSResetMapTable(NSMapTable *table)
|
|||
if (table == nil)
|
||||
{
|
||||
NSWarnFLog(@"Null table argument supplied");
|
||||
return;
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
{
|
||||
if (((GSIMapTable)table)->nodeCount > 0)
|
||||
{
|
||||
GSIMapCleanMap((GSIMapTable)table);
|
||||
((GSIMapTable)table)->version++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[table removeAllObjects];
|
||||
GSIMapCleanMap((GSIMapTable)table);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -950,51 +757,44 @@ NSResetMapTable(NSMapTable *table)
|
|||
NSString *
|
||||
NSStringFromMapTable(NSMapTable *table)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
NSMutableString *string;
|
||||
NSMapEnumerator enumerator;
|
||||
void *key;
|
||||
void *value;
|
||||
|
||||
if (table == nil)
|
||||
{
|
||||
NSWarnFLog(@"Null table argument supplied");
|
||||
return nil;
|
||||
}
|
||||
if (GSObjCClass(table) == concreteClass)
|
||||
string = [NSMutableString stringWithCapacity: 0];
|
||||
enumerator = NSEnumerateMapTable(table);
|
||||
|
||||
/*
|
||||
* Now, just step through the elements of the table, and add their
|
||||
* descriptions to the string.
|
||||
*/
|
||||
if (t->legacy)
|
||||
{
|
||||
GSIMapTable t = (GSIMapTable)table;
|
||||
NSMutableString *string;
|
||||
NSMapEnumerator enumerator;
|
||||
void *key;
|
||||
void *value;
|
||||
|
||||
string = [NSMutableString stringWithCapacity: 0];
|
||||
enumerator = NSEnumerateMapTable(table);
|
||||
|
||||
/*
|
||||
* Now, just step through the elements of the table, and add their
|
||||
* descriptions to the string.
|
||||
*/
|
||||
if (t->legacy)
|
||||
while (NSNextMapEnumeratorPair(&enumerator, &key, &value) == YES)
|
||||
{
|
||||
while (NSNextMapEnumeratorPair(&enumerator, &key, &value) == YES)
|
||||
{
|
||||
[string appendFormat: @"%@ = %@;\n",
|
||||
(t->cb.old.k.describe)(table, key),
|
||||
(t->cb.old.v.describe)(table, value)];
|
||||
}
|
||||
[string appendFormat: @"%@ = %@;\n",
|
||||
(t->cb.old.k.describe)(table, key),
|
||||
(t->cb.old.v.describe)(table, value)];
|
||||
}
|
||||
else
|
||||
{
|
||||
while (NSNextMapEnumeratorPair(&enumerator, &key, &value) == YES)
|
||||
{
|
||||
[string appendFormat: @"%@ = %@;\n",
|
||||
(t->cb.pf.k.descriptionFunction)(key),
|
||||
(t->cb.pf.v.descriptionFunction)(value)];
|
||||
}
|
||||
}
|
||||
NSEndMapTableEnumeration(&enumerator);
|
||||
return string;
|
||||
}
|
||||
else
|
||||
{
|
||||
return [table description];
|
||||
while (NSNextMapEnumeratorPair(&enumerator, &key, &value) == YES)
|
||||
{
|
||||
[string appendFormat: @"%@ = %@;\n",
|
||||
(t->cb.pf.k.descriptionFunction)(key),
|
||||
(t->cb.pf.v.descriptionFunction)(value)];
|
||||
}
|
||||
}
|
||||
NSEndMapTableEnumeration(&enumerator);
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1116,17 +916,6 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|||
|
||||
|
||||
|
||||
@interface NSConcreteMapTableKeyEnumerator : NSEnumerator
|
||||
{
|
||||
NSConcreteMapTable *table;
|
||||
GSIMapEnumerator_t enumerator;
|
||||
}
|
||||
- (id) initWithMapTable: (NSConcreteMapTable*)m;
|
||||
@end
|
||||
|
||||
@interface NSConcreteMapTableObjectEnumerator : NSConcreteMapTableKeyEnumerator
|
||||
@end
|
||||
|
||||
@implementation NSConcreteMapTable
|
||||
|
||||
+ (void) initialize
|
||||
|
@ -1168,37 +957,7 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|||
objects: (id*)stackbuf
|
||||
count: (NSUInteger)len
|
||||
{
|
||||
NSInteger count;
|
||||
NSMapEnumerator enumerator;
|
||||
|
||||
state->mutationsPtr = (unsigned long *)version;
|
||||
if (state->state == 0 && state->extra[0] == 0)
|
||||
{
|
||||
enumerator = GSIMapEnumeratorForMap(self);
|
||||
}
|
||||
else
|
||||
{
|
||||
enumerator.map = self;
|
||||
enumerator.node = (GSIMapNode)(uintptr_t)state->state;
|
||||
enumerator.bucket = state->extra[0];
|
||||
}
|
||||
for (count = 0; count < len; count++)
|
||||
{
|
||||
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
|
||||
|
||||
if (node == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
stackbuf[count] = node->key.obj;
|
||||
}
|
||||
}
|
||||
state->state = (unsigned long)(uintptr_t)enumerator.node;
|
||||
state->extra[0] = enumerator.bucket;
|
||||
state->itemsPtr = stackbuf;
|
||||
return count;
|
||||
return (NSUInteger)[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
@ -1207,6 +966,11 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSDictionary*) dictionaryRepresentation
|
||||
{
|
||||
return [self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
@ -1296,10 +1060,7 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|||
|
||||
- (NSEnumerator*) keyEnumerator
|
||||
{
|
||||
NSEnumerator *e;
|
||||
|
||||
e = [[NSConcreteMapTableKeyEnumerator alloc] initWithMapTable: self];
|
||||
return [e autorelease];
|
||||
return [self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (NSPointerFunctions*) keyPointerFunctions
|
||||
|
@ -1312,10 +1073,7 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|||
|
||||
- (NSEnumerator*) objectEnumerator
|
||||
{
|
||||
NSEnumerator *e;
|
||||
|
||||
e = [[NSConcreteMapTableObjectEnumerator alloc] initWithMapTable: self];
|
||||
return [e autorelease];
|
||||
return [self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (id) objectForKey: (id)aKey
|
||||
|
@ -1334,11 +1092,7 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|||
|
||||
- (void) removeAllObjects
|
||||
{
|
||||
if (nodeCount > 0)
|
||||
{
|
||||
GSIMapEmptyMap(self);
|
||||
version++;
|
||||
}
|
||||
GSIMapEmptyMap(self);
|
||||
}
|
||||
|
||||
- (void) removeObjectForKey: (id)aKey
|
||||
|
@ -1348,21 +1102,7 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|||
NSWarnMLog(@"attempt to remove nil key from map table %@", self);
|
||||
return;
|
||||
}
|
||||
if (nodeCount > 0)
|
||||
{
|
||||
GSIMapTable map = (GSIMapTable)self;
|
||||
GSIMapBucket bucket;
|
||||
GSIMapNode node;
|
||||
|
||||
bucket = GSIMapBucketForKey(map, (GSIMapKey)aKey);
|
||||
node = GSIMapNodeForKeyInBucket(map, bucket, (GSIMapKey)aKey);
|
||||
if (node != 0)
|
||||
{
|
||||
GSIMapRemoveNodeFromMap(map, bucket, node);
|
||||
GSIMapFreeNode(map, node);
|
||||
version++;
|
||||
}
|
||||
}
|
||||
GSIMapRemoveKey(self, (GSIMapKey)aKey);
|
||||
}
|
||||
|
||||
- (void) setObject: (id)anObject forKey: (id)aKey
|
||||
|
@ -1371,9 +1111,12 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|||
|
||||
if (aKey == nil)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@:] given nil argument",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
NSException *e;
|
||||
|
||||
e = [NSException exceptionWithName: NSInvalidArgumentException
|
||||
reason: @"Tried to add nil key to map table"
|
||||
userInfo: nil];
|
||||
[e raise];
|
||||
}
|
||||
node = GSIMapNodeForKey(self, (GSIMapKey)aKey);
|
||||
if (node)
|
||||
|
@ -1383,13 +1126,11 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|||
GSI_MAP_RELEASE_VAL(self, node->value);
|
||||
node->value.obj = anObject;
|
||||
GSI_MAP_RETAIN_VAL(self, node->value);
|
||||
version++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GSIMapAddPair(self, (GSIMapKey)aKey, (GSIMapVal)anObject);
|
||||
version++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1402,47 +1143,3 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|||
}
|
||||
@end
|
||||
|
||||
@implementation NSConcreteMapTableKeyEnumerator
|
||||
|
||||
- (id) initWithMapTable: (NSConcreteMapTable*)t
|
||||
{
|
||||
table = RETAIN(t);
|
||||
enumerator = GSIMapEnumeratorForMap(table);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) nextObject
|
||||
{
|
||||
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
|
||||
|
||||
if (node == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return node->key.obj;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
GSIMapEndEnumerator(&enumerator);
|
||||
RELEASE(table);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSConcreteMapTableObjectEnumerator
|
||||
|
||||
- (id) nextObject
|
||||
{
|
||||
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
|
||||
|
||||
if (node == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return node->value.obj;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#import "Foundation/NSEnumerator.h"
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
|
||||
/*
|
||||
* Setup for inline operation of pointer map tables.
|
||||
|
@ -1905,7 +1904,6 @@ static void retDecoder(DOContext *ctxt)
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(USE_FFCALL) && !defined(USE_LIBFFI)
|
||||
static void retEncoder (DOContext *ctxt)
|
||||
{
|
||||
switch (*ctxt->type)
|
||||
|
@ -1930,7 +1928,6 @@ static void retEncoder (DOContext *ctxt)
|
|||
[ctxt->encoder encodeValueOfObjCType: ctxt->type at: ctxt->datum];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NSDistantObject's -forward:: method calls this to send the message
|
||||
|
@ -1940,7 +1937,6 @@ static void retEncoder (DOContext *ctxt)
|
|||
selector: (SEL)sel
|
||||
argFrame: (arglist_t)argframe
|
||||
{
|
||||
#if !defined(USE_FFCALL) && !defined(USE_LIBFFI)
|
||||
BOOL outParams;
|
||||
BOOL needsResponse;
|
||||
const char *type;
|
||||
|
@ -2075,14 +2071,6 @@ static void retEncoder (DOContext *ctxt)
|
|||
NSAssert(ctxt.decoder == nil, NSInternalInconsistencyException);
|
||||
}
|
||||
return retframe;
|
||||
#else
|
||||
/* If we've got to here then something has gone badly wrong. Most likely a
|
||||
* mismatch between NSDistantObject and NSConnection implementations.
|
||||
*/
|
||||
NSAssert(NO, @"Legacy forwardForProxy:selector:argFrame: method called when"
|
||||
" compiled with fcall/ffi.");
|
||||
return 0; // Not reached.
|
||||
#endif //!defined(USE_FFCALL) && !defined(USE_LIBFFI)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2882,22 +2870,15 @@ static void callEncoder (DOContext *ctxt)
|
|||
NSTimeInterval last_interval = 0.0001;
|
||||
NSTimeInterval delay_interval = last_interval;
|
||||
NSDate *delay_date = nil;
|
||||
NSRunLoop *runLoop;
|
||||
NSRunLoop *runLoop = GSRunLoopForThread(nil);
|
||||
BOOL isLocked = NO;
|
||||
|
||||
if (_isValid == NO)
|
||||
{
|
||||
[NSException raise: NSObjectInaccessibleException
|
||||
format: @"Connection has been invalidated"];
|
||||
}
|
||||
|
||||
/*
|
||||
* If we have sent out a request on a run loop that we don't already
|
||||
* know about, it must be on a new thread - so if we have multipleThreads
|
||||
* enabled, we must add the run loop of the new thread so that we can
|
||||
* get the reply in this thread.
|
||||
*/
|
||||
runLoop = GSRunLoopForThread(nil);
|
||||
if ([_runLoops indexOfObjectIdenticalTo: runLoop] == NSNotFound)
|
||||
{
|
||||
if (_multipleThreads == YES)
|
||||
|
|
797
Source/NSData.m
797
Source/NSData.m
|
@ -553,22 +553,16 @@ failure:
|
|||
|
||||
if (bufferSize > 0)
|
||||
{
|
||||
if (aBuffer == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-initWithBytes:length:] called with "
|
||||
@"length but null bytes", NSStringFromClass([self class])];
|
||||
}
|
||||
#if GS_WITH_GC
|
||||
ptr = NSAllocateCollectable(bufferSize, 0);
|
||||
#else
|
||||
ptr = NSZoneMalloc(NSDefaultMallocZone(), bufferSize);
|
||||
#endif
|
||||
if (ptr == 0)
|
||||
{
|
||||
{
|
||||
DESTROY(self);
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
memcpy(ptr, aBuffer, bufferSize);
|
||||
}
|
||||
return [self initWithBytesNoCopy: ptr
|
||||
|
@ -845,27 +839,334 @@ failure:
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Writes a copy of the data encapsulated by the receiver to a file
|
||||
* at path. If the useAuxiliaryFile flag is YES, this writes to a
|
||||
* temporary file and then renames that to the file at path, thus
|
||||
* ensuring that path exists and does not contain partially written
|
||||
* data at any point.
|
||||
* </p>
|
||||
* <p>On success returns YES, on failure returns NO.
|
||||
* </p>
|
||||
*/
|
||||
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
NSUInteger length = [path length];
|
||||
unichar wthePath[length + 100];
|
||||
unichar wtheRealPath[length + 100];
|
||||
#else
|
||||
char thePath[BUFSIZ*2+8];
|
||||
char theRealPath[BUFSIZ*2];
|
||||
#endif
|
||||
int c;
|
||||
FILE *theFile;
|
||||
BOOL error_BadPath = YES;
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
[path getCharacters: wtheRealPath];
|
||||
wtheRealPath[length] = L'\0';
|
||||
error_BadPath = (length <= 0);
|
||||
#else
|
||||
if ([path canBeConvertedToEncoding: [NSString defaultCStringEncoding]])
|
||||
{
|
||||
const char *local_c_path = [path cString];
|
||||
|
||||
if (local_c_path != 0 && strlen(local_c_path) < (BUFSIZ*2))
|
||||
{
|
||||
strcpy(theRealPath,local_c_path);
|
||||
error_BadPath = NO;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (error_BadPath)
|
||||
{
|
||||
NSWarnMLog(@"Open (%@) attempt failed - bad path",path);
|
||||
return NO;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MKSTEMP
|
||||
if (useAuxiliaryFile)
|
||||
{
|
||||
return [self writeToFile: path options: NSAtomicWrite error: 0];
|
||||
int desc;
|
||||
int mask;
|
||||
|
||||
strcpy(thePath, theRealPath);
|
||||
strcat(thePath, "XXXXXX");
|
||||
if ((desc = mkstemp(thePath)) < 0)
|
||||
{
|
||||
NSWarnMLog(@"mkstemp (%s) failed - %@", thePath, [NSError _last]);
|
||||
goto failure;
|
||||
}
|
||||
mask = umask(0);
|
||||
umask(mask);
|
||||
fchmod(desc, 0644 & ~mask);
|
||||
if ((theFile = fdopen(desc, "w")) == 0)
|
||||
{
|
||||
close(desc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return [self writeToFile: path options: 0 error: 0];
|
||||
strcpy(thePath, theRealPath);
|
||||
theFile = fopen(thePath, "wb");
|
||||
}
|
||||
#else
|
||||
if (useAuxiliaryFile)
|
||||
{
|
||||
/* Use the path name of the destination file as a prefix for the
|
||||
* mktemp() call so that we can be sure that both files are on
|
||||
* the same filesystem and the subsequent rename() will work. */
|
||||
#if defined(__MINGW32__)
|
||||
wcscpy(wthePath, wtheRealPath);
|
||||
wcscat(wthePath, L"XXXXXX");
|
||||
if (_wmktemp(wthePath) == 0)
|
||||
{
|
||||
NSWarnMLog(@"mktemp (%@) failed - %@",
|
||||
[NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
|
||||
[NSError _last]);
|
||||
goto failure;
|
||||
}
|
||||
#else
|
||||
strcpy(thePath, theRealPath);
|
||||
strcat(thePath, "XXXXXX");
|
||||
if (mktemp(thePath) == 0)
|
||||
{
|
||||
NSWarnMLog(@"mktemp (%s) failed - %@", thePath, [NSError _last]);
|
||||
goto failure;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
wcscpy(wthePath,wtheRealPath);
|
||||
#else
|
||||
strcpy(thePath, theRealPath);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Open the file (whether temp or real) for writing. */
|
||||
#if defined(__MINGW32__)
|
||||
theFile = _wfopen(wthePath, L"wb");
|
||||
#else
|
||||
theFile = fopen(thePath, "wb");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (theFile == 0)
|
||||
{
|
||||
/* Something went wrong; we weren't
|
||||
* even able to open the file. */
|
||||
#if defined(__MINGW32__)
|
||||
NSWarnMLog(@"Open (%@) failed - %@",
|
||||
[NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
|
||||
[NSError _last]);
|
||||
#else
|
||||
NSWarnMLog(@"Open (%s) failed - %@", thePath, [NSError _last]);
|
||||
#endif
|
||||
goto failure;
|
||||
}
|
||||
|
||||
/* Now we try and write the NSData's bytes to the file. Here `c' is
|
||||
* the number of bytes which were successfully written to the file
|
||||
* in the fwrite() call. */
|
||||
c = fwrite([self bytes], sizeof(char), [self length], theFile);
|
||||
|
||||
if (c < (int)[self length]) /* We failed to write everything for
|
||||
* some reason. */
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
NSWarnMLog(@"Fwrite (%@) failed - %@",
|
||||
[NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
|
||||
[NSError _last]);
|
||||
#else
|
||||
NSWarnMLog(@"Fwrite (%s) failed - %@", thePath, [NSError _last]);
|
||||
#endif
|
||||
goto failure;
|
||||
}
|
||||
|
||||
/* We're done, so close everything up. */
|
||||
c = fclose(theFile);
|
||||
|
||||
if (c != 0) /* I can't imagine what went wrong
|
||||
* closing the file, but we got here,
|
||||
* so we need to deal with it. */
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
NSWarnMLog(@"Fclose (%@) failed - %@",
|
||||
[NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
|
||||
[NSError _last]);
|
||||
#else
|
||||
NSWarnMLog(@"Fclose (%s) failed - %@", thePath, [NSError _last]);
|
||||
#endif
|
||||
goto failure;
|
||||
}
|
||||
|
||||
/* If we used a temporary file, we still need to rename() it be the
|
||||
* real file. Also, we need to try to retain the file attributes of
|
||||
* the original file we are overwriting (if we are) */
|
||||
if (useAuxiliaryFile)
|
||||
{
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSMutableDictionary *att = nil;
|
||||
#if defined(__MINGW32__)
|
||||
NSUInteger perm;
|
||||
#endif
|
||||
|
||||
if ([mgr fileExistsAtPath: path])
|
||||
{
|
||||
att = [[mgr fileAttributesAtPath: path
|
||||
traverseLink: YES] mutableCopy];
|
||||
IF_NO_GC(TEST_AUTORELEASE(att));
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
/* To replace the existing file on windows, it must be writable.
|
||||
*/
|
||||
perm = [att filePosixPermissions];
|
||||
if (perm != NSNotFound && (perm & 0200) == 0)
|
||||
{
|
||||
[mgr changeFileAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithUnsignedInt: 0777], NSFilePosixPermissions,
|
||||
nil] atPath: path];
|
||||
}
|
||||
/*
|
||||
* The windoze implementation of the POSIX rename() function is buggy
|
||||
* and doesn't work if the destination file already exists ... so we
|
||||
* try to use a windoze specific function instead.
|
||||
*/
|
||||
#if 0
|
||||
if (ReplaceFile(theRealPath, thePath, 0,
|
||||
REPLACEFILE_IGNORE_MERGE_ERRORS, 0, 0) != 0)
|
||||
{
|
||||
c = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = -1;
|
||||
}
|
||||
#else
|
||||
if (MoveFileExW(wthePath, wtheRealPath, MOVEFILE_REPLACE_EXISTING) != 0)
|
||||
{
|
||||
c = 0;
|
||||
}
|
||||
/* Windows 9x does not support MoveFileEx */
|
||||
else if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
unichar secondaryFile[length + 100];
|
||||
|
||||
wcscpy(secondaryFile, wthePath);
|
||||
wcscat(secondaryFile, L"-delete");
|
||||
// Delete the intermediate name just in case
|
||||
DeleteFileW(secondaryFile);
|
||||
// Move the existing file to the temp name
|
||||
if (MoveFileW(wtheRealPath, secondaryFile) != 0)
|
||||
{
|
||||
if (MoveFileW(wthePath, wtheRealPath) != 0)
|
||||
{
|
||||
c = 0;
|
||||
// Delete the old file if possible
|
||||
DeleteFileW(secondaryFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
c = -1; // failure, restore the old file if possible
|
||||
MoveFileW(secondaryFile, wtheRealPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
c = -1; // failure
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
c = -1;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
c = rename(thePath, theRealPath);
|
||||
#endif
|
||||
if (c != 0) /* Many things could go wrong, I guess. */
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
NSWarnMLog(@"Rename ('%@' to '%@') failed - %@",
|
||||
[NSString stringWithCharacters: wthePath
|
||||
length: wcslen(wthePath)],
|
||||
[NSString stringWithCharacters: wtheRealPath
|
||||
length: wcslen(wtheRealPath)],
|
||||
[NSError _last]);
|
||||
#else
|
||||
NSWarnMLog(@"Rename ('%s' to '%s') failed - %@",
|
||||
thePath, theRealPath, [NSError _last]);
|
||||
#endif
|
||||
goto failure;
|
||||
}
|
||||
|
||||
if (att != nil)
|
||||
{
|
||||
/*
|
||||
* We have created a new file - so we attempt to make it's
|
||||
* attributes match that of the original.
|
||||
*/
|
||||
[att removeObjectForKey: NSFileSize];
|
||||
[att removeObjectForKey: NSFileModificationDate];
|
||||
[att removeObjectForKey: NSFileReferenceCount];
|
||||
[att removeObjectForKey: NSFileSystemNumber];
|
||||
[att removeObjectForKey: NSFileSystemFileNumber];
|
||||
[att removeObjectForKey: NSFileDeviceIdentifier];
|
||||
[att removeObjectForKey: NSFileType];
|
||||
if ([mgr changeFileAttributes: att atPath: path] == NO)
|
||||
{
|
||||
NSWarnMLog(@"Unable to correctly set all attributes for '%@'",
|
||||
path);
|
||||
}
|
||||
}
|
||||
#ifndef __MINGW32__
|
||||
else if (geteuid() == 0 && [@"root" isEqualToString: NSUserName()] == NO)
|
||||
{
|
||||
att = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
NSFileOwnerAccountName, NSUserName(), nil];
|
||||
if ([mgr changeFileAttributes: att atPath: path] == NO)
|
||||
{
|
||||
NSWarnMLog(@"Unable to correctly set ownership for '%@'", path);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* success: */
|
||||
return YES;
|
||||
|
||||
/* Just in case the failure action needs to be changed. */
|
||||
failure:
|
||||
/*
|
||||
* Attempt to tidy up by removing temporary file on failure.
|
||||
*/
|
||||
if (useAuxiliaryFile)
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
_wunlink(wthePath);
|
||||
#else
|
||||
unlink(thePath);
|
||||
#endif
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a copy of the contents of the receiver to the specified URL.
|
||||
*/
|
||||
- (BOOL) writeToURL: (NSURL*)anURL atomically: (BOOL)flag
|
||||
{
|
||||
if (flag)
|
||||
if ([anURL isFileURL] == YES)
|
||||
{
|
||||
return [self writeToURL: anURL options: NSAtomicWrite error: 0];
|
||||
return [self writeToFile: [anURL path] atomically: flag];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [self writeToURL: anURL options: 0 error: 0];
|
||||
return [anURL setResourceData: self];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1299,312 +1600,6 @@ failure:
|
|||
options: (NSUInteger)writeOptionsMask
|
||||
error: (NSError **)errorPtr
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
NSUInteger length = [path length];
|
||||
unichar wthePath[length + 100];
|
||||
unichar wtheRealPath[length + 100];
|
||||
#else
|
||||
char thePath[BUFSIZ*2+8];
|
||||
char theRealPath[BUFSIZ*2];
|
||||
#endif
|
||||
int c;
|
||||
FILE *theFile;
|
||||
BOOL useAuxiliaryFile = NO;
|
||||
BOOL error_BadPath = YES;
|
||||
|
||||
if (writeOptionsMask & NSAtomicWrite)
|
||||
{
|
||||
useAuxiliaryFile = YES;
|
||||
}
|
||||
#if defined(__MINGW32__)
|
||||
[path getCharacters: wtheRealPath];
|
||||
wtheRealPath[length] = L'\0';
|
||||
error_BadPath = (length <= 0);
|
||||
#else
|
||||
if ([path canBeConvertedToEncoding: [NSString defaultCStringEncoding]])
|
||||
{
|
||||
const char *local_c_path = [path cString];
|
||||
|
||||
if (local_c_path != 0 && strlen(local_c_path) < (BUFSIZ*2))
|
||||
{
|
||||
strcpy(theRealPath,local_c_path);
|
||||
error_BadPath = NO;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (error_BadPath)
|
||||
{
|
||||
NSWarnMLog(@"Open (%@) attempt failed - bad path",path);
|
||||
return NO;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MKSTEMP
|
||||
if (useAuxiliaryFile)
|
||||
{
|
||||
int desc;
|
||||
int mask;
|
||||
|
||||
strcpy(thePath, theRealPath);
|
||||
strcat(thePath, "XXXXXX");
|
||||
if ((desc = mkstemp(thePath)) < 0)
|
||||
{
|
||||
NSWarnMLog(@"mkstemp (%s) failed - %@", thePath, [NSError _last]);
|
||||
goto failure;
|
||||
}
|
||||
mask = umask(0);
|
||||
umask(mask);
|
||||
fchmod(desc, 0644 & ~mask);
|
||||
if ((theFile = fdopen(desc, "w")) == 0)
|
||||
{
|
||||
close(desc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(thePath, theRealPath);
|
||||
theFile = fopen(thePath, "wb");
|
||||
}
|
||||
#else
|
||||
if (useAuxiliaryFile)
|
||||
{
|
||||
/* Use the path name of the destination file as a prefix for the
|
||||
* mktemp() call so that we can be sure that both files are on
|
||||
* the same filesystem and the subsequent rename() will work. */
|
||||
#if defined(__MINGW32__)
|
||||
wcscpy(wthePath, wtheRealPath);
|
||||
wcscat(wthePath, L"XXXXXX");
|
||||
if (_wmktemp(wthePath) == 0)
|
||||
{
|
||||
NSWarnMLog(@"mktemp (%@) failed - %@",
|
||||
[NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
|
||||
[NSError _last]);
|
||||
goto failure;
|
||||
}
|
||||
#else
|
||||
strcpy(thePath, theRealPath);
|
||||
strcat(thePath, "XXXXXX");
|
||||
if (mktemp(thePath) == 0)
|
||||
{
|
||||
NSWarnMLog(@"mktemp (%s) failed - %@", thePath, [NSError _last]);
|
||||
goto failure;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
wcscpy(wthePath,wtheRealPath);
|
||||
#else
|
||||
strcpy(thePath, theRealPath);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Open the file (whether temp or real) for writing. */
|
||||
#if defined(__MINGW32__)
|
||||
theFile = _wfopen(wthePath, L"wb");
|
||||
#else
|
||||
theFile = fopen(thePath, "wb");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (theFile == 0)
|
||||
{
|
||||
/* Something went wrong; we weren't
|
||||
* even able to open the file. */
|
||||
#if defined(__MINGW32__)
|
||||
NSWarnMLog(@"Open (%@) failed - %@",
|
||||
[NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
|
||||
[NSError _last]);
|
||||
#else
|
||||
NSWarnMLog(@"Open (%s) failed - %@", thePath, [NSError _last]);
|
||||
#endif
|
||||
goto failure;
|
||||
}
|
||||
|
||||
/* Now we try and write the NSData's bytes to the file. Here `c' is
|
||||
* the number of bytes which were successfully written to the file
|
||||
* in the fwrite() call. */
|
||||
c = fwrite([self bytes], sizeof(char), [self length], theFile);
|
||||
|
||||
if (c < (int)[self length]) /* We failed to write everything for
|
||||
* some reason. */
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
NSWarnMLog(@"Fwrite (%@) failed - %@",
|
||||
[NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
|
||||
[NSError _last]);
|
||||
#else
|
||||
NSWarnMLog(@"Fwrite (%s) failed - %@", thePath, [NSError _last]);
|
||||
#endif
|
||||
goto failure;
|
||||
}
|
||||
|
||||
/* We're done, so close everything up. */
|
||||
c = fclose(theFile);
|
||||
|
||||
if (c != 0) /* I can't imagine what went wrong
|
||||
* closing the file, but we got here,
|
||||
* so we need to deal with it. */
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
NSWarnMLog(@"Fclose (%@) failed - %@",
|
||||
[NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
|
||||
[NSError _last]);
|
||||
#else
|
||||
NSWarnMLog(@"Fclose (%s) failed - %@", thePath, [NSError _last]);
|
||||
#endif
|
||||
goto failure;
|
||||
}
|
||||
|
||||
/* If we used a temporary file, we still need to rename() it be the
|
||||
* real file. Also, we need to try to retain the file attributes of
|
||||
* the original file we are overwriting (if we are) */
|
||||
if (useAuxiliaryFile)
|
||||
{
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSMutableDictionary *att = nil;
|
||||
#if defined(__MINGW32__)
|
||||
NSUInteger perm;
|
||||
#endif
|
||||
|
||||
if ([mgr fileExistsAtPath: path])
|
||||
{
|
||||
att = [[mgr fileAttributesAtPath: path
|
||||
traverseLink: YES] mutableCopy];
|
||||
IF_NO_GC(TEST_AUTORELEASE(att));
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
/* To replace the existing file on windows, it must be writable.
|
||||
*/
|
||||
perm = [att filePosixPermissions];
|
||||
if (perm != NSNotFound && (perm & 0200) == 0)
|
||||
{
|
||||
[mgr changeFileAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithUnsignedInt: 0777], NSFilePosixPermissions,
|
||||
nil] atPath: path];
|
||||
}
|
||||
/*
|
||||
* The windoze implementation of the POSIX rename() function is buggy
|
||||
* and doesn't work if the destination file already exists ... so we
|
||||
* try to use a windoze specific function instead.
|
||||
*/
|
||||
#if 0
|
||||
if (ReplaceFile(theRealPath, thePath, 0,
|
||||
REPLACEFILE_IGNORE_MERGE_ERRORS, 0, 0) != 0)
|
||||
{
|
||||
c = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = -1;
|
||||
}
|
||||
#else
|
||||
if (MoveFileExW(wthePath, wtheRealPath, MOVEFILE_REPLACE_EXISTING) != 0)
|
||||
{
|
||||
c = 0;
|
||||
}
|
||||
/* Windows 9x does not support MoveFileEx */
|
||||
else if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
unichar secondaryFile[length + 100];
|
||||
|
||||
wcscpy(secondaryFile, wthePath);
|
||||
wcscat(secondaryFile, L"-delete");
|
||||
// Delete the intermediate name just in case
|
||||
DeleteFileW(secondaryFile);
|
||||
// Move the existing file to the temp name
|
||||
if (MoveFileW(wtheRealPath, secondaryFile) != 0)
|
||||
{
|
||||
if (MoveFileW(wthePath, wtheRealPath) != 0)
|
||||
{
|
||||
c = 0;
|
||||
// Delete the old file if possible
|
||||
DeleteFileW(secondaryFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
c = -1; // failure, restore the old file if possible
|
||||
MoveFileW(secondaryFile, wtheRealPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
c = -1; // failure
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
c = -1;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
c = rename(thePath, theRealPath);
|
||||
#endif
|
||||
if (c != 0) /* Many things could go wrong, I guess. */
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
NSWarnMLog(@"Rename ('%@' to '%@') failed - %@",
|
||||
[NSString stringWithCharacters: wthePath
|
||||
length: wcslen(wthePath)],
|
||||
[NSString stringWithCharacters: wtheRealPath
|
||||
length: wcslen(wtheRealPath)],
|
||||
[NSError _last]);
|
||||
#else
|
||||
NSWarnMLog(@"Rename ('%s' to '%s') failed - %@",
|
||||
thePath, theRealPath, [NSError _last]);
|
||||
#endif
|
||||
goto failure;
|
||||
}
|
||||
|
||||
if (att != nil)
|
||||
{
|
||||
/*
|
||||
* We have created a new file - so we attempt to make it's
|
||||
* attributes match that of the original.
|
||||
*/
|
||||
[att removeObjectForKey: NSFileSize];
|
||||
[att removeObjectForKey: NSFileModificationDate];
|
||||
[att removeObjectForKey: NSFileReferenceCount];
|
||||
[att removeObjectForKey: NSFileSystemNumber];
|
||||
[att removeObjectForKey: NSFileSystemFileNumber];
|
||||
[att removeObjectForKey: NSFileDeviceIdentifier];
|
||||
[att removeObjectForKey: NSFileType];
|
||||
if ([mgr changeFileAttributes: att atPath: path] == NO)
|
||||
{
|
||||
NSWarnMLog(@"Unable to correctly set all attributes for '%@'",
|
||||
path);
|
||||
}
|
||||
}
|
||||
#ifndef __MINGW32__
|
||||
else if (geteuid() == 0 && [@"root" isEqualToString: NSUserName()] == NO)
|
||||
{
|
||||
att = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
NSFileOwnerAccountName, NSUserName(), nil];
|
||||
if ([mgr changeFileAttributes: att atPath: path] == NO)
|
||||
{
|
||||
NSWarnMLog(@"Unable to correctly set ownership for '%@'", path);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* success: */
|
||||
return YES;
|
||||
|
||||
/* Just in case the failure action needs to be changed. */
|
||||
failure:
|
||||
/*
|
||||
* Attempt to tidy up by removing temporary file on failure.
|
||||
*/
|
||||
if (useAuxiliaryFile)
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
_wunlink(wthePath);
|
||||
#else
|
||||
unlink(thePath);
|
||||
#endif
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -1612,16 +1607,6 @@ failure:
|
|||
options: (NSUInteger)writeOptionsMask
|
||||
error: (NSError **)errorPtr
|
||||
{
|
||||
if ([url isFileURL] == YES)
|
||||
{
|
||||
return [self writeToFile: [url path]
|
||||
options: writeOptionsMask
|
||||
error: errorPtr];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [url setResourceData: self];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
@end
|
||||
|
@ -2500,11 +2485,22 @@ failure:
|
|||
|
||||
/* Creation and Destruction of objects. */
|
||||
|
||||
- (id) copy
|
||||
{
|
||||
return RETAIN(self);
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone*)z
|
||||
{
|
||||
return RETAIN(self);
|
||||
}
|
||||
|
||||
- (id) mutableCopy
|
||||
{
|
||||
return [[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytes: bytes length: length];
|
||||
}
|
||||
|
||||
- (id) mutableCopyWithZone: (NSZone*)z
|
||||
{
|
||||
return [[mutableDataMalloc allocWithZone: z]
|
||||
|
@ -2522,12 +2518,6 @@ failure:
|
|||
length: (NSUInteger)bufferSize
|
||||
freeWhenDone: (BOOL)shouldFree
|
||||
{
|
||||
if (bytes == 0 && length > 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-initWithBytesNoCopy:length:freeWhenDone:] called with "
|
||||
@"length but null bytes", NSStringFromClass([self class])];
|
||||
}
|
||||
bytes = aBuffer;
|
||||
length = bufferSize;
|
||||
return self;
|
||||
|
@ -2922,6 +2912,15 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
|
||||
@implementation NSDataMalloc
|
||||
|
||||
- (id) copy
|
||||
{
|
||||
if (NSShouldRetainWithZone(self, NSDefaultMallocZone()))
|
||||
return RETAIN(self);
|
||||
else
|
||||
return [[dataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytes: bytes length: length];
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone*)z
|
||||
{
|
||||
if (NSShouldRetainWithZone(self, z))
|
||||
|
@ -2945,12 +2944,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
length: (NSUInteger)bufferSize
|
||||
freeWhenDone: (BOOL)shouldFree
|
||||
{
|
||||
if (aBuffer == 0 && bufferSize > 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-initWithBytesNoCopy:length:freeWhenDone:] called with "
|
||||
@"length but null bytes", NSStringFromClass([self class])];
|
||||
}
|
||||
if (shouldFree == NO)
|
||||
{
|
||||
GSPrivateSwizzle(self, dataStatic);
|
||||
|
@ -3101,14 +3094,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
- (id) initWithBytes: (const void*)aBuffer length: (NSUInteger)bufferSize
|
||||
{
|
||||
shmid = -1;
|
||||
if (bufferSize > 0)
|
||||
if (aBuffer && bufferSize)
|
||||
{
|
||||
if (aBuffer == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-initWithBytes:length:] called with "
|
||||
@"length but null bytes", NSStringFromClass([self class])];
|
||||
}
|
||||
shmid = shmget(IPC_PRIVATE, bufferSize, IPC_CREAT|VM_RDONLY);
|
||||
if (shmid == -1) /* Created memory? */
|
||||
{
|
||||
|
@ -3194,6 +3181,12 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
return NSMutableDataAbstract;
|
||||
}
|
||||
|
||||
- (id) copy
|
||||
{
|
||||
return [[dataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytes: bytes length: length];
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone*)z
|
||||
{
|
||||
return [[dataMalloc allocWithZone: z]
|
||||
|
@ -3220,16 +3213,10 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
self = [self initWithCapacity: bufferSize];
|
||||
if (self)
|
||||
{
|
||||
if (bufferSize > 0)
|
||||
if (aBuffer && bufferSize > 0)
|
||||
{
|
||||
if (aBuffer == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-initWithBytes:length:] called with "
|
||||
@"length but null bytes", NSStringFromClass([self class])];
|
||||
}
|
||||
memcpy(bytes, aBuffer, bufferSize);
|
||||
length = bufferSize;
|
||||
memcpy(bytes, aBuffer, length);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
|
@ -3241,14 +3228,11 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
{
|
||||
if (aBuffer == 0)
|
||||
{
|
||||
if (bufferSize > 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-initWithBytesNoCopy:length:freeWhenDone:] called with "
|
||||
@"length but null bytes", NSStringFromClass([self class])];
|
||||
}
|
||||
self = [self initWithCapacity: bufferSize];
|
||||
[self setLength: 0];
|
||||
if (self != nil)
|
||||
{
|
||||
[self setLength: bufferSize];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
#if GS_WITH_GC
|
||||
|
@ -3267,10 +3251,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
{
|
||||
zone = 0; // Don't free this memory.
|
||||
}
|
||||
else
|
||||
{
|
||||
zone = NSZoneFromPointer(aBuffer);
|
||||
}
|
||||
#endif
|
||||
bytes = aBuffer;
|
||||
length = bufferSize;
|
||||
|
@ -3333,6 +3313,25 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithContentsOfFile: (NSString *)path
|
||||
{
|
||||
self = [self initWithCapacity: 0];
|
||||
#if GS_WITH_GC
|
||||
if (readContentsOfFile(path, &bytes, &length, 0) == NO)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
#else
|
||||
if (readContentsOfFile(path, &bytes, &length, zone) == NO)
|
||||
{
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
capacity = length;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithContentsOfMappedFile: (NSString *)path
|
||||
{
|
||||
return [self initWithContentsOfFile: path];
|
||||
|
@ -3341,24 +3340,15 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
- (void) appendBytes: (const void*)aBuffer
|
||||
length: (NSUInteger)bufferSize
|
||||
{
|
||||
if (bufferSize > 0)
|
||||
{
|
||||
unsigned oldLength = length;
|
||||
unsigned minimum = length + bufferSize;
|
||||
unsigned oldLength = length;
|
||||
unsigned minimum = length + bufferSize;
|
||||
|
||||
if (aBuffer == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-appendBytes:length:] called with "
|
||||
@"length but null bytes", NSStringFromClass([self class])];
|
||||
}
|
||||
if (minimum > capacity)
|
||||
{
|
||||
[self _grow: minimum];
|
||||
}
|
||||
memcpy(bytes + oldLength, aBuffer, bufferSize);
|
||||
length = minimum;
|
||||
if (minimum > capacity)
|
||||
{
|
||||
[self _grow: minimum];
|
||||
}
|
||||
memcpy(bytes + oldLength, aBuffer, bufferSize);
|
||||
length = minimum;
|
||||
}
|
||||
|
||||
- (NSUInteger) capacity
|
||||
|
@ -3398,16 +3388,10 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
if (aRange.location > length)
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
format: @"location bad in replaceBytesInRange:withBytes:"];
|
||||
format: @"location bad in replaceByteInRange:withBytes:"];
|
||||
}
|
||||
if (aRange.length > 0)
|
||||
{
|
||||
if (moreBytes == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-replaceBytesInRange:withBytes:] called with "
|
||||
@"range but null bytes", NSStringFromClass([self class])];
|
||||
}
|
||||
if (need > length)
|
||||
{
|
||||
[self setCapacity: need];
|
||||
|
@ -3706,30 +3690,25 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
|
||||
#if GS_WITH_GC
|
||||
tmp = NSAllocateCollectable(size, 0);
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, size);
|
||||
#endif
|
||||
if (tmp == 0)
|
||||
{
|
||||
[NSException raise: NSMallocException
|
||||
format: @"Unable to set data capacity to '%d'", size];
|
||||
}
|
||||
|
||||
if (bytes)
|
||||
{
|
||||
memcpy(tmp, bytes, capacity < size ? capacity : size);
|
||||
#if GS_WITH_GC
|
||||
if (owned == YES)
|
||||
{
|
||||
NSZoneFree(NSDefaultMallocZone(), bytes);
|
||||
owned = NO;
|
||||
}
|
||||
}
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, size);
|
||||
if (tmp == 0)
|
||||
{
|
||||
[NSException raise: NSMallocException
|
||||
format: @"Unable to set data capacity to '%d'", size];
|
||||
}
|
||||
if (bytes)
|
||||
{
|
||||
memcpy(tmp, bytes, capacity < size ? capacity : size);
|
||||
if (zone == 0)
|
||||
{
|
||||
zone = NSDefaultMallocZone();
|
||||
|
@ -3738,12 +3717,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
{
|
||||
NSZoneFree(zone, bytes);
|
||||
}
|
||||
}
|
||||
else if (zone == 0)
|
||||
{
|
||||
zone = NSDefaultMallocZone();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
bytes = tmp;
|
||||
capacity = size;
|
||||
growth = capacity/2;
|
||||
|
@ -3840,6 +3815,18 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
[super finalize];
|
||||
}
|
||||
|
||||
- (id) initWithBytes: (const void*)aBuffer length: (NSUInteger)bufferSize
|
||||
{
|
||||
self = [self initWithCapacity: bufferSize];
|
||||
if (self)
|
||||
{
|
||||
if (bufferSize && aBuffer)
|
||||
memcpy(bytes, aBuffer, bufferSize);
|
||||
length = bufferSize;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithCapacity: (NSUInteger)bufferSize
|
||||
{
|
||||
shmid = shmget(IPC_PRIVATE, bufferSize, IPC_CREAT|VM_ACCESS);
|
||||
|
|
|
@ -1120,7 +1120,7 @@ NSSimpleCompare(const NSDecimal *leftOperand, const NSDecimal *rightOperand)
|
|||
}
|
||||
|
||||
void
|
||||
NSDecimalRound(NSDecimal *result, const NSDecimal *number, NSInteger scale,
|
||||
NSDecimalRound(NSDecimal *result, const NSDecimal *number, int scale,
|
||||
NSRoundingMode mode)
|
||||
{
|
||||
GSDecimal m;
|
||||
|
|
|
@ -47,9 +47,13 @@
|
|||
|
||||
static BOOL GSMacOSXCompatiblePropertyLists(void)
|
||||
{
|
||||
#if defined(HAVE_LIBXML)
|
||||
if (GSPrivateDefaultsFlag(NSWriteOldStylePropertyLists) == YES)
|
||||
return NO;
|
||||
return GSPrivateDefaultsFlag(GSMacOSXCompatible);
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
@class GSDictionary;
|
||||
|
|
|
@ -443,24 +443,6 @@ enum proxyLocation
|
|||
{
|
||||
return _connection;
|
||||
}
|
||||
/**
|
||||
* NSProxy subclasses must override -init or an exception will be thrown. This
|
||||
* calls the forwarding mechanism to invoke -init on the remote object.
|
||||
*/
|
||||
- (id) init
|
||||
{
|
||||
NSMethodSignature *sig;
|
||||
NSInvocation *inv;
|
||||
id ret;
|
||||
|
||||
sig = [self methodSignatureForSelector: _cmd];
|
||||
inv = [NSInvocation invocationWithMethodSignature: sig];
|
||||
[inv setTarget: self];
|
||||
[inv setSelector: _cmd];
|
||||
[self forwardInvocation: inv];
|
||||
[inv getReturnValue: &ret];
|
||||
return ret;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
|
|
|
@ -339,7 +339,7 @@ static NSDistributedNotificationCenter *netCenter = nil;
|
|||
NS_DURING
|
||||
{
|
||||
[self _connect];
|
||||
[(id<GDNCProtocol>)_remote addObserver: (uint64_t)(uintptr_t)anObserver
|
||||
[(id<GDNCProtocol>)_remote addObserver: (uint64_t)anObserver
|
||||
selector: NSStringFromSelector(aSelector)
|
||||
name: notificationName
|
||||
object: anObject
|
||||
|
@ -465,7 +465,7 @@ static NSDistributedNotificationCenter *netCenter = nil;
|
|||
NS_DURING
|
||||
{
|
||||
[self _connect];
|
||||
[(id<GDNCProtocol>)_remote removeObserver: (uint64_t)(uintptr_t)anObserver
|
||||
[(id<GDNCProtocol>)_remote removeObserver: (uint64_t)anObserver
|
||||
name: notificationName
|
||||
object: anObject
|
||||
for: (id<GDNCClient>)self];
|
||||
|
@ -808,7 +808,7 @@ static NSDistributedNotificationCenter *netCenter = nil;
|
|||
{
|
||||
id userInfo;
|
||||
NSNotification *notification;
|
||||
id recipient = (id)(uintptr_t)observer;
|
||||
id recipient = (id)observer;
|
||||
|
||||
userInfo = [NSUnarchiver unarchiveObjectWithData: info];
|
||||
notification = [NSNotification notificationWithName: name
|
||||
|
|
|
@ -238,7 +238,6 @@
|
|||
*/
|
||||
@interface GSAttrDictionary : NSDictionary
|
||||
{
|
||||
@public
|
||||
struct _STATB statbuf;
|
||||
_CHAR _path[0];
|
||||
}
|
||||
|
@ -246,8 +245,6 @@
|
|||
traverseLink: (BOOL)traverse;
|
||||
@end
|
||||
|
||||
static Class GSAttrDictionaryClass = 0;
|
||||
|
||||
/*
|
||||
* We also need a special enumerator class to enumerate the dictionary.
|
||||
*/
|
||||
|
@ -345,7 +342,6 @@ static NSStringEncoding defaultEncoding;
|
|||
+ (void) initialize
|
||||
{
|
||||
defaultEncoding = [NSString defaultCStringEncoding];
|
||||
GSAttrDictionaryClass = [GSAttrDictionary class];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
@ -404,16 +400,7 @@ static NSStringEncoding defaultEncoding;
|
|||
lpath = [defaultManager fileSystemRepresentationWithPath: path];
|
||||
|
||||
#ifndef __MINGW32__
|
||||
if (GSObjCClass(attributes) == GSAttrDictionaryClass)
|
||||
{
|
||||
num = ((GSAttrDictionary*)attributes)->statbuf.st_uid;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSNumber *tmpNum = [attributes fileOwnerAccountID];
|
||||
|
||||
num = tmpNum ? [tmpNum unsignedLongValue] : NSNotFound;
|
||||
}
|
||||
num = [attributes fileOwnerAccountID];
|
||||
if (num != NSNotFound)
|
||||
{
|
||||
if (chown(lpath, num, -1) != 0)
|
||||
|
@ -468,16 +455,7 @@ static NSStringEncoding defaultEncoding;
|
|||
}
|
||||
}
|
||||
|
||||
if (GSObjCClass(attributes) == GSAttrDictionaryClass)
|
||||
{
|
||||
num = ((GSAttrDictionary*)attributes)->statbuf.st_gid;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSNumber *tmpNum = [attributes fileGroupOwnerAccountID];
|
||||
|
||||
num = tmpNum ? [tmpNum unsignedLongValue] : NSNotFound;
|
||||
}
|
||||
num = [attributes fileGroupOwnerAccountID];
|
||||
if (num != NSNotFound)
|
||||
{
|
||||
if (chown(lpath, -1, num) != 0)
|
||||
|
@ -791,7 +769,7 @@ static NSStringEncoding defaultEncoding;
|
|||
* If there is no file owner specified, and we are running setuid to
|
||||
* root, then we assume we need to change ownership to correct user.
|
||||
*/
|
||||
if (attributes == nil || ([attributes fileOwnerAccountID] == nil
|
||||
if (attributes == nil || ([attributes fileOwnerAccountID] == NSNotFound
|
||||
&& [attributes fileOwnerAccountName] == nil))
|
||||
{
|
||||
if (geteuid() == 0 && [@"root" isEqualToString: NSUserName()] == NO)
|
||||
|
@ -954,7 +932,7 @@ static NSStringEncoding defaultEncoding;
|
|||
* If there is no file owner specified, and we are running setuid to
|
||||
* root, then we assume we need to change ownership to correct user.
|
||||
*/
|
||||
if (attributes == nil || ([attributes fileOwnerAccountID] == nil
|
||||
if (attributes == nil || ([attributes fileOwnerAccountID] == NSNotFound
|
||||
&& [attributes fileOwnerAccountName] == nil))
|
||||
{
|
||||
if (geteuid() == 0 && [@"root" isEqualToString: NSUserName()] == NO)
|
||||
|
@ -1743,7 +1721,7 @@ static NSStringEncoding defaultEncoding;
|
|||
{
|
||||
NSDictionary *d;
|
||||
|
||||
d = [GSAttrDictionaryClass attributesAt:
|
||||
d = [GSAttrDictionary attributesAt:
|
||||
[self fileSystemRepresentationWithPath: path] traverseLink: flag];
|
||||
return d;
|
||||
}
|
||||
|
@ -1925,6 +1903,11 @@ static NSStringEncoding defaultEncoding;
|
|||
return [path lastPathComponent];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enumerator which can be used to return each item with
|
||||
* the directory at path in turn.<br />
|
||||
* The enumeration is recursive ... following all nested subdirectories.
|
||||
*/
|
||||
- (NSDirectoryEnumerator*) enumeratorAtPath: (NSString*)path
|
||||
{
|
||||
return AUTORELEASE([[NSDirectoryEnumerator alloc]
|
||||
|
@ -2017,10 +2000,6 @@ static NSStringEncoding defaultEncoding;
|
|||
#if defined(__MINGW32__)
|
||||
- (const GSNativeChar*) fileSystemRepresentationWithPath: (NSString*)path
|
||||
{
|
||||
if (path != nil && [path rangeOfString: @"/"].length > 0)
|
||||
{
|
||||
path = [path stringByReplacingString: @"/" withString: @"\\"];
|
||||
}
|
||||
return
|
||||
(const GSNativeChar*)[path cStringUsingEncoding: NSUnicodeStringEncoding];
|
||||
}
|
||||
|
@ -2076,6 +2055,16 @@ static inline void gsedRelease(GSEnumeratedDirectory X)
|
|||
#include "GNUstepBase/GSIArray.h"
|
||||
|
||||
|
||||
/**
|
||||
* <p>This is a subclass of <code>NSEnumerator</code> which provides a full
|
||||
* listing of all the files beneath a directory and its subdirectories.
|
||||
* Instances can be obtained through [NSFileManager-enumeratorAtPath:],
|
||||
* or through an initializer in this class. (For compatibility with OS X,
|
||||
* use the <code>NSFileManager</code> method.)</p>
|
||||
*
|
||||
* <p>This implementation is optimized and performance should be comparable
|
||||
* to the speed of standard Unix tools for large directories.</p>
|
||||
*/
|
||||
@implementation NSDirectoryEnumerator
|
||||
/*
|
||||
* The Objective-C interface hides a traditional C implementation.
|
||||
|
@ -2090,6 +2079,8 @@ static inline void gsedRelease(GSEnumeratedDirectory X)
|
|||
}
|
||||
}
|
||||
|
||||
// Initializing
|
||||
|
||||
/**
|
||||
* Initialize instance to enumerate contents at path, which should be a
|
||||
* directory and can be specified in relative or absolute, and may include
|
||||
|
@ -2349,17 +2340,17 @@ static inline void gsedRelease(GSEnumeratedDirectory X)
|
|||
/**
|
||||
* Returns HFS creator attribute (OS X).
|
||||
*/
|
||||
- (OSType) fileHFSCreatorCode
|
||||
- (int) fileHFSCreatorCode
|
||||
{
|
||||
return [[self objectForKey: NSFileHFSCreatorCode] unsignedLongValue];
|
||||
return [[self objectForKey: NSFileHFSCreatorCode] intValue];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HFS type code attribute (OS X).
|
||||
*/
|
||||
- (OSType) fileHFSTypeCode
|
||||
- (int) fileHFSTypeCode
|
||||
{
|
||||
return [[self objectForKey: NSFileHFSTypeCode] unsignedLongValue];
|
||||
return [[self objectForKey: NSFileHFSTypeCode] intValue];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2410,12 +2401,18 @@ static inline void gsedRelease(GSEnumeratedDirectory X)
|
|||
}
|
||||
|
||||
/**
|
||||
* Return an NSNumber with the numeric value of the NSFileOwnerAccountID attribute
|
||||
* in the dictionary, or nil if the attribute is not present.
|
||||
* Return the numeric value of the NSFileOwnerAccountID attribute
|
||||
* in the dictionary, or NSNotFound if the attribute is not present.
|
||||
*/
|
||||
- (NSNumber*) fileOwnerAccountID
|
||||
- (unsigned long) fileOwnerAccountID
|
||||
{
|
||||
return [self objectForKey: NSFileOwnerAccountID];
|
||||
NSNumber *n = [self objectForKey: NSFileOwnerAccountID];
|
||||
|
||||
if (n == nil)
|
||||
{
|
||||
return NSNotFound;
|
||||
}
|
||||
return [n unsignedIntValue];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2427,12 +2424,18 @@ static inline void gsedRelease(GSEnumeratedDirectory X)
|
|||
}
|
||||
|
||||
/**
|
||||
* Return an NSNumber with the numeric value of the NSFileGroupOwnerAccountID attribute
|
||||
* in the dictionary, or nil if the attribute is not present.
|
||||
* Return the numeric value of the NSFileGroupOwnerAccountID attribute
|
||||
* in the dictionary, or NSNotFound if the attribute is not present.
|
||||
*/
|
||||
- (NSNumber*) fileGroupOwnerAccountID
|
||||
- (unsigned long) fileGroupOwnerAccountID
|
||||
{
|
||||
return [self objectForKey: NSFileGroupOwnerAccountID];
|
||||
NSNumber *n = [self objectForKey: NSFileGroupOwnerAccountID];
|
||||
|
||||
if (n == nil)
|
||||
{
|
||||
return NSNotFound;
|
||||
}
|
||||
return [n unsignedIntValue];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2931,9 +2934,9 @@ static NSSet *fileKeys = nil;
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (NSNumber*) fileGroupOwnerAccountID
|
||||
- (unsigned long) fileGroupOwnerAccountID
|
||||
{
|
||||
return [NSNumber numberWithInt: statbuf.st_gid];
|
||||
return statbuf.st_gid;
|
||||
}
|
||||
|
||||
- (NSString*) fileGroupOwnerAccountName
|
||||
|
@ -3058,12 +3061,12 @@ static NSSet *fileKeys = nil;
|
|||
return group;
|
||||
}
|
||||
|
||||
- (OSType) fileHFSCreatorCode
|
||||
- (int) fileHFSCreatorCode
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (OSType) fileHFSTypeCode
|
||||
- (int) fileHFSTypeCode
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -3088,9 +3091,9 @@ static NSSet *fileKeys = nil;
|
|||
return (statbuf.st_mode & ~S_IFMT);
|
||||
}
|
||||
|
||||
- (NSNumber*) fileOwnerAccountID
|
||||
- (unsigned long) fileOwnerAccountID
|
||||
{
|
||||
return [NSNumber numberWithInt: statbuf.st_uid];
|
||||
return statbuf.st_uid;
|
||||
}
|
||||
|
||||
- (NSString*) fileOwnerAccountName
|
||||
|
@ -3276,11 +3279,11 @@ static NSSet *fileKeys = nil;
|
|||
if (key == NSFileGroupOwnerAccountName)
|
||||
return [self fileGroupOwnerAccountName];
|
||||
if (key == NSFileGroupOwnerAccountID)
|
||||
return [self fileGroupOwnerAccountID];
|
||||
return [NSNumber numberWithInt: [self fileGroupOwnerAccountID]];
|
||||
if (key == NSFileHFSCreatorCode)
|
||||
return [NSNumber numberWithUnsignedLong: [self fileHFSCreatorCode]];
|
||||
return [NSNumber numberWithInt: [self fileHFSCreatorCode]];
|
||||
if (key == NSFileHFSTypeCode)
|
||||
return [NSNumber numberWithUnsignedLong: [self fileHFSTypeCode]];
|
||||
return [NSNumber numberWithInt: [self fileHFSTypeCode]];
|
||||
if (key == NSFileImmutable)
|
||||
return [NSNumber numberWithBool: [self fileIsImmutable]];
|
||||
if (key == NSFileModificationDate)
|
||||
|
@ -3288,7 +3291,7 @@ static NSSet *fileKeys = nil;
|
|||
if (key == NSFileOwnerAccountName)
|
||||
return [self fileOwnerAccountName];
|
||||
if (key == NSFileOwnerAccountID)
|
||||
return [self fileOwnerAccountID];
|
||||
return [NSNumber numberWithInt: [self fileOwnerAccountID]];
|
||||
if (key == NSFilePosixPermissions)
|
||||
return [NSNumber numberWithUnsignedInt: [self filePosixPermissions]];
|
||||
if (key == NSFileReferenceCount)
|
||||
|
|
|
@ -30,12 +30,10 @@
|
|||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSPointerFunctions.h"
|
||||
#include "Foundation/NSSet.h"
|
||||
#include "Foundation/NSZone.h"
|
||||
#include "Foundation/NSHashTable.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "NSCallBacks.h"
|
||||
#include "GSPrivate.h"
|
||||
|
||||
@implementation NSHashTable
|
||||
|
||||
|
@ -72,7 +70,7 @@ static Class concreteClass = 0;
|
|||
return AUTORELEASE(t);
|
||||
}
|
||||
|
||||
+ (id) hashTableWithWeakObjects
|
||||
+ (id) hashTableWithWeakObjects;
|
||||
{
|
||||
return [self hashTableWithOptions:
|
||||
NSPointerFunctionsObjectPersonality | NSPointerFunctionsZeroingWeakMemory];
|
||||
|
@ -105,31 +103,17 @@ static Class concreteClass = 0;
|
|||
|
||||
- (NSArray*) allObjects
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
unsigned nodeCount = [self count];
|
||||
unsigned index;
|
||||
NSArray *a;
|
||||
GS_BEGINITEMBUF(objects, nodeCount, id);
|
||||
|
||||
enumerator = [self objectEnumerator];
|
||||
index = 0;
|
||||
while ((objects[index] = [enumerator nextObject]) != nil)
|
||||
{
|
||||
index++;
|
||||
}
|
||||
a = [[[NSArray alloc] initWithObjects: objects count: nodeCount] autorelease];
|
||||
GS_ENDITEMBUF();
|
||||
return a;
|
||||
return [self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (id) anyObject
|
||||
{
|
||||
return [[self objectEnumerator] nextObject];
|
||||
return [self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (BOOL) containsObject: (id)anObject
|
||||
{
|
||||
return [self member: anObject] ? YES : NO;
|
||||
return (BOOL)(uintptr_t)[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone*)aZone
|
||||
|
@ -156,7 +140,7 @@ static Class concreteClass = 0;
|
|||
|
||||
- (NSUInteger) hash
|
||||
{
|
||||
return [self count];
|
||||
return (NSUInteger)[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
|
@ -166,45 +150,12 @@ static Class concreteClass = 0;
|
|||
|
||||
- (void) intersectHashTable: (NSHashTable*)other
|
||||
{
|
||||
unsigned count = [self count];
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSMutableArray *array;
|
||||
id object;
|
||||
|
||||
array = [NSMutableArray arrayWithCapacity: count];
|
||||
enumerator = [self objectEnumerator];
|
||||
while ((object = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([other member: object] == nil)
|
||||
{
|
||||
[array addObject: object];
|
||||
}
|
||||
}
|
||||
enumerator = [array objectEnumerator];
|
||||
while ((object = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[self removeObject: object];
|
||||
}
|
||||
}
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (BOOL) intersectsHashTable: (NSHashTable*)other
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id object;
|
||||
|
||||
enumerator = [self objectEnumerator];
|
||||
while ((object = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([other member: object] != nil)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
return (BOOL)(uintptr_t)[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (BOOL) isEqual: (id)other
|
||||
|
@ -220,18 +171,7 @@ static Class concreteClass = 0;
|
|||
|
||||
- (BOOL) isSubsetOfHashTable: (NSHashTable*)other
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id object;
|
||||
|
||||
enumerator = [self objectEnumerator];
|
||||
while ((object = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([other member: object] == nil)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
return (BOOL)(uintptr_t)[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (id) member: (id)object
|
||||
|
@ -241,17 +181,7 @@ static Class concreteClass = 0;
|
|||
|
||||
- (void) minusHashTable: (NSHashTable*)other
|
||||
{
|
||||
if ([self count] > 0 && [other count] > 0)
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id object;
|
||||
|
||||
enumerator = [other objectEnumerator];
|
||||
while ((object = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[self removeObject: object];
|
||||
}
|
||||
}
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (NSEnumerator*) objectEnumerator
|
||||
|
@ -266,46 +196,22 @@ static Class concreteClass = 0;
|
|||
|
||||
- (void) removeAllObjects
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id object;
|
||||
|
||||
enumerator = [[self allObjects] objectEnumerator];
|
||||
while ((object = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[self removeObject: object];
|
||||
}
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) removeObject: (id)object
|
||||
- (void) removeObject: (id)aKey
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (NSSet*) setRepresentation
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSMutableSet *set;
|
||||
id object;
|
||||
|
||||
set = [NSMutableSet setWithCapacity: [self count]];
|
||||
enumerator = [[self allObjects] objectEnumerator];
|
||||
while ((object = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[set addObject: object];
|
||||
}
|
||||
return [[set copy] autorelease];
|
||||
return [self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) unionHashTable: (NSHashTable*)other
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id object;
|
||||
|
||||
enumerator = [other objectEnumerator];
|
||||
while ((object = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[self addObject: object];
|
||||
}
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -660,7 +660,82 @@ _arg_addr(NSInvocation *inv, int index)
|
|||
*/
|
||||
- (void) invokeWithTarget: (id)anObject
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
id old_target;
|
||||
retval_t returned;
|
||||
IMP imp;
|
||||
int stack_argsize;
|
||||
|
||||
|
||||
CLEAR_RETURN_VALUE_IF_OBJECT;
|
||||
_validReturn = NO;
|
||||
|
||||
/*
|
||||
* A message to a nil object returns nil.
|
||||
*/
|
||||
if (anObject == nil)
|
||||
{
|
||||
_validReturn = YES;
|
||||
memset(_retval, '\0', _info[0].size); /* Clear return value */
|
||||
return;
|
||||
}
|
||||
|
||||
NSAssert(_selector != 0, @"you must set the selector before invoking");
|
||||
|
||||
/*
|
||||
* Temporarily set new target and copy it (and the selector) into the
|
||||
* _cframe.
|
||||
*/
|
||||
old_target = RETAIN(_target);
|
||||
[self setTarget: anObject];
|
||||
|
||||
_set_arg(self, 0, &_target);
|
||||
_set_arg(self, 1, &_selector);
|
||||
|
||||
if (_sendToSuper == YES)
|
||||
{
|
||||
Super s;
|
||||
|
||||
#ifndef NeXT_RUNTIME
|
||||
s.self = _target;
|
||||
#else
|
||||
s.receiver = _target;
|
||||
#endif
|
||||
if (GSObjCIsInstance(_target))
|
||||
s.class = GSObjCSuper(GSObjCClass(_target));
|
||||
else
|
||||
s.class = GSObjCSuper((Class)_target);
|
||||
imp = objc_msg_lookup_super(&s, _selector);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSMethod method;
|
||||
method = GSGetMethod((GSObjCIsInstance(_target)
|
||||
? (id)GSObjCClass(_target)
|
||||
: (id)_target),
|
||||
_selector,
|
||||
GSObjCIsInstance(_target),
|
||||
YES);
|
||||
imp = method_get_imp(method);
|
||||
/*
|
||||
* If fast lookup failed, we may be forwarding or something ...
|
||||
*/
|
||||
if (imp == 0)
|
||||
imp = objc_msg_lookup(_target, _selector);
|
||||
}
|
||||
[self setTarget: old_target];
|
||||
RELEASE(old_target);
|
||||
|
||||
stack_argsize = [_sig frameLength];
|
||||
|
||||
returned = __builtin_apply((void(*)(void))imp,
|
||||
(arglist_t)_cframe, stack_argsize);
|
||||
if (_info[0].size)
|
||||
{
|
||||
mframe_decode_return(_info[0].type, _retval, returned);
|
||||
}
|
||||
|
||||
RETAIN_RETURN_VALUE;
|
||||
_validReturn = YES;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -898,8 +973,6 @@ _arg_addr(NSInvocation *inv, int index)
|
|||
|
||||
@end
|
||||
|
||||
#if !defined(USE_FFCALL) && !defined(USE_LIBFFI)
|
||||
#warning Using unreliable NSInvocation implementation. It is strongly recommended that you use libffi.
|
||||
@implementation GSFrameInvocation
|
||||
|
||||
- (id) initWithArgframe: (arglist_t)frame selector: (SEL)aSelector
|
||||
|
@ -945,92 +1018,12 @@ _arg_addr(NSInvocation *inv, int index)
|
|||
}
|
||||
return self;
|
||||
}
|
||||
- (void)invokeWithTarget: (id)anObject
|
||||
{
|
||||
id old_target;
|
||||
retval_t returned;
|
||||
IMP imp;
|
||||
int stack_argsize;
|
||||
|
||||
|
||||
CLEAR_RETURN_VALUE_IF_OBJECT;
|
||||
_validReturn = NO;
|
||||
|
||||
/*
|
||||
* A message to a nil object returns nil.
|
||||
*/
|
||||
if (anObject == nil)
|
||||
{
|
||||
_validReturn = YES;
|
||||
memset(_retval, '\0', _info[0].size); /* Clear return value */
|
||||
return;
|
||||
}
|
||||
|
||||
NSAssert(_selector != 0, @"you must set the selector before invoking");
|
||||
|
||||
/*
|
||||
* Temporarily set new target and copy it (and the selector) into the
|
||||
* _cframe.
|
||||
*/
|
||||
old_target = RETAIN(_target);
|
||||
[self setTarget: anObject];
|
||||
|
||||
_set_arg(self, 0, &_target);
|
||||
_set_arg(self, 1, &_selector);
|
||||
|
||||
if (_sendToSuper == YES)
|
||||
{
|
||||
Super s;
|
||||
|
||||
#ifndef NeXT_RUNTIME
|
||||
s.self = _target;
|
||||
#else
|
||||
s.receiver = _target;
|
||||
#endif
|
||||
if (GSObjCIsInstance(_target))
|
||||
s.class = GSObjCSuper(GSObjCClass(_target));
|
||||
else
|
||||
s.class = GSObjCSuper((Class)_target);
|
||||
imp = objc_msg_lookup_super(&s, _selector);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSMethod method;
|
||||
method = GSGetMethod((GSObjCIsInstance(_target)
|
||||
? (id)GSObjCClass(_target)
|
||||
: (id)_target),
|
||||
_selector,
|
||||
GSObjCIsInstance(_target),
|
||||
YES);
|
||||
imp = method_get_imp(method);
|
||||
/*
|
||||
* If fast lookup failed, we may be forwarding or something ...
|
||||
*/
|
||||
if (imp == 0)
|
||||
imp = objc_msg_lookup(_target, _selector);
|
||||
}
|
||||
[self setTarget: old_target];
|
||||
RELEASE(old_target);
|
||||
|
||||
stack_argsize = [_sig frameLength];
|
||||
|
||||
returned = __builtin_apply((void(*)(void))imp,
|
||||
(arglist_t)_cframe, stack_argsize);
|
||||
if (_info[0].size)
|
||||
{
|
||||
mframe_decode_return(_info[0].type, _retval, returned);
|
||||
}
|
||||
|
||||
RETAIN_RETURN_VALUE;
|
||||
_validReturn = YES;
|
||||
}
|
||||
|
||||
- (void*) returnFrame: (arglist_t)argFrame
|
||||
{
|
||||
return mframe_handle_return(_info[0].type, _retval, argFrame);
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
||||
|
||||
@implementation GSInvocationProxy
|
||||
|
|
|
@ -473,10 +473,11 @@ replacementForClass(Class c)
|
|||
}
|
||||
|
||||
/*
|
||||
* A setter must take three arguments (self, _cmd, value).
|
||||
* The return value (if any) is ignored.
|
||||
* A setter must take three arguments (self, _cmd, value)
|
||||
* and return nothing.
|
||||
*/
|
||||
if ([sig numberOfArguments] != 3)
|
||||
if (*[sig methodReturnType] != _C_VOID
|
||||
|| [sig numberOfArguments] != 3)
|
||||
{
|
||||
continue; // Not a valid setter method.
|
||||
}
|
||||
|
|
|
@ -780,6 +780,13 @@ static NSMapTable *globalClassMap = 0;
|
|||
errorDescription: &error];
|
||||
if (_archive == nil)
|
||||
{
|
||||
#ifndef HAVE_LIBXML
|
||||
if (format == NSPropertyListXMLFormat_v1_0)
|
||||
{
|
||||
NSLog(@"Unable to parse XML archive as the base "
|
||||
@"library was not configured with libxml2 support.");
|
||||
}
|
||||
#endif
|
||||
DESTROY(self);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "Foundation/NSObject.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSPointerFunctions.h"
|
||||
#include "Foundation/NSZone.h"
|
||||
|
@ -147,17 +146,7 @@ static Class concreteClass = 0;
|
|||
|
||||
- (NSDictionary*) dictionaryRepresentation
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSMutableDictionary *dictionary;
|
||||
id key;
|
||||
|
||||
dictionary = [NSMutableDictionary dictionaryWithCapacity: [self count]];
|
||||
enumerator = [self keyEnumerator];
|
||||
while ((key = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[dictionary setObject: [self objectForKey: key] forKey: key];
|
||||
}
|
||||
return [[dictionary copy] autorelease];
|
||||
return [self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
|
@ -167,7 +156,7 @@ static Class concreteClass = 0;
|
|||
|
||||
- (NSUInteger) hash
|
||||
{
|
||||
return [self count];
|
||||
return (NSUInteger)[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
|
@ -203,27 +192,7 @@ static Class concreteClass = 0;
|
|||
|
||||
- (void) removeAllObjects
|
||||
{
|
||||
unsigned count = [self count];
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSMutableArray *array;
|
||||
id key;
|
||||
|
||||
array = [[NSMutableArray alloc] initWithCapacity: count];
|
||||
enumerator = [self objectEnumerator];
|
||||
while ((key = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[array addObject: key];
|
||||
}
|
||||
enumerator = [array objectEnumerator];
|
||||
while ((key = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[self removeObjectForKey: key];
|
||||
}
|
||||
[array release];
|
||||
}
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) removeObjectForKey: (id)aKey
|
||||
|
|
|
@ -65,9 +65,6 @@
|
|||
#ifdef HAVE_SYS_SIGNAL_H
|
||||
#include <sys/signal.h>
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
#include <fenv.h>
|
||||
#endif
|
||||
|
||||
#include "GSPrivate.h"
|
||||
|
||||
|
@ -222,15 +219,6 @@ typedef int32_t volatile *gsatomic_t;
|
|||
#define GSAtomicDecrement(X) InterlockedDecrement((LONG volatile*)X)
|
||||
|
||||
|
||||
#elif defined(__llvm__) || (defined(USE_ATOMIC_BUILDINS) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)))
|
||||
/* Use the GCC atomic operations with recent GCC versions */
|
||||
|
||||
typedef int32_t volatile *gsatomic_t;
|
||||
#define GSATOMICREAD(X) (*(X))
|
||||
#define GSAtomicIncrement(X) __sync_fetch_and_add(X, 1)
|
||||
#define GSAtomicDecrement(X) __sync_fetch_and_sub(X, 1)
|
||||
|
||||
|
||||
#elif defined(__linux__) && (defined(__i386__) || defined(__x86_64__))
|
||||
/* Set up atomic read, increment and decrement for intel style linux
|
||||
*/
|
||||
|
@ -268,11 +256,11 @@ GSAtomicIncrement(gsatomic_t X)
|
|||
{
|
||||
int tmp;
|
||||
__asm__ __volatile__ (
|
||||
"incmodified:"
|
||||
"modified:"
|
||||
"lwarx %0,0,%1 \n"
|
||||
"addic %0,%0,1 \n"
|
||||
"stwcx. %0,0,%1 \n"
|
||||
"bne- incmodified \n"
|
||||
"bne- modified \n"
|
||||
:"=&r" (tmp)
|
||||
:"r" (X)
|
||||
:"cc", "memory");
|
||||
|
@ -284,41 +272,17 @@ GSAtomicDecrement(gsatomic_t X)
|
|||
{
|
||||
int tmp;
|
||||
__asm__ __volatile__ (
|
||||
"decmodified:"
|
||||
"modified:"
|
||||
"lwarx %0,0,%1 \n"
|
||||
"addic %0,%0,-1 \n"
|
||||
"stwcx. %0,0,%1 \n"
|
||||
"bne- decmodified \n"
|
||||
"bne- modified \n"
|
||||
:"=&r" (tmp)
|
||||
:"r" (X)
|
||||
:"cc", "memory");
|
||||
return *X;
|
||||
}
|
||||
|
||||
#elif defined(__m68k__)
|
||||
|
||||
typedef int32_t volatile *gsatomic_t;
|
||||
|
||||
#define GSATOMICREAD(X) (*(X))
|
||||
|
||||
static __inline__ int
|
||||
GSAtomicIncrement(gsatomic_t X)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"addq%.l %#1, %0"
|
||||
:"=m" (*X));
|
||||
return *X;
|
||||
}
|
||||
|
||||
static __inline__ int
|
||||
GSAtomicDecrement(gsatomic_t X)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"subq%.l %#1, %0"
|
||||
:"=m" (*X));
|
||||
return *X;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(GSATOMICREAD)
|
||||
|
@ -692,15 +656,12 @@ GSPrivateSwizzle(id o, Class c)
|
|||
}
|
||||
else if (GSIsFinalizable(c))
|
||||
{
|
||||
/* New class is finalizable, so we must register the instance
|
||||
/* New clas is finalizable, so we must register the instance
|
||||
* for finalisation and do allocation acounting for it.
|
||||
*/
|
||||
AADD(c, o);
|
||||
GC_REGISTER_FINALIZER (o, GSFinalize, NULL, NULL, NULL);
|
||||
}
|
||||
#else
|
||||
AREM(o->class_pointer, o);
|
||||
AADD(c, o);
|
||||
#endif /* GS_WITH_GC */
|
||||
o->class_pointer = c;
|
||||
}
|
||||
|
@ -974,7 +935,14 @@ GSGarbageCollectorLog(char *msg, GC_word arg)
|
|||
// Manipulate the FPU to add the exception mask. (Fixes SIGFPE
|
||||
// problems on *BSD)
|
||||
// Note this only works on x86
|
||||
fedisableexcept(FE_INVALID);
|
||||
|
||||
{
|
||||
volatile short cw;
|
||||
|
||||
__asm__ volatile ("fstcw (%0)" : : "g" (&cw));
|
||||
cw |= 1; /* Mask 'invalid' exception */
|
||||
__asm__ volatile ("fldcw (%0)" : : "g" (&cw));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -1,246 +0,0 @@
|
|||
/**Implementation for NSOperation for GNUStep
|
||||
Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Gregory Casamento <greg.casamento@gmail.com>
|
||||
Date: 2009
|
||||
|
||||
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 Lesser 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 Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
<title>NSOperation class reference</title>
|
||||
$Date: 2008-06-08 11:38:33 +0100 (Sun, 08 Jun 2008) $ $Revision: 26606 $
|
||||
*/
|
||||
|
||||
#import "config.h"
|
||||
#import "Foundation/NSOperation.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSException.h"
|
||||
|
||||
#define GSInternal NSOperationInternal
|
||||
#include "GSInternal.h"
|
||||
GS_BEGIN_INTERNAL(NSOperation)
|
||||
NSOperationQueuePriority priority;
|
||||
BOOL cancelled;
|
||||
BOOL concurrent;
|
||||
BOOL executing;
|
||||
BOOL finished;
|
||||
BOOL ready;
|
||||
NSMutableArray *dependencies;
|
||||
GS_END_INTERNAL(NSOperation)
|
||||
|
||||
|
||||
@implementation NSOperation : NSObject
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (internal != nil)
|
||||
{
|
||||
RELEASE(internal->dependencies);
|
||||
GS_DESTROY_INTERNAL(NSOperation);
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
GS_CREATE_INTERNAL(NSOperation);
|
||||
internal->priority = NSOperationQueuePriorityNormal;
|
||||
internal->dependencies = [[NSMutableArray alloc] initWithCapacity: 5];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
// Executing the operation
|
||||
- (void) start
|
||||
{
|
||||
internal->executing = YES;
|
||||
internal->finished = NO;
|
||||
|
||||
if ([self isConcurrent])
|
||||
{
|
||||
[self main];
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_DURING
|
||||
{
|
||||
[self main];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSLog(@"%@",[localException reason]);
|
||||
}
|
||||
NS_ENDHANDLER;
|
||||
}
|
||||
|
||||
internal->executing = NO;
|
||||
internal->finished = YES;
|
||||
}
|
||||
|
||||
- (void) main;
|
||||
{
|
||||
// subclass responsibility...
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
// Cancelling the operation
|
||||
- (void) cancel
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
// Getting the operation status
|
||||
- (BOOL) isCancelled
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) isExecuting
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) isFinished
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) isConcurrent
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) isReady
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Managing dependencies
|
||||
- (void) addDependency: (NSOperation *)op
|
||||
{
|
||||
[internal->dependencies addObject: op];
|
||||
}
|
||||
|
||||
- (void) removeDependency: (NSOperation *)op
|
||||
{
|
||||
[internal->dependencies removeObject: op];
|
||||
}
|
||||
|
||||
- (NSArray *)dependencies
|
||||
{
|
||||
return [NSArray arrayWithArray: internal->dependencies];
|
||||
}
|
||||
|
||||
// Prioritization
|
||||
- (NSOperationQueuePriority) queuePriority
|
||||
{
|
||||
return internal->priority;
|
||||
}
|
||||
|
||||
- (void) setQueuePriority: (NSOperationQueuePriority)pri
|
||||
{
|
||||
internal->priority = pri;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
#undef GSInternal
|
||||
#define GSInternal NSOperationQueueInternal
|
||||
#include "GSInternal.h"
|
||||
GS_BEGIN_INTERNAL(NSOperationQueue)
|
||||
NSMutableArray *operations;
|
||||
BOOL suspended;
|
||||
NSInteger count;
|
||||
GS_END_INTERNAL(NSOperationQueue)
|
||||
|
||||
|
||||
@implementation NSOperationQueue
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (_internal != nil)
|
||||
{
|
||||
[internal->operations release];
|
||||
GS_DESTROY_INTERNAL(NSOperationQueue);
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
GS_CREATE_INTERNAL(NSOperationQueue);
|
||||
internal->suspended = NO;
|
||||
internal->count = NSOperationQueueDefaultMaxConcurrentOperationCount;
|
||||
internal->operations = [NSMutableArray new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// status
|
||||
- (BOOL) isSuspended
|
||||
{
|
||||
return internal->suspended;
|
||||
}
|
||||
|
||||
- (void) setSuspended: (BOOL)flag
|
||||
{
|
||||
internal->suspended = flag;
|
||||
}
|
||||
|
||||
- (NSInteger) maxConcurrentOperationCount
|
||||
{
|
||||
return internal->count;
|
||||
}
|
||||
|
||||
- (void) setMaxConcurrentOperationCount: (NSInteger)cnt
|
||||
{
|
||||
internal->count = cnt;
|
||||
}
|
||||
|
||||
// operations
|
||||
- (void) addOperation: (NSOperation *) op
|
||||
{
|
||||
[internal->operations addObject: op];
|
||||
}
|
||||
|
||||
- (NSArray *) operations
|
||||
{
|
||||
return [NSArray arrayWithArray: internal->operations];
|
||||
}
|
||||
|
||||
- (void) cancelAllOperations
|
||||
{
|
||||
NSEnumerator *en = [internal->operations objectEnumerator];
|
||||
id o = nil;
|
||||
|
||||
while ((o = [en nextObject]) != nil )
|
||||
{
|
||||
[o cancel];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) waitUntilAllOperationsAreFinished
|
||||
{
|
||||
// not yet implemented...
|
||||
}
|
||||
@end
|
|
@ -1445,11 +1445,6 @@ BOOL GSDebugSet(NSString *level)
|
|||
[[NSProcessInfo processInfo] debugSet];
|
||||
}
|
||||
debugImp = [_debug_set methodForSelector: debugSel];
|
||||
if (debugImp == 0)
|
||||
{
|
||||
fprintf(stderr, "Unable to set up with [NSProcessInfo-debugSet]\n");
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
if ((*debugImp)(_debug_set, debugSel, level) == nil)
|
||||
{
|
||||
|
|
|
@ -81,8 +81,6 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
|||
NSString *key;
|
||||
BOOL inArray;
|
||||
BOOL inDictionary;
|
||||
BOOL parsed;
|
||||
BOOL success;
|
||||
id plist;
|
||||
NSPropertyListMutabilityOptions opts;
|
||||
}
|
||||
|
@ -121,6 +119,7 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
|||
{
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
stack = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||
theParser = [[GSSloppyXMLParser alloc] initWithData: data];
|
||||
[theParser setDelegate: self];
|
||||
opts = options;
|
||||
|
@ -134,6 +133,10 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
|||
string = [string stringByTrimmingSpaces];
|
||||
if ([string length] > 0)
|
||||
{
|
||||
if (value == nil)
|
||||
{
|
||||
value = [[NSMutableString alloc] initWithCapacity: 50];
|
||||
}
|
||||
[value appendString: string];
|
||||
}
|
||||
}
|
||||
|
@ -230,8 +233,8 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
|||
}
|
||||
else if ([elementName isEqualToString: @"key"] == YES)
|
||||
{
|
||||
ASSIGNCOPY(key, value);
|
||||
[value setString: @""];
|
||||
ASSIGN(key, [value makeImmutableCopyOnFail: NO]);
|
||||
DESTROY(value);
|
||||
return;
|
||||
}
|
||||
else if ([elementName isEqualToString: @"data"])
|
||||
|
@ -273,11 +276,25 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
|||
|
||||
if (opts == NSPropertyListMutableContainersAndLeaves)
|
||||
{
|
||||
o = [value mutableCopy];
|
||||
if (value == nil)
|
||||
{
|
||||
o = [NSMutableString string];
|
||||
}
|
||||
else
|
||||
{
|
||||
o = value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
o = [value copy];
|
||||
if (value == nil)
|
||||
{
|
||||
o = @"";
|
||||
}
|
||||
else
|
||||
{
|
||||
o = [value makeImmutableCopyOnFail: NO];
|
||||
}
|
||||
}
|
||||
ASSIGN(plist, o);
|
||||
}
|
||||
|
@ -299,7 +316,7 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
|||
}
|
||||
else if ([elementName isEqualToString: @"plist"])
|
||||
{
|
||||
[value setString: @""];
|
||||
DESTROY(value);
|
||||
return;
|
||||
}
|
||||
else // invalid tag
|
||||
|
@ -323,19 +340,12 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
|||
[(NSMutableDictionary*)[stack lastObject] setObject: plist forKey: key];
|
||||
DESTROY(key);
|
||||
}
|
||||
[value setString: @""];
|
||||
DESTROY(value);
|
||||
}
|
||||
|
||||
- (BOOL) parse
|
||||
{
|
||||
if (parsed == NO)
|
||||
{
|
||||
parsed = YES;
|
||||
stack = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||
value = [[NSMutableString alloc] initWithCapacity: 50];
|
||||
success = [theParser parse];
|
||||
}
|
||||
return success;
|
||||
return [theParser parse];
|
||||
}
|
||||
|
||||
- (id) result
|
||||
|
@ -511,6 +521,11 @@ static void setupQuotables(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBXML
|
||||
#import "GNUstepBase/GSXML.h"
|
||||
static int XML_ELEMENT_NODE;
|
||||
#endif
|
||||
|
||||
#define inrange(ch,min,max) ((ch)>=(min) && (ch)<=(max))
|
||||
#define char2num(ch) \
|
||||
inrange(ch,'0','9') \
|
||||
|
@ -1164,6 +1179,216 @@ static id parsePlItem(pldata* pld)
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBXML
|
||||
static GSXMLNode*
|
||||
elementNode(GSXMLNode* node)
|
||||
{
|
||||
while (node != nil)
|
||||
{
|
||||
if ([node type] == XML_ELEMENT_NODE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
node = [node next];
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
static id
|
||||
nodeToObject(GSXMLNode* node, NSPropertyListMutabilityOptions o, NSString **e)
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
id result = nil;
|
||||
|
||||
node = elementNode(node);
|
||||
if (node != nil)
|
||||
{
|
||||
NSString *name;
|
||||
NSString *content;
|
||||
GSXMLNode *children;
|
||||
BOOL isKey = NO;
|
||||
|
||||
name = [node name];
|
||||
children = [node firstChild];
|
||||
content = [children content];
|
||||
children = elementNode(children);
|
||||
|
||||
isKey = [name isEqualToString: @"key"];
|
||||
if (isKey == YES || [name isEqualToString: @"string"] == YES)
|
||||
{
|
||||
if (content == nil)
|
||||
{
|
||||
content = @"";
|
||||
}
|
||||
else
|
||||
{
|
||||
NSRange r;
|
||||
|
||||
r = [content rangeOfString: @"\\"];
|
||||
if (r.length == 1)
|
||||
{
|
||||
unsigned len = [content length];
|
||||
unichar buf[len];
|
||||
unsigned pos = r.location;
|
||||
|
||||
[content getCharacters: buf];
|
||||
while (pos < len)
|
||||
{
|
||||
if (++pos < len)
|
||||
{
|
||||
if ((buf[pos] == 'u' || buf[pos] == 'U')
|
||||
&& (len >= pos + 4))
|
||||
{
|
||||
unichar val = 0;
|
||||
unsigned i;
|
||||
BOOL ok = YES;
|
||||
|
||||
for (i = 1; i < 5; i++)
|
||||
{
|
||||
unichar c = buf[pos + i];
|
||||
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
val = (val << 4) + c - '0';
|
||||
}
|
||||
else if (c >= 'A' && c <= 'F')
|
||||
{
|
||||
val = (val << 4) + c - 'A' + 10;
|
||||
}
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
{
|
||||
val = (val << 4) + c - 'a' + 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
ok = NO;
|
||||
}
|
||||
}
|
||||
if (ok == YES)
|
||||
{
|
||||
len -= 5;
|
||||
memcpy(&buf[pos], &buf[pos+5],
|
||||
(len - pos) * sizeof(unichar));
|
||||
buf[pos - 1] = val;
|
||||
}
|
||||
}
|
||||
while (pos < len && buf[pos] != '\\')
|
||||
{
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isKey == NO
|
||||
&& o == NSPropertyListMutableContainersAndLeaves)
|
||||
{
|
||||
content = [NSMutableString stringWithCharacters: buf
|
||||
length: len];
|
||||
}
|
||||
else
|
||||
{
|
||||
content = [NSString stringWithCharacters: buf
|
||||
length: len];
|
||||
}
|
||||
}
|
||||
}
|
||||
result = content;
|
||||
}
|
||||
else if ([name isEqualToString: @"true"])
|
||||
{
|
||||
result = [NSNumber numberWithBool: YES];
|
||||
}
|
||||
else if ([name isEqualToString: @"false"])
|
||||
{
|
||||
result = [NSNumber numberWithBool: NO];
|
||||
}
|
||||
else if ([name isEqualToString: @"integer"])
|
||||
{
|
||||
if (content == nil)
|
||||
{
|
||||
content = @"0";
|
||||
}
|
||||
result = [NSNumber numberWithInt: [content intValue]];
|
||||
}
|
||||
else if ([name isEqualToString: @"real"])
|
||||
{
|
||||
if (content == nil)
|
||||
{
|
||||
content = @"0.0";
|
||||
}
|
||||
result = [NSNumber numberWithDouble: [content doubleValue]];
|
||||
}
|
||||
else if ([name isEqualToString: @"date"])
|
||||
{
|
||||
if (content == nil)
|
||||
{
|
||||
content = @"";
|
||||
}
|
||||
if ([content hasSuffix: @"Z"] == YES && [content length] == 20)
|
||||
{
|
||||
result = [NSCalendarDate dateWithString: content
|
||||
calendarFormat: @"%Y-%m-%dT%H:%M:%SZ"];
|
||||
}
|
||||
else
|
||||
{
|
||||
result = [NSCalendarDate dateWithString: content
|
||||
calendarFormat: @"%Y-%m-%d %H:%M:%S %z"];
|
||||
}
|
||||
}
|
||||
else if ([name isEqualToString: @"data"])
|
||||
{
|
||||
result = [GSMimeDocument decodeBase64:
|
||||
[content dataUsingEncoding: NSASCIIStringEncoding]];
|
||||
if (o == NSPropertyListMutableContainersAndLeaves)
|
||||
{
|
||||
result = AUTORELEASE([result mutableCopy]);
|
||||
}
|
||||
}
|
||||
// container class
|
||||
else if ([name isEqualToString: @"array"])
|
||||
{
|
||||
NSMutableArray *container = [plArray array];
|
||||
|
||||
while (children != nil)
|
||||
{
|
||||
id val;
|
||||
|
||||
val = nodeToObject(children, o, e);
|
||||
[container addObject: val];
|
||||
children = [children nextElement];
|
||||
}
|
||||
result = container;
|
||||
if (o == NSPropertyListImmutable)
|
||||
{
|
||||
[result makeImmutableCopyOnFail: NO];
|
||||
}
|
||||
}
|
||||
else if ([name isEqualToString: @"dict"])
|
||||
{
|
||||
NSMutableDictionary *container = [plDictionary dictionary];
|
||||
|
||||
while (children != nil)
|
||||
{
|
||||
NSString *key;
|
||||
id val;
|
||||
|
||||
key = nodeToObject(children, o, e);
|
||||
children = [children nextElement];
|
||||
val = nodeToObject(children, o, e);
|
||||
children = [children nextElement];
|
||||
[container setObject: val forKey: key];
|
||||
}
|
||||
result = container;
|
||||
if (o == NSPropertyListImmutable)
|
||||
{
|
||||
[result makeImmutableCopyOnFail: NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
IF_NO_GC([result retain]; [arp release];)
|
||||
return AUTORELEASE(result);
|
||||
}
|
||||
#endif
|
||||
|
||||
id
|
||||
GSPropertyListFromStringsFormat(NSString *string)
|
||||
{
|
||||
|
@ -1986,15 +2211,8 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step,
|
|||
{
|
||||
if ([keys[i] isKindOfClass: NSStringClass] == NO)
|
||||
{
|
||||
if ([keys[i] isKindOfClass: NSNumberClass] == YES)
|
||||
{
|
||||
keys[i] = [keys[i] description];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Bad key in property list: '%@'", keys[i]];
|
||||
}
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Bad key in property list: '%@'", keys[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2197,6 +2415,13 @@ static BOOL classInitialized = NO;
|
|||
{
|
||||
classInitialized = YES;
|
||||
|
||||
#if HAVE_LIBXML
|
||||
/*
|
||||
* Cache XML node information.
|
||||
*/
|
||||
XML_ELEMENT_NODE = [GSXMLNode typeFromDescription: @"XML_ELEMENT_NODE"];
|
||||
#endif
|
||||
|
||||
NSStringClass = [NSString class];
|
||||
NSMutableStringClass = [NSMutableString class];
|
||||
NSDataClass = [NSData class];
|
||||
|
@ -2414,19 +2639,47 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
|||
{
|
||||
case NSPropertyListXMLFormat_v1_0:
|
||||
{
|
||||
GSXMLPListParser *parser;
|
||||
#if HAVE_LIBXML
|
||||
GSXMLParser *parser;
|
||||
GSXMLNode *node;
|
||||
|
||||
parser = [GSXMLPListParser alloc];
|
||||
parser = AUTORELEASE([parser initWithData: data
|
||||
mutability: anOption]);
|
||||
if ([parser parse] == YES)
|
||||
parser = [GSXMLParser parser];
|
||||
[parser substituteEntities: YES];
|
||||
[parser doValidityChecking: YES];
|
||||
[parser saveMessages: YES];
|
||||
if ([parser parse: data] == NO || [parser parse: nil] == NO)
|
||||
{
|
||||
result = AUTORELEASE(RETAIN([parser result]));
|
||||
error = @"failed to parse as valid XML matching DTD";
|
||||
}
|
||||
else if (error == nil)
|
||||
node = [[parser document] root];
|
||||
if (error == nil && [[node name] isEqualToString: @"plist"] == NO)
|
||||
{
|
||||
error = @"failed to parse as XML property list";
|
||||
}
|
||||
if (error == nil)
|
||||
{
|
||||
result = nodeToObject([node firstChild], anOption, &error);
|
||||
}
|
||||
#endif
|
||||
/* The libxml based parser is stricter than the fallback
|
||||
* parser, so if parsing failed using that, we can try again.
|
||||
*/
|
||||
if (result == nil)
|
||||
{
|
||||
GSXMLPListParser *parser;
|
||||
|
||||
parser = [GSXMLPListParser alloc];
|
||||
parser = AUTORELEASE([parser initWithData: data
|
||||
mutability: anOption]);
|
||||
if ([parser parse] == YES)
|
||||
{
|
||||
result = AUTORELEASE(RETAIN([parser result]));
|
||||
}
|
||||
else if (error == nil)
|
||||
{
|
||||
error = @"failed to parse as XML property list";
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -390,7 +390,6 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
- (GSRunLoopWatcher*) _getWatcher: (void*)data
|
||||
type: (RunLoopEventType)type
|
||||
forMode: (NSString*)mode;
|
||||
- (id) _init;
|
||||
- (void) _removeWatcher: (void*)data
|
||||
type: (RunLoopEventType)type
|
||||
forMode: (NSString*)mode;
|
||||
|
@ -524,27 +523,6 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (id) _init
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_contextStack = [NSMutableArray new];
|
||||
_contextMap = NSCreateMapTable (NSNonRetainedObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 0);
|
||||
_timedPerformers = [[NSMutableArray alloc] initWithCapacity: 8];
|
||||
#ifdef HAVE_POLL_F
|
||||
#if GS_WITH_GC
|
||||
_extra = NSAllocateCollectable(sizeof(pollextra), NSScannedOption);
|
||||
#else
|
||||
_extra = NSZoneMalloc(NSDefaultMallocZone(), sizeof(pollextra));
|
||||
memset(_extra, '\0', sizeof(pollextra));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a runloop watcher matching the specified data and type in this
|
||||
* runloop. If the mode is nil, either the currentMode is used (if the
|
||||
|
@ -674,9 +652,8 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
* [NSTimer]s, and sending notifications and other messages
|
||||
* asynchronously.</p>
|
||||
*
|
||||
* <p>There is one run loop per thread in an application, which
|
||||
* may always be obtained through the <code>+currentRunLoop</code> method
|
||||
* (you cannot use -init or +new),
|
||||
* <p>In general, there is one run loop per thread in an application, which
|
||||
* may always be obtained through the <code>+currentRunLoop</code> method,
|
||||
* however unless you are using the AppKit and the [NSApplication] class, the
|
||||
* run loop will not be started unless you explicitly send it a
|
||||
* <code>-run</code> message.</p>
|
||||
|
@ -706,7 +683,7 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
|
||||
if (current == nil)
|
||||
{
|
||||
current = info->loop = [[self alloc] _init];
|
||||
current = info->loop = [self new];
|
||||
/* If this is the main thread, set up a housekeeping timer.
|
||||
*/
|
||||
if ([GSCurrentThread() isMainThread] == YES)
|
||||
|
@ -758,10 +735,26 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
return current;
|
||||
}
|
||||
|
||||
/* This is the designated initializer. */
|
||||
- (id) init
|
||||
{
|
||||
[self release];
|
||||
return nil;
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_contextStack = [NSMutableArray new];
|
||||
_contextMap = NSCreateMapTable (NSNonRetainedObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 0);
|
||||
_timedPerformers = [[NSMutableArray alloc] initWithCapacity: 8];
|
||||
#ifdef HAVE_POLL_F
|
||||
#if GS_WITH_GC
|
||||
_extra = NSAllocateCollectable(sizeof(pollextra), NSScannedOption);
|
||||
#else
|
||||
_extra = NSZoneMalloc(NSDefaultMallocZone(), sizeof(pollextra));
|
||||
memset(_extra, '\0', sizeof(pollextra));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
@ -846,10 +839,7 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
/**
|
||||
* Fires timers whose fire date has passed, and checks timers and limit dates
|
||||
* for input sources, determining the earliest time that any future timeout
|
||||
* becomes due. Returns that date/time.<br />
|
||||
* Returns distant future if the loop contains no timers, just input sources
|
||||
* without timeouts.<br />
|
||||
* Returns nil if the loop contains neither timers nor input sources.
|
||||
* becomes due. Returns that date/time.
|
||||
*/
|
||||
- (NSDate*) limitDateForMode: (NSString*)mode
|
||||
{
|
||||
|
@ -1094,7 +1084,7 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
* otherwise block until input is available or until the
|
||||
* earliest limit date has passed (whichever comes first).<br />
|
||||
* If the supplied mode is nil, uses NSDefaultRunLoopMode.<br />
|
||||
* If there are no input sources or timers in the mode, returns immediately.
|
||||
* If there are no input sources in the mode, returns immediately.
|
||||
*/
|
||||
- (void) acceptInputForMode: (NSString*)mode
|
||||
beforeDate: (NSDate*)limit_date
|
||||
|
@ -1129,11 +1119,9 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
limit_date = timerDate(context->housekeeper);
|
||||
}
|
||||
|
||||
if (context == nil
|
||||
|| (GSIArrayCount(context->watchers) == 0
|
||||
&& GSIArrayCount(context->timers) == 0))
|
||||
if (context == nil || GSIArrayCount(context->watchers) == 0)
|
||||
{
|
||||
NSDebugMLLog(@"NSRunLoop", @"no inputs or timers in mode %@", mode);
|
||||
NSDebugMLLog(@"NSRunLoop", @"no inputs in mode %@", mode);
|
||||
GSPrivateNotifyASAP();
|
||||
GSPrivateNotifyIdle();
|
||||
/* Pause until the limit date or until we might have
|
||||
|
@ -1167,13 +1155,13 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
}
|
||||
else
|
||||
{
|
||||
timeout_ms = (ti * 1000.0);
|
||||
timeout_ms = ti * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
NSDebugMLLog(@"NSRunLoop",
|
||||
@"accept I/P before %d millisec from now in %@",
|
||||
timeout_ms, mode);
|
||||
@"accept I/P before %f (sec from now %f) in %@",
|
||||
[limit_date timeIntervalSinceReferenceDate], ti, mode);
|
||||
|
||||
if ([_contextStack indexOfObjectIdenticalTo: context] == NSNotFound)
|
||||
{
|
||||
|
@ -1216,13 +1204,13 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
* until the limit date of the first input or timeout.<br />
|
||||
* If the specified date is in the past, this runs the loop once only,
|
||||
* to handle any events already available.<br />
|
||||
* If there are no input sources or timers in mode, this method
|
||||
* returns NO without running the loop (irrespective of the supplied
|
||||
* date argument), otherwise returns YES.
|
||||
* If there are no input sources in mode, returns NO without running the loop,
|
||||
* otherwise returns YES.
|
||||
*/
|
||||
- (BOOL) runMode: (NSString*)mode beforeDate: (NSDate*)date
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
GSRunLoopCtxt *context;
|
||||
NSDate *d;
|
||||
|
||||
NSAssert(mode != nil, NSInvalidArgumentException);
|
||||
|
@ -1230,6 +1218,23 @@ static inline BOOL timerInvalidated(NSTimer *t)
|
|||
/* Find out how long we can wait before first limit date. */
|
||||
d = [self limitDateForMode: mode];
|
||||
if (d == nil)
|
||||
{
|
||||
NSDebugMLLog(@"NSRunLoop", @"run mode with nothing to do %@", mode);
|
||||
/*
|
||||
* Notify if any tasks have completed.
|
||||
*/
|
||||
if (GSPrivateCheckTasks() == YES)
|
||||
{
|
||||
GSPrivateNotifyASAP();
|
||||
}
|
||||
RELEASE(arp);
|
||||
return NO;
|
||||
}
|
||||
|
||||
/* Check to see if we have any input sources.
|
||||
*/
|
||||
context = NSMapGet(_contextMap, mode);
|
||||
if (context == nil || GSIArrayCount(context->watchers) == 0)
|
||||
{
|
||||
RELEASE(arp);
|
||||
return NO;
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "Foundation/NSConnection.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
|
||||
#include "GSNetwork.h"
|
||||
#include "GSPortPrivate.h"
|
||||
#include "GSPrivate.h"
|
||||
|
||||
|
@ -55,6 +54,7 @@
|
|||
|
||||
#ifdef __MINGW32__
|
||||
#define close closesocket
|
||||
#define socklen_t int
|
||||
#else
|
||||
#include <sys/param.h> /* for MAXHOSTNAMELEN */
|
||||
#include <sys/types.h>
|
||||
|
@ -1874,7 +1874,6 @@ static Class tcpPortClass;
|
|||
if (handle->recvPort == recvSelf && handle->inReplyMode == NO)
|
||||
{
|
||||
fds[(*count)++] = (uintptr_t)event;
|
||||
NSDebugMLLog(@"NSPort", @"Add event %p", event);
|
||||
}
|
||||
}
|
||||
NSEndMapTableEnumeration(&me);
|
||||
|
@ -2149,8 +2148,8 @@ static Class tcpPortClass;
|
|||
#endif
|
||||
GSTcpHandle *handle;
|
||||
|
||||
NSDebugMLLog(@"NSPort", @"received %s event %p on 0x%x",
|
||||
type == ET_RPORT ? "read" : "write", extra, self);
|
||||
NSDebugMLLog(@"NSPort", @"received %s event on 0x%x",
|
||||
type == ET_RPORT ? "read" : "write", self);
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
if (event == eventListener)
|
||||
|
|
|
@ -1057,12 +1057,7 @@ GSRunLoopInfoForThread(NSThread *aThread)
|
|||
}
|
||||
if (((NSThread_ivars*)aThread)->_runLoopInfo == nil)
|
||||
{
|
||||
[gnustep_global_lock lock];
|
||||
if (((NSThread_ivars*)aThread)->_runLoopInfo == nil)
|
||||
{
|
||||
((NSThread_ivars*)aThread)->_runLoopInfo = [GSRunLoopThreadInfo new];
|
||||
}
|
||||
[gnustep_global_lock unlock];
|
||||
((NSThread_ivars*)aThread)->_runLoopInfo = [GSRunLoopThreadInfo new];
|
||||
}
|
||||
info = ((NSThread_ivars*)aThread)->_runLoopInfo;
|
||||
return info;
|
||||
|
|
|
@ -40,16 +40,12 @@
|
|||
static Class NSDate_class;
|
||||
|
||||
/**
|
||||
* <p>An <code>NSTimer</code> provides a way to send a message at some time in
|
||||
* An <code>NSTimer</code> provides a way to send a message at some time in
|
||||
* the future, possibly repeating every time a fixed interval has passed. To
|
||||
* use a timer, you can either create one that will automatically be added to
|
||||
* the run loop in the current thread (using the -addTimer:forMode: method),
|
||||
* or you can create it without adding it then add it to an [NSRunLoop]
|
||||
* explicitly later.
|
||||
* </p>
|
||||
* <p>NB. You may not use -init or +new to create a timer, as the timer must
|
||||
* be properly initialised to send an action after some interval.
|
||||
* </p>
|
||||
*/
|
||||
@implementation NSTimer
|
||||
|
||||
|
@ -61,14 +57,6 @@ static Class NSDate_class;
|
|||
}
|
||||
}
|
||||
|
||||
/* For MacOS-X compatibility, this returns nil.
|
||||
*/
|
||||
- (id) init
|
||||
{
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* <init />
|
||||
* Initialise the receive, a newly allocated NSTimer object.<br />
|
||||
|
|
|
@ -46,7 +46,6 @@ function may be incorrect
|
|||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSMapTable.h"
|
||||
#import "Foundation/NSObject.h"
|
||||
#import "Foundation/NSPortCoder.h"
|
||||
#import "Foundation/NSRunLoop.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSURL.h"
|
||||
|
@ -1412,7 +1411,6 @@ static unsigned urlAlign;
|
|||
unsigned int len = (_baseURL ? strlen(baseData->path) : 0)
|
||||
+ strlen(myData->path) + 3;
|
||||
char buf[len];
|
||||
char *ptr = buf;
|
||||
char *tmp = buf;
|
||||
|
||||
if (myData->pathIsAbsolute == YES)
|
||||
|
@ -1458,29 +1456,7 @@ static unsigned urlAlign;
|
|||
{
|
||||
*tmp = '\0';
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
/* On windows a file URL path may be of the form C:\xxx (ie we should
|
||||
* not insert the leading slash).
|
||||
* Also the vertical bar symbol may have been used instead of the
|
||||
* colon, so we need to convert that.
|
||||
*/
|
||||
if (myData->isFile == YES)
|
||||
{
|
||||
if (ptr[1] && isalpha(ptr[1]))
|
||||
{
|
||||
if (ptr[2] == ':' || ptr[2] == '|')
|
||||
{
|
||||
if (ptr[3] == '\0' || ptr[3] == '/' || ptr[3] == '\\')
|
||||
{
|
||||
ptr[2] = ':';
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
path = [NSString stringWithUTF8String: ptr];
|
||||
path = [NSString stringWithUTF8String: buf];
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
@ -1559,15 +1535,6 @@ static unsigned urlAlign;
|
|||
return _urlString;
|
||||
}
|
||||
|
||||
/* Encode bycopy unless explicitly requested otherwise.
|
||||
*/
|
||||
- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder
|
||||
{
|
||||
if ([aCoder isByref] == NO)
|
||||
return self;
|
||||
return [super replacementObjectForPortCoder: aCoder];
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the resource data for the represented URL and returns the result.
|
||||
* The shouldUseCache flag determines whether data previously retrieved by
|
||||
|
|
|
@ -344,10 +344,8 @@ static NSURLProtocol *placeholder = nil;
|
|||
+(Class) _classToHandleRequest:(NSURLRequest *)request
|
||||
{
|
||||
Class protoClass = nil;
|
||||
int count;
|
||||
[regLock lock];
|
||||
|
||||
count = [registered count];
|
||||
int count = [registered count];
|
||||
while (count-- > 0)
|
||||
{
|
||||
Class proto = [registered objectAtIndex: count];
|
||||
|
@ -1305,21 +1303,7 @@ static NSURLProtocol *placeholder = nil;
|
|||
}
|
||||
if ([this->request valueForHTTPHeaderField: @"Host"] == nil)
|
||||
{
|
||||
id p = [u port];
|
||||
id h = [u host];
|
||||
|
||||
if (h == nil)
|
||||
{
|
||||
h = @""; // Must send an empty host header
|
||||
}
|
||||
if (p == nil)
|
||||
{
|
||||
[m appendFormat: @"Host: %@\r\n", h];
|
||||
}
|
||||
else
|
||||
{
|
||||
[m appendFormat: @"Host: %@:%@\r\n", h, p];
|
||||
}
|
||||
[m appendFormat: @"Host: %@\r\n", [u host]];
|
||||
}
|
||||
if (l >= 0 && [this->request
|
||||
valueForHTTPHeaderField: @"Content-Length"] == nil)
|
||||
|
|
|
@ -162,9 +162,9 @@
|
|||
|
||||
@implementation NSUndoManager (Private)
|
||||
/* This method is used to begin undo grouping internally.
|
||||
* It's necessary to have a different mechanism from the -beginUndoGrouping
|
||||
* because it seems that in MacOS X a call to -beginUndoGrouping when at the
|
||||
* top level will actually create two undo groups.
|
||||
* It's necessary to have a different mechanism from the -beginUndoGroup
|
||||
* because it seems that in MacOS-X 10.5 a call to -beginUndoGroup when
|
||||
* at the top level will actually create two undo groups.
|
||||
*/
|
||||
- (void) _begin
|
||||
{
|
||||
|
@ -222,14 +222,14 @@
|
|||
* It first posts an NSUndoManagerCheckpointNotification
|
||||
* unless an undo is currently in progress.<br />
|
||||
* The order of these notifications is undefined, but the GNUstep
|
||||
* implementation currently mimics the observed order in MacOS X 10.5
|
||||
* implementation currently mimics the observed order in MacOS-X 10.5
|
||||
*/
|
||||
- (void) beginUndoGrouping
|
||||
{
|
||||
/* It seems that MacOS X implicitly creates a top-level group if this
|
||||
* method is called when groupsByEvent is set and there is no existing
|
||||
* top level group. There is no checkpoint notification posted for the
|
||||
* implicit group creation.
|
||||
/* It seems that MacOS-X 10.5 implicitly creates a top-level group
|
||||
* if this method is called when groupsByEvent is set and there is
|
||||
* no existing top level group. There is no checkpoint notification
|
||||
* posted for the implicit group creation.
|
||||
*/
|
||||
if (_group == nil && [self groupsByEvent])
|
||||
{
|
||||
|
@ -238,9 +238,12 @@
|
|||
|
||||
/* Post the checkpoint notification and THEN create the group.
|
||||
*/
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSUndoManagerCheckpointNotification
|
||||
object: self];
|
||||
if (_isUndoing == NO)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSUndoManagerCheckpointNotification
|
||||
object: self];
|
||||
}
|
||||
[self _begin]; // Start a new group
|
||||
}
|
||||
|
||||
|
@ -350,14 +353,14 @@
|
|||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSUndoManagerCheckpointNotification
|
||||
object: self];
|
||||
if (_isUndoing == NO && _isRedoing == NO)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSUndoManagerWillCloseUndoGroupNotification
|
||||
object: self];
|
||||
g = (PrivateUndoGroup*)_group;
|
||||
p = RETAIN([g parent]);
|
||||
_group = p;
|
||||
[g orphan];
|
||||
if (_isUndoing == NO && _isRedoing == NO)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSUndoManagerWillCloseUndoGroupNotification
|
||||
object: self];
|
||||
if (p == nil)
|
||||
{
|
||||
if (_isUndoing)
|
||||
|
@ -637,7 +640,7 @@
|
|||
_group = nil;
|
||||
_isRedoing = YES;
|
||||
|
||||
[self _begin];
|
||||
[self beginUndoGrouping];
|
||||
[groupToRedo perform];
|
||||
RELEASE(groupToRedo);
|
||||
[self endUndoGrouping];
|
||||
|
@ -1050,7 +1053,7 @@
|
|||
|
||||
name = [NSString stringWithString: [groupToUndo actionName]];
|
||||
|
||||
[self _begin];
|
||||
[self beginUndoGrouping];
|
||||
[groupToUndo perform];
|
||||
RELEASE(groupToUndo);
|
||||
[self endUndoGrouping];
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "Foundation/NSNotification.h"
|
||||
#include "Foundation/NSPathUtilities.h"
|
||||
#include "Foundation/NSProcessInfo.h"
|
||||
#include "Foundation/NSPropertyList.h"
|
||||
#include "Foundation/NSRunLoop.h"
|
||||
#include "Foundation/NSSet.h"
|
||||
#include "Foundation/NSThread.h"
|
||||
|
@ -135,42 +134,6 @@ static void updateCache(NSUserDefaults *self)
|
|||
}
|
||||
}
|
||||
|
||||
static BOOL
|
||||
writeDictionary(NSDictionary *dict, NSString *file)
|
||||
{
|
||||
if (dict == nil)
|
||||
{
|
||||
NSLog(@"Defaults database is nil when writing");
|
||||
}
|
||||
else if ([file length] == 0)
|
||||
{
|
||||
NSLog(@"Defaults database filename is empty when writing");
|
||||
}
|
||||
else
|
||||
{
|
||||
NSData *data;
|
||||
NSString *err;
|
||||
|
||||
err = nil;
|
||||
data = [NSPropertyListSerialization dataFromPropertyList: dict
|
||||
format: NSPropertyListXMLFormat_v1_0
|
||||
errorDescription: &err];
|
||||
if (data == nil)
|
||||
{
|
||||
NSLog(@"Failed to serialize defaults database for writing: %@", err);
|
||||
}
|
||||
else if ([data writeToFile: file atomically: YES] == NO)
|
||||
{
|
||||
NSLog(@"Failed to write defaults database to file: %@", file);
|
||||
}
|
||||
else
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
*** Local method definitions
|
||||
*************************************************************************/
|
||||
|
@ -1468,17 +1431,16 @@ static BOOL isLocked = NO;
|
|||
uint32_t attributes;
|
||||
|
||||
/*
|
||||
* If the lock did not exist ... make sure the database exists.
|
||||
* If the lock did not exist ... make sure the databsase exists.
|
||||
*/
|
||||
if ([mgr isReadableFileAtPath: _defaultsDatabase] == NO)
|
||||
{
|
||||
NSDictionary *empty = [NSDictionary new];
|
||||
|
||||
NSLog(@"Creating empty user defaults database");
|
||||
/*
|
||||
* Create empty database.
|
||||
*/
|
||||
if (writeDictionary(empty, _defaultsDatabase) == NO)
|
||||
if ([empty writeToFile: _defaultsDatabase atomically: NO] == NO)
|
||||
{
|
||||
NSLog(@"Failed to create defaults database file %@",
|
||||
_defaultsDatabase);
|
||||
|
@ -1560,7 +1522,10 @@ NSLog(@"Creating empty user defaults database");
|
|||
// Save the changes if we have an external database file
|
||||
if (_fileLock != nil)
|
||||
{
|
||||
return writeDictionary(defaults, _defaultsDatabase);
|
||||
if ([defaults writeToFile: _defaultsDatabase atomically: YES] == NO)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ static NSNull *null = nil;
|
|||
@interface GSSloppyXMLParser : NSXMLParser
|
||||
@end
|
||||
|
||||
#include <GNUstepBase/GSXML.h>
|
||||
#include <Additions/GNUstepBase/GSXML.h>
|
||||
|
||||
@interface NSXMLSAXHandler : GSSAXHandler
|
||||
{
|
||||
|
@ -1235,7 +1235,6 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes);
|
|||
case '\n':
|
||||
this->line++;
|
||||
this->column = 0;
|
||||
break;
|
||||
|
||||
case EOF:
|
||||
case '<':
|
||||
|
@ -1504,7 +1503,7 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes);
|
|||
}
|
||||
}
|
||||
}
|
||||
return [self _parseError: @"aborted"
|
||||
return [self _parseError: @"this->aborted"
|
||||
code: NSXMLParserDelegateAbortedParseError];
|
||||
}
|
||||
|
||||
|
|
|
@ -372,9 +372,9 @@ NSZoneStats NSZoneStats (NSZone *zone)
|
|||
}
|
||||
|
||||
void
|
||||
GSMakeWeakPointer(Class theClass, const char *iVarName)
|
||||
GSMakeWeakPointer(Class class, const char *iVarName)
|
||||
{
|
||||
class_ivar_set_gcinvisible(theClass, iVarName, YES);
|
||||
class_ivar_set_gcinvisible(class, iVarName, YES);
|
||||
}
|
||||
|
||||
BOOL
|
||||
|
@ -1992,7 +1992,7 @@ GSAtomicMallocZone (void)
|
|||
}
|
||||
|
||||
void
|
||||
GSMakeWeakPointer(Class theClass, const char *iVarName)
|
||||
GSMakeWeakPointer(Class class, const char *iVarName)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -803,7 +803,6 @@ mframe_dissect_call (arglist_t argframe, const char *type,
|
|||
single data item (for distributed objects).
|
||||
*/
|
||||
|
||||
#if !defined(USE_FFCALL) && !defined(USE_LIBFFI)
|
||||
static inline id retframe_id(void *rframe)
|
||||
{
|
||||
__builtin_return (rframe);
|
||||
|
@ -1796,4 +1795,3 @@ mframe_handle_return(const char* type, void* retval, arglist_t argframe)
|
|||
return retframe;
|
||||
}
|
||||
|
||||
#endif //!defined(USE_FFCALL) && !defined(USE_LIBFFI)
|
||||
|
|
|
@ -562,7 +562,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
|||
NSDebugMLLog(@"NSRunLoop", @"Event callback found");
|
||||
[watcher->receiver receivedEvent: watcher->data
|
||||
type: watcher->type
|
||||
extra: (void*)handle
|
||||
extra: watcher->data
|
||||
forMode: mode];
|
||||
}
|
||||
|
||||
|
|
|
@ -872,11 +872,7 @@ again:
|
|||
}
|
||||
else if ((errno = GetLastError()) != ERROR_IO_PENDING)
|
||||
{
|
||||
/* This is probably an end of file
|
||||
* eg. when the process at the other end has terminated.
|
||||
*/
|
||||
NSDebugMLog(@"NSMessagePort",
|
||||
@"unable to write to mailslot '%@' - %@",
|
||||
NSLog(@"unable to write to mailslot '%@' - %@",
|
||||
this->name, [NSError _last]);
|
||||
[self invalidate];
|
||||
}
|
||||
|
|
|
@ -1215,8 +1215,8 @@ static NSString *mainFont = nil;
|
|||
if (url == nil)
|
||||
{
|
||||
[buf appendString: @"<dt>"];
|
||||
[buf appendString: [[[author attributes]
|
||||
objectForKey: @"name"] stringByEscapingXML]];
|
||||
[buf appendString: [[author attributes]
|
||||
objectForKey: @"name"]];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1224,8 +1224,8 @@ static NSString *mainFont = nil;
|
|||
[buf appendString: [[url attributes]
|
||||
objectForKey: @"url"]];
|
||||
[buf appendString: @"\">"];
|
||||
[buf appendString: [[[author attributes]
|
||||
objectForKey: @"name"] stringByEscapingXML]];
|
||||
[buf appendString: [[author attributes]
|
||||
objectForKey: @"name"]];
|
||||
[buf appendString: @"</a>"];
|
||||
}
|
||||
if (email != nil)
|
||||
|
@ -2209,14 +2209,14 @@ static NSString *mainFont = nil;
|
|||
}
|
||||
[buf appendString: indent];
|
||||
[buf appendString: @"<dt>"];
|
||||
[buf appendString: [[dProp objectForKey: @"key"] stringByEscapingXML]];
|
||||
[buf appendString: [dProp objectForKey: @"key"]];
|
||||
[buf appendString: @" = </dt>\n"];
|
||||
[buf appendString: indent];
|
||||
[buf appendString: @"<dd>\n"];
|
||||
[self incIndent];
|
||||
if (value != nil)
|
||||
{
|
||||
[buf appendString: [value stringByEscapingXML]];
|
||||
[buf appendString: value];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -23,15 +23,6 @@
|
|||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
$(warning )
|
||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
||||
$(warning Perhaps gnustep-make is not properly installed,)
|
||||
$(warning so gnustep-config is not in your PATH.)
|
||||
$(warning )
|
||||
$(warning Your PATH is currently $(PATH))
|
||||
$(warning )
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
|
@ -43,9 +34,9 @@ GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../base.make
|
|||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
-include ../Version
|
||||
-include ../config.mak
|
||||
-include ../Source/pathconfig/pathconfig.mak
|
||||
include ../Version
|
||||
include ../config.mak
|
||||
include ../Source/pathconfig/pathconfig.mak
|
||||
|
||||
# DTDs to install
|
||||
dtddir = $(GNUSTEP_LIBRARY)/DTDs
|
||||
|
|
|
@ -89,23 +89,6 @@ static int isname(unsigned char ch)
|
|||
be any reason to).
|
||||
|
||||
*/
|
||||
|
||||
#define add_arg_ch(ch)\
|
||||
{\
|
||||
if (arg_len[num_args]+1>=arg_size[num_args])\
|
||||
{\
|
||||
arg_size[num_args]+=512;\
|
||||
args[num_args]=realloc(args[num_args],arg_size[num_args]);\
|
||||
if (!args[num_args])\
|
||||
{\
|
||||
NSLog(@"out of memory!\n");\
|
||||
exit(1);\
|
||||
}\
|
||||
}\
|
||||
args[num_args][arg_len[num_args]++]=ch;\
|
||||
args[num_args][arg_len[num_args]]=0;\
|
||||
}
|
||||
|
||||
static int ParseFile(const char *filename,NSMutableDictionary *tables)
|
||||
{
|
||||
FILE *f;
|
||||
|
@ -137,6 +120,21 @@ static int ParseFile(const char *filename,NSMutableDictionary *tables)
|
|||
|
||||
int depth=0;
|
||||
|
||||
void add_arg_ch(int ch)
|
||||
{
|
||||
if (arg_len[num_args]+1>=arg_size[num_args])
|
||||
{
|
||||
arg_size[num_args]+=512;
|
||||
args[num_args]=realloc(args[num_args],arg_size[num_args]);
|
||||
if (!args[num_args])
|
||||
{
|
||||
NSLog(@"out of memory!\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
args[num_args][arg_len[num_args]++]=ch;
|
||||
args[num_args][arg_len[num_args]]=0;
|
||||
}
|
||||
|
||||
|
||||
filenamestr = [NSString stringWithCString: filename
|
||||
|
|
4
Version
4
Version
|
@ -7,9 +7,9 @@ GCC_VERSION=2.9.5
|
|||
# The version number of this release.
|
||||
MAJOR_VERSION=1
|
||||
MINOR_VERSION=19
|
||||
SUBMINOR_VERSION=1
|
||||
SUBMINOR_VERSION=0
|
||||
# numeric value should match above
|
||||
VERSION_NUMBER=119.1
|
||||
VERSION_NUMBER=119.0
|
||||
GNUSTEP_BASE_VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${SUBMINOR_VERSION}
|
||||
VERSION=${GNUSTEP_BASE_VERSION}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include <objc/objc.h>
|
||||
#include <objc/objc-api.h>
|
||||
|
||||
int main (void)
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
/* Mac OS X has a native poll implementation since Mac OS X 10.4, but
|
||||
* this implementation is broken in (at least) OS X 10.4 and 10.5 in
|
||||
* that it does not support devices.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
int fd, n;
|
||||
struct pollfd pollfds[1];
|
||||
|
||||
fd = open("/dev/null", O_RDONLY | O_NONBLOCK, 0);
|
||||
|
||||
pollfds[0].fd = fd;
|
||||
pollfds[0].events = POLLIN;
|
||||
n = poll(pollfds, 1, 0);
|
||||
close(fd);
|
||||
|
||||
return (n == 1 && !(pollfds[0].revents & POLLNVAL)) ? 0 : 1;
|
||||
}
|
46
configure
vendored
46
configure
vendored
|
@ -11743,57 +11743,11 @@ rm -f conftest*
|
|||
if test $have_poll = yes; then
|
||||
echo "$as_me:$LINENO: result: no" >&5
|
||||
echo "${ECHO_T}no" >&6
|
||||
echo "$as_me:$LINENO: checking if poll supports devices" >&5
|
||||
echo $ECHO_N "checking if poll supports devices... $ECHO_C" >&6
|
||||
if test "$cross_compiling" = yes; then
|
||||
{ { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
|
||||
See \`config.log' for more details." >&5
|
||||
echo "$as_me: error: cannot run test program while cross compiling
|
||||
See \`config.log' for more details." >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
else
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include "$srcdir/config/config.poll-dev.c"
|
||||
_ACEOF
|
||||
rm -f conftest$ac_exeext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
||||
(eval $ac_link) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
:
|
||||
else
|
||||
echo "$as_me: program exited with status $ac_status" >&5
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
( exit $ac_status )
|
||||
have_poll=no
|
||||
fi
|
||||
rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
|
||||
fi
|
||||
if test $have_poll = yes; then
|
||||
echo "$as_me:$LINENO: result: yes" >&5
|
||||
echo "${ECHO_T}yes" >&6
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define HAVE_POLL_F 1
|
||||
_ACEOF
|
||||
|
||||
else
|
||||
echo "$as_me:$LINENO: result: no" >&5
|
||||
echo "${ECHO_T}no" >&6
|
||||
fi
|
||||
else
|
||||
echo "$as_me:$LINENO: result: yes" >&5
|
||||
echo "${ECHO_T}yes" >&6
|
||||
|
|
|
@ -817,14 +817,7 @@ if test $ac_cv_header_poll_h = yes; then
|
|||
have_poll=no,)
|
||||
if test $have_poll = yes; then
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_CHECKING([if poll supports devices])
|
||||
AC_TRY_RUN([#include "$srcdir/config/config.poll-dev.c"], ,have_poll=no, )
|
||||
if test $have_poll = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_POLL_F,1, [ Define if poll is NOT emulated via select])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
AC_DEFINE(HAVE_POLL_F,1, [ Define if poll is NOT emulated via select])
|
||||
else
|
||||
AC_MSG_RESULT(yes)
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue