Added patch from nicola

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8318 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-12-13 14:38:55 +00:00
parent 29d2f5690b
commit 38e2332a79
3 changed files with 39 additions and 20 deletions

View file

@ -1,3 +1,8 @@
2000-12-13 Nicola Pero <n.pero@mi.flashnet.it>
* Headers/gnustep/base/NSRange.h, Source/NSRange.m: Inlined
NSMakeRange.
2000-12-12 Nicola Pero <n.pero@mi.flashnet.it> 2000-12-12 Nicola Pero <n.pero@mi.flashnet.it>
* Source/NSDebug.m (table_entry): Added peak field. * Source/NSDebug.m (table_entry): Added peak field.

View file

@ -27,6 +27,9 @@
#include <Foundation/NSObject.h> #include <Foundation/NSObject.h>
@class NSException;
@class NXConstantString;
/**** Type, Constant, and Macro Definitions **********************************/ /**** Type, Constant, and Macro Definitions **********************************/
#ifndef MAX #ifndef MAX
@ -56,7 +59,7 @@ struct _NSRange
* All but the most complex functions are declared static inline in this * All but the most complex functions are declared static inline in this
* header file so that they are maximally efficient. In order to provide * header file so that they are maximally efficient. In order to provide
* true functions (for code modules that don't have this header) this * true functions (for code modules that don't have this header) this
* header is included in NSGeometry.m where the functions are no longer * header is included in NSRange.m where the functions are no longer
* declared inline. * declared inline.
*/ */
#ifdef IN_NSRANGE_M #ifdef IN_NSRANGE_M
@ -85,9 +88,31 @@ NSLocationInRange(unsigned location, NSRange range)
return (location >= range.location) && (location < NSMaxRange(range)); return (location >= range.location) && (location < NSMaxRange(range));
} }
/* Create an NSRange having the specified LOCATION and LENGTH. */ GS_RANGE_SCOPE NSRange
GS_EXPORT NSRange NSMakeRange(unsigned int location, unsigned int length) GS_RANGE_ATTR;
NSMakeRange(unsigned int location, unsigned int length);
GS_RANGE_SCOPE NSRange
NSMakeRange(unsigned int location, unsigned int length)
{
NSRange range;
unsigned int end = location + length;
if (end < location || end < length)
{
extern void _NSRangeExceptionRaise ();
/* NB: The implementation of _NSRangeExceptionRaise is:
[NSException raise: NSRangeException
format: @"Range location + length too great"]; */
/* _NSRangeExceptionRaise is defined in NSRange.m so that this
file (NSRange.h) can be included without problems in the
implementation of the base classes themselves. */
_NSRangeExceptionRaise ();
}
range.location = location;
range.length = length;
return range;
}
GS_RANGE_SCOPE BOOL GS_RANGE_SCOPE BOOL
NSEqualRanges(NSRange range1, NSRange range2) GS_RANGE_ATTR; NSEqualRanges(NSRange range1, NSRange range2) GS_RANGE_ATTR;

View file

@ -40,22 +40,6 @@ setupCache()
} }
} }
NSRange
NSMakeRange(unsigned int location, unsigned int length)
{
NSRange range;
unsigned int end = location + length;
if (end < location || end < length)
{
[NSException raise: NSRangeException
format: @"Range location + length too great"];
}
range.location = location;
range.length = length;
return range;
}
NSRange NSRange
NSRangeFromString(NSString* string) NSRangeFromString(NSString* string)
{ {
@ -86,3 +70,8 @@ NSStringFromRange(NSRange range)
range.location, range.length]; range.location, range.length];
} }
void _NSRangeExceptionRaise ()
{
[NSException raise: NSRangeException
format: @"Range location + length too great"];
}