zenilib: zenilib/jni/external/sdl/src/stdlib/SDL_string.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_string.c
Go to the documentation of this file.
1 /*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "SDL_config.h"
22
23 /* This file contains portable string manipulation functions for SDL */
24
25 #include "SDL_stdinc.h"
26
27
28 #define SDL_isupperhex(X) (((X) >= 'A') && ((X) <= 'F'))
29 #define SDL_islowerhex(X) (((X) >= 'a') && ((X) <= 'f'))
30
31 #define UTF8_IsLeadByte(c) ((c) >= 0xC0 && (c) <= 0xF4)
32 #define UTF8_IsTrailingByte(c) ((c) >= 0x80 && (c) <= 0xBF)
33
34 static int UTF8_TrailingBytes(unsigned char c)
35 {
36 if (c >= 0xC0 && c <= 0xDF)
37 return 1;
38 else if (c >= 0xE0 && c <= 0xEF)
39 return 2;
40 else if (c >= 0xF0 && c <= 0xF4)
41 return 3;
42 else
43 return 0;
44 }
45
46 #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOL)
47 static size_t
48 SDL_ScanLong(const char *text, int radix, long *valuep)
49 {
50 const char *textstart = text;
51 long value = 0;
52 SDL_bool negative = SDL_FALSE;
53
54 if (*text == '-') {
55 negative = SDL_TRUE;
56 ++text;
57 }
58 if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
59 text += 2;
60 }
61 for (;;) {
62 int v;
63 if (SDL_isdigit((unsigned char) *text)) {
64 v = *text - '0';
65 } else if (radix == 16 && SDL_isupperhex(*text)) {
66 v = 10 + (*text - 'A');
67 } else if (radix == 16 && SDL_islowerhex(*text)) {
68 v = 10 + (*text - 'a');
69 } else {
70 break;
71 }
72 value *= radix;
73 value += v;
74 ++text;
75 }
76 if (valuep) {
77 if (negative && value) {
78 *valuep = -value;
79 } else {
80 *valuep = value;
81 }
82 }
83 return (text - textstart);
84 }
85 #endif
86
87 #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD)
88 static size_t
89 SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
90 {
91 const char *textstart = text;
92 unsigned long value = 0;
93
94 if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
95 text += 2;
96 }
97 for (;;) {
98 int v;
99 if (SDL_isdigit((unsigned char) *text)) {
100 v = *text - '0';
101 } else if (radix == 16 && SDL_isupperhex(*text)) {
102 v = 10 + (*text - 'A');
103 } else if (radix == 16 && SDL_islowerhex(*text)) {
104 v = 10 + (*text - 'a');
105 } else {
106 break;
107 }
108 value *= radix;
109 value += v;
110 ++text;
111 }
112 if (valuep) {
113 *valuep = value;
114 }
115 return (text - textstart);
116 }
117 #endif
118
119 #ifndef HAVE_SSCANF
120 static size_t
121 SDL_ScanUintPtrT(const char *text, int radix, uintptr_t * valuep)
122 {
123 const char *textstart = text;
124 uintptr_t value = 0;
125
126 if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
127 text += 2;
128 }
129 for (;;) {
130 int v;
131 if (SDL_isdigit((unsigned char) *text)) {
132 v = *text - '0';
133 } else if (radix == 16 && SDL_isupperhex(*text)) {
134 v = 10 + (*text - 'A');
135 } else if (radix == 16 && SDL_islowerhex(*text)) {
136 v = 10 + (*text - 'a');
137 } else {
138 break;
139 }
140 value *= radix;
141 value += v;
142 ++text;
143 }
144 if (valuep) {
145 *valuep = value;
146 }
147 return (text - textstart);
148 }
149 #endif
150
151 #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOLL)
152 static size_t
153 SDL_ScanLongLong(const char *text, int radix, Sint64 * valuep)
154 {
155 const char *textstart = text;
156 Sint64 value = 0;
157 SDL_bool negative = SDL_FALSE;
158
159 if (*text == '-') {
160 negative = SDL_TRUE;
161 ++text;
162 }
163 if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
164 text += 2;
165 }
166 for (;;) {
167 int v;
168 if (SDL_isdigit((unsigned char) *text)) {
169 v = *text - '0';
170 } else if (radix == 16 && SDL_isupperhex(*text)) {
171 v = 10 + (*text - 'A');
172 } else if (radix == 16 && SDL_islowerhex(*text)) {
173 v = 10 + (*text - 'a');
174 } else {
175 break;
176 }
177 value *= radix;
178 value += v;
179 ++text;
180 }
181 if (valuep) {
182 if (negative && value) {
183 *valuep = -value;
184 } else {
185 *valuep = value;
186 }
187 }
188 return (text - textstart);
189 }
190 #endif
191
192 #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOULL)
193 static size_t
194 SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 * valuep)
195 {
196 const char *textstart = text;
197 Uint64 value = 0;
198
199 if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
200 text += 2;
201 }
202 for (;;) {
203 int v;
204 if (SDL_isdigit((unsigned char) *text)) {
205 v = *text - '0';
206 } else if (radix == 16 && SDL_isupperhex(*text)) {
207 v = 10 + (*text - 'A');
208 } else if (radix == 16 && SDL_islowerhex(*text)) {
209 v = 10 + (*text - 'a');
210 } else {
211 break;
212 }
213 value *= radix;
214 value += v;
215 ++text;
216 }
217 if (valuep) {
218 *valuep = value;
219 }
220 return (text - textstart);
221 }
222 #endif
223
224 #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOD)
225 static size_t
226 SDL_ScanFloat(const char *text, double *valuep)
227 {
228 const char *textstart = text;
229 unsigned long lvalue = 0;
230 double value = 0.0;
231 SDL_bool negative = SDL_FALSE;
232
233 if (*text == '-') {
234 negative = SDL_TRUE;
235 ++text;
236 }
237 text += SDL_ScanUnsignedLong(text, 10, &lvalue);
238 value += lvalue;
239 if (*text == '.') {
240 int mult = 10;
241 ++text;
242 while (SDL_isdigit((unsigned char) *text)) {
243 lvalue = *text - '0';
244 value += (double) lvalue / mult;
245 mult *= 10;
246 ++text;
247 }
248 }
249 if (valuep) {
250 if (negative && value) {
251 *valuep = -value;
252 } else {
253 *valuep = value;
254 }
255 }
256 return (text - textstart);
257 }
258 #endif
259
260 void *
261 SDL_memset(void *dst, int c, size_t len)
262 {
263 #if defined(HAVE_MEMSET)
264 return memset(dst, c, len);
265 #else
266 size_t left = (len % 4);
267 Uint32 *dstp4;
268 Uint8 *dstp1;
269 Uint32 value4 = (c | (c << 8) | (c << 16) | (c << 24));
270 Uint8 value1 = (Uint8) c;
271
272 dstp4 = (Uint32 *) dst;
273 len /= 4;
274 while (len--) {
275 *dstp4++ = value4;
276 }
277
278 dstp1 = (Uint8 *) dstp4;
279 switch (left) {
280 case 3:
281 *dstp1++ = value1;
282 case 2:
283 *dstp1++ = value1;
284 case 1:
285 *dstp1++ = value1;
286 }
287
288 return dst;
289 #endif /* HAVE_MEMSET */
290 }
291
292 void *
293 SDL_memcpy(void *dst, const void *src, size_t len)
294 {
295 #ifdef __GNUC__
296 /* Presumably this is well tuned for speed.
297 On my machine this is twice as fast as the C code below.
298 */
299 return __builtin_memcpy(dst, src, len);
300 #elif defined(HAVE_MEMCPY)
301 return memcpy(dst, src, len);
302 #elif defined(HAVE_BCOPY)
303 bcopy(src, dst, len);
304 return dst;
305 #else
306 /* GCC 4.9.0 with -O3 will generate movaps instructions with the loop
307 using Uint32* pointers, so we need to make sure the pointers are
308 aligned before we loop using them.
309 */
310 if (((intptr_t)src & 0x3) || ((intptr_t)dst & 0x3)) {
311 /* Do an unaligned byte copy */
312 Uint8 *srcp1 = (Uint8 *)src;
313 Uint8 *dstp1 = (Uint8 *)dst;
314
315 while (len--) {
316 *dstp1++ = *srcp1++;
317 }
318 } else {
319 size_t left = (len % 4);
320 Uint32 *srcp4, *dstp4;
321 Uint8 *srcp1, *dstp1;
322
323 srcp4 = (Uint32 *) src;
324 dstp4 = (Uint32 *) dst;
325 len /= 4;
326 while (len--) {
327 *dstp4++ = *srcp4++;
328 }
329
330 srcp1 = (Uint8 *) srcp4;
331 dstp1 = (Uint8 *) dstp4;
332 switch (left) {
333 case 3:
334 *dstp1++ = *srcp1++;
335 case 2:
336 *dstp1++ = *srcp1++;
337 case 1:
338 *dstp1++ = *srcp1++;
339 }
340 }
341 return dst;
342 #endif /* __GNUC__ */
343 }
344
345 void *
346 SDL_memmove(void *dst, const void *src, size_t len)
347 {
348 #if defined(HAVE_MEMMOVE)
349 return memmove(dst, src, len);
350 #else
351 char *srcp = (char *) src;
352 char *dstp = (char *) dst;
353
354 if (src < dst) {
355 srcp += len - 1;
356 dstp += len - 1;
357 while (len--) {
358 *dstp-- = *srcp--;
359 }
360 } else {
361 while (len--) {
362 *dstp++ = *srcp++;
363 }
364 }
365 return dst;
366 #endif /* HAVE_MEMMOVE */
367 }
368
369 int
370 SDL_memcmp(const void *s1, const void *s2, size_t len)
371 {
372 #if defined(HAVE_MEMCMP)
373 return memcmp(s1, s2, len);
374 #else
375 char *s1p = (char *) s1;
376 char *s2p = (char *) s2;
377 while (len--) {
378 if (*s1p != *s2p) {
379 return (*s1p - *s2p);
380 }
381 ++s1p;
382 ++s2p;
383 }
384 return 0;
385 #endif /* HAVE_MEMCMP */
386 }
387
388 size_t
389 SDL_strlen(const char *string)
390 {
391 #if defined(HAVE_STRLEN)
392 return strlen(string);
393 #else
394 size_t len = 0;
395 while (*string++) {
396 ++len;
397 }
398 return len;
399 #endif /* HAVE_STRLEN */
400 }
401
402 size_t
403 SDL_wcslen(const wchar_t * string)
404 {
405 #if defined(HAVE_WCSLEN)
406 return wcslen(string);
407 #else
408 size_t len = 0;
409 while (*string++) {
410 ++len;
411 }
412 return len;
413 #endif /* HAVE_WCSLEN */
414 }
415
416 size_t
417 SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen)
418 {
419 #if defined(HAVE_WCSLCPY)
420 return wcslcpy(dst, src, maxlen);
421 #else
422 size_t srclen = SDL_wcslen(src);
423 if (maxlen > 0) {
424 size_t len = SDL_min(srclen, maxlen - 1);
425 SDL_memcpy(dst, src, len * sizeof(wchar_t));
426 dst[len] = '\0';
427 }
428 return srclen;
429 #endif /* HAVE_WCSLCPY */
430 }
431
432 size_t
433 SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen)
434 {
435 #if defined(HAVE_WCSLCAT)
436 return wcslcat(dst, src, maxlen);
437 #else
438 size_t dstlen = SDL_wcslen(dst);
439 size_t srclen = SDL_wcslen(src);
440 if (dstlen < maxlen) {
441 SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen);
442 }
443 return dstlen + srclen;
444 #endif /* HAVE_WCSLCAT */
445 }
446
447 size_t
448 SDL_strlcpy(char *dst, const char *src, size_t maxlen)
449 {
450 #if defined(HAVE_STRLCPY)
451 return strlcpy(dst, src, maxlen);
452 #else
453 size_t srclen = SDL_strlen(src);
454 if (maxlen > 0) {
455 size_t len = SDL_min(srclen, maxlen - 1);
456 SDL_memcpy(dst, src, len);
457 dst[len] = '\0';
458 }
459 return srclen;
460 #endif /* HAVE_STRLCPY */
461 }
462
463 size_t SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes)
464 {
465 size_t src_bytes = SDL_strlen(src);
466 size_t bytes = SDL_min(src_bytes, dst_bytes - 1);
467 size_t i = 0;
468 char trailing_bytes = 0;
469 if (bytes)
470 {
471 unsigned char c = (unsigned char)src[bytes - 1];
472 if (UTF8_IsLeadByte(c))
473 --bytes;
474 else if (UTF8_IsTrailingByte(c))
475 {
476 for (i = bytes - 1; i != 0; --i)
477 {
478 c = (unsigned char)src[i];
479 trailing_bytes = UTF8_TrailingBytes(c);
480 if (trailing_bytes)
481 {
482 if (bytes - i != trailing_bytes + 1)
483 bytes = i;
484
485 break;
486 }
487 }
488 }
489 SDL_memcpy(dst, src, bytes);
490 }
491 dst[bytes] = '\0';
492 return bytes;
493 }
494
495 size_t
496 SDL_strlcat(char *dst, const char *src, size_t maxlen)
497 {
498 #if defined(HAVE_STRLCAT)
499 return strlcat(dst, src, maxlen);
500 #else
501 size_t dstlen = SDL_strlen(dst);
502 size_t srclen = SDL_strlen(src);
503 if (dstlen < maxlen) {
504 SDL_strlcpy(dst + dstlen, src, maxlen - dstlen);
505 }
506 return dstlen + srclen;
507 #endif /* HAVE_STRLCAT */
508 }
509
510 char *
511 SDL_strdup(const char *string)
512 {
513 #if defined(HAVE_STRDUP)
514 return strdup(string);
515 #else
516 size_t len = SDL_strlen(string) + 1;
517 char *newstr = SDL_malloc(len);
518 if (newstr) {
519 SDL_strlcpy(newstr, string, len);
520 }
521 return newstr;
522 #endif /* HAVE_STRDUP */
523 }
524
525 char *
526 SDL_strrev(char *string)
527 {
528 #if defined(HAVE__STRREV)
529 return _strrev(string);
530 #else
531 size_t len = SDL_strlen(string);
532 char *a = &string[0];
533 char *b = &string[len - 1];
534 len /= 2;
535 while (len--) {
536 char c = *a;
537 *a++ = *b;
538 *b-- = c;
539 }
540 return string;
541 #endif /* HAVE__STRREV */
542 }
543
544 char *
545 SDL_strupr(char *string)
546 {
547 #if defined(HAVE__STRUPR)
548 return _strupr(string);
549 #else
550 char *bufp = string;
551 while (*bufp) {
552 *bufp = SDL_toupper((unsigned char) *bufp);
553 ++bufp;
554 }
555 return string;
556 #endif /* HAVE__STRUPR */
557 }
558
559 char *
560 SDL_strlwr(char *string)
561 {
562 #if defined(HAVE__STRLWR)
563 return _strlwr(string);
564 #else
565 char *bufp = string;
566 while (*bufp) {
567 *bufp = SDL_tolower((unsigned char) *bufp);
568 ++bufp;
569 }
570 return string;
571 #endif /* HAVE__STRLWR */
572 }
573
574 char *
575 SDL_strchr(const char *string, int c)
576 {
577 #ifdef HAVE_STRCHR
578 return SDL_const_cast(char*,strchr(string, c));
579 #elif defined(HAVE_INDEX)
580 return SDL_const_cast(char*,index(string, c));
581 #else
582 while (*string) {
583 if (*string == c) {
584 return (char *) string;
585 }
586 ++string;
587 }
588 return NULL;
589 #endif /* HAVE_STRCHR */
590 }
591
592 char *
593 SDL_strrchr(const char *string, int c)
594 {
595 #ifdef HAVE_STRRCHR
596 return SDL_const_cast(char*,strrchr(string, c));
597 #elif defined(HAVE_RINDEX)
598 return SDL_const_cast(char*,rindex(string, c));
599 #else
600 const char *bufp = string + SDL_strlen(string) - 1;
601 while (bufp >= string) {
602 if (*bufp == c) {
603 return (char *) bufp;
604 }
605 --bufp;
606 }
607 return NULL;
608 #endif /* HAVE_STRRCHR */
609 }
610
611 char *
612 SDL_strstr(const char *haystack, const char *needle)
613 {
614 #if defined(HAVE_STRSTR)
615 return SDL_const_cast(char*,strstr(haystack, needle));
616 #else
617 size_t length = SDL_strlen(needle);
618 while (*haystack) {
619 if (SDL_strncmp(haystack, needle, length) == 0) {
620 return (char *) haystack;
621 }
622 ++haystack;
623 }
624 return NULL;
625 #endif /* HAVE_STRSTR */
626 }
627
628 #if !defined(HAVE__LTOA) || !defined(HAVE__I64TOA) || \
629 !defined(HAVE__ULTOA) || !defined(HAVE__UI64TOA)
630 static const char ntoa_table[] = {
631 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
632 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
633 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
634 'U', 'V', 'W', 'X', 'Y', 'Z'
635 };
636 #endif /* ntoa() conversion table */
637
638 char *
639 SDL_itoa(int value, char *string, int radix)
640 {
641 #ifdef HAVE_ITOA
642 return itoa(value, string, radix);
643 #else
644 return SDL_ltoa((long)value, string, radix);
645 #endif /* HAVE_ITOA */
646 }
647
648 char *
649 SDL_uitoa(unsigned int value, char *string, int radix)
650 {
651 #ifdef HAVE__UITOA
652 return _uitoa(value, string, radix);
653 #else
654 return SDL_ultoa((unsigned long)value, string, radix);
655 #endif /* HAVE__UITOA */
656 }
657
658 char *
659 SDL_ltoa(long value, char *string, int radix)
660 {
661 #if defined(HAVE__LTOA)
662 return _ltoa(value, string, radix);
663 #else
664 char *bufp = string;
665
666 if (value < 0) {
667 *bufp++ = '-';
668 value = -value;
669 }
670 if (value) {
671 while (value > 0) {
672 *bufp++ = ntoa_table[value % radix];
673 value /= radix;
674 }
675 } else {
676 *bufp++ = '0';
677 }
678 *bufp = '\0';
679
680 /* The numbers went into the string backwards. :) */
681 if (*string == '-') {
682 SDL_strrev(string + 1);
683 } else {
684 SDL_strrev(string);
685 }
686
687 return string;
688 #endif /* HAVE__LTOA */
689 }
690
691 char *
692 SDL_ultoa(unsigned long value, char *string, int radix)
693 {
694 #if defined(HAVE__ULTOA)
695 return _ultoa(value, string, radix);
696 #else
697 char *bufp = string;
698
699 if (value) {
700 while (value > 0) {
701 *bufp++ = ntoa_table[value % radix];
702 value /= radix;
703 }
704 } else {
705 *bufp++ = '0';
706 }
707 *bufp = '\0';
708
709 /* The numbers went into the string backwards. :) */
710 SDL_strrev(string);
711
712 return string;
713 #endif /* HAVE__ULTOA */
714 }
715
716 char *
717 SDL_lltoa(Sint64 value, char *string, int radix)
718 {
719 #if defined(HAVE__I64TOA)
720 return _i64toa(value, string, radix);
721 #else
722 char *bufp = string;
723
724 if (value < 0) {
725 *bufp++ = '-';
726 value = -value;
727 }
728 if (value) {
729 while (value > 0) {
730 *bufp++ = ntoa_table[value % radix];
731 value /= radix;
732 }
733 } else {
734 *bufp++ = '0';
735 }
736 *bufp = '\0';
737
738 /* The numbers went into the string backwards. :) */
739 if (*string == '-') {
740 SDL_strrev(string + 1);
741 } else {
742 SDL_strrev(string);
743 }
744
745 return string;
746 #endif /* HAVE__I64TOA */
747 }
748
749 char *
750 SDL_ulltoa(Uint64 value, char *string, int radix)
751 {
752 #if defined(HAVE__UI64TOA)
753 return _ui64toa(value, string, radix);
754 #else
755 char *bufp = string;
756
757 if (value) {
758 while (value > 0) {
759 *bufp++ = ntoa_table[value % radix];
760 value /= radix;
761 }
762 } else {
763 *bufp++ = '0';
764 }
765 *bufp = '\0';
766
767 /* The numbers went into the string backwards. :) */
768 SDL_strrev(string);
769
770 return string;
771 #endif /* HAVE__UI64TOA */
772 }
773
774 int SDL_atoi(const char *string)
775 {
776 #ifdef HAVE_ATOI
777 return atoi(string);
778 #else
779 return SDL_strtol(string, NULL, 0);
780 #endif /* HAVE_ATOI */
781 }
782
783 double SDL_atof(const char *string)
784 {
785 #ifdef HAVE_ATOF
786 return (double) atof(string);
787 #else
788 return SDL_strtod(string, NULL);
789 #endif /* HAVE_ATOF */
790 }
791
792 long
793 SDL_strtol(const char *string, char **endp, int base)
794 {
795 #if defined(HAVE_STRTOL)
796 return strtol(string, endp, base);
797 #else
798 size_t len;
799 long value;
800
801 if (!base) {
802 if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
803 base = 16;
804 } else {
805 base = 10;
806 }
807 }
808
809 len = SDL_ScanLong(string, base, &value);
810 if (endp) {
811 *endp = (char *) string + len;
812 }
813 return value;
814 #endif /* HAVE_STRTOL */
815 }
816
817 unsigned long
818 SDL_strtoul(const char *string, char **endp, int base)
819 {
820 #if defined(HAVE_STRTOUL)
821 return strtoul(string, endp, base);
822 #else
823 size_t len;
824 unsigned long value;
825
826 if (!base) {
827 if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
828 base = 16;
829 } else {
830 base = 10;
831 }
832 }
833
834 len = SDL_ScanUnsignedLong(string, base, &value);
835 if (endp) {
836 *endp = (char *) string + len;
837 }
838 return value;
839 #endif /* HAVE_STRTOUL */
840 }
841
842 Sint64
843 SDL_strtoll(const char *string, char **endp, int base)
844 {
845 #if defined(HAVE_STRTOLL)
846 return strtoll(string, endp, base);
847 #else
848 size_t len;
849 Sint64 value;
850
851 if (!base) {
852 if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
853 base = 16;
854 } else {
855 base = 10;
856 }
857 }
858
859 len = SDL_ScanLongLong(string, base, &value);
860 if (endp) {
861 *endp = (char *) string + len;
862 }
863 return value;
864 #endif /* HAVE_STRTOLL */
865 }
866
867 Uint64
868 SDL_strtoull(const char *string, char **endp, int base)
869 {
870 #if defined(HAVE_STRTOULL)
871 return strtoull(string, endp, base);
872 #else
873 size_t len;
874 Uint64 value;
875
876 if (!base) {
877 if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
878 base = 16;
879 } else {
880 base = 10;
881 }
882 }
883
884 len = SDL_ScanUnsignedLongLong(string, base, &value);
885 if (endp) {
886 *endp = (char *) string + len;
887 }
888 return value;
889 #endif /* HAVE_STRTOULL */
890 }
891
892 double
893 SDL_strtod(const char *string, char **endp)
894 {
895 #if defined(HAVE_STRTOD)
896 return strtod(string, endp);
897 #else
898 size_t len;
899 double value;
900
901 len = SDL_ScanFloat(string, &value);
902 if (endp) {
903 *endp = (char *) string + len;
904 }
905 return value;
906 #endif /* HAVE_STRTOD */
907 }
908
909 int
910 SDL_strcmp(const char *str1, const char *str2)
911 {
912 #if defined(HAVE_STRCMP)
913 return strcmp(str1, str2);
914 #else
915 while (*str1 && *str2) {
916 if (*str1 != *str2)
917 break;
918 ++str1;
919 ++str2;
920 }
921 return (int) ((unsigned char) *str1 - (unsigned char) *str2);
922 #endif /* HAVE_STRCMP */
923 }
924
925 int
926 SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
927 {
928 #if defined(HAVE_STRNCMP)
929 return strncmp(str1, str2, maxlen);
930 #else
931 while (*str1 && *str2 && maxlen) {
932 if (*str1 != *str2)
933 break;
934 ++str1;
935 ++str2;
936 --maxlen;
937 }
938 if (!maxlen) {
939 return 0;
940 }
941 return (int) ((unsigned char) *str1 - (unsigned char) *str2);
942 #endif /* HAVE_STRNCMP */
943 }
944
945 int
946 SDL_strcasecmp(const char *str1, const char *str2)
947 {
948 #ifdef HAVE_STRCASECMP
949 return strcasecmp(str1, str2);
950 #elif defined(HAVE__STRICMP)
951 return _stricmp(str1, str2);
952 #else
953 char a = 0;
954 char b = 0;
955 while (*str1 && *str2) {
956 a = SDL_toupper((unsigned char) *str1);
957 b = SDL_toupper((unsigned char) *str2);
958 if (a != b)
959 break;
960 ++str1;
961 ++str2;
962 }
963 a = SDL_toupper(*str1);
964 b = SDL_toupper(*str2);
965 return (int) ((unsigned char) a - (unsigned char) b);
966 #endif /* HAVE_STRCASECMP */
967 }
968
969 int
970 SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen)
971 {
972 #ifdef HAVE_STRNCASECMP
973 return strncasecmp(str1, str2, maxlen);
974 #elif defined(HAVE__STRNICMP)
975 return _strnicmp(str1, str2, maxlen);
976 #else
977 char a = 0;
978 char b = 0;
979 while (*str1 && *str2 && maxlen) {
980 a = SDL_tolower((unsigned char) *str1);
981 b = SDL_tolower((unsigned char) *str2);
982 if (a != b)
983 break;
984 ++str1;
985 ++str2;
986 --maxlen;
987 }
988 if (maxlen == 0) {
989 return 0;
990 } else {
991 a = SDL_tolower((unsigned char) *str1);
992 b = SDL_tolower((unsigned char) *str2);
993 return (int) ((unsigned char) a - (unsigned char) b);
994 }
995 #endif /* HAVE_STRNCASECMP */
996 }
997
998 #ifdef HAVE_SSCANF
999 int
1000 SDL_sscanf(const char *text, const char *fmt, ...)
1001 {
1002 int rc;
1003 va_list ap;
1004 va_start(ap, fmt);
1005 rc = vsscanf(text, fmt, ap);
1006 va_end(ap);
1007 return rc;
1008 }
1009 #else
1010 int
1011 SDL_sscanf(const char *text, const char *fmt, ...)
1012 {
1013 va_list ap;
1014 int retval = 0;
1015
1016 va_start(ap, fmt);
1017 while (*fmt) {
1018 if (*fmt == ' ') {
1019 while (SDL_isspace((unsigned char) *text)) {
1020 ++text;
1021 }
1022 ++fmt;
1023 continue;
1024 }
1025 if (*fmt == '%') {
1026 SDL_bool done = SDL_FALSE;
1027 long count = 0;
1028 int radix = 10;
1029 enum
1030 {
1031 DO_SHORT,
1032 DO_INT,
1033 DO_LONG,
1034 DO_LONGLONG
1035 } inttype = DO_INT;
1036 SDL_bool suppress = SDL_FALSE;
1037
1038 ++fmt;
1039 if (*fmt == '%') {
1040 if (*text == '%') {
1041 ++text;
1042 ++fmt;
1043 continue;
1044 }
1045 break;
1046 }
1047 if (*fmt == '*') {
1048 suppress = SDL_TRUE;
1049 ++fmt;
1050 }
1051 fmt += SDL_ScanLong(fmt, 10, &count);
1052
1053 if (*fmt == 'c') {
1054 if (!count) {
1055 count = 1;
1056 }
1057 if (suppress) {
1058 while (count--) {
1059 ++text;
1060 }
1061 } else {
1062 char *valuep = va_arg(ap, char *);
1063 while (count--) {
1064 *valuep++ = *text++;
1065 }
1066 ++retval;
1067 }
1068 continue;
1069 }
1070
1071 while (SDL_isspace((unsigned char) *text)) {
1072 ++text;
1073 }
1074
1075 /* FIXME: implement more of the format specifiers */
1076 while (!done) {
1077 switch (*fmt) {
1078 case '*':
1079 suppress = SDL_TRUE;
1080 break;
1081 case 'h':
1082 if (inttype > DO_SHORT) {
1083 ++inttype;
1084 }
1085 break;
1086 case 'l':
1087 if (inttype < DO_LONGLONG) {
1088 ++inttype;
1089 }
1090 break;
1091 case 'I':
1092 if (SDL_strncmp(fmt, "I64", 3) == 0) {
1093 fmt += 2;
1094 inttype = DO_LONGLONG;
1095 }
1096 break;
1097 case 'i':
1098 {
1099 int index = 0;
1100 if (text[index] == '-') {
1101 ++index;
1102 }
1103 if (text[index] == '0') {
1104 if (SDL_tolower((unsigned char) text[index + 1]) == 'x') {
1105 radix = 16;
1106 } else {
1107 radix = 8;
1108 }
1109 }
1110 }
1111 /* Fall through to %d handling */
1112 case 'd':
1113 if (inttype == DO_LONGLONG) {
1114 Sint64 value;
1115 text += SDL_ScanLongLong(text, radix, &value);
1116 if (!suppress) {
1117 Sint64 *valuep = va_arg(ap, Sint64 *);
1118 *valuep = value;
1119 ++retval;
1120 }
1121 } else {
1122 long value;
1123 text += SDL_ScanLong(text, radix, &value);
1124 if (!suppress) {
1125 switch (inttype) {
1126 case DO_SHORT:
1127 {
1128 short *valuep = va_arg(ap, short *);
1129 *valuep = (short) value;
1130 }
1131 break;
1132 case DO_INT:
1133 {
1134 int *valuep = va_arg(ap, int *);
1135 *valuep = (int) value;
1136 }
1137 break;
1138 case DO_LONG:
1139 {
1140 long *valuep = va_arg(ap, long *);
1141 *valuep = value;
1142 }
1143 break;
1144 case DO_LONGLONG:
1145 /* Handled above */
1146 break;
1147 }
1148 ++retval;
1149 }
1150 }
1151 done = SDL_TRUE;
1152 break;
1153 case 'o':
1154 if (radix == 10) {
1155 radix = 8;
1156 }
1157 /* Fall through to unsigned handling */
1158 case 'x':
1159 case 'X':
1160 if (radix == 10) {
1161 radix = 16;
1162 }
1163 /* Fall through to unsigned handling */
1164 case 'u':
1165 if (inttype == DO_LONGLONG) {
1166 Uint64 value;
1167 text += SDL_ScanUnsignedLongLong(text, radix, &value);
1168 if (!suppress) {
1169 Uint64 *valuep = va_arg(ap, Uint64 *);
1170 *valuep = value;
1171 ++retval;
1172 }
1173 } else {
1174 unsigned long value;
1175 text += SDL_ScanUnsignedLong(text, radix, &value);
1176 if (!suppress) {
1177 switch (inttype) {
1178 case DO_SHORT:
1179 {
1180 short *valuep = va_arg(ap, short *);
1181 *valuep = (short) value;
1182 }
1183 break;
1184 case DO_INT:
1185 {
1186 int *valuep = va_arg(ap, int *);
1187 *valuep = (int) value;
1188 }
1189 break;
1190 case DO_LONG:
1191 {
1192 long *valuep = va_arg(ap, long *);
1193 *valuep = value;
1194 }
1195 break;
1196 case DO_LONGLONG:
1197 /* Handled above */
1198 break;
1199 }
1200 ++retval;
1201 }
1202 }
1203 done = SDL_TRUE;
1204 break;
1205 case 'p':
1206 {
1207 uintptr_t value;
1208 text += SDL_ScanUintPtrT(text, 16, &value);
1209 if (!suppress) {
1210 void **valuep = va_arg(ap, void **);
1211 *valuep = (void *) value;
1212 ++retval;
1213 }
1214 }
1215 done = SDL_TRUE;
1216 break;
1217 case 'f':
1218 {
1219 double value;
1220 text += SDL_ScanFloat(text, &value);
1221 if (!suppress) {
1222 float *valuep = va_arg(ap, float *);
1223 *valuep = (float) value;
1224 ++retval;
1225 }
1226 }
1227 done = SDL_TRUE;
1228 break;
1229 case 's':
1230 if (suppress) {
1231 while (!SDL_isspace((unsigned char) *text)) {
1232 ++text;
1233 if (count) {
1234 if (--count == 0) {
1235 break;
1236 }
1237 }
1238 }
1239 } else {
1240 char *valuep = va_arg(ap, char *);
1241 while (!SDL_isspace((unsigned char) *text)) {
1242 *valuep++ = *text++;
1243 if (count) {
1244 if (--count == 0) {
1245 break;
1246 }
1247 }
1248 }
1249 *valuep = '\0';
1250 ++retval;
1251 }
1252 done = SDL_TRUE;
1253 break;
1254 default:
1255 done = SDL_TRUE;
1256 break;
1257 }
1258 ++fmt;
1259 }
1260 continue;
1261 }
1262 if (*text == *fmt) {
1263 ++text;
1264 ++fmt;
1265 continue;
1266 }
1267 /* Text didn't match format specifier */
1268 break;
1269 }
1270 va_end(ap);
1271
1272 return retval;
1273 }
1274 #endif /* HAVE_SSCANF */
1275
1276 int
1277 SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...)
1278 {
1279 va_list ap;
1280 int retval;
1281
1282 va_start(ap, fmt);
1283 retval = SDL_vsnprintf(text, maxlen, fmt, ap);
1284 va_end(ap);
1285
1286 return retval;
1287 }
1288
1289 #ifdef HAVE_VSNPRINTF
1290 int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
1291 {
1292 return vsnprintf(text, maxlen, fmt, ap);
1293 }
1294 #else
1295 /* FIXME: implement more of the format specifiers */
1296 typedef enum
1297 {
1298 SDL_CASE_NOCHANGE,
1299 SDL_CASE_LOWER,
1300 SDL_CASE_UPPER
1301 } SDL_letter_case;
1302
1303 typedef struct
1304 {
1305 SDL_bool left_justify;
1306 SDL_bool force_sign;
1307 SDL_bool force_type;
1308 SDL_bool pad_zeroes;
1309 SDL_letter_case force_case;
1310 int width;
1311 int radix;
1312 int precision;
1313 } SDL_FormatInfo;
1314
1315 static size_t
1316 SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
1317 {
1318 size_t length = 0;
1319
1320 if (info && info->width && (size_t)info->width > SDL_strlen(string)) {
1321 char fill = info->pad_zeroes ? '0' : ' ';
1322 size_t width = info->width - SDL_strlen(string);
1323 while (width-- > 0 && maxlen > 0) {
1324 *text++ = fill;
1325 ++length;
1326 --maxlen;
1327 }
1328 }
1329
1330 length += SDL_strlcpy(text, string, maxlen);
1331
1332 if (info) {
1333 if (info->force_case == SDL_CASE_LOWER) {
1334 SDL_strlwr(text);
1335 } else if (info->force_case == SDL_CASE_UPPER) {
1336 SDL_strupr(text);
1337 }
1338 }
1339 return length;
1340 }
1341
1342 static size_t
1343 SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
1344 {
1345 char num[130];
1346
1347 SDL_ltoa(value, num, info ? info->radix : 10);
1348 return SDL_PrintString(text, maxlen, info, num);
1349 }
1350
1351 static size_t
1352 SDL_PrintUnsignedLong(char *text, size_t maxlen, SDL_FormatInfo *info, unsigned long value)
1353 {
1354 char num[130];
1355
1356 SDL_ultoa(value, num, info ? info->radix : 10);
1357 return SDL_PrintString(text, maxlen, info, num);
1358 }
1359
1360 static size_t
1361 SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
1362 {
1363 char num[130];
1364
1365 SDL_lltoa(value, num, info ? info->radix : 10);
1366 return SDL_PrintString(text, maxlen, info, num);
1367 }
1368
1369 static size_t
1370 SDL_PrintUnsignedLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Uint64 value)
1371 {
1372 char num[130];
1373
1374 SDL_ulltoa(value, num, info ? info->radix : 10);
1375 return SDL_PrintString(text, maxlen, info, num);
1376 }
1377
1378 static size_t
1379 SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
1380 {
1381 int width;
1382 size_t len;
1383 size_t left = maxlen;
1384 char *textstart = text;
1385
1386 if (arg) {
1387 /* This isn't especially accurate, but hey, it's easy. :) */
1388 unsigned long value;
1389
1390 if (arg < 0) {
1391 if (left > 1) {
1392 *text = '-';
1393 --left;
1394 }
1395 ++text;
1396 arg = -arg;
1397 } else if (info->force_sign) {
1398 if (left > 1) {
1399 *text = '+';
1400 --left;
1401 }
1402 ++text;
1403 }
1404 value = (unsigned long) arg;
1405 len = SDL_PrintUnsignedLong(text, left, NULL, value);
1406 text += len;
1407 if (len >= left) {
1408 left = SDL_min(left, 1);
1409 } else {
1410 left -= len;
1411 }
1412 arg -= value;
1413 if (info->precision < 0) {
1414 info->precision = 6;
1415 }
1416 if (info->force_type || info->precision > 0) {
1417 int mult = 10;
1418 if (left > 1) {
1419 *text = '.';
1420 --left;
1421 }
1422 ++text;
1423 while (info->precision-- > 0) {
1424 value = (unsigned long) (arg * mult);
1425 len = SDL_PrintUnsignedLong(text, left, NULL, value);
1426 text += len;
1427 if (len >= left) {
1428 left = SDL_min(left, 1);
1429 } else {
1430 left -= len;
1431 }
1432 arg -= (double) value / mult;
1433 mult *= 10;
1434 }
1435 }
1436 } else {
1437 if (left > 1) {
1438 *text = '0';
1439 --left;
1440 }
1441 ++text;
1442 if (info->force_type) {
1443 if (left > 1) {
1444 *text = '.';
1445 --left;
1446 }
1447 ++text;
1448 }
1449 }
1450
1451 width = info->width - (int)(text - textstart);
1452 if (width > 0) {
1453 char fill = info->pad_zeroes ? '0' : ' ';
1454 char *end = text+left-1;
1455 len = (text - textstart);
1456 for (len = (text - textstart); len--; ) {
1457 if ((textstart+len+width) < end) {
1458 *(textstart+len+width) = *(textstart+len);
1459 }
1460 }
1461 len = (size_t)width;
1462 text += len;
1463 if (len >= left) {
1464 left = SDL_min(left, 1);
1465 } else {
1466 left -= len;
1467 }
1468 while (len--) {
1469 if (textstart+len < end) {
1470 textstart[len] = fill;
1471 }
1472 }
1473 }
1474
1475 return (text - textstart);
1476 }
1477
1478 int
1479 SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
1480 {
1481 size_t left = maxlen;
1482 char *textstart = text;
1483
1484 while (*fmt) {
1485 if (*fmt == '%') {
1486 SDL_bool done = SDL_FALSE;
1487 size_t len = 0;
1488 SDL_bool check_flag;
1489 SDL_FormatInfo info;
1490 enum
1491 {
1492 DO_INT,
1493 DO_LONG,
1494 DO_LONGLONG
1495 } inttype = DO_INT;
1496
1497 SDL_zero(info);
1498 info.radix = 10;
1499 info.precision = -1;
1500
1501 check_flag = SDL_TRUE;
1502 while (check_flag) {
1503 ++fmt;
1504 switch (*fmt) {
1505 case '-':
1506 info.left_justify = SDL_TRUE;
1507 break;
1508 case '+':
1509 info.force_sign = SDL_TRUE;
1510 break;
1511 case '#':
1512 info.force_type = SDL_TRUE;
1513 break;
1514 case '0':
1515 info.pad_zeroes = SDL_TRUE;
1516 break;
1517 default:
1518 check_flag = SDL_FALSE;
1519 break;
1520 }
1521 }
1522
1523 if (*fmt >= '0' && *fmt <= '9') {
1524 info.width = SDL_strtol(fmt, (char **)&fmt, 0);
1525 }
1526
1527 if (*fmt == '.') {
1528 ++fmt;
1529 if (*fmt >= '0' && *fmt <= '9') {
1530 info.precision = SDL_strtol(fmt, (char **)&fmt, 0);
1531 } else {
1532 info.precision = 0;
1533 }
1534 }
1535
1536 while (!done) {
1537 switch (*fmt) {
1538 case '%':
1539 if (left > 1) {
1540 *text = '%';
1541 }
1542 len = 1;
1543 done = SDL_TRUE;
1544 break;
1545 case 'c':
1546 /* char is promoted to int when passed through (...) */
1547 if (left > 1) {
1548 *text = (char) va_arg(ap, int);
1549 }
1550 len = 1;
1551 done = SDL_TRUE;
1552 break;
1553 case 'h':
1554 /* short is promoted to int when passed through (...) */
1555 break;
1556 case 'l':
1557 if (inttype < DO_LONGLONG) {
1558 ++inttype;
1559 }
1560 break;
1561 case 'I':
1562 if (SDL_strncmp(fmt, "I64", 3) == 0) {
1563 fmt += 2;
1564 inttype = DO_LONGLONG;
1565 }
1566 break;
1567 case 'i':
1568 case 'd':
1569 switch (inttype) {
1570 case DO_INT:
1571 len = SDL_PrintLong(text, left, &info,
1572 (long) va_arg(ap, int));
1573 break;
1574 case DO_LONG:
1575 len = SDL_PrintLong(text, left, &info,
1576 va_arg(ap, long));
1577 break;
1578 case DO_LONGLONG:
1579 len = SDL_PrintLongLong(text, left, &info,
1580 va_arg(ap, Sint64));
1581 break;
1582 }
1583 done = SDL_TRUE;
1584 break;
1585 case 'p':
1586 case 'x':
1587 info.force_case = SDL_CASE_LOWER;
1588 /* Fall through to 'X' handling */
1589 case 'X':
1590 if (info.force_case == SDL_CASE_NOCHANGE) {
1591 info.force_case = SDL_CASE_UPPER;
1592 }
1593 if (info.radix == 10) {
1594 info.radix = 16;
1595 }
1596 if (*fmt == 'p') {
1597 inttype = DO_LONG;
1598 }
1599 /* Fall through to unsigned handling */
1600 case 'o':
1601 if (info.radix == 10) {
1602 info.radix = 8;
1603 }
1604 /* Fall through to unsigned handling */
1605 case 'u':
1606 info.pad_zeroes = SDL_TRUE;
1607 switch (inttype) {
1608 case DO_INT:
1609 len = SDL_PrintUnsignedLong(text, left, &info,
1610 (unsigned long)
1611 va_arg(ap, unsigned int));
1612 break;
1613 case DO_LONG:
1614 len = SDL_PrintUnsignedLong(text, left, &info,
1615 va_arg(ap, unsigned long));
1616 break;
1617 case DO_LONGLONG:
1618 len = SDL_PrintUnsignedLongLong(text, left, &info,
1619 va_arg(ap, Uint64));
1620 break;
1621 }
1622 done = SDL_TRUE;
1623 break;
1624 case 'f':
1625 len = SDL_PrintFloat(text, left, &info, va_arg(ap, double));
1626 done = SDL_TRUE;
1627 break;
1628 case 's':
1629 len = SDL_PrintString(text, left, &info, va_arg(ap, char *));
1630 done = SDL_TRUE;
1631 break;
1632 default:
1633 done = SDL_TRUE;
1634 break;
1635 }
1636 ++fmt;
1637 }
1638 text += len;
1639 if (len >= left) {
1640 left = SDL_min(left, 1);
1641 } else {
1642 left -= len;
1643 }
1644 } else {
1645 if (left > 1) {
1646 *text = *fmt;
1647 --left;
1648 }
1649 ++fmt;
1650 ++text;
1651 }
1652 }
1653 if (left > 0) {
1654 *text = '\0';
1655 }
1656 return (int)(text - textstart);
1657 }
1658 #endif /* HAVE_VSNPRINTF */
1659
1660 /* vi: set ts=4 sw=4 expandtab: */
SDL_isspace
DECLSPEC int SDLCALL SDL_isspace(int x)
Definition: SDL_stdlib.c:185
SDL_itoa
DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix)
Definition: SDL_string.c:639
SDL_ScanFloat
static size_t SDL_ScanFloat(const char *text, double *valuep)
Definition: SDL_string.c:226
SDL_strtod
DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp)
Definition: SDL_string.c:893
left
GLint left
Definition: glew.h:7291
strdup
char * strdup(const char *inStr)
Definition: strdup.c:6
NULL
#define NULL
Definition: ftobjs.h:61
SDL_snprintf
DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt,...)
Definition: SDL_string.c:1277
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:116
SDL_ltoa
DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix)
Definition: SDL_string.c:659
memmove
#define memmove
Definition: SDL_qsort.c:81
SDL_TRUE
Definition: SDL_stdinc.h:119
SDL_atof
DECLSPEC double SDLCALL SDL_atof(const char *str)
Definition: SDL_string.c:783
SDL_strrchr
DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c)
Definition: SDL_string.c:593
SDL_tolower
DECLSPEC int SDLCALL SDL_tolower(int x)
Definition: SDL_stdlib.c:187
memset
#define memset
Definition: SDL_malloc.c:633
SDL_ulltoa
DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix)
Definition: SDL_string.c:750
SDL_sscanf
DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt,...)
Definition: SDL_string.c:1011
a
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:8736
SDL_utf8strlcpy
DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes)
Definition: SDL_string.c:463
SDL_strlcat
DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:496
SDL_memcmp
DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len)
Definition: SDL_string.c:370
ntoa_table
static const char ntoa_table[]
Definition: SDL_string.c:630
len
GLenum GLsizei len
Definition: glew.h:7035
SDL_const_cast
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:100
SDL_strchr
DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c)
Definition: SDL_string.c:575
SDL_FALSE
Definition: SDL_stdinc.h:118
SDL_islowerhex
#define SDL_islowerhex(X)
Definition: SDL_string.c:29
SDL_ScanUintPtrT
static size_t SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep)
Definition: SDL_string.c:121
SDL_config.h
SDL_PrintLongLong
static size_t SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
Definition: SDL_string.c:1361
SDL_PrintLong
static size_t SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
Definition: SDL_string.c:1343
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:145
SDL_strtoul
DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base)
Definition: SDL_string.c:818
SDL_lltoa
DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *str, int radix)
Definition: SDL_string.c:717
SDL_strtol
DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base)
Definition: SDL_string.c:793
SDL_strtoull
DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base)
Definition: SDL_string.c:868
SDL_ScanLong
static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
Definition: SDL_string.c:48
SDL_memmove
DECLSPEC void *SDLCALL SDL_memmove(void *dst, const void *src, size_t len)
Definition: SDL_string.c:346
v
const GLdouble * v
Definition: glew.h:1377
SDL_uitoa
DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix)
Definition: SDL_string.c:649
dst
GLenum GLenum dst
Definition: glew.h:2396
int
int
Definition: SDL_systhread.c:37
length
GLsizei GLsizei * length
Definition: gl2ext.h:792
width
EGLSurface EGLint EGLint EGLint width
Definition: eglext.h:293
SDL_strupr
DECLSPEC char *SDLCALL SDL_strupr(char *str)
Definition: SDL_string.c:545
SDL_strdup
DECLSPEC char *SDLCALL SDL_strdup(const char *str)
Definition: SDL_string.c:511
Uint64
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:154
count
GLint GLsizei count
Definition: gl2ext.h:1011
UTF8_IsLeadByte
#define UTF8_IsLeadByte(c)
Definition: SDL_string.c:31
Zeni::itoa
String itoa(const int &number)
Definition: Serialization.cpp:98
SDL_strstr
DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle)
Definition: SDL_string.c:612
SDL_strlcpy
DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:448
c
const GLfloat * c
Definition: glew.h:14913
SDL_strtoll
DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base)
Definition: SDL_string.c:843
SDL_memset
DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len)
Definition: SDL_string.c:261
SDL_wcslcat
DECLSPEC size_t SDLCALL SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen)
Definition: SDL_string.c:433
SDL_malloc
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
index
GLuint index
Definition: glew.h:1800
uintptr_t
unsigned int uintptr_t
Definition: SDL_config_windows.h:69
SDL_strcmp
DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2)
Definition: SDL_string.c:910
s1
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
Definition: glew.h:11582
SDL_strncmp
DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:926
SDL_wcslen
DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr)
Definition: SDL_string.c:403
SDL_CASE_LOWER
Definition: SDL_string.c:1299
num
GLuint num
Definition: glew.h:2631
SDL_isupperhex
#define SDL_isupperhex(X)
Definition: SDL_string.c:28
SDL_strlen
DECLSPEC size_t SDLCALL SDL_strlen(const char *str)
Definition: SDL_string.c:389
value
EGLSurface EGLint void ** value
Definition: eglext.h:301
SDL_memcpy
DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len)
Definition: SDL_string.c:293
memcpy
#define memcpy
Definition: SDL_malloc.c:634
Uint8
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:129
string
GLsizei const GLcharARB ** string
Definition: glew.h:5638
SDL_atoi
DECLSPEC int SDLCALL SDL_atoi(const char *str)
Definition: SDL_string.c:774
SDL_strlwr
DECLSPEC char *SDLCALL SDL_strlwr(char *str)
Definition: SDL_string.c:560
SDL_letter_case
SDL_letter_case
Definition: SDL_string.c:1296
SDL_toupper
DECLSPEC int SDLCALL SDL_toupper(int x)
Definition: SDL_stdlib.c:186
b
GLdouble GLdouble GLdouble b
Definition: glew.h:8383
end
GLuint GLuint end
Definition: glew.h:1239
SDL_PrintUnsignedLongLong
static size_t SDL_PrintUnsignedLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Uint64 value)
Definition: SDL_string.c:1370
UTF8_TrailingBytes
static int UTF8_TrailingBytes(unsigned char c)
Definition: SDL_string.c:34
SDL_CASE_NOCHANGE
Definition: SDL_string.c:1298
SDL_strncasecmp
DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len)
Definition: SDL_string.c:970
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:254
SDL_ScanLongLong
static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
Definition: SDL_string.c:153
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:244
src
GLenum src
Definition: glew.h:2396
i
int i
Definition: pngrutil.c:1377
precision
GLenum GLint GLint * precision
Definition: glew.h:3391
Sint64
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:150
SDL_ultoa
DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *str, int radix)
Definition: SDL_string.c:692
UTF8_IsTrailingByte
#define UTF8_IsTrailingByte(c)
Definition: SDL_string.c:32
SDL_PrintString
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
Definition: SDL_string.c:1316
SDL_strrev
DECLSPEC char *SDLCALL SDL_strrev(char *str)
Definition: SDL_string.c:526
SDL_isdigit
DECLSPEC int SDLCALL SDL_isdigit(int x)
Definition: SDL_stdlib.c:184
SDL_strcasecmp
DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2)
Definition: SDL_string.c:946
SDL_CASE_UPPER
Definition: SDL_string.c:1300
SDL_vsnprintf
DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
Definition: SDL_string.c:1479
SDL_ScanUnsignedLongLong
static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
Definition: SDL_string.c:194
SDL_wcslcpy
DECLSPEC size_t SDLCALL SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen)
Definition: SDL_string.c:417
size_t
unsigned int size_t
Definition: SDL_config_windows.h:67
SDL_PrintUnsignedLong
static size_t SDL_PrintUnsignedLong(char *text, size_t maxlen, SDL_FormatInfo *info, unsigned long value)
Definition: SDL_string.c:1352
SDL_PrintFloat
static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
Definition: SDL_string.c:1379
SDL_ScanUnsignedLong
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:89