comparison src/stdlib/SDL_string.c @ 1693:504cb581ae1c SDL-1.3

Fixed bug #251
author Sam Lantinga <slouken@libsdl.org>
date Tue, 20 Jun 2006 05:57:50 +0000
parents 4da1ee79c9af
children
comparison
equal deleted inserted replaced
1692:75f2ace8511a 1693:504cb581ae1c
532 SDL_strtol(const char *string, char **endp, int base) 532 SDL_strtol(const char *string, char **endp, int base)
533 { 533 {
534 size_t len; 534 size_t len;
535 long value; 535 long value;
536 536
537 len = SDL_ScanLong(string, base ? base : 10, &value); 537 if (!base) {
538 if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
539 base = 16;
540 } else {
541 base = 10;
542 }
543 }
544
545 len = SDL_ScanLong(string, base, &value);
538 if (endp) { 546 if (endp) {
539 *endp = (char *) string + len; 547 *endp = (char *) string + len;
540 } 548 }
541 return value; 549 return value;
542 } 550 }
547 SDL_strtoul(const char *string, char **endp, int base) 555 SDL_strtoul(const char *string, char **endp, int base)
548 { 556 {
549 size_t len; 557 size_t len;
550 unsigned long value; 558 unsigned long value;
551 559
552 len = SDL_ScanUnsignedLong(string, base ? base : 10, &value); 560 if (!base) {
561 if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
562 base = 16;
563 } else {
564 base = 10;
565 }
566 }
567
568 len = SDL_ScanUnsignedLong(string, base, &value);
553 if (endp) { 569 if (endp) {
554 *endp = (char *) string + len; 570 *endp = (char *) string + len;
555 } 571 }
556 return value; 572 return value;
557 } 573 }
618 SDL_strtoll(const char *string, char **endp, int base) 634 SDL_strtoll(const char *string, char **endp, int base)
619 { 635 {
620 size_t len; 636 size_t len;
621 Sint64 value; 637 Sint64 value;
622 638
623 len = SDL_ScanLongLong(string, base ? base : 10, &value); 639 if (!base) {
640 if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
641 base = 16;
642 } else {
643 base = 10;
644 }
645 }
646
647 len = SDL_ScanLongLong(string, base, &value);
624 if (endp) { 648 if (endp) {
625 *endp = (char *) string + len; 649 *endp = (char *) string + len;
626 } 650 }
627 return value; 651 return value;
628 } 652 }
633 SDL_strtoull(const char *string, char **endp, int base) 657 SDL_strtoull(const char *string, char **endp, int base)
634 { 658 {
635 size_t len; 659 size_t len;
636 Uint64 value; 660 Uint64 value;
637 661
638 len = SDL_ScanUnsignedLongLong(string, base ? base : 10, &value); 662 if (!base) {
663 if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
664 base = 16;
665 } else {
666 base = 10;
667 }
668 }
669
670 len = SDL_ScanUnsignedLongLong(string, base, &value);
639 if (endp) { 671 if (endp) {
640 *endp = (char *) string + len; 672 *endp = (char *) string + len;
641 } 673 }
642 return value; 674 return value;
643 } 675 }