4 Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
7 Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
8 Mircea Oancea <mircea@jupiter.elcom.pub.ro>
10 This file is part of libFoundation.
12 Permission to use, copy, modify, and distribute this software and its
13 documentation for any purpose and without fee is hereby granted, provided
14 that the above copyright notice appear in all copies and that both that
15 copyright notice and this permission notice appear in supporting
18 We disclaim all warranties with regard to this software, including all
19 implied warranties of merchantability and fitness, in no event shall
20 we be liable for any special, indirect or consequential damages or any
21 damages whatsoever resulting from loss of use, data or profits, whether in
22 an action of contract, negligence or other tortious action, arising out of
23 or in connection with the use or performance of this software.
26 #include <Foundation/common.h>
27 #include <Foundation/NSString.h>
31 NSEqualRanges(NSRange range1, NSRange range2)
33 return ((range1.location == range2.location)
34 && (range1.length == range2.length));
37 /* Compute a Range from Two Other Ranges */
39 NSUnionRange(NSRange aRange, NSRange bRange)
43 range.location = MIN(aRange.location, bRange.location);
44 range.length = MAX(NSMaxRange(aRange), NSMaxRange(bRange))
50 NSIntersectionRange (NSRange aRange, NSRange bRange)
54 if (NSMaxRange(aRange) < bRange.location
55 || NSMaxRange(bRange) < aRange.location)
56 return NSMakeRange(0, 0);
58 range.location = MAX(aRange.location, bRange.location);
59 range.length = MIN(NSMaxRange(aRange), NSMaxRange(bRange))
65 NSStringFromRange(NSRange range)
67 return [NSString stringWithFormat:@"{location = %d; length = %d}",
68 range.location, range.length];
72 NSSRangeFromString(NSString* string)
74 return NSMakeRange(0,0);