This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
/
SDL_string.c
1348 lines (1249 loc) · 33.7 KB
1
2
/*
SDL - Simple DirectMedia Layer
3
Copyright (C) 1997-2010 Sam Lantinga
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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.1 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
Lesser 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 St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
22
#include "SDL_config.h"
23
24
25
/* This file contains portable string manipulation functions for SDL */
26
#include "SDL_stdinc.h"
27
28
29
30
#define SDL_isupperhex(X) (((X) >= 'A') && ((X) <= 'F'))
#define SDL_islowerhex(X) (((X) >= 'a') && ((X) <= 'f'))
31
32
#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOL)
33
34
static size_t
SDL_ScanLong(const char *text, int radix, long *valuep)
35
36
37
38
39
{
const char *textstart = text;
long value = 0;
SDL_bool negative = SDL_FALSE;
40
if (*text == '-') {
41
42
43
negative = SDL_TRUE;
++text;
}
44
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
45
46
text += 2;
}
47
for (;;) {
48
int v;
49
if (SDL_isdigit((unsigned char) *text)) {
50
v = *text - '0';
51
} else if (radix == 16 && SDL_isupperhex(*text)) {
52
v = 10 + (*text - 'A');
53
} else if (radix == 16 && SDL_islowerhex(*text)) {
54
55
56
57
58
59
60
61
v = 10 + (*text - 'a');
} else {
break;
}
value *= radix;
value += v;
++text;
}
62
63
if (valuep) {
if (negative && value) {
64
65
66
67
68
69
70
71
72
*valuep = -value;
} else {
*valuep = value;
}
}
return (text - textstart);
}
#endif
73
#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD)
74
75
static size_t
SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
76
77
78
79
{
const char *textstart = text;
unsigned long value = 0;
80
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
81
82
text += 2;
}
83
for (;;) {
84
int v;
85
if (SDL_isdigit((unsigned char) *text)) {
86
v = *text - '0';
87
} else if (radix == 16 && SDL_isupperhex(*text)) {
88
v = 10 + (*text - 'A');
89
} else if (radix == 16 && SDL_islowerhex(*text)) {
90
91
92
93
94
95
96
97
v = 10 + (*text - 'a');
} else {
break;
}
value *= radix;
value += v;
++text;
}
98
if (valuep) {
99
100
101
102
103
104
*valuep = value;
}
return (text - textstart);
}
#endif
105
#ifndef HAVE_SSCANF
106
107
static size_t
SDL_ScanUintPtrT(const char *text, int radix, uintptr_t * valuep)
108
109
110
111
{
const char *textstart = text;
uintptr_t value = 0;
112
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
113
114
text += 2;
}
115
for (;;) {
116
int v;
117
if (SDL_isdigit((unsigned char) *text)) {
118
v = *text - '0';
119
} else if (radix == 16 && SDL_isupperhex(*text)) {
120
v = 10 + (*text - 'A');
121
} else if (radix == 16 && SDL_islowerhex(*text)) {
122
123
124
125
126
127
128
129
v = 10 + (*text - 'a');
} else {
break;
}
value *= radix;
value += v;
++text;
}
130
if (valuep) {
131
132
133
134
135
136
*valuep = value;
}
return (text - textstart);
}
#endif
137
138
#ifdef SDL_HAS_64BIT_TYPE
#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOLL)
139
140
static size_t
SDL_ScanLongLong(const char *text, int radix, Sint64 * valuep)
141
142
143
144
145
{
const char *textstart = text;
Sint64 value = 0;
SDL_bool negative = SDL_FALSE;
146
if (*text == '-') {
147
148
149
negative = SDL_TRUE;
++text;
}
150
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
151
152
text += 2;
}
153
for (;;) {
154
int v;
155
if (SDL_isdigit((unsigned char) *text)) {
156
v = *text - '0';
157
} else if (radix == 16 && SDL_isupperhex(*text)) {
158
v = 10 + (*text - 'A');
159
} else if (radix == 16 && SDL_islowerhex(*text)) {
160
161
162
163
164
165
166
167
v = 10 + (*text - 'a');
} else {
break;
}
value *= radix;
value += v;
++text;
}
168
169
if (valuep) {
if (negative && value) {
170
171
172
173
174
175
176
177
178
*valuep = -value;
} else {
*valuep = value;
}
}
return (text - textstart);
}
#endif
179
#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOULL)
180
181
static size_t
SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 * valuep)
182
183
184
185
{
const char *textstart = text;
Uint64 value = 0;
186
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
187
188
text += 2;
}
189
for (;;) {
190
int v;
191
if (SDL_isdigit((unsigned char) *text)) {
192
v = *text - '0';
193
} else if (radix == 16 && SDL_isupperhex(*text)) {
194
v = 10 + (*text - 'A');
195
} else if (radix == 16 && SDL_islowerhex(*text)) {
196
197
198
199
200
201
202
203
v = 10 + (*text - 'a');
} else {
break;
}
value *= radix;
value += v;
++text;
}
204
if (valuep) {
205
206
207
208
209
210
211
*valuep = value;
}
return (text - textstart);
}
#endif
#endif /* SDL_HAS_64BIT_TYPE */
212
#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOD)
213
214
static size_t
SDL_ScanFloat(const char *text, double *valuep)
215
216
217
218
219
220
{
const char *textstart = text;
unsigned long lvalue = 0;
double value = 0.0;
SDL_bool negative = SDL_FALSE;
221
if (*text == '-') {
222
223
224
225
226
negative = SDL_TRUE;
++text;
}
text += SDL_ScanUnsignedLong(text, 10, &lvalue);
value += lvalue;
227
if (*text == '.') {
228
229
int mult = 10;
++text;
230
while (SDL_isdigit((unsigned char) *text)) {
231
lvalue = *text - '0';
232
value += (double) lvalue / mult;
233
234
235
236
mult *= 10;
++text;
}
}
237
238
if (valuep) {
if (negative && value) {
239
240
241
242
243
244
245
246
247
248
*valuep = -value;
} else {
*valuep = value;
}
}
return (text - textstart);
}
#endif
#ifndef SDL_memset
249
250
void *
SDL_memset(void *dst, int c, size_t len)
251
252
{
size_t left = (len % 4);
253
if (len >= 4) {
254
Uint32 value = 0;
255
Uint32 *dstp = (Uint32 *) dst;
256
257
258
259
260
261
int i;
for (i = 0; i < 4; ++i) {
value <<= 8;
value |= c;
}
len /= 4;
262
while (len--) {
263
264
265
*dstp++ = value;
}
}
266
267
268
269
270
if (left > 0) {
Uint8 value = (Uint8) c;
Uint8 *dstp = (Uint8 *) dst;
switch (left) {
case 3:
271
*dstp++ = value;
272
case 2:
273
*dstp++ = value;
274
case 1:
275
276
277
278
279
280
281
282
*dstp++ = value;
}
}
return dst;
}
#endif
#ifndef SDL_memcpy
283
284
void *
SDL_memcpy(void *dst, const void *src, size_t len)
285
{
286
287
288
char *srcp = (char *) src;
char *dstp = (char *) dst;
while (len--) {
289
290
291
292
293
294
295
*dstp++ = *srcp++;
}
return dst;
}
#endif
#ifndef SDL_revcpy
296
297
void *
SDL_revcpy(void *dst, const void *src, size_t len)
298
{
299
300
char *srcp = (char *) src;
char *dstp = (char *) dst;
301
302
srcp += len - 1;
dstp += len - 1;
303
while (len--) {
304
305
306
307
308
309
310
*dstp-- = *srcp--;
}
return dst;
}
#endif
#ifndef SDL_memcmp
311
312
int
SDL_memcmp(const void *s1, const void *s2, size_t len)
313
{
314
315
316
317
char *s1p = (char *) s1;
char *s2p = (char *) s2;
while (len--) {
if (*s1p != *s2p) {
318
return (*s1p - *s2p);
319
320
321
}
++s1p;
++s2p;
322
323
324
325
326
327
}
return 0;
}
#endif
#ifndef HAVE_STRLEN
328
329
size_t
SDL_strlen(const char *string)
330
331
{
size_t len = 0;
332
while (*string++) {
333
334
335
336
337
338
++len;
}
return len;
}
#endif
339
340
#ifndef HAVE_WCSLEN
size_t
341
SDL_wcslen(const wchar_t * string)
342
343
344
345
346
347
348
349
350
{
size_t len = 0;
while (*string++) {
++len;
}
return len;
}
#endif
351
#ifndef HAVE_STRLCPY
352
353
size_t
SDL_strlcpy(char *dst, const char *src, size_t maxlen)
354
{
355
size_t srclen = SDL_strlen(src);
356
357
if (maxlen > 0) {
size_t len = SDL_min(srclen, maxlen - 1);
358
359
SDL_memcpy(dst, src, len);
dst[len] = '\0';
360
}
361
return srclen;
362
363
364
}
#endif
365
#ifndef HAVE_STRLCAT
366
367
size_t
SDL_strlcat(char *dst, const char *src, size_t maxlen)
368
{
369
370
size_t dstlen = SDL_strlen(dst);
size_t srclen = SDL_strlen(src);
371
372
if (dstlen < maxlen) {
SDL_strlcpy(dst + dstlen, src, maxlen - dstlen);
373
}
374
return dstlen + srclen;
375
376
377
}
#endif
378
#ifndef HAVE_STRDUP
379
380
char *
SDL_strdup(const char *string)
381
{
382
size_t len = SDL_strlen(string) + 1;
383
char *newstr = SDL_malloc(len);
384
if (newstr) {
385
SDL_strlcpy(newstr, string, len);
386
387
388
389
390
}
return newstr;
}
#endif
391
#ifndef HAVE__STRREV
392
393
char *
SDL_strrev(char *string)
394
395
396
{
size_t len = SDL_strlen(string);
char *a = &string[0];
397
char *b = &string[len - 1];
398
len /= 2;
399
while (len--) {
400
401
402
403
404
405
406
407
408
char c = *a;
*a++ = *b;
*b-- = c;
}
return string;
}
#endif
#ifndef HAVE__STRUPR
409
410
char *
SDL_strupr(char *string)
411
412
{
char *bufp = string;
413
while (*bufp) {
414
*bufp = SDL_toupper((unsigned char) *bufp);
415
++bufp;
416
417
418
419
420
421
}
return string;
}
#endif
#ifndef HAVE__STRLWR
422
423
char *
SDL_strlwr(char *string)
424
425
{
char *bufp = string;
426
while (*bufp) {
427
*bufp = SDL_tolower((unsigned char) *bufp);
428
++bufp;
429
430
431
432
433
434
}
return string;
}
#endif
#ifndef HAVE_STRCHR
435
436
char *
SDL_strchr(const char *string, int c)
437
{
438
439
440
while (*string) {
if (*string == c) {
return (char *) string;
441
}
442
++string;
443
444
445
446
447
448
}
return NULL;
}
#endif
#ifndef HAVE_STRRCHR
449
450
char *
SDL_strrchr(const char *string, int c)
451
{
452
const char *bufp = string + SDL_strlen(string) - 1;
453
454
455
while (bufp >= string) {
if (*bufp == c) {
return (char *) bufp;
456
}
457
--bufp;
458
459
460
461
462
463
}
return NULL;
}
#endif
#ifndef HAVE_STRSTR
464
465
char *
SDL_strstr(const char *haystack, const char *needle)
466
{
467
size_t length = SDL_strlen(needle);
468
469
470
while (*haystack) {
if (SDL_strncmp(haystack, needle, length) == 0) {
return (char *) haystack;
471
}
472
++haystack;
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
}
return NULL;
}
#endif
#if !defined(HAVE__LTOA) || !defined(HAVE__I64TOA) || \
!defined(HAVE__ULTOA) || !defined(HAVE__UI64TOA)
static const char ntoa_table[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z'
};
#endif /* ntoa() conversion table */
#ifndef HAVE__LTOA
489
490
char *
SDL_ltoa(long value, char *string, int radix)
491
492
493
{
char *bufp = string;
494
if (value < 0) {
495
496
497
*bufp++ = '-';
value = -value;
}
498
499
if (value) {
while (value > 0) {
500
501
502
503
504
505
506
507
508
*bufp++ = ntoa_table[value % radix];
value /= radix;
}
} else {
*bufp++ = '0';
}
*bufp = '\0';
/* The numbers went into the string backwards. :) */
509
510
if (*string == '-') {
SDL_strrev(string + 1);
511
} else {
512
SDL_strrev(string);
513
514
515
516
517
518
519
}
return string;
}
#endif
#ifndef HAVE__ULTOA
520
521
char *
SDL_ultoa(unsigned long value, char *string, int radix)
522
523
524
{
char *bufp = string;
525
526
if (value) {
while (value > 0) {
527
528
529
530
531
532
533
534
535
*bufp++ = ntoa_table[value % radix];
value /= radix;
}
} else {
*bufp++ = '0';
}
*bufp = '\0';
/* The numbers went into the string backwards. :) */
536
SDL_strrev(string);
537
538
539
540
541
542
return string;
}
#endif
#ifndef HAVE_STRTOL
543
544
long
SDL_strtol(const char *string, char **endp, int base)
545
546
547
548
{
size_t len;
long value;
549
550
if (!base) {
if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
551
552
553
554
555
556
557
base = 16;
} else {
base = 10;
}
}
len = SDL_ScanLong(string, base, &value);
558
559
if (endp) {
*endp = (char *) string + len;
560
561
562
563
564
}
return value;
}
#endif
565
#ifndef HAVE_STRTOUL
566
567
unsigned long
SDL_strtoul(const char *string, char **endp, int base)
568
569
570
571
{
size_t len;
unsigned long value;
572
573
if (!base) {
if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
574
575
576
577
578
579
580
base = 16;
} else {
base = 10;
}
}
len = SDL_ScanUnsignedLong(string, base, &value);
581
582
if (endp) {
*endp = (char *) string + len;
583
584
585
586
587
}
return value;
}
#endif
588
589
590
#ifdef SDL_HAS_64BIT_TYPE
#ifndef HAVE__I64TOA
591
592
char *
SDL_lltoa(Sint64 value, char *string, int radix)
593
594
595
{
char *bufp = string;
596
if (value < 0) {
597
598
599
*bufp++ = '-';
value = -value;
}
600
601
if (value) {
while (value > 0) {
602
603
604
605
606
607
608
609
610
*bufp++ = ntoa_table[value % radix];
value /= radix;
}
} else {
*bufp++ = '0';
}
*bufp = '\0';
/* The numbers went into the string backwards. :) */
611
612
if (*string == '-') {
SDL_strrev(string + 1);
613
} else {
614
SDL_strrev(string);
615
616
617
618
619
620
621
}
return string;
}
#endif
#ifndef HAVE__UI64TOA
622
623
char *
SDL_ulltoa(Uint64 value, char *string, int radix)
624
625
626
{
char *bufp = string;
627
628
if (value) {
while (value > 0) {
629
630
631
632
633
634
635
636
637
*bufp++ = ntoa_table[value % radix];
value /= radix;
}
} else {
*bufp++ = '0';
}
*bufp = '\0';
/* The numbers went into the string backwards. :) */
638
SDL_strrev(string);
639
640
641
642
643
644
return string;
}
#endif
#ifndef HAVE_STRTOLL
645
646
Sint64
SDL_strtoll(const char *string, char **endp, int base)
647
648
649
650
{
size_t len;
Sint64 value;
651
652
if (!base) {
if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
653
654
655
656
657
658
659
base = 16;
} else {
base = 10;
}
}
len = SDL_ScanLongLong(string, base, &value);
660
661
if (endp) {
*endp = (char *) string + len;
662
663
664
665
666
}
return value;
}
#endif
667
#ifndef HAVE_STRTOULL
668
669
Uint64
SDL_strtoull(const char *string, char **endp, int base)
670
671
672
673
{
size_t len;
Uint64 value;
674
675
if (!base) {
if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
676
677
678
679
680
681
682
base = 16;
} else {
base = 10;
}
}
len = SDL_ScanUnsignedLongLong(string, base, &value);
683
684
if (endp) {
*endp = (char *) string + len;
685
686
687
688
689
}
return value;
}
#endif
690
691
#endif /* SDL_HAS_64BIT_TYPE */
692
#ifndef HAVE_STRTOD
693
694
double
SDL_strtod(const char *string, char **endp)
695
696
697
698
699
{
size_t len;
double value;
len = SDL_ScanFloat(string, &value);
700
701
if (endp) {
*endp = (char *) string + len;
702
703
704
705
706
}
return value;
}
#endif
707
#ifndef HAVE_STRCMP
708
709
int
SDL_strcmp(const char *str1, const char *str2)
710
711
{
while (*str1 && *str2) {
712
if (*str1 != *str2)
713
714
715
716
break;
++str1;
++str2;
}
717
return (int) ((unsigned char) *str1 - (unsigned char) *str2);
718
719
720
721
}
#endif
#ifndef HAVE_STRNCMP
722
723
int
SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
724
{
725
726
while (*str1 && *str2 && maxlen) {
if (*str1 != *str2)
727
728
729
730
731
break;
++str1;
++str2;
--maxlen;
}
732
if (!maxlen) {
733
734
return 0;
}
735
return (int) ((unsigned char) *str1 - (unsigned char) *str2);
736
737
738
}
#endif
739
#if !defined(HAVE_STRCASECMP) && !defined(HAVE__STRICMP)
740
741
int
SDL_strcasecmp(const char *str1, const char *str2)
742
743
744
{
char a = 0;
char b = 0;
745
while (*str1 && *str2) {
746
747
a = SDL_tolower((unsigned char) *str1);
b = SDL_tolower((unsigned char) *str2);
748
if (a != b)
749
750
751
752
break;
++str1;
++str2;
}
753
754
a = SDL_tolower(*str1);
b = SDL_tolower(*str2);
755
return (int) ((unsigned char) a - (unsigned char) b);
756
757
758
}
#endif
759
#if !defined(HAVE_STRNCASECMP) && !defined(HAVE__STRNICMP)
760
761
int
SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen)
762
763
764
{
char a = 0;
char b = 0;
765
while (*str1 && *str2 && maxlen) {
766
767
a = SDL_tolower((unsigned char) *str1);
b = SDL_tolower((unsigned char) *str2);
768
if (a != b)
769
770
771
772
773
break;
++str1;
++str2;
--maxlen;
}
774
775
a = SDL_tolower(*str1);
b = SDL_tolower(*str2);
776
return (int) ((unsigned char) a - (unsigned char) b);
777
778
779
}
#endif
780
#ifndef HAVE_SSCANF
781
782
int
SDL_sscanf(const char *text, const char *fmt, ...)
783
784
785
786
787
{
va_list ap;
int retval = 0;
va_start(ap, fmt);
788
789
while (*fmt) {
if (*fmt == ' ') {
790
while (SDL_isspace((unsigned char) *text)) {
791
792
793
794
795
++text;
}
++fmt;
continue;
}
796
if (*fmt == '%') {
797
798
799
SDL_bool done = SDL_FALSE;
long count = 0;
int radix = 10;
800
801
enum
{
802
803
804
805
806
807
808
809
DO_SHORT,
DO_INT,
DO_LONG,
DO_LONGLONG
} inttype = DO_INT;
SDL_bool suppress = SDL_FALSE;
++fmt;
810
811
if (*fmt == '%') {
if (*text == '%') {
812
813
814
815
816
817
++text;
++fmt;
continue;
}
break;
}
818
if (*fmt == '*') {
819
820
821
822
823
suppress = SDL_TRUE;
++fmt;
}
fmt += SDL_ScanLong(fmt, 10, &count);
824
825
if (*fmt == 'c') {
if (!count) {
826
827
count = 1;
}
828
829
if (suppress) {
while (count--) {
830
831
832
++text;
}
} else {
833
834
char *valuep = va_arg(ap, char *);
while (count--) {
835
836
837
838
839
840
841
*valuep++ = *text++;
}
++retval;
}
continue;
}
842
while (SDL_isspace((unsigned char) *text)) {
843
844
845
846
847
++text;
}
/* FIXME: implement more of the format specifiers */
while (!done) {
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
switch (*fmt) {
case '*':
suppress = SDL_TRUE;
break;
case 'h':
if (inttype > DO_SHORT) {
++inttype;
}
break;
case 'l':
if (inttype < DO_LONGLONG) {
++inttype;
}
break;
case 'I':
if (SDL_strncmp(fmt, "I64", 3) == 0) {
fmt += 2;
inttype = DO_LONGLONG;
}
break;
case 'i':
{
int index = 0;
if (text[index] == '-') {
++index;
873
}
874
if (text[index] == '0') {
875
876
if (SDL_tolower((unsigned char) text[index + 1])
== 'x') {
877
878
879
radix = 16;
} else {
radix = 8;
880
881
}
}
882
883
884
}
/* Fall through to %d handling */
case 'd':
885
#ifdef SDL_HAS_64BIT_TYPE
886
887
888
889
890
891
892
if (inttype == DO_LONGLONG) {
Sint64 value;
text += SDL_ScanLongLong(text, radix, &value);
if (!suppress) {
Sint64 *valuep = va_arg(ap, Sint64 *);
*valuep = value;
++retval;
893
}
894
} else
895
#endif /* SDL_HAS_64BIT_TYPE */
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
{
long value;
text += SDL_ScanLong(text, radix, &value);
if (!suppress) {
switch (inttype) {
case DO_SHORT:
{
short *valuep = va_arg(ap, short *);
*valuep = (short) value;
}
break;
case DO_INT:
{
int *valuep = va_arg(ap, int *);
*valuep = (int) value;
911
}
912
913
914
915
916
917
918
919
920
921
break;
case DO_LONG:
{
long *valuep = va_arg(ap, long *);
*valuep = value;
}
break;
case DO_LONGLONG:
/* Handled above */
break;
922
}
923
++retval;
924
}
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
}
done = SDL_TRUE;
break;
case 'o':
if (radix == 10) {
radix = 8;
}
/* Fall through to unsigned handling */
case 'x':
case 'X':
if (radix == 10) {
radix = 16;
}
/* Fall through to unsigned handling */
case 'u':
940
#ifdef SDL_HAS_64BIT_TYPE
941
942
943
944
945
946
947
if (inttype == DO_LONGLONG) {
Uint64 value;
text += SDL_ScanUnsignedLongLong(text, radix, &value);
if (!suppress) {
Uint64 *valuep = va_arg(ap, Uint64 *);
*valuep = value;
++retval;
948
}
949
} else
950
#endif /* SDL_HAS_64BIT_TYPE */
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
{
unsigned long value;
text += SDL_ScanUnsignedLong(text, radix, &value);
if (!suppress) {
switch (inttype) {
case DO_SHORT:
{
short *valuep = va_arg(ap, short *);
*valuep = (short) value;
}
break;
case DO_INT:
{
int *valuep = va_arg(ap, int *);
*valuep = (int) value;
966
}
967
968
969
970
971
972
973
974
975
976
break;
case DO_LONG:
{
long *valuep = va_arg(ap, long *);
*valuep = value;
}
break;
case DO_LONGLONG:
/* Handled above */
break;
977
}
978
++retval;
979
}
980
981
982
983
984
985
986
987
988
989
990
}
done = SDL_TRUE;
break;
case 'p':
{
uintptr_t value;
text += SDL_ScanUintPtrT(text, 16, &value);
if (!suppress) {
void **valuep = va_arg(ap, void **);
*valuep = (void *) value;
++retval;
991
}
992
993
994
995
996
997
998
999
1000
}
done = SDL_TRUE;
break;
case 'f':
{
double value;
text += SDL_ScanFloat(text, &value);
if (!suppress) {
float *valuep = va_arg(ap, float *);