Mercurial > sdl-ios-xcode
comparison src/stdlib/SDL_string.c @ 1659:14717b52abc0 SDL-1.3
Merge trunk-1.3-3
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 17 May 2006 08:18:28 +0000 |
parents | 845b1619c8f6 |
children | 782fd950bd46 887c3600826b |
comparison
equal
deleted
inserted
replaced
1658:e49147870aac | 1659:14717b52abc0 |
---|---|
983 char num[130]; | 983 char num[130]; |
984 size_t size; | 984 size_t size; |
985 | 985 |
986 SDL_ltoa(value, num, radix); | 986 SDL_ltoa(value, num, radix); |
987 size = SDL_strlen(num); | 987 size = SDL_strlen(num); |
988 if ( size > maxlen ) { | 988 if ( size >= maxlen ) { |
989 size = maxlen; | 989 size = maxlen-1; |
990 } | 990 } |
991 SDL_strlcpy(text, num, size); | 991 SDL_strlcpy(text, num, size+1); |
992 | 992 |
993 return size; | 993 return size; |
994 } | 994 } |
995 static size_t SDL_PrintUnsignedLong(char *text, unsigned long value, int radix, size_t maxlen) | 995 static size_t SDL_PrintUnsignedLong(char *text, unsigned long value, int radix, size_t maxlen) |
996 { | 996 { |
997 char num[130]; | 997 char num[130]; |
998 size_t size; | 998 size_t size; |
999 | 999 |
1000 SDL_ultoa(value, num, radix); | 1000 SDL_ultoa(value, num, radix); |
1001 size = SDL_strlen(num); | 1001 size = SDL_strlen(num); |
1002 if ( size > maxlen ) { | 1002 if ( size >= maxlen ) { |
1003 size = maxlen; | 1003 size = maxlen-1; |
1004 } | 1004 } |
1005 SDL_strlcpy(text, num, size); | 1005 SDL_strlcpy(text, num, size+1); |
1006 | 1006 |
1007 return size; | 1007 return size; |
1008 } | 1008 } |
1009 #ifdef SDL_HAS_64BIT_TYPE | 1009 #ifdef SDL_HAS_64BIT_TYPE |
1010 static size_t SDL_PrintLongLong(char *text, Sint64 value, int radix, size_t maxlen) | 1010 static size_t SDL_PrintLongLong(char *text, Sint64 value, int radix, size_t maxlen) |
1012 char num[130]; | 1012 char num[130]; |
1013 size_t size; | 1013 size_t size; |
1014 | 1014 |
1015 SDL_lltoa(value, num, radix); | 1015 SDL_lltoa(value, num, radix); |
1016 size = SDL_strlen(num); | 1016 size = SDL_strlen(num); |
1017 if ( size > maxlen ) { | 1017 if ( size >= maxlen ) { |
1018 size = maxlen; | 1018 size = maxlen-1; |
1019 } | 1019 } |
1020 SDL_strlcpy(text, num, size); | 1020 SDL_strlcpy(text, num, size+1); |
1021 | 1021 |
1022 return size; | 1022 return size; |
1023 } | 1023 } |
1024 static size_t SDL_PrintUnsignedLongLong(char *text, Uint64 value, int radix, size_t maxlen) | 1024 static size_t SDL_PrintUnsignedLongLong(char *text, Uint64 value, int radix, size_t maxlen) |
1025 { | 1025 { |
1026 char num[130]; | 1026 char num[130]; |
1027 size_t size; | 1027 size_t size; |
1028 | 1028 |
1029 SDL_ulltoa(value, num, radix); | 1029 SDL_ulltoa(value, num, radix); |
1030 size = SDL_strlen(num); | 1030 size = SDL_strlen(num); |
1031 if ( size > maxlen ) { | 1031 if ( size >= maxlen ) { |
1032 size = maxlen; | 1032 size = maxlen-1; |
1033 } | 1033 } |
1034 SDL_strlcpy(text, num, size); | 1034 SDL_strlcpy(text, num, size+1); |
1035 | 1035 |
1036 return size; | 1036 return size; |
1037 } | 1037 } |
1038 #endif /* SDL_HAS_64BIT_TYPE */ | 1038 #endif /* SDL_HAS_64BIT_TYPE */ |
1039 static size_t SDL_PrintFloat(char *text, double arg, size_t maxlen) | 1039 static size_t SDL_PrintFloat(char *text, double arg, size_t maxlen) |
1099 DO_LONGLONG | 1099 DO_LONGLONG |
1100 } inttype = DO_INT; | 1100 } inttype = DO_INT; |
1101 | 1101 |
1102 ++fmt; | 1102 ++fmt; |
1103 /* FIXME: implement more of the format specifiers */ | 1103 /* FIXME: implement more of the format specifiers */ |
1104 while ( *fmt == '.' || (*fmt >= '0' && *fmt <= '9') ) { | |
1105 ++fmt; | |
1106 } | |
1104 while (!done) { | 1107 while (!done) { |
1105 switch(*fmt) { | 1108 switch(*fmt) { |
1106 case '%': | 1109 case '%': |
1107 *text = '%'; | 1110 *text = '%'; |
1108 len = 1; | 1111 len = 1; |