24
24
Boston, MA 02111 USA.
26
26
<title>NSScanner class reference</title>
27
$Date: 2008-06-08 11:38:33 +0100 (Sun, 08 Jun 2008) $ $Revision: 26606 $
27
$Date: 2010-02-25 11:49:31 -0700 (Thu, 25 Feb 2010) $ $Revision: 29753 $
30
/* We need to define _GNU_SOURCE on systems (SuSE) to get LONG_LONG_MAX. */
36
#include "GNUstepBase/Unicode.h"
37
#include "Foundation/NSScanner.h"
38
#include "Foundation/NSException.h"
39
#include "Foundation/NSObjCRuntime.h"
40
#include "Foundation/NSUserDefaults.h"
32
#if defined(HAVE_FLOAT_H)
36
#if !defined(LLONG_MAX)
37
# if defined(__LONG_LONG_MAX__)
38
# define LLONG_MAX __LONG_LONG_MAX__
39
# define LLONG_MIN (-LLONG_MAX-1)
40
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
42
# error Neither LLONG_MAX nor __LONG_LONG_MAX__ found
45
47
#include <ctype.h> /* FIXME: May go away once I figure out Unicode */
46
#include "GSPrivate.h"
48
/* BSD and Solaris have this */
49
#if defined(HANDLE_LLONG_MAX) && !defined(HANDLE_LONG_LONG_MAX)
50
#define LONG_LONG_MAX LLONG_MAX
51
#define LONG_LONG_MIN LLONG_MIN
52
#define ULONG_LONG_MAX ULLONG_MAX
49
#define EXPOSE_NSScanner_IVARS 1
50
#import "GNUstepBase/Unicode.h"
51
#import "Foundation/NSScanner.h"
52
#import "Foundation/NSException.h"
53
#import "Foundation/NSUserDefaults.h"
54
#import "GNUstepBase/NSObject+GNUstepBase.h"
88
91
* Hack for direct access to internals of an concrete string object.
93
typedef GSString *ivars;
93
94
#define myLength() (((ivars)_string)->_count)
94
95
#define myUnicode(I) (((ivars)_string)->_contents.u[I])
95
96
#define myChar(I) myGetC((((ivars)_string)->_contents.c[I]))
373
374
* Scan an unsigned int of the given radix into value.
374
375
* Internal version used by scanRadixUnsignedInt: and scanHexInt: .
376
- (BOOL) scanUnsignedInt_: (unsigned int *)value
377
radix: (unsigned int)radix
377
- (BOOL) scanUnsignedInt_: (unsigned int*)value
378
radix: (NSUInteger)radix
378
379
gotDigits: (BOOL)gotDigits
380
381
unsigned int num = 0;
558
559
* Returns YES if anything is scanned, NO otherwise.
560
* On overflow, LONG_LONG_MAX or LONG_LONG_MIN is put into
561
* On overflow, LLONG_MAX or LLONG_MIN is put into
561
562
* <em>longLongValue</em>
563
564
* Scans past any excess digits
565
566
- (BOOL) scanLongLong: (long long *)value
567
#if defined(LONG_LONG_MAX)
568
#if defined(LLONG_MAX)
568
569
unsigned long long num = 0;
569
const unsigned long long limit = ULONG_LONG_MAX / 10;
570
const unsigned long long limit = ULLONG_MAX / 10;
570
571
BOOL negative = NO;
571
572
BOOL overflow = NO;
572
573
BOOL got_digits = NO;
624
if (overflow || (num > (unsigned long long)LONG_LONG_MIN))
625
*value = LONG_LONG_MIN;
625
if (overflow || (num > (unsigned long long)LLONG_MIN))
631
if (overflow || (num > (unsigned long long)LONG_LONG_MAX))
632
*value = LONG_LONG_MAX;
632
if (overflow || (num > (unsigned long long)LLONG_MAX))
638
#else /* defined(LONG_LONG_MAX) */
639
#else /* defined(LLONG_MAX) */
640
641
* Provide compile-time warning and run-time exception.
935
936
unsigned int saveScanLocation = _scanLocation;
938
if (skipToNextField() == NO)
938
942
range.location = _scanLocation;
939
943
range.length = [string length];
940
944
if (range.location + range.length > myLength())
989
993
unsigned int saveScanLocation = _scanLocation;
995
if (skipToNextField() == NO)
992
999
range.location = _scanLocation;
993
1000
range.length = myLength() - _scanLocation;
994
1001
found = [_string rangeOfString: string
1233
* Scan in a double value in the standard locale ('.' as decimal point).<br />
1240
* Scan in a double value in the standard locale ('.' as decimal poNSInteger).<br />
1234
1241
* Return YES on success, NO on failure.<br />
1235
1242
* The value pointed to by result is unmodified on failure.<br />
1236
1243
* No value is returned in result if it is a null pointer.