SDL_string.c File Reference
`#include "../SDL_internal.h"`
`#include "SDL_stdinc.h"`
Include dependency graph for SDL_string.c:

Go to the source code of this file.

## Data Structures

struct | SDL_FormatInfo

## Macros

#define | _GNU_SOURCE 1
#define | SDL_isupperhex(X) (((X) >= 'A') && ((X) <= 'F'))
#define | SDL_islowerhex(X) (((X) >= 'a') && ((X) <= 'f'))
#define | UTF8_IsLeadByte(c) ((c) >= 0xC0 && (c) <= 0xF4)
#define | UTF8_IsTrailingByte(c) ((c) >= 0x80 && (c) <= 0xBF)

## Enumerations

enum | SDL_letter_case { SDL_CASE_NOCHANGE, SDL_CASE_LOWER, SDL_CASE_UPPER }

## Functions

static int | UTF8_TrailingBytes (unsigned char c)
static size_t | SDL_ScanLong (const char *text, int radix, long *valuep)
static size_t | SDL_ScanUnsignedLong (const char *text, int radix, unsigned long *valuep)
static size_t | SDL_ScanUintPtrT (const char *text, int radix, uintptr_t *valuep)
static size_t | SDL_ScanLongLong (const char *text, int radix, Sint64 *valuep)
static size_t | SDL_ScanUnsignedLongLong (const char *text, int radix, Uint64 *valuep)
static size_t | SDL_ScanFloat (const char *text, double *valuep)
void * | SDL_memset (SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
void * | SDL_memcpy (SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
void * | SDL_memmove (SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
int | SDL_memcmp (const void *s1, const void *s2, size_t len)
size_t | SDL_strlen (const char *string)
size_t | SDL_wcslen (const wchar_t *string)
size_t | SDL_wcslcpy (SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
size_t | SDL_wcslcat (SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
size_t | SDL_strlcpy (SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
size_t | SDL_utf8strlcpy (SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes)
size_t | SDL_strlcat (SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
char * | SDL_strdup (const char *string)
char * | SDL_strrev (char *string)
char * | SDL_strupr (char *string)
char * | SDL_strlwr (char *string)
char * | SDL_strchr (const char *string, int c)
char * | SDL_strrchr (const char *string, int c)
char * | SDL_strstr (const char *haystack, const char *needle)
char * | SDL_itoa (int value, char *string, int radix)
char * | SDL_uitoa (unsigned int value, char *string, int radix)
char * | SDL_ltoa (long value, char *string, int radix)
char * | SDL_ultoa (unsigned long value, char *string, int radix)
char * | SDL_lltoa (Sint64 value, char *string, int radix)
char * | SDL_ulltoa (Uint64 value, char *string, int radix)
int | SDL_atoi (const char *string)
double | SDL_atof (const char *string)
long | SDL_strtol (const char *string, char **endp, int base)
unsigned long | SDL_strtoul (const char *string, char **endp, int base)
Sint64 | SDL_strtoll (const char *string, char **endp, int base)
Uint64 | SDL_strtoull (const char *string, char **endp, int base)
double | SDL_strtod (const char *string, char **endp)
int | SDL_strcmp (const char *str1, const char *str2)
int | SDL_strncmp (const char *str1, const char *str2, size_t maxlen)
int | SDL_strcasecmp (const char *str1, const char *str2)
int | SDL_strncasecmp (const char *str1, const char *str2, size_t maxlen)
int | SDL_sscanf (const char *text, SDL_SCANF_FORMAT_STRING const char *fmt,...)
int | SDL_vsscanf (const char *text, const char *fmt, va_list ap)
int | SDL_snprintf (SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
static size_t | SDL_PrintString (char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
static size_t | SDL_PrintLong (char *text, size_t maxlen, SDL_FormatInfo *info, long value)
static size_t | SDL_PrintUnsignedLong (char *text, size_t maxlen, SDL_FormatInfo *info, unsigned long value)
static size_t | SDL_PrintLongLong (char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
static size_t | SDL_PrintUnsignedLongLong (char *text, size_t maxlen, SDL_FormatInfo *info, Uint64 value)
static size_t | SDL_PrintFloat (char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
int | SDL_vsnprintf (SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)

## Variables

static const char | ntoa_table []

## Macro Definition Documentation

#define _GNU_SOURCE 1

Definition at line 27 of file SDL_string.c.

#define SDL_islowerhex | ( |  | X | ) | (((X) >= 'a') && ((X) <= 'f'))

Definition at line 38 of file SDL_string.c.

Referenced by SDL_ScanLong(), SDL_ScanLongLong(), SDL_ScanUintPtrT(), SDL_ScanUnsignedLong(), and SDL_ScanUnsignedLongLong().

#define SDL_isupperhex | ( |  | X | ) | (((X) >= 'A') && ((X) <= 'F'))

Definition at line 37 of file SDL_string.c.

Referenced by SDL_ScanLong(), SDL_ScanLongLong(), SDL_ScanUintPtrT(), SDL_ScanUnsignedLong(), and SDL_ScanUnsignedLongLong().

#define UTF8_IsLeadByte | ( |  | c | ) | ((c) >= 0xC0 && (c) <= 0xF4)

Definition at line 40 of file SDL_string.c.

Referenced by SDL_utf8strlcpy().

#define UTF8_IsTrailingByte | ( |  | c | ) | ((c) >= 0x80 && (c) <= 0xBF)

Definition at line 41 of file SDL_string.c.

Referenced by SDL_utf8strlcpy().

## Enumeration Type Documentation

enum SDL_letter_case

Enumerator
SDL_CASE_NOCHANGE |
SDL_CASE_LOWER |
SDL_CASE_UPPER |

Definition at line 1295 of file SDL_string.c.

{
SDL_CASE_NOCHANGE,
SDL_CASE_LOWER,
SDL_CASE_UPPER
} SDL_letter_case;
SDL_CASE_LOWER
Definition: SDL_string.c:1298
SDL_letter_case
SDL_letter_case
Definition: SDL_string.c:1295
SDL_CASE_NOCHANGE
Definition: SDL_string.c:1297
SDL_CASE_UPPER
Definition: SDL_string.c:1299

## Function Documentation

double SDL_atof | ( | const char * | string | ) |

Definition at line 776 of file SDL_string.c.

References NULL, and SDL_strtod().

Referenced by SDL_memset4().

{
#ifdef HAVE_ATOF
return (double) atof(string);
#else
return SDL_strtod(string, NULL);
#endif /* HAVE_ATOF */
}
SDL_strtod
double SDL_strtod(const char *string, char **endp)
Definition: SDL_string.c:886
NULL
#define NULL
Definition: begin_code.h:143

int SDL_atoi | ( | const char * | string | ) |

Definition at line 767 of file SDL_string.c.

References NULL, and SDL_strtol().

Referenced by SDL_memset4().

{
#ifdef HAVE_ATOI
return atoi(string);
#else
return SDL_strtol(string, NULL, 0);
#endif /* HAVE_ATOI */
}
SDL_strtol
long SDL_strtol(const char *string, char **endp, int base)
Definition: SDL_string.c:786
NULL
#define NULL
Definition: begin_code.h:143

char* SDL_itoa | ( | int | value,
|  | char * | string,
|  | int | radix
| ) |  |

Definition at line 660 of file SDL_string.c.

References SDL_ltoa().

Referenced by SDL_memset4().

{
#ifdef HAVE_ITOA
return itoa(value, string, radix);
#else
return SDL_ltoa((long)value, string, radix);
#endif /* HAVE_ITOA */
}
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_ltoa
char * SDL_ltoa(long value, char *string, int radix)
Definition: SDL_string.c:680

char* SDL_lltoa | ( | Sint64 | value,
|  | char * | string,
|  | int | radix
| ) |  |

Definition at line 724 of file SDL_string.c.

References SDL_ulltoa().

Referenced by SDL_memset4(), and SDL_PrintLongLong().

{
#if defined(HAVE__I64TOA)
return _i64toa(value, string, radix);
#else
char *bufp = string;
if (value < 0) {
*bufp++ = '-';
SDL_ulltoa(-value, bufp, radix);
} else {
SDL_ulltoa(value, bufp, radix);
}
return string;
#endif /* HAVE__I64TOA */
}
string
GLsizei const GLchar *const * string
Definition: SDL_opengl_glext.h:688
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_ulltoa
char * SDL_ulltoa(Uint64 value, char *string, int radix)
Definition: SDL_string.c:743

char* SDL_ltoa | ( | long | value,
|  | char * | string,
|  | int | radix
| ) |  |

Definition at line 680 of file SDL_string.c.

References SDL_ultoa().

Referenced by SDL_itoa(), SDL_memset4(), and SDL_PrintLong().

{
#if defined(HAVE__LTOA)
return _ltoa(value, string, radix);
#else
char *bufp = string;
if (value < 0) {
*bufp++ = '-';
SDL_ultoa(-value, bufp, radix);
} else {
SDL_ultoa(value, bufp, radix);
}
return string;
#endif /* HAVE__LTOA */
}
string
GLsizei const GLchar *const * string
Definition: SDL_opengl_glext.h:688
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_ultoa
char * SDL_ultoa(unsigned long value, char *string, int radix)
Definition: SDL_string.c:699

int SDL_memcmp | ( | const void * | s1,
|  | const void * | s2,
|  | size_t | len
| ) |  |

Definition at line 391 of file SDL_string.c.

Referenced by SDL_memset4().

{
#if defined(HAVE_MEMCMP)
return memcmp(s1, s2, len);
#else
char *s1p = (char *) s1;
char *s2p = (char *) s2;
while (len--) {
if (*s1p != *s2p) {
return (*s1p - *s2p);
}
++s1p;
++s2p;
}
return 0;
#endif /* HAVE_MEMCMP */
}
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
s1
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
Definition: SDL_opengl_glext.h:8583

void* SDL_memcpy | ( | SDL_OUT_BYTECAP(len) void * | dst,
|  | SDL_IN_BYTECAP(len) const void * | src,
|  | size_t | len
| ) |  |

Definition at line 314 of file SDL_string.c.

References memcpy.

Referenced by SDL_memcpy4(), SDL_memset4(), SDL_strlcpy(), SDL_utf8strlcpy(), and SDL_wcslcpy().

{
#ifdef __GNUC__
/* Presumably this is well tuned for speed.
On my machine this is twice as fast as the C code below.
*/
return __builtin_memcpy(dst, src, len);
#elif defined(HAVE_MEMCPY)
return memcpy(dst, src, len);
#elif defined(HAVE_BCOPY)
bcopy(src, dst, len);
return dst;
#else
/* GCC 4.9.0 with -O3 will generate movaps instructions with the loop
using Uint32* pointers, so we need to make sure the pointers are
aligned before we loop using them.
*/
if (((intptr_t)src & 0x3) || ((intptr_t)dst & 0x3)) {
/* Do an unaligned byte copy */
Uint8 *srcp1 = (Uint8 *)src;
Uint8 *dstp1 = (Uint8 *)dst;
while (len--) {
*dstp1++ = *srcp1++;
}
} else {
size_t left = (len % 4);
Uint32 *srcp4, *dstp4;
Uint8 *srcp1, *dstp1;
srcp4 = (Uint32 *) src;
dstp4 = (Uint32 *) dst;
len /= 4;
while (len--) {
*dstp4++ = *srcp4++;
}
srcp1 = (Uint8 *) srcp4;
dstp1 = (Uint8 *) dstp4;
switch (left) {
case 3:
*dstp1++ = *srcp1++;
case 2:
*dstp1++ = *srcp1++;
case 1:
*dstp1++ = *srcp1++;
}
}
return dst;
#endif /* __GNUC__ */
}
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
left
GLint left
Definition: SDL_opengl_glext.h:1949
Uint8
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
memcpy
#define memcpy
Definition: SDL_malloc.c:640
src
GLenum src
Definition: SDL_opengl_glext.h:1737

void* SDL_memmove | ( | SDL_OUT_BYTECAP(len) void * | dst,
|  | SDL_IN_BYTECAP(len) const void * | src,
|  | size_t | len
| ) |  |

Definition at line 367 of file SDL_string.c.

References memmove.

Referenced by SDL_memset4().

{
#if defined(HAVE_MEMMOVE)
return memmove(dst, src, len);
#else
char *srcp = (char *) src;
char *dstp = (char *) dst;
if (src < dst) {
srcp += len - 1;
dstp += len - 1;
while (len--) {
*dstp-- = *srcp--;
}
} else {
while (len--) {
*dstp++ = *srcp++;
}
}
return dst;
#endif /* HAVE_MEMMOVE */
}
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
memmove
#define memmove
Definition: SDL_qsort.c:86
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
src
GLenum src
Definition: SDL_opengl_glext.h:1737

void* SDL_memset | ( | SDL_OUT_BYTECAP(len) void * | dst,
|  | int | c,
|  | size_t | len
| ) |  |

Definition at line 270 of file SDL_string.c.

References memset.

{
#if defined(HAVE_MEMSET)
return memset(dst, c, len);
#else
size_t left;
Uint32 *dstp4;
Uint8 *dstp1 = (Uint8 *) dst;
Uint32 value4 = (c | (c << 8) | (c << 16) | (c << 24));
Uint8 value1 = (Uint8) c;
/* The destination pointer needs to be aligned on a 4-byte boundary to
* execute a 32-bit set. Set first bytes manually if needed until it is
* aligned. */
while ((intptr_t)dstp1 & 0x3) {
if (len--) {
*dstp1++ = value1;
} else {
return dst;
}
}
dstp4 = (Uint32 *) dstp1;
left = (len % 4);
len /= 4;
while (len--) {
*dstp4++ = value4;
}
dstp1 = (Uint8 *) dstp4;
switch (left) {
case 3:
*dstp1++ = value1;
case 2:
*dstp1++ = value1;
case 1:
*dstp1++ = value1;
}
return dst;
#endif /* HAVE_MEMSET */
}
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
memset
#define memset
Definition: SDL_malloc.c:639
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
left
GLint left
Definition: SDL_opengl_glext.h:1949
Uint8
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11093

static size_t SDL_PrintFloat | ( | char * | text,
|  | size_t | maxlen,
|  | SDL_FormatInfo * | info,
|  | double | arg
| ) |  |

static

Definition at line 1378 of file SDL_string.c.

References SDL_FormatInfo::force_sign, SDL_FormatInfo::force_type, NULL, SDL_FormatInfo::pad_zeroes, SDL_FormatInfo::precision, SDL_min, SDL_PrintUnsignedLong(), text, and SDL_FormatInfo::width.

Referenced by SDL_vsnprintf().

{
int width;
size_t len;
size_t left = maxlen;
char *textstart = text;
if (arg) {
/* This isn't especially accurate, but hey, it's easy. :) */
unsigned long value;
if (arg < 0) {
if (left > 1) {
*text = '-';
--left;
}
++text;
arg = -arg;
} else if (info->force_sign) {
if (left > 1) {
*text = '+';
--left;
}
++text;
}
value = (unsigned long) arg;
len = SDL_PrintUnsignedLong(text, left, NULL, value);
text += len;
if (len >= left) {
left = SDL_min(left, 1);
} else {
left -= len;
}
arg -= value;
if (info->precision < 0) {
info->precision = 6;
}
if (info->force_type || info->precision > 0) {
int mult = 10;
if (left > 1) {
*text = '.';
--left;
}
++text;
while (info->precision-- > 0) {
value = (unsigned long) (arg * mult);
len = SDL_PrintUnsignedLong(text, left, NULL, value);
text += len;
if (len >= left) {
left = SDL_min(left, 1);
} else {
left -= len;
}
arg -= (double) value / mult;
mult *= 10;
}
}
} else {
if (left > 1) {
*text = '0';
--left;
}
++text;
if (info->force_type) {
if (left > 1) {
*text = '.';
--left;
}
++text;
}
}
width = info->width - (int)(text - textstart);
if (width > 0) {
char fill = info->pad_zeroes ? '0' : ' ';
char *end = text+left-1;
len = (text - textstart);
for (len = (text - textstart); len--; ) {
if ((textstart+len+width) < end) {
*(textstart+len+width) = *(textstart+len);
}
}
len = (size_t)width;
text += len;
if (len >= left) {
left = SDL_min(left, 1);
} else {
left -= len;
}
while (len--) {
if (textstart+len < end) {
textstart[len] = fill;
}
}
}
return (text - textstart);
}
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:345
SDL_FormatInfo::pad_zeroes
SDL_bool pad_zeroes
Definition: SDL_string.c:1307
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
SDL_FormatInfo::force_type
SDL_bool force_type
Definition: SDL_string.c:1306
end
GLuint GLuint end
Definition: SDL_opengl.h:1564
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
size_t
unsigned int size_t
Definition: SDL_config_windows.h:67
SDL_FormatInfo::force_sign
SDL_bool force_sign
Definition: SDL_string.c:1305
left
GLint left
Definition: SDL_opengl_glext.h:1949
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
NULL
#define NULL
Definition: begin_code.h:143
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_FormatInfo::width
int width
Definition: SDL_string.c:1309
SDL_FormatInfo::precision
int precision
Definition: SDL_string.c:1311
SDL_PrintUnsignedLong
static size_t SDL_PrintUnsignedLong(char *text, size_t maxlen, SDL_FormatInfo *info, unsigned long value)
Definition: SDL_string.c:1351

static size_t SDL_PrintLong | ( | char * | text,
|  | size_t | maxlen,
|  | SDL_FormatInfo * | info,
|  | long | value
| ) |  |

static

Definition at line 1342 of file SDL_string.c.

References SDL_FormatInfo::radix, SDL_ltoa(), and SDL_PrintString().

Referenced by SDL_vsnprintf().

{
char num[130];
SDL_ltoa(value, num, info ? info->radix : 10);
return SDL_PrintString(text, maxlen, info, num);
}
SDL_FormatInfo::radix
int radix
Definition: SDL_string.c:1310
num
GLuint num
Definition: SDL_opengl_glext.h:4956
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_ltoa
char * SDL_ltoa(long value, char *string, int radix)
Definition: SDL_string.c:680
SDL_PrintString
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
Definition: SDL_string.c:1315

static size_t SDL_PrintLongLong | ( | char * | text,
|  | size_t | maxlen,
|  | SDL_FormatInfo * | info,
|  | Sint64 | value
| ) |  |

static

Definition at line 1360 of file SDL_string.c.

References SDL_FormatInfo::radix, SDL_lltoa(), and SDL_PrintString().

Referenced by SDL_vsnprintf().

{
char num[130];
SDL_lltoa(value, num, info ? info->radix : 10);
return SDL_PrintString(text, maxlen, info, num);
}
SDL_FormatInfo::radix
int radix
Definition: SDL_string.c:1310
num
GLuint num
Definition: SDL_opengl_glext.h:4956
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_lltoa
char * SDL_lltoa(Sint64 value, char *string, int radix)
Definition: SDL_string.c:724
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_PrintString
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
Definition: SDL_string.c:1315

static size_t SDL_PrintString | ( | char * | text,
|  | size_t | maxlen,
|  | SDL_FormatInfo * | info,
|  | const char * | string
| ) |  |

static

Definition at line 1315 of file SDL_string.c.

References SDL_FormatInfo::force_case, SDL_FormatInfo::pad_zeroes, SDL_CASE_LOWER, SDL_CASE_UPPER, SDL_strlcpy(), SDL_strlen(), SDL_strlwr(), SDL_strupr(), and SDL_FormatInfo::width.

Referenced by SDL_PrintLong(), SDL_PrintLongLong(), SDL_PrintUnsignedLong(), SDL_PrintUnsignedLongLong(), and SDL_vsnprintf().

{
size_t length = 0;
if (info && info->width && (size_t)info->width > SDL_strlen(string)) {
char fill = info->pad_zeroes ? '0' : ' ';
size_t width = info->width - SDL_strlen(string);
while (width-- > 0 && maxlen > 0) {
*text++ = fill;
++length;
--maxlen;
}
}
length += SDL_strlcpy(text, string, maxlen);
if (info) {
if (info->force_case == SDL_CASE_LOWER) {
SDL_strlwr(text);
} else if (info->force_case == SDL_CASE_UPPER) {
SDL_strupr(text);
}
}
return length;
}
SDL_FormatInfo::pad_zeroes
SDL_bool pad_zeroes
Definition: SDL_string.c:1307
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
SDL_strupr
char * SDL_strupr(char *string)
Definition: SDL_string.c:566
SDL_strlcpy
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:469
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
SDL_strlwr
char * SDL_strlwr(char *string)
Definition: SDL_string.c:581
SDL_CASE_LOWER
Definition: SDL_string.c:1298
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_FormatInfo::force_case
SDL_letter_case force_case
Definition: SDL_string.c:1308
length
GLuint GLsizei GLsizei * length
Definition: SDL_opengl_glext.h:669
SDL_FormatInfo::width
int width
Definition: SDL_string.c:1309
SDL_CASE_UPPER
Definition: SDL_string.c:1299

static size_t SDL_PrintUnsignedLong | ( | char * | text,
|  | size_t | maxlen,
|  | SDL_FormatInfo * | info,
|  | unsigned long | value
| ) |  |

static

Definition at line 1351 of file SDL_string.c.

References SDL_FormatInfo::radix, SDL_PrintString(), and SDL_ultoa().

Referenced by SDL_PrintFloat(), and SDL_vsnprintf().

{
char num[130];
SDL_ultoa(value, num, info ? info->radix : 10);
return SDL_PrintString(text, maxlen, info, num);
}
SDL_FormatInfo::radix
int radix
Definition: SDL_string.c:1310
num
GLuint num
Definition: SDL_opengl_glext.h:4956
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_ultoa
char * SDL_ultoa(unsigned long value, char *string, int radix)
Definition: SDL_string.c:699
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_PrintString
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
Definition: SDL_string.c:1315

static size_t SDL_PrintUnsignedLongLong | ( | char * | text,
|  | size_t | maxlen,
|  | SDL_FormatInfo * | info,
|  | Uint64 | value
| ) |  |

static

Definition at line 1369 of file SDL_string.c.

References SDL_FormatInfo::radix, SDL_PrintString(), and SDL_ulltoa().

Referenced by SDL_vsnprintf().

{
char num[130];
SDL_ulltoa(value, num, info ? info->radix : 10);
return SDL_PrintString(text, maxlen, info, num);
}
SDL_FormatInfo::radix
int radix
Definition: SDL_string.c:1310
num
GLuint num
Definition: SDL_opengl_glext.h:4956
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_ulltoa
char * SDL_ulltoa(Uint64 value, char *string, int radix)
Definition: SDL_string.c:743
SDL_PrintString
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
Definition: SDL_string.c:1315

static size_t SDL_ScanFloat | ( | const char * | text,
|  | double * | valuep
| ) |  |

static

Definition at line 235 of file SDL_string.c.

References SDL_FALSE, SDL_isdigit, SDL_ScanUnsignedLong(), SDL_TRUE, and text.

Referenced by SDL_strtod(), and SDL_vsscanf().

{
const char *textstart = text;
unsigned long lvalue = 0;
double value = 0.0;
SDL_bool negative = SDL_FALSE;
if (*text == '-') {
negative = SDL_TRUE;
++text;
}
text += SDL_ScanUnsignedLong(text, 10, &lvalue);
value += lvalue;
if (*text == '.') {
int mult = 10;
++text;
while (SDL_isdigit((unsigned char) *text)) {
lvalue = *text - '0';
value += (double) lvalue / mult;
mult *= 10;
++text;
}
}
if (valuep) {
if (negative && value) {
*valuep = -value;
} else {
*valuep = value;
}
}
return (text - textstart);
}
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:126
SDL_isdigit
#define SDL_isdigit
Definition: SDL_dynapi_overrides.h:388
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_TRUE
Definition: SDL_stdinc.h:129
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_FALSE
Definition: SDL_stdinc.h:128
SDL_ScanUnsignedLong
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:98

static size_t SDL_ScanLong | ( | const char * | text,
|  | int | radix,
|  | long * | valuep
| ) |  |

static

Definition at line 57 of file SDL_string.c.

References SDL_FALSE, SDL_isdigit, SDL_islowerhex, SDL_isupperhex, SDL_strncmp(), SDL_TRUE, and text.

Referenced by SDL_strtol(), and SDL_vsscanf().

{
const char *textstart = text;
long value = 0;
SDL_bool negative = SDL_FALSE;
if (*text == '-') {
negative = SDL_TRUE;
++text;
}
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
text += 2;
}
for (;;) {
int v;
if (SDL_isdigit((unsigned char) *text)) {
v = *text - '0';
} else if (radix == 16 && SDL_isupperhex(*text)) {
v = 10 + (*text - 'A');
} else if (radix == 16 && SDL_islowerhex(*text)) {
v = 10 + (*text - 'a');
} else {
break;
}
value *= radix;
value += v;
++text;
}
if (valuep) {
if (negative && value) {
*valuep = -value;
} else {
*valuep = value;
}
}
return (text - textstart);
}
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
SDL_islowerhex
#define SDL_islowerhex(X)
Definition: SDL_string.c:38
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:126
v
const GLdouble * v
Definition: SDL_opengl.h:2057
SDL_isdigit
#define SDL_isdigit
Definition: SDL_dynapi_overrides.h:388
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_TRUE
Definition: SDL_stdinc.h:129
SDL_isupperhex
#define SDL_isupperhex(X)
Definition: SDL_string.c:37
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_FALSE
Definition: SDL_stdinc.h:128

static size_t SDL_ScanLongLong | ( | const char * | text,
|  | int | radix,
|  | Sint64 * | valuep
| ) |  |

static

Definition at line 162 of file SDL_string.c.

References SDL_FALSE, SDL_isdigit, SDL_islowerhex, SDL_isupperhex, SDL_strncmp(), SDL_TRUE, and text.

Referenced by SDL_strtoll(), and SDL_vsscanf().

{
const char *textstart = text;
Sint64 value = 0;
SDL_bool negative = SDL_FALSE;
if (*text == '-') {
negative = SDL_TRUE;
++text;
}
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
text += 2;
}
for (;;) {
int v;
if (SDL_isdigit((unsigned char) *text)) {
v = *text - '0';
} else if (radix == 16 && SDL_isupperhex(*text)) {
v = 10 + (*text - 'A');
} else if (radix == 16 && SDL_islowerhex(*text)) {
v = 10 + (*text - 'a');
} else {
break;
}
value *= radix;
value += v;
++text;
}
if (valuep) {
if (negative && value) {
*valuep = -value;
} else {
*valuep = value;
}
}
return (text - textstart);
}
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
SDL_islowerhex
#define SDL_islowerhex(X)
Definition: SDL_string.c:38
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:126
v
const GLdouble * v
Definition: SDL_opengl.h:2057
SDL_isdigit
#define SDL_isdigit
Definition: SDL_dynapi_overrides.h:388
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_TRUE
Definition: SDL_stdinc.h:129
SDL_isupperhex
#define SDL_isupperhex(X)
Definition: SDL_string.c:37
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_FALSE
Definition: SDL_stdinc.h:128
Sint64
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:160

static size_t SDL_ScanUintPtrT | ( | const char * | text,
|  | int | radix,
|  | uintptr_t * | valuep
| ) |  |

static

Definition at line 130 of file SDL_string.c.

References SDL_isdigit, SDL_islowerhex, SDL_isupperhex, SDL_strncmp(), and text.

Referenced by SDL_vsscanf().

{
const char *textstart = text;
uintptr_t value = 0;
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
text += 2;
}
for (;;) {
int v;
if (SDL_isdigit((unsigned char) *text)) {
v = *text - '0';
} else if (radix == 16 && SDL_isupperhex(*text)) {
v = 10 + (*text - 'A');
} else if (radix == 16 && SDL_islowerhex(*text)) {
v = 10 + (*text - 'a');
} else {
break;
}
value *= radix;
value += v;
++text;
}
if (valuep) {
*valuep = value;
}
return (text - textstart);
}
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
SDL_islowerhex
#define SDL_islowerhex(X)
Definition: SDL_string.c:38
v
const GLdouble * v
Definition: SDL_opengl.h:2057
SDL_isdigit
#define SDL_isdigit
Definition: SDL_dynapi_overrides.h:388
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
uintptr_t
unsigned int uintptr_t
Definition: SDL_config_windows.h:69
SDL_isupperhex
#define SDL_isupperhex(X)
Definition: SDL_string.c:37
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34

static size_t SDL_ScanUnsignedLong | ( | const char * | text,
|  | int | radix,
|  | unsigned long * | valuep
| ) |  |

static

Definition at line 98 of file SDL_string.c.

References SDL_isdigit, SDL_islowerhex, SDL_isupperhex, SDL_strncmp(), and text.

Referenced by SDL_ScanFloat(), SDL_strtoul(), and SDL_vsscanf().

{
const char *textstart = text;
unsigned long value = 0;
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
text += 2;
}
for (;;) {
int v;
if (SDL_isdigit((unsigned char) *text)) {
v = *text - '0';
} else if (radix == 16 && SDL_isupperhex(*text)) {
v = 10 + (*text - 'A');
} else if (radix == 16 && SDL_islowerhex(*text)) {
v = 10 + (*text - 'a');
} else {
break;
}
value *= radix;
value += v;
++text;
}
if (valuep) {
*valuep = value;
}
return (text - textstart);
}
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
SDL_islowerhex
#define SDL_islowerhex(X)
Definition: SDL_string.c:38
v
const GLdouble * v
Definition: SDL_opengl.h:2057
SDL_isdigit
#define SDL_isdigit
Definition: SDL_dynapi_overrides.h:388
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_isupperhex
#define SDL_isupperhex(X)
Definition: SDL_string.c:37
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34

static size_t SDL_ScanUnsignedLongLong | ( | const char * | text,
|  | int | radix,
|  | Uint64 * | valuep
| ) |  |

static

Definition at line 203 of file SDL_string.c.

References SDL_isdigit, SDL_islowerhex, SDL_isupperhex, SDL_strncmp(), and text.

Referenced by SDL_strtoull(), and SDL_vsscanf().

{
const char *textstart = text;
Uint64 value = 0;
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
text += 2;
}
for (;;) {
int v;
if (SDL_isdigit((unsigned char) *text)) {
v = *text - '0';
} else if (radix == 16 && SDL_isupperhex(*text)) {
v = 10 + (*text - 'A');
} else if (radix == 16 && SDL_islowerhex(*text)) {
v = 10 + (*text - 'a');
} else {
break;
}
value *= radix;
value += v;
++text;
}
if (valuep) {
*valuep = value;
}
return (text - textstart);
}
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
SDL_islowerhex
#define SDL_islowerhex(X)
Definition: SDL_string.c:38
Uint64
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:164
v
const GLdouble * v
Definition: SDL_opengl.h:2057
SDL_isdigit
#define SDL_isdigit
Definition: SDL_dynapi_overrides.h:388
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_isupperhex
#define SDL_isupperhex(X)
Definition: SDL_string.c:37
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34

int SDL_snprintf | ( | SDL_OUT_Z_CAP(maxlen) char * | text,
|  | size_t | maxlen,
|  | SDL_PRINTF_FORMAT_STRING const char * | fmt,
|  |  | ...
| ) |  |

Definition at line 1273 of file SDL_string.c.

References retval, SDL_OUT_Z_CAP, and SDL_vsnprintf().

Referenced by SDL_memset4().

{
va_list ap;
int retval;
va_start(ap, fmt);
retval = SDL_vsnprintf(text, maxlen, fmt, ap);
va_end(ap);
return retval;
}
SDL_vsnprintf
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
Definition: SDL_string.c:1478
retval
SDL_bool retval
Definition: testgamecontroller.c:65
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34

int SDL_sscanf | ( | const char * | text,
|  | SDL_SCANF_FORMAT_STRING const char * | fmt,
|  |  | ...
| ) |  |

Definition at line 992 of file SDL_string.c.

References SDL_vsscanf(), and text.

Referenced by SDL_memset4().

{
int rc;
va_list ap;
va_start(ap, fmt);
rc = SDL_vsscanf(text, fmt, ap);
va_end(ap);
return rc;
}
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_vsscanf
int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
Definition: SDL_string.c:1010

int SDL_strcasecmp | ( | const char * | str1,
|  | const char * | str2
| ) |  |

Definition at line 939 of file SDL_string.c.

References SDL_toupper.

Referenced by SDL_memset4().

{
#ifdef HAVE_STRCASECMP
return strcasecmp(str1, str2);
#elif defined(HAVE__STRICMP)
return _stricmp(str1, str2);
#else
char a = 0;
char b = 0;
while (*str1 && *str2) {
a = SDL_toupper((unsigned char) *str1);
b = SDL_toupper((unsigned char) *str2);
if (a != b)
break;
++str1;
++str2;
}
a = SDL_toupper(*str1);
b = SDL_toupper(*str2);
return (int) ((unsigned char) a - (unsigned char) b);
#endif /* HAVE_STRCASECMP */
}
SDL_toupper
#define SDL_toupper
Definition: SDL_dynapi_overrides.h:390
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109

char* SDL_strchr | ( | const char * | string,
|  | int | c
| ) |  |

Definition at line 596 of file SDL_string.c.

References NULL, and SDL_const_cast.

Referenced by SDL_memset4().

{
#ifdef HAVE_STRCHR
return SDL_const_cast(char*,strchr(string, c));
#elif defined(HAVE_INDEX)
return SDL_const_cast(char*,index(string, c));
#else
while (*string) {
if (*string == c) {
return (char *) string;
}
++string;
}
return NULL;
#endif /* HAVE_STRCHR */
}
SDL_const_cast
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:110
string
GLsizei const GLchar *const * string
Definition: SDL_opengl_glext.h:688
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11093
index
GLuint index
Definition: SDL_opengl_glext.h:660
NULL
#define NULL
Definition: begin_code.h:143

int SDL_strcmp | ( | const char * | str1,
|  | const char * | str2
| ) |  |

Definition at line 903 of file SDL_string.c.

Referenced by SDL_memset4().

{
#if defined(HAVE_STRCMP)
return strcmp(str1, str2);
#else
while (*str1 && *str2) {
if (*str1 != *str2)
break;
++str1;
++str2;
}
return (int) ((unsigned char) *str1 - (unsigned char) *str2);
#endif /* HAVE_STRCMP */
}

char* SDL_strdup | ( | const char * | string | ) |

Definition at line 532 of file SDL_string.c.

References SDL_malloc, SDL_strlcpy(), and SDL_strlen().

Referenced by SDL_memset4().

{
#if defined(HAVE_STRDUP)
return strdup(string);
#else
size_t len = SDL_strlen(string) + 1;
char *newstr = SDL_malloc(len);
if (newstr) {
SDL_strlcpy(newstr, string, len);
}
return newstr;
#endif /* HAVE_STRDUP */
}
SDL_strlcpy
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:469
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:380

size_t SDL_strlcat | ( | SDL_INOUT_Z_CAP(maxlen) char * | dst,
|  | const char * | src,
|  | size_t | maxlen
| ) |  |

Definition at line 517 of file SDL_string.c.

References SDL_strlcpy(), and SDL_strlen().

Referenced by SDL_memset4().

{
#if defined(HAVE_STRLCAT)
return strlcat(dst, src, maxlen);
#else
size_t dstlen = SDL_strlen(dst);
size_t srclen = SDL_strlen(src);
if (dstlen < maxlen) {
SDL_strlcpy(dst + dstlen, src, maxlen - dstlen);
}
return dstlen + srclen;
#endif /* HAVE_STRLCAT */
}
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
SDL_strlcpy
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:469
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
src
GLenum src
Definition: SDL_opengl_glext.h:1737

size_t SDL_strlcpy | ( | SDL_OUT_Z_CAP(maxlen) char * | dst,
|  | const char * | src,
|  | size_t | maxlen
| ) |  |

Definition at line 469 of file SDL_string.c.

References SDL_memcpy(), SDL_min, and SDL_strlen().

Referenced by SDL_memset4(), SDL_PrintString(), SDL_strdup(), and SDL_strlcat().

{
#if defined(HAVE_STRLCPY)
return strlcpy(dst, src, maxlen);
#else
size_t srclen = SDL_strlen(src);
if (maxlen > 0) {
size_t len = SDL_min(srclen, maxlen - 1);
SDL_memcpy(dst, src, len);
dst[len] = '\0';
}
return srclen;
#endif /* HAVE_STRLCPY */
}
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:345
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
SDL_memcpy
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:314
src
GLenum src
Definition: SDL_opengl_glext.h:1737

size_t SDL_strlen | ( | const char * | string | ) |

Definition at line 410 of file SDL_string.c.

Referenced by SDL_memset4(), SDL_PrintString(), SDL_strdup(), SDL_strlcat(), SDL_strlcpy(), SDL_strrchr(), SDL_strrev(), SDL_strstr(), SDL_strtol(), SDL_strtoll(), SDL_strtoul(), SDL_strtoull(), and SDL_utf8strlcpy().

{
#if defined(HAVE_STRLEN)
return strlen(string);
#else
size_t len = 0;
while (*string++) {
++len;
}
return len;
#endif /* HAVE_STRLEN */
}
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926

char* SDL_strlwr | ( | char * | string | ) |

Definition at line 581 of file SDL_string.c.

References SDL_tolower.

Referenced by SDL_memset4(), and SDL_PrintString().

{
#if defined(HAVE__STRLWR)
return _strlwr(string);
#else
char *bufp = string;
while (*bufp) {
*bufp = SDL_tolower((unsigned char) *bufp);
++bufp;
}
return string;
#endif /* HAVE__STRLWR */
}
string
GLsizei const GLchar *const * string
Definition: SDL_opengl_glext.h:688
SDL_tolower
#define SDL_tolower
Definition: SDL_dynapi_overrides.h:391

int SDL_strncasecmp | ( | const char * | str1,
|  | const char * | str2,
|  | size_t | maxlen
| ) |  |

Definition at line 963 of file SDL_string.c.

References SDL_tolower.

Referenced by SDL_memset4().

{
#ifdef HAVE_STRNCASECMP
return strncasecmp(str1, str2, maxlen);
#elif defined(HAVE__STRNICMP)
return _strnicmp(str1, str2, maxlen);
#else
char a = 0;
char b = 0;
while (*str1 && *str2 && maxlen) {
a = SDL_tolower((unsigned char) *str1);
b = SDL_tolower((unsigned char) *str2);
if (a != b)
break;
++str1;
++str2;
--maxlen;
}
if (maxlen == 0) {
return 0;
} else {
a = SDL_tolower((unsigned char) *str1);
b = SDL_tolower((unsigned char) *str2);
return (int) ((unsigned char) a - (unsigned char) b);
}
#endif /* HAVE_STRNCASECMP */
}
SDL_tolower
#define SDL_tolower
Definition: SDL_dynapi_overrides.h:391
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109

int SDL_strncmp | ( | const char * | str1,
|  | const char * | str2,
|  | size_t | maxlen
| ) |  |

Definition at line 919 of file SDL_string.c.

Referenced by SDL_memset4(), SDL_ScanLong(), SDL_ScanLongLong(), SDL_ScanUintPtrT(), SDL_ScanUnsignedLong(), SDL_ScanUnsignedLongLong(), SDL_strstr(), SDL_strtol(), SDL_strtoll(), SDL_strtoul(), SDL_strtoull(), SDL_vsnprintf(), and SDL_vsscanf().

{
#if defined(HAVE_STRNCMP)
return strncmp(str1, str2, maxlen);
#else
while (*str1 && *str2 && maxlen) {
if (*str1 != *str2)
break;
++str1;
++str2;
--maxlen;
}
if (!maxlen) {
return 0;
}
return (int) ((unsigned char) *str1 - (unsigned char) *str2);
#endif /* HAVE_STRNCMP */
}

char* SDL_strrchr | ( | const char * | string,
|  | int | c
| ) |  |

Definition at line 614 of file SDL_string.c.

References NULL, SDL_const_cast, and SDL_strlen().

Referenced by SDL_memset4().

{
#ifdef HAVE_STRRCHR
return SDL_const_cast(char*,strrchr(string, c));
#elif defined(HAVE_RINDEX)
return SDL_const_cast(char*,rindex(string, c));
#else
const char *bufp = string + SDL_strlen(string) - 1;
while (bufp >= string) {
if (*bufp == c) {
return (char *) bufp;
}
--bufp;
}
return NULL;
#endif /* HAVE_STRRCHR */
}
SDL_const_cast
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:110
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11093
NULL
#define NULL
Definition: begin_code.h:143

char* SDL_strrev | ( | char * | string | ) |

Definition at line 547 of file SDL_string.c.

References SDL_strlen().

Referenced by SDL_memset4(), SDL_ulltoa(), and SDL_ultoa().

{
#if defined(HAVE__STRREV)
return _strrev(string);
#else
size_t len = SDL_strlen(string);
char *a = &string[0];
char *b = &string[len - 1];
len /= 2;
while (len--) {
char c = *a;
*a++ = *b;
*b-- = c;
}
return string;
#endif /* HAVE__STRREV */
}
string
GLsizei const GLchar *const * string
Definition: SDL_opengl_glext.h:688
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11093
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109

char* SDL_strstr | ( | const char * | haystack,
|  | const char * | needle
| ) |  |

Definition at line 633 of file SDL_string.c.

References NULL, SDL_const_cast, SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

{
#if defined(HAVE_STRSTR)
return SDL_const_cast(char*,strstr(haystack, needle));
#else
size_t length = SDL_strlen(needle);
while (*haystack) {
if (SDL_strncmp(haystack, needle, length) == 0) {
return (char *) haystack;
}
++haystack;
}
return NULL;
#endif /* HAVE_STRSTR */
}
SDL_const_cast
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:110
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
NULL
#define NULL
Definition: begin_code.h:143
length
GLuint GLsizei GLsizei * length
Definition: SDL_opengl_glext.h:669

double SDL_strtod | ( | const char * | string,
|  | char ** | endp
| ) |  |

Definition at line 886 of file SDL_string.c.

References SDL_ScanFloat().

Referenced by SDL_atof(), and SDL_memset4().

{
#if defined(HAVE_STRTOD)
return strtod(string, endp);
#else
size_t len;
double value;
len = SDL_ScanFloat(string, &value);
if (endp) {
*endp = (char *) string + len;
}
return value;
#endif /* HAVE_STRTOD */
}
SDL_ScanFloat
static size_t SDL_ScanFloat(const char *text, double *valuep)
Definition: SDL_string.c:235
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698

long SDL_strtol | ( | const char * | string,
|  | char ** | endp,
|  | int | base
| ) |  |

Definition at line 786 of file SDL_string.c.

References SDL_ScanLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_atoi(), SDL_memset4(), and SDL_vsnprintf().

{
#if defined(HAVE_STRTOL)
return strtol(string, endp, base);
#else
size_t len;
long value;
if (!base) {
if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
base = 16;
} else {
base = 10;
}
}
len = SDL_ScanLong(string, base, &value);
if (endp) {
*endp = (char *) string + len;
}
return value;
#endif /* HAVE_STRTOL */
}
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
SDL_ScanLong
static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
Definition: SDL_string.c:57
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698

Sint64 SDL_strtoll | ( | const char * | string,
|  | char ** | endp,
|  | int | base
| ) |  |

Definition at line 836 of file SDL_string.c.

References SDL_ScanLongLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

{
#if defined(HAVE_STRTOLL)
return strtoll(string, endp, base);
#else
size_t len;
Sint64 value;
if (!base) {
if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
base = 16;
} else {
base = 10;
}
}
len = SDL_ScanLongLong(string, base, &value);
if (endp) {
*endp = (char *) string + len;
}
return value;
#endif /* HAVE_STRTOLL */
}
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_ScanLongLong
static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
Definition: SDL_string.c:162
Sint64
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:160

unsigned long SDL_strtoul | ( | const char * | string,
|  | char ** | endp,
|  | int | base
| ) |  |

Definition at line 811 of file SDL_string.c.

References SDL_ScanUnsignedLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

{
#if defined(HAVE_STRTOUL)
return strtoul(string, endp, base);
#else
size_t len;
unsigned long value;
if (!base) {
if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
base = 16;
} else {
base = 10;
}
}
len = SDL_ScanUnsignedLong(string, base, &value);
if (endp) {
*endp = (char *) string + len;
}
return value;
#endif /* HAVE_STRTOUL */
}
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_ScanUnsignedLong
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:98

Uint64 SDL_strtoull | ( | const char * | string,
|  | char ** | endp,
|  | int | base
| ) |  |

Definition at line 861 of file SDL_string.c.

References SDL_ScanUnsignedLongLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

{
#if defined(HAVE_STRTOULL)
return strtoull(string, endp, base);
#else
size_t len;
Uint64 value;
if (!base) {
if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
base = 16;
} else {
base = 10;
}
}
len = SDL_ScanUnsignedLongLong(string, base, &value);
if (endp) {
*endp = (char *) string + len;
}
return value;
#endif /* HAVE_STRTOULL */
}
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
Uint64
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:164
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_ScanUnsignedLongLong
static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
Definition: SDL_string.c:203

char* SDL_strupr | ( | char * | string | ) |

Definition at line 566 of file SDL_string.c.

References SDL_toupper.

Referenced by SDL_memset4(), and SDL_PrintString().

{
#if defined(HAVE__STRUPR)
return _strupr(string);
#else
char *bufp = string;
while (*bufp) {
*bufp = SDL_toupper((unsigned char) *bufp);
++bufp;
}
return string;
#endif /* HAVE__STRUPR */
}
string
GLsizei const GLchar *const * string
Definition: SDL_opengl_glext.h:688
SDL_toupper
#define SDL_toupper
Definition: SDL_dynapi_overrides.h:390

char* SDL_uitoa | ( | unsigned int | value,
|  | char * | string,
|  | int | radix
| ) |  |

Definition at line 670 of file SDL_string.c.

References SDL_ultoa().

Referenced by SDL_memset4().

{
#ifdef HAVE__UITOA
return _uitoa(value, string, radix);
#else
return SDL_ultoa((unsigned long)value, string, radix);
#endif /* HAVE__UITOA */
}
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_ultoa
char * SDL_ultoa(unsigned long value, char *string, int radix)
Definition: SDL_string.c:699

char* SDL_ulltoa | ( | Uint64 | value,
|  | char * | string,
|  | int | radix
| ) |  |

Definition at line 743 of file SDL_string.c.

References SDL_strrev().

Referenced by SDL_lltoa(), SDL_memset4(), and SDL_PrintUnsignedLongLong().

{
#if defined(HAVE__UI64TOA)
return _ui64toa(value, string, radix);
#else
char *bufp = string;
if (value) {
while (value > 0) {
*bufp++ = ntoa_table[value % radix];
value /= radix;
}
} else {
*bufp++ = '0';
}
*bufp = '\0';
/* The numbers went into the string backwards. :) */
SDL_strrev(string);
return string;
#endif /* HAVE__UI64TOA */
}
string
GLsizei const GLchar *const * string
Definition: SDL_opengl_glext.h:688
ntoa_table
static const char ntoa_table[]
Definition: SDL_string.c:651
SDL_strrev
char * SDL_strrev(char *string)
Definition: SDL_string.c:547
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698

char* SDL_ultoa | ( | unsigned long | value,
|  | char * | string,
|  | int | radix
| ) |  |

Definition at line 699 of file SDL_string.c.

References SDL_strrev().

Referenced by SDL_ltoa(), SDL_memset4(), SDL_PrintUnsignedLong(), and SDL_uitoa().

{
#if defined(HAVE__ULTOA)
return _ultoa(value, string, radix);
#else
char *bufp = string;
if (value) {
while (value > 0) {
*bufp++ = ntoa_table[value % radix];
value /= radix;
}
} else {
*bufp++ = '0';
}
*bufp = '\0';
/* The numbers went into the string backwards. :) */
SDL_strrev(string);
return string;
#endif /* HAVE__ULTOA */
}
string
GLsizei const GLchar *const * string
Definition: SDL_opengl_glext.h:688
ntoa_table
static const char ntoa_table[]
Definition: SDL_string.c:651
SDL_strrev
char * SDL_strrev(char *string)
Definition: SDL_string.c:547
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698

size_t SDL_utf8strlcpy | ( | SDL_OUT_Z_CAP(dst_bytes) char * | dst,
|  | const char * | src,
|  | size_t | dst_bytes
| ) |  |

Definition at line 484 of file SDL_string.c.

References i, SDL_memcpy(), SDL_min, SDL_strlen(), UTF8_IsLeadByte, UTF8_IsTrailingByte, and UTF8_TrailingBytes().

Referenced by SDL_memset4().

{
size_t src_bytes = SDL_strlen(src);
size_t bytes = SDL_min(src_bytes, dst_bytes - 1);
size_t i = 0;
char trailing_bytes = 0;
if (bytes)
{
unsigned char c = (unsigned char)src[bytes - 1];
if (UTF8_IsLeadByte(c))
--bytes;
else if (UTF8_IsTrailingByte(c))
{
for (i = bytes - 1; i != 0; --i)
{
c = (unsigned char)src[i];
trailing_bytes = UTF8_TrailingBytes(c);
if (trailing_bytes)
{
if (bytes - i != trailing_bytes + 1)
bytes = i;
break;
}
}
}
SDL_memcpy(dst, src, bytes);
}
dst[bytes] = '\0';
return bytes;
}
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:345
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:410
UTF8_IsLeadByte
#define UTF8_IsLeadByte(c)
Definition: SDL_string.c:40
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11093
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:42
SDL_memcpy
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:314
UTF8_TrailingBytes
static int UTF8_TrailingBytes(unsigned char c)
Definition: SDL_string.c:43
src
GLenum src
Definition: SDL_opengl_glext.h:1737
UTF8_IsTrailingByte
#define UTF8_IsTrailingByte(c)
Definition: SDL_string.c:41

int SDL_vsnprintf | ( | SDL_OUT_Z_CAP(maxlen) char * | text,
|  | size_t | maxlen,
|  | const char * | fmt,
|  | va_list | ap
| ) |  |

Definition at line 1478 of file SDL_string.c.

References done, SDL_FormatInfo::force_case, SDL_FormatInfo::force_sign, SDL_FormatInfo::force_type, SDL_FormatInfo::left_justify, SDL_FormatInfo::pad_zeroes, SDL_FormatInfo::precision, SDL_FormatInfo::radix, SDL_CASE_LOWER, SDL_CASE_NOCHANGE, SDL_CASE_UPPER, SDL_FALSE, SDL_min, SDL_PrintFloat(), SDL_PrintLong(), SDL_PrintLongLong(), SDL_PrintString(), SDL_PrintUnsignedLong(), SDL_PrintUnsignedLongLong(), SDL_strncmp(), SDL_strtol(), SDL_TRUE, SDL_zero, text, and SDL_FormatInfo::width.

Referenced by SDL_memset4(), and SDL_snprintf().

{
size_t left = maxlen;
char *textstart = text;
if (!fmt) {
fmt = "";
}
while (*fmt) {
if (*fmt == '%') {
SDL_bool done = SDL_FALSE;
size_t len = 0;
SDL_bool check_flag;
SDL_FormatInfo info;
enum
{
DO_INT,
DO_LONG,
DO_LONGLONG
} inttype = DO_INT;
SDL_zero(info);
info.radix = 10;
info.precision = -1;
check_flag = SDL_TRUE;
while (check_flag) {
++fmt;
switch (*fmt) {
case '-':
info.left_justify = SDL_TRUE;
break;
case '+':
info.force_sign = SDL_TRUE;
break;
case '#':
info.force_type = SDL_TRUE;
break;
case '0':
info.pad_zeroes = SDL_TRUE;
break;
default:
check_flag = SDL_FALSE;
break;
}
}
if (*fmt >= '0' && *fmt <= '9') {
info.width = SDL_strtol(fmt, (char **)&fmt, 0);
}
if (*fmt == '.') {
++fmt;
if (*fmt >= '0' && *fmt <= '9') {
info.precision = SDL_strtol(fmt, (char **)&fmt, 0);
} else {
info.precision = 0;
}
}
while (!done) {
switch (*fmt) {
case '%':
if (left > 1) {
*text = '%';
}
len = 1;
done = SDL_TRUE;
break;
case 'c':
/* char is promoted to int when passed through (...) */
if (left > 1) {
*text = (char) va_arg(ap, int);
}
len = 1;
done = SDL_TRUE;
break;
case 'h':
/* short is promoted to int when passed through (...) */
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':
case 'd':
switch (inttype) {
case DO_INT:
len = SDL_PrintLong(text, left, &info,
(long) va_arg(ap, int));
break;
case DO_LONG:
len = SDL_PrintLong(text, left, &info,
va_arg(ap, long));
break;
case DO_LONGLONG:
len = SDL_PrintLongLong(text, left, &info,
va_arg(ap, Sint64));
break;
}
done = SDL_TRUE;
break;
case 'p':
case 'x':
info.force_case = SDL_CASE_LOWER;
/* Fall through to 'X' handling */
case 'X':
if (info.force_case == SDL_CASE_NOCHANGE) {
info.force_case = SDL_CASE_UPPER;
}
if (info.radix == 10) {
info.radix = 16;
}
if (*fmt == 'p') {
inttype = DO_LONG;
}
/* Fall through to unsigned handling */
case 'o':
if (info.radix == 10) {
info.radix = 8;
}
/* Fall through to unsigned handling */
case 'u':
info.pad_zeroes = SDL_TRUE;
switch (inttype) {
case DO_INT:
len = SDL_PrintUnsignedLong(text, left, &info,
(unsigned long)
va_arg(ap, unsigned int));
break;
case DO_LONG:
len = SDL_PrintUnsignedLong(text, left, &info,
va_arg(ap, unsigned long));
break;
case DO_LONGLONG:
len = SDL_PrintUnsignedLongLong(text, left, &info,
va_arg(ap, Uint64));
break;
}
done = SDL_TRUE;
break;
case 'f':
len = SDL_PrintFloat(text, left, &info, va_arg(ap, double));
done = SDL_TRUE;
break;
case 's':
len = SDL_PrintString(text, left, &info, va_arg(ap, char *));
done = SDL_TRUE;
break;
default:
done = SDL_TRUE;
break;
}
++fmt;
}
text += len;
if (len >= left) {
left = SDL_min(left, 1);
} else {
left -= len;
}
} else {
if (left > 1) {
*text = *fmt;
--left;
}
++fmt;
++text;
}
}
if (left > 0) {
*text = '\0';
}
return (int)(text - textstart);
}
SDL_FormatInfo::radix
int radix
Definition: SDL_string.c:1310
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:345
SDL_FormatInfo::left_justify
SDL_bool left_justify
Definition: SDL_string.c:1304
SDL_FormatInfo::pad_zeroes
SDL_bool pad_zeroes
Definition: SDL_string.c:1307
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
SDL_FormatInfo::force_type
SDL_bool force_type
Definition: SDL_string.c:1306
SDL_FormatInfo
Definition: SDL_string.c:1302
Uint64
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:164
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
SDL_strtol
long SDL_strtol(const char *string, char **endp, int base)
Definition: SDL_string.c:786
SDL_PrintLongLong
static size_t SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
Definition: SDL_string.c:1360
SDL_PrintLong
static size_t SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
Definition: SDL_string.c:1342
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:126
SDL_FormatInfo::force_sign
SDL_bool force_sign
Definition: SDL_string.c:1305
left
GLint left
Definition: SDL_opengl_glext.h:1949
done
int done
Definition: checkkeys.c:28
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:355
SDL_TRUE
Definition: SDL_stdinc.h:129
SDL_CASE_LOWER
Definition: SDL_string.c:1298
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_FALSE
Definition: SDL_stdinc.h:128
SDL_FormatInfo::force_case
SDL_letter_case force_case
Definition: SDL_string.c:1308
SDL_PrintUnsignedLongLong
static size_t SDL_PrintUnsignedLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Uint64 value)
Definition: SDL_string.c:1369
SDL_CASE_NOCHANGE
Definition: SDL_string.c:1297
Sint64
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:160
SDL_FormatInfo::width
int width
Definition: SDL_string.c:1309
SDL_PrintString
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
Definition: SDL_string.c:1315
SDL_FormatInfo::precision
int precision
Definition: SDL_string.c:1311
SDL_CASE_UPPER
Definition: SDL_string.c:1299
SDL_PrintUnsignedLong
static size_t SDL_PrintUnsignedLong(char *text, size_t maxlen, SDL_FormatInfo *info, unsigned long value)
Definition: SDL_string.c:1351
SDL_PrintFloat
static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
Definition: SDL_string.c:1378

int SDL_vsscanf | ( | const char * | text,
|  | const char * | fmt,
|  | va_list | ap
| ) |  |

Definition at line 1010 of file SDL_string.c.

References done, retval, SDL_FALSE, SDL_isspace, SDL_ScanFloat(), SDL_ScanLong(), SDL_ScanLongLong(), SDL_ScanUintPtrT(), SDL_ScanUnsignedLong(), SDL_ScanUnsignedLongLong(), SDL_strncmp(), SDL_tolower, SDL_TRUE, and text.

Referenced by SDL_memset4(), and SDL_sscanf().

{
int retval = 0;
while (*fmt) {
if (*fmt == ' ') {
while (SDL_isspace((unsigned char) *text)) {
++text;
}
++fmt;
continue;
}
if (*fmt == '%') {
SDL_bool done = SDL_FALSE;
long count = 0;
int radix = 10;
enum
{
DO_SHORT,
DO_INT,
DO_LONG,
DO_LONGLONG
} inttype = DO_INT;
SDL_bool suppress = SDL_FALSE;
++fmt;
if (*fmt == '%') {
if (*text == '%') {
++text;
++fmt;
continue;
}
break;
}
if (*fmt == '*') {
suppress = SDL_TRUE;
++fmt;
}
fmt += SDL_ScanLong(fmt, 10, &count);
if (*fmt == 'c') {
if (!count) {
count = 1;
}
if (suppress) {
while (count--) {
++text;
}
} else {
char *valuep = va_arg(ap, char *);
while (count--) {
*valuep++ = *text++;
}
++retval;
}
continue;
}
while (SDL_isspace((unsigned char) *text)) {
++text;
}
/* FIXME: implement more of the format specifiers */
while (!done) {
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;
}
if (text[index] == '0') {
if (SDL_tolower((unsigned char) text[index + 1]) == 'x') {
radix = 16;
} else {
radix = 8;
}
}
}
/* Fall through to %d handling */
case 'd':
if (inttype == DO_LONGLONG) {
Sint64 value;
text += SDL_ScanLongLong(text, radix, &value);
if (!suppress) {
Sint64 *valuep = va_arg(ap, Sint64 *);
*valuep = value;
++retval;
}
} else {
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;
}
break;
case DO_LONG:
{
long *valuep = va_arg(ap, long *);
*valuep = value;
}
break;
case DO_LONGLONG:
/* Handled above */
break;
}
++retval;
}
}
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':
if (inttype == DO_LONGLONG) {
Uint64 value;
text += SDL_ScanUnsignedLongLong(text, radix, &value);
if (!suppress) {
Uint64 *valuep = va_arg(ap, Uint64 *);
*valuep = value;
++retval;
}
} else {
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;
}
break;
case DO_LONG:
{
long *valuep = va_arg(ap, long *);
*valuep = value;
}
break;
case DO_LONGLONG:
/* Handled above */
break;
}
++retval;
}
}
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;
}
}
done = SDL_TRUE;
break;
case 'f':
{
double value;
text += SDL_ScanFloat(text, &value);
if (!suppress) {
float *valuep = va_arg(ap, float *);
*valuep = (float) value;
++retval;
}
}
done = SDL_TRUE;
break;
case 's':
if (suppress) {
while (!SDL_isspace((unsigned char) *text)) {
++text;
if (count) {
if (--count == 0) {
break;
}
}
}
} else {
char *valuep = va_arg(ap, char *);
while (!SDL_isspace((unsigned char) *text)) {
*valuep++ = *text++;
if (count) {
if (--count == 0) {
break;
}
}
}
*valuep = '\0';
++retval;
}
done = SDL_TRUE;
break;
default:
done = SDL_TRUE;
break;
}
++fmt;
}
continue;
}
if (*text == *fmt) {
++text;
++fmt;
continue;
}
/* Text didn't match format specifier */
break;
}
return retval;
}
SDL_ScanFloat
static size_t SDL_ScanFloat(const char *text, double *valuep)
Definition: SDL_string.c:235
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:919
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1564
SDL_tolower
#define SDL_tolower
Definition: SDL_dynapi_overrides.h:391
Uint64
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:164
SDL_ScanUintPtrT
static size_t SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep)
Definition: SDL_string.c:130
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:126
SDL_ScanLong
static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
Definition: SDL_string.c:57
retval
SDL_bool retval
Definition: testgamecontroller.c:65
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
done
int done
Definition: checkkeys.c:28
uintptr_t
unsigned int uintptr_t
Definition: SDL_config_windows.h:69
SDL_TRUE
Definition: SDL_stdinc.h:129
SDL_isspace
#define SDL_isspace
Definition: SDL_dynapi_overrides.h:389
index
GLuint index
Definition: SDL_opengl_glext.h:660
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:34
SDL_FALSE
Definition: SDL_stdinc.h:128
SDL_ScanLongLong
static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
Definition: SDL_string.c:162
Sint64
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:160
SDL_ScanUnsignedLongLong
static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
Definition: SDL_string.c:203
SDL_ScanUnsignedLong
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:98

size_t SDL_wcslcat | ( | SDL_INOUT_Z_CAP(maxlen) wchar_t * | dst,
|  | const wchar_t * | src,
|  | size_t | maxlen
| ) |  |

Definition at line 454 of file SDL_string.c.

References SDL_wcslcpy(), and SDL_wcslen().

Referenced by SDL_memset4().

{
#if defined(HAVE_WCSLCAT)
return wcslcat(dst, src, maxlen);
#else
size_t dstlen = SDL_wcslen(dst);
size_t srclen = SDL_wcslen(src);
if (dstlen < maxlen) {
SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen);
}
return dstlen + srclen;
#endif /* HAVE_WCSLCAT */
}
SDL_wcslen
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:424
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
SDL_wcslcpy
size_t SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
Definition: SDL_string.c:438
src
GLenum src
Definition: SDL_opengl_glext.h:1737

size_t SDL_wcslcpy | ( | SDL_OUT_Z_CAP(maxlen) wchar_t * | dst,
|  | const wchar_t * | src,
|  | size_t | maxlen
| ) |  |

Definition at line 438 of file SDL_string.c.

References SDL_memcpy(), SDL_min, and SDL_wcslen().

Referenced by SDL_memset4(), and SDL_wcslcat().

{
#if defined(HAVE_WCSLCPY)
return wcslcpy(dst, src, maxlen);
#else
size_t srclen = SDL_wcslen(src);
if (maxlen > 0) {
size_t len = SDL_min(srclen, maxlen - 1);
SDL_memcpy(dst, src, len * sizeof(wchar_t));
dst[len] = '\0';
}
return srclen;
#endif /* HAVE_WCSLCPY */
}
SDL_wcslen
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:424
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:345
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
SDL_memcpy
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:314
src
GLenum src
Definition: SDL_opengl_glext.h:1737

size_t SDL_wcslen | ( | const wchar_t * | string | ) |

Definition at line 424 of file SDL_string.c.

Referenced by SDL_memset4(), SDL_wcslcat(), and SDL_wcslcpy().

{
#if defined(HAVE_WCSLEN)
return wcslen(string);
#else
size_t len = 0;
while (*string++) {
++len;
}
return len;
#endif /* HAVE_WCSLEN */
}
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926

static int UTF8_TrailingBytes | ( | unsigned char | c | ) |

static

Definition at line 43 of file SDL_string.c.

Referenced by SDL_utf8strlcpy().

{
if (c >= 0xC0 && c <= 0xDF)
return 1;
else if (c >= 0xE0 && c <= 0xEF)
return 2;
else if (c >= 0xF0 && c <= 0xF4)
return 3;
else
return 0;
}
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11093

## Variable Documentation

const char ntoa_table[]

static

Initial value:
= {
'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'
}

Definition at line 651 of file SDL_string.c.