SDL  2.0
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 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)
 
voidSDL_memset (SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
 
voidSDL_memcpy (SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
 
voidSDL_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)
 
wchar_t * SDL_wcsdup (const wchar_t *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)
 
int SDL_wcscmp (const wchar_t *str1, const wchar_t *str2)
 
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_utf8strlen (const char *str)
 
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 void SDL_IntPrecisionAdjust (char *num, size_t maxlen, SDL_FormatInfo *info)
 
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

◆ SDL_islowerhex

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

Definition at line 33 of file SDL_string.c.

◆ SDL_isupperhex

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

Definition at line 32 of file SDL_string.c.

◆ UTF8_IsLeadByte

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

Definition at line 36 of file SDL_string.c.

◆ UTF8_IsTrailingByte

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

Definition at line 37 of file SDL_string.c.

Enumeration Type Documentation

◆ SDL_letter_case

Enumerator
SDL_CASE_NOCHANGE 
SDL_CASE_LOWER 
SDL_CASE_UPPER 

Definition at line 1359 of file SDL_string.c.

1360 {
1364 } SDL_letter_case;

Function Documentation

◆ SDL_atof()

double SDL_atof ( const char *  string)

Definition at line 818 of file SDL_string.c.

819 {
820 #ifdef HAVE_ATOF
821  return (double) atof(string);
822 #else
823  return SDL_strtod(string, NULL);
824 #endif /* HAVE_ATOF */
825 }

References NULL, and SDL_strtod().

◆ SDL_atoi()

int SDL_atoi ( const char *  string)

Definition at line 809 of file SDL_string.c.

810 {
811 #ifdef HAVE_ATOI
812  return atoi(string);
813 #else
814  return SDL_strtol(string, NULL, 0);
815 #endif /* HAVE_ATOI */
816 }

References NULL, and SDL_strtol().

◆ SDL_IntPrecisionAdjust()

static void SDL_IntPrecisionAdjust ( char *  num,
size_t  maxlen,
SDL_FormatInfo info 
)
static

Definition at line 1422 of file SDL_string.c.

1423 {/* left-pad num with zeroes. */
1424  size_t sz, pad, have_sign;
1425 
1426  if (!info)
1427  return;
1428 
1429  have_sign = 0;
1430  if (*num == '-' || *num == '+') {
1431  have_sign = 1;
1432  ++num;
1433  --maxlen;
1434  }
1435  sz = SDL_strlen(num);
1436  if (info->precision > 0 && sz < (size_t)info->precision) {
1437  pad = (size_t)info->precision - sz;
1438  if (pad + sz + 1 <= maxlen) { /* otherwise ignore the precision */
1439  SDL_memmove(num + pad, num, sz + 1);
1440  SDL_memset(num, '0', pad);
1441  }
1442  }
1443  info->precision = -1;/* so that SDL_PrintString() doesn't make a mess. */
1444 
1445  if (info->pad_zeroes && info->width > 0 && (size_t)info->width > sz + have_sign) {
1446  /* handle here: spaces are added before the sign
1447  but zeroes must be placed _after_ the sign. */
1448  /* sz hasn't changed: we ignore pad_zeroes if a precision is given. */
1449  pad = (size_t)info->width - sz - have_sign;
1450  if (pad + sz + 1 <= maxlen) {
1451  SDL_memmove(num + pad, num, sz + 1);
1452  SDL_memset(num, '0', pad);
1453  }
1454  info->width = 0; /* so that SDL_PrintString() doesn't make a mess. */
1455  }
1456 }

References SDL_FormatInfo::pad_zeroes, SDL_FormatInfo::precision, SDL_memmove(), SDL_memset(), SDL_strlen(), and SDL_FormatInfo::width.

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

◆ SDL_itoa()

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

Definition at line 702 of file SDL_string.c.

703 {
704 #ifdef HAVE_ITOA
705  return itoa(value, string, radix);
706 #else
707  return SDL_ltoa((long)value, string, radix);
708 #endif /* HAVE_ITOA */
709 }

References SDL_ltoa().

◆ SDL_lltoa()

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

Definition at line 766 of file SDL_string.c.

767 {
768 #if defined(HAVE__I64TOA)
769  return _i64toa(value, string, radix);
770 #else
771  char *bufp = string;
772 
773  if (value < 0) {
774  *bufp++ = '-';
775  SDL_ulltoa(-value, bufp, radix);
776  } else {
777  SDL_ulltoa(value, bufp, radix);
778  }
779 
780  return string;
781 #endif /* HAVE__I64TOA */
782 }

References SDL_ulltoa().

Referenced by SDL_PrintLongLong().

◆ SDL_ltoa()

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

Definition at line 722 of file SDL_string.c.

723 {
724 #if defined(HAVE__LTOA)
725  return _ltoa(value, string, radix);
726 #else
727  char *bufp = string;
728 
729  if (value < 0) {
730  *bufp++ = '-';
731  SDL_ultoa(-value, bufp, radix);
732  } else {
733  SDL_ultoa(value, bufp, radix);
734  }
735 
736  return string;
737 #endif /* HAVE__LTOA */
738 }

References SDL_ultoa().

Referenced by SDL_itoa(), and SDL_PrintLong().

◆ SDL_memcmp()

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

Definition at line 392 of file SDL_string.c.

393 {
394 #if defined(HAVE_MEMCMP)
395  return memcmp(s1, s2, len);
396 #else
397  char *s1p = (char *) s1;
398  char *s2p = (char *) s2;
399  while (len--) {
400  if (*s1p != *s2p) {
401  return (*s1p - *s2p);
402  }
403  ++s1p;
404  ++s2p;
405  }
406  return 0;
407 #endif /* HAVE_MEMCMP */
408 }

◆ SDL_memcpy()

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

Definition at line 315 of file SDL_string.c.

316 {
317 #ifdef __GNUC__
318  /* Presumably this is well tuned for speed.
319  On my machine this is twice as fast as the C code below.
320  */
321  return __builtin_memcpy(dst, src, len);
322 #elif defined(HAVE_MEMCPY)
323  return memcpy(dst, src, len);
324 #elif defined(HAVE_BCOPY)
325  bcopy(src, dst, len);
326  return dst;
327 #else
328  /* GCC 4.9.0 with -O3 will generate movaps instructions with the loop
329  using Uint32* pointers, so we need to make sure the pointers are
330  aligned before we loop using them.
331  */
332  if (((intptr_t)src & 0x3) || ((intptr_t)dst & 0x3)) {
333  /* Do an unaligned byte copy */
334  Uint8 *srcp1 = (Uint8 *)src;
335  Uint8 *dstp1 = (Uint8 *)dst;
336 
337  while (len--) {
338  *dstp1++ = *srcp1++;
339  }
340  } else {
341  size_t left = (len % 4);
342  Uint32 *srcp4, *dstp4;
343  Uint8 *srcp1, *dstp1;
344 
345  srcp4 = (Uint32 *) src;
346  dstp4 = (Uint32 *) dst;
347  len /= 4;
348  while (len--) {
349  *dstp4++ = *srcp4++;
350  }
351 
352  srcp1 = (Uint8 *) srcp4;
353  dstp1 = (Uint8 *) dstp4;
354  switch (left) {
355  case 3:
356  *dstp1++ = *srcp1++;
357  case 2:
358  *dstp1++ = *srcp1++;
359  case 1:
360  *dstp1++ = *srcp1++;
361  }
362  }
363  return dst;
364 #endif /* __GNUC__ */
365 }

References memcpy.

Referenced by SDL_memcpy4(), SDL_strdup(), SDL_strlcpy(), SDL_utf8strlcpy(), SDL_wcsdup(), and SDL_wcslcpy().

◆ SDL_memmove()

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

Definition at line 368 of file SDL_string.c.

369 {
370 #if defined(HAVE_MEMMOVE)
371  return memmove(dst, src, len);
372 #else
373  char *srcp = (char *) src;
374  char *dstp = (char *) dst;
375 
376  if (src < dst) {
377  srcp += len - 1;
378  dstp += len - 1;
379  while (len--) {
380  *dstp-- = *srcp--;
381  }
382  } else {
383  while (len--) {
384  *dstp++ = *srcp++;
385  }
386  }
387  return dst;
388 #endif /* HAVE_MEMMOVE */
389 }

References memmove.

Referenced by SDL_IntPrecisionAdjust().

◆ SDL_memset()

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

Definition at line 266 of file SDL_string.c.

267 {
268 #if defined(HAVE_MEMSET)
269  return memset(dst, c, len);
270 #else
271  size_t left;
272  Uint32 *dstp4;
273  Uint8 *dstp1 = (Uint8 *) dst;
274  Uint8 value1;
275  Uint32 value4;
276 
277  /* The value used in memset() is a byte, passed as an int */
278  c &= 0xff;
279 
280  /* The destination pointer needs to be aligned on a 4-byte boundary to
281  * execute a 32-bit set. Set first bytes manually if needed until it is
282  * aligned. */
283  value1 = (Uint8)c;
284  while ((intptr_t)dstp1 & 0x3) {
285  if (len--) {
286  *dstp1++ = value1;
287  } else {
288  return dst;
289  }
290  }
291 
292  value4 = (c | (c << 8) | (c << 16) | (c << 24));
293  dstp4 = (Uint32 *) dstp1;
294  left = (len % 4);
295  len /= 4;
296  while (len--) {
297  *dstp4++ = value4;
298  }
299 
300  dstp1 = (Uint8 *) dstp4;
301  switch (left) {
302  case 3:
303  *dstp1++ = value1;
304  case 2:
305  *dstp1++ = value1;
306  case 1:
307  *dstp1++ = value1;
308  }
309 
310  return dst;
311 #endif /* HAVE_MEMSET */
312 }

References memset.

Referenced by SDL_IntPrecisionAdjust().

◆ SDL_PrintFloat()

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

Definition at line 1507 of file SDL_string.c.

1508 {
1509  int width;
1510  size_t len;
1511  size_t left = maxlen;
1512  char *textstart = text;
1513 
1514  if (arg) {
1515  /* This isn't especially accurate, but hey, it's easy. :) */
1516  unsigned long value;
1517 
1518  if (arg < 0) {
1519  if (left > 1) {
1520  *text = '-';
1521  --left;
1522  }
1523  ++text;
1524  arg = -arg;
1525  } else if (info->force_sign) {
1526  if (left > 1) {
1527  *text = '+';
1528  --left;
1529  }
1530  ++text;
1531  }
1532  value = (unsigned long) arg;
1534  if (len >= left) {
1535  text += (left > 1) ? left - 1 : 0;
1536  left = SDL_min(left, 1);
1537  } else {
1538  text += len;
1539  left -= len;
1540  }
1541  arg -= value;
1542  if (info->precision < 0) {
1543  info->precision = 6;
1544  }
1545  if (info->force_type || info->precision > 0) {
1546  int mult = 10;
1547  if (left > 1) {
1548  *text = '.';
1549  --left;
1550  }
1551  ++text;
1552  while (info->precision-- > 0) {
1553  value = (unsigned long) (arg * mult);
1555  if (len >= left) {
1556  text += (left > 1) ? left - 1 : 0;
1557  left = SDL_min(left, 1);
1558  } else {
1559  text += len;
1560  left -= len;
1561  }
1562  arg -= (double) value / mult;
1563  mult *= 10;
1564  }
1565  }
1566  } else {
1567  if (left > 1) {
1568  *text = '0';
1569  --left;
1570  }
1571  ++text;
1572  if (info->force_type) {
1573  if (left > 1) {
1574  *text = '.';
1575  --left;
1576  }
1577  ++text;
1578  }
1579  }
1580 
1581  width = info->width - (int)(text - textstart);
1582  if (width > 0) {
1583  char fill = info->pad_zeroes ? '0' : ' ';
1584  char *end = text+left-1;
1585  len = (text - textstart);
1586  for (len = (text - textstart); len--; ) {
1587  if ((textstart+len+width) < end) {
1588  *(textstart+len+width) = *(textstart+len);
1589  }
1590  }
1591  len = (size_t)width;
1592  if (len >= left) {
1593  text += (left > 1) ? left - 1 : 0;
1594  left = SDL_min(left, 1);
1595  } else {
1596  text += len;
1597  left -= len;
1598  }
1599  while (len--) {
1600  if (textstart+len < end) {
1601  textstart[len] = fill;
1602  }
1603  }
1604  }
1605 
1606  return (text - textstart);
1607 }

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().

◆ SDL_PrintLong()

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

Definition at line 1459 of file SDL_string.c.

1460 {
1461  char num[130], *p = num;
1462 
1463  if (info->force_sign && value >= 0L) {
1464  *p++ = '+';
1465  }
1466 
1467  SDL_ltoa(value, p, info ? info->radix : 10);
1468  SDL_IntPrecisionAdjust(num, maxlen, info);
1469  return SDL_PrintString(text, maxlen, info, num);
1470 }

References SDL_FormatInfo::force_sign, SDL_FormatInfo::radix, SDL_IntPrecisionAdjust(), SDL_ltoa(), SDL_PrintString(), and text.

Referenced by SDL_vsnprintf().

◆ SDL_PrintLongLong()

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

Definition at line 1483 of file SDL_string.c.

1484 {
1485  char num[130], *p = num;
1486 
1487  if (info->force_sign && value >= (Sint64)0) {
1488  *p++ = '+';
1489  }
1490 
1491  SDL_lltoa(value, p, info ? info->radix : 10);
1492  SDL_IntPrecisionAdjust(num, maxlen, info);
1493  return SDL_PrintString(text, maxlen, info, num);
1494 }

References SDL_FormatInfo::force_sign, SDL_FormatInfo::radix, SDL_IntPrecisionAdjust(), SDL_lltoa(), SDL_PrintString(), and text.

Referenced by SDL_vsnprintf().

◆ SDL_PrintString()

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

Definition at line 1379 of file SDL_string.c.

1380 {
1381  size_t length = 0;
1382  size_t slen, sz;
1383 
1384  if (string == NULL) {
1385  string = "(null)";
1386  }
1387 
1388  sz = SDL_strlen(string);
1389  if (info && info->width > 0 && (size_t)info->width > sz) {
1390  char fill = info->pad_zeroes ? '0' : ' ';
1391  size_t width = info->width - sz;
1392  if (info->precision >= 0 && (size_t)info->precision < sz)
1393  width += sz - (size_t)info->precision;
1394  while (width-- > 0 && maxlen > 0) {
1395  *text++ = fill;
1396  ++length;
1397  --maxlen;
1398  }
1399  }
1400 
1401  slen = SDL_strlcpy(text, string, maxlen);
1402  length += SDL_min(slen, maxlen);
1403 
1404  if (info) {
1405  if (info->precision >= 0 && (size_t)info->precision < sz) {
1406  slen = (size_t)info->precision;
1407  if (slen < maxlen) {
1408  text[slen] = 0;
1409  length -= (sz - slen);
1410  }
1411  }
1412  if (info->force_case == SDL_CASE_LOWER) {
1413  SDL_strlwr(text);
1414  } else if (info->force_case == SDL_CASE_UPPER) {
1415  SDL_strupr(text);
1416  }
1417  }
1418  return length;
1419 }

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

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

◆ SDL_PrintUnsignedLong()

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

Definition at line 1473 of file SDL_string.c.

1474 {
1475  char num[130];
1476 
1477  SDL_ultoa(value, num, info ? info->radix : 10);
1478  SDL_IntPrecisionAdjust(num, maxlen, info);
1479  return SDL_PrintString(text, maxlen, info, num);
1480 }

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

Referenced by SDL_PrintFloat(), and SDL_vsnprintf().

◆ SDL_PrintUnsignedLongLong()

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

Definition at line 1497 of file SDL_string.c.

1498 {
1499  char num[130];
1500 
1501  SDL_ulltoa(value, num, info ? info->radix : 10);
1502  SDL_IntPrecisionAdjust(num, maxlen, info);
1503  return SDL_PrintString(text, maxlen, info, num);
1504 }

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

Referenced by SDL_vsnprintf().

◆ SDL_ScanFloat()

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

Definition at line 231 of file SDL_string.c.

232 {
233  const char *textstart = text;
234  unsigned long lvalue = 0;
235  double value = 0.0;
236  SDL_bool negative = SDL_FALSE;
237 
238  if (*text == '-') {
239  negative = SDL_TRUE;
240  ++text;
241  }
242  text += SDL_ScanUnsignedLong(text, 10, &lvalue);
243  value += lvalue;
244  if (*text == '.') {
245  int mult = 10;
246  ++text;
247  while (SDL_isdigit((unsigned char) *text)) {
248  lvalue = *text - '0';
249  value += (double) lvalue / mult;
250  mult *= 10;
251  ++text;
252  }
253  }
254  if (valuep && text > textstart) {
255  if (negative && value) {
256  *valuep = -value;
257  } else {
258  *valuep = value;
259  }
260  }
261  return (text - textstart);
262 }

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

Referenced by SDL_strtod(), and SDL_vsscanf().

◆ SDL_ScanLong()

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

Definition at line 53 of file SDL_string.c.

54 {
55  const char *textstart = text;
56  long value = 0;
57  SDL_bool negative = SDL_FALSE;
58 
59  if (*text == '-') {
60  negative = SDL_TRUE;
61  ++text;
62  }
63  if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
64  text += 2;
65  }
66  for (;;) {
67  int v;
68  if (SDL_isdigit((unsigned char) *text)) {
69  v = *text - '0';
70  } else if (radix == 16 && SDL_isupperhex(*text)) {
71  v = 10 + (*text - 'A');
72  } else if (radix == 16 && SDL_islowerhex(*text)) {
73  v = 10 + (*text - 'a');
74  } else {
75  break;
76  }
77  value *= radix;
78  value += v;
79  ++text;
80  }
81  if (valuep && text > textstart) {
82  if (negative && value) {
83  *valuep = -value;
84  } else {
85  *valuep = value;
86  }
87  }
88  return (text - textstart);
89 }

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

Referenced by SDL_strtol(), and SDL_vsscanf().

◆ SDL_ScanLongLong()

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

Definition at line 158 of file SDL_string.c.

159 {
160  const char *textstart = text;
161  Sint64 value = 0;
162  SDL_bool negative = SDL_FALSE;
163 
164  if (*text == '-') {
165  negative = SDL_TRUE;
166  ++text;
167  }
168  if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
169  text += 2;
170  }
171  for (;;) {
172  int v;
173  if (SDL_isdigit((unsigned char) *text)) {
174  v = *text - '0';
175  } else if (radix == 16 && SDL_isupperhex(*text)) {
176  v = 10 + (*text - 'A');
177  } else if (radix == 16 && SDL_islowerhex(*text)) {
178  v = 10 + (*text - 'a');
179  } else {
180  break;
181  }
182  value *= radix;
183  value += v;
184  ++text;
185  }
186  if (valuep && text > textstart) {
187  if (negative && value) {
188  *valuep = -value;
189  } else {
190  *valuep = value;
191  }
192  }
193  return (text - textstart);
194 }

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

Referenced by SDL_strtoll(), and SDL_vsscanf().

◆ SDL_ScanUintPtrT()

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

Definition at line 126 of file SDL_string.c.

127 {
128  const char *textstart = text;
129  uintptr_t value = 0;
130 
131  if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
132  text += 2;
133  }
134  for (;;) {
135  int v;
136  if (SDL_isdigit((unsigned char) *text)) {
137  v = *text - '0';
138  } else if (radix == 16 && SDL_isupperhex(*text)) {
139  v = 10 + (*text - 'A');
140  } else if (radix == 16 && SDL_islowerhex(*text)) {
141  v = 10 + (*text - 'a');
142  } else {
143  break;
144  }
145  value *= radix;
146  value += v;
147  ++text;
148  }
149  if (valuep && text > textstart) {
150  *valuep = value;
151  }
152  return (text - textstart);
153 }

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

Referenced by SDL_vsscanf().

◆ SDL_ScanUnsignedLong()

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

Definition at line 94 of file SDL_string.c.

95 {
96  const char *textstart = text;
97  unsigned long value = 0;
98 
99  if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
100  text += 2;
101  }
102  for (;;) {
103  int v;
104  if (SDL_isdigit((unsigned char) *text)) {
105  v = *text - '0';
106  } else if (radix == 16 && SDL_isupperhex(*text)) {
107  v = 10 + (*text - 'A');
108  } else if (radix == 16 && SDL_islowerhex(*text)) {
109  v = 10 + (*text - 'a');
110  } else {
111  break;
112  }
113  value *= radix;
114  value += v;
115  ++text;
116  }
117  if (valuep && text > textstart) {
118  *valuep = value;
119  }
120  return (text - textstart);
121 }

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

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

◆ SDL_ScanUnsignedLongLong()

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

Definition at line 199 of file SDL_string.c.

200 {
201  const char *textstart = text;
202  Uint64 value = 0;
203 
204  if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
205  text += 2;
206  }
207  for (;;) {
208  int v;
209  if (SDL_isdigit((unsigned char) *text)) {
210  v = *text - '0';
211  } else if (radix == 16 && SDL_isupperhex(*text)) {
212  v = 10 + (*text - 'A');
213  } else if (radix == 16 && SDL_islowerhex(*text)) {
214  v = 10 + (*text - 'a');
215  } else {
216  break;
217  }
218  value *= radix;
219  value += v;
220  ++text;
221  }
222  if (valuep && text > textstart) {
223  *valuep = value;
224  }
225  return (text - textstart);
226 }

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

Referenced by SDL_strtoull(), and SDL_vsscanf().

◆ SDL_snprintf()

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

Definition at line 1326 of file SDL_string.c.

1327 {
1328  va_list ap;
1329  int retval;
1330 
1331  va_start(ap, fmt);
1332  retval = SDL_vsnprintf(text, maxlen, fmt, ap);
1333  va_end(ap);
1334 
1335  return retval;
1336 }

References retval, SDL_vsnprintf(), and text.

◆ SDL_sscanf()

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

Definition at line 1034 of file SDL_string.c.

1035 {
1036  int rc;
1037  va_list ap;
1038  va_start(ap, fmt);
1039  rc = SDL_vsscanf(text, fmt, ap);
1040  va_end(ap);
1041  return rc;
1042 }

References SDL_vsscanf(), and text.

◆ SDL_strcasecmp()

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

Definition at line 981 of file SDL_string.c.

982 {
983 #ifdef HAVE_STRCASECMP
984  return strcasecmp(str1, str2);
985 #elif defined(HAVE__STRICMP)
986  return _stricmp(str1, str2);
987 #else
988  char a = 0;
989  char b = 0;
990  while (*str1 && *str2) {
991  a = SDL_toupper((unsigned char) *str1);
992  b = SDL_toupper((unsigned char) *str2);
993  if (a != b)
994  break;
995  ++str1;
996  ++str2;
997  }
998  a = SDL_toupper(*str1);
999  b = SDL_toupper(*str2);
1000  return (int) ((unsigned char) a - (unsigned char) b);
1001 #endif /* HAVE_STRCASECMP */
1002 }

References SDL_toupper.

◆ SDL_strchr()

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

Definition at line 638 of file SDL_string.c.

639 {
640 #ifdef HAVE_STRCHR
641  return SDL_const_cast(char*,strchr(string, c));
642 #elif defined(HAVE_INDEX)
643  return SDL_const_cast(char*,index(string, c));
644 #else
645  while (*string) {
646  if (*string == c) {
647  return (char *) string;
648  }
649  ++string;
650  }
651  return NULL;
652 #endif /* HAVE_STRCHR */
653 }

References NULL, and SDL_const_cast.

◆ SDL_strcmp()

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

Definition at line 945 of file SDL_string.c.

946 {
947 #if defined(HAVE_STRCMP)
948  return strcmp(str1, str2);
949 #else
950  while (*str1 && *str2) {
951  if (*str1 != *str2)
952  break;
953  ++str1;
954  ++str2;
955  }
956  return (int)((unsigned char) *str1 - (unsigned char) *str2);
957 #endif /* HAVE_STRCMP */
958 }

◆ SDL_strdup()

char* SDL_strdup ( const char *  string)

Definition at line 578 of file SDL_string.c.

579 {
580  size_t len = SDL_strlen(string) + 1;
581  char *newstr = (char *)SDL_malloc(len);
582  if (newstr) {
583  SDL_memcpy(newstr, string, len);
584  }
585  return newstr;
586 }

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

◆ SDL_strlcat()

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

Definition at line 563 of file SDL_string.c.

564 {
565 #if defined(HAVE_STRLCAT)
566  return strlcat(dst, src, maxlen);
567 #else
568  size_t dstlen = SDL_strlen(dst);
569  size_t srclen = SDL_strlen(src);
570  if (dstlen < maxlen) {
571  SDL_strlcpy(dst + dstlen, src, maxlen - dstlen);
572  }
573  return dstlen + srclen;
574 #endif /* HAVE_STRLCAT */
575 }

References SDL_strlcpy(), and SDL_strlen().

◆ SDL_strlcpy()

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

Definition at line 497 of file SDL_string.c.

498 {
499 #if defined(HAVE_STRLCPY)
500  return strlcpy(dst, src, maxlen);
501 #else
502  size_t srclen = SDL_strlen(src);
503  if (maxlen > 0) {
504  size_t len = SDL_min(srclen, maxlen - 1);
505  SDL_memcpy(dst, src, len);
506  dst[len] = '\0';
507  }
508  return srclen;
509 #endif /* HAVE_STRLCPY */
510 }

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

Referenced by SDL_PrintString(), and SDL_strlcat().

◆ SDL_strlen()

size_t SDL_strlen ( const char *  string)

Definition at line 411 of file SDL_string.c.

412 {
413 #if defined(HAVE_STRLEN)
414  return strlen(string);
415 #else
416  size_t len = 0;
417  while (*string++) {
418  ++len;
419  }
420  return len;
421 #endif /* HAVE_STRLEN */
422 }

Referenced by SDL_IntPrecisionAdjust(), 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().

◆ SDL_strlwr()

char* SDL_strlwr ( char *  string)

Definition at line 623 of file SDL_string.c.

624 {
625 #if defined(HAVE__STRLWR)
626  return _strlwr(string);
627 #else
628  char *bufp = string;
629  while (*bufp) {
630  *bufp = SDL_tolower((unsigned char) *bufp);
631  ++bufp;
632  }
633  return string;
634 #endif /* HAVE__STRLWR */
635 }

References SDL_tolower.

Referenced by SDL_PrintString().

◆ SDL_strncasecmp()

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

Definition at line 1005 of file SDL_string.c.

1006 {
1007 #ifdef HAVE_STRNCASECMP
1008  return strncasecmp(str1, str2, maxlen);
1009 #elif defined(HAVE__STRNICMP)
1010  return _strnicmp(str1, str2, maxlen);
1011 #else
1012  char a = 0;
1013  char b = 0;
1014  while (*str1 && *str2 && maxlen) {
1015  a = SDL_tolower((unsigned char) *str1);
1016  b = SDL_tolower((unsigned char) *str2);
1017  if (a != b)
1018  break;
1019  ++str1;
1020  ++str2;
1021  --maxlen;
1022  }
1023  if (maxlen == 0) {
1024  return 0;
1025  } else {
1026  a = SDL_tolower((unsigned char) *str1);
1027  b = SDL_tolower((unsigned char) *str2);
1028  return (int) ((unsigned char) a - (unsigned char) b);
1029  }
1030 #endif /* HAVE_STRNCASECMP */
1031 }

References SDL_tolower.

◆ SDL_strncmp()

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

Definition at line 961 of file SDL_string.c.

962 {
963 #if defined(HAVE_STRNCMP)
964  return strncmp(str1, str2, maxlen);
965 #else
966  while (*str1 && *str2 && maxlen) {
967  if (*str1 != *str2)
968  break;
969  ++str1;
970  ++str2;
971  --maxlen;
972  }
973  if (!maxlen) {
974  return 0;
975  }
976  return (int) ((unsigned char) *str1 - (unsigned char) *str2);
977 #endif /* HAVE_STRNCMP */
978 }

Referenced by 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().

◆ SDL_strrchr()

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

Definition at line 656 of file SDL_string.c.

657 {
658 #ifdef HAVE_STRRCHR
659  return SDL_const_cast(char*,strrchr(string, c));
660 #elif defined(HAVE_RINDEX)
661  return SDL_const_cast(char*,rindex(string, c));
662 #else
663  const char *bufp = string + SDL_strlen(string) - 1;
664  while (bufp >= string) {
665  if (*bufp == c) {
666  return (char *) bufp;
667  }
668  --bufp;
669  }
670  return NULL;
671 #endif /* HAVE_STRRCHR */
672 }

References NULL, SDL_const_cast, and SDL_strlen().

◆ SDL_strrev()

char* SDL_strrev ( char *  string)

Definition at line 589 of file SDL_string.c.

590 {
591 #if defined(HAVE__STRREV)
592  return _strrev(string);
593 #else
594  size_t len = SDL_strlen(string);
595  char *a = &string[0];
596  char *b = &string[len - 1];
597  len /= 2;
598  while (len--) {
599  char c = *a;
600  *a++ = *b;
601  *b-- = c;
602  }
603  return string;
604 #endif /* HAVE__STRREV */
605 }

References SDL_strlen().

Referenced by SDL_ulltoa(), and SDL_ultoa().

◆ SDL_strstr()

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

Definition at line 675 of file SDL_string.c.

676 {
677 #if defined(HAVE_STRSTR)
678  return SDL_const_cast(char*,strstr(haystack, needle));
679 #else
680  size_t length = SDL_strlen(needle);
681  while (*haystack) {
682  if (SDL_strncmp(haystack, needle, length) == 0) {
683  return (char *) haystack;
684  }
685  ++haystack;
686  }
687  return NULL;
688 #endif /* HAVE_STRSTR */
689 }

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

◆ SDL_strtod()

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

Definition at line 928 of file SDL_string.c.

929 {
930 #if defined(HAVE_STRTOD)
931  return strtod(string, endp);
932 #else
933  size_t len;
934  double value = 0.0;
935 
936  len = SDL_ScanFloat(string, &value);
937  if (endp) {
938  *endp = (char *) string + len;
939  }
940  return value;
941 #endif /* HAVE_STRTOD */
942 }

References SDL_ScanFloat().

Referenced by SDL_atof().

◆ SDL_strtol()

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

Definition at line 828 of file SDL_string.c.

829 {
830 #if defined(HAVE_STRTOL)
831  return strtol(string, endp, base);
832 #else
833  size_t len;
834  long value = 0;
835 
836  if (!base) {
837  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
838  base = 16;
839  } else {
840  base = 10;
841  }
842  }
843 
844  len = SDL_ScanLong(string, base, &value);
845  if (endp) {
846  *endp = (char *) string + len;
847  }
848  return value;
849 #endif /* HAVE_STRTOL */
850 }

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

Referenced by SDL_atoi(), and SDL_vsnprintf().

◆ SDL_strtoll()

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

Definition at line 878 of file SDL_string.c.

879 {
880 #if defined(HAVE_STRTOLL)
881  return strtoll(string, endp, base);
882 #else
883  size_t len;
884  Sint64 value = 0;
885 
886  if (!base) {
887  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
888  base = 16;
889  } else {
890  base = 10;
891  }
892  }
893 
894  len = SDL_ScanLongLong(string, base, &value);
895  if (endp) {
896  *endp = (char *) string + len;
897  }
898  return value;
899 #endif /* HAVE_STRTOLL */
900 }

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

◆ SDL_strtoul()

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

Definition at line 853 of file SDL_string.c.

854 {
855 #if defined(HAVE_STRTOUL)
856  return strtoul(string, endp, base);
857 #else
858  size_t len;
859  unsigned long value = 0;
860 
861  if (!base) {
862  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
863  base = 16;
864  } else {
865  base = 10;
866  }
867  }
868 
869  len = SDL_ScanUnsignedLong(string, base, &value);
870  if (endp) {
871  *endp = (char *) string + len;
872  }
873  return value;
874 #endif /* HAVE_STRTOUL */
875 }

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

◆ SDL_strtoull()

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

Definition at line 903 of file SDL_string.c.

904 {
905 #if defined(HAVE_STRTOULL)
906  return strtoull(string, endp, base);
907 #else
908  size_t len;
909  Uint64 value = 0;
910 
911  if (!base) {
912  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
913  base = 16;
914  } else {
915  base = 10;
916  }
917  }
918 
919  len = SDL_ScanUnsignedLongLong(string, base, &value);
920  if (endp) {
921  *endp = (char *) string + len;
922  }
923  return value;
924 #endif /* HAVE_STRTOULL */
925 }

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

◆ SDL_strupr()

char* SDL_strupr ( char *  string)

Definition at line 608 of file SDL_string.c.

609 {
610 #if defined(HAVE__STRUPR)
611  return _strupr(string);
612 #else
613  char *bufp = string;
614  while (*bufp) {
615  *bufp = SDL_toupper((unsigned char) *bufp);
616  ++bufp;
617  }
618  return string;
619 #endif /* HAVE__STRUPR */
620 }

References SDL_toupper.

Referenced by SDL_PrintString().

◆ SDL_uitoa()

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

Definition at line 712 of file SDL_string.c.

713 {
714 #ifdef HAVE__UITOA
715  return _uitoa(value, string, radix);
716 #else
717  return SDL_ultoa((unsigned long)value, string, radix);
718 #endif /* HAVE__UITOA */
719 }

References SDL_ultoa().

◆ SDL_ulltoa()

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

Definition at line 785 of file SDL_string.c.

786 {
787 #if defined(HAVE__UI64TOA)
788  return _ui64toa(value, string, radix);
789 #else
790  char *bufp = string;
791 
792  if (value) {
793  while (value > 0) {
794  *bufp++ = ntoa_table[value % radix];
795  value /= radix;
796  }
797  } else {
798  *bufp++ = '0';
799  }
800  *bufp = '\0';
801 
802  /* The numbers went into the string backwards. :) */
803  SDL_strrev(string);
804 
805  return string;
806 #endif /* HAVE__UI64TOA */
807 }

References ntoa_table, and SDL_strrev().

Referenced by SDL_lltoa(), and SDL_PrintUnsignedLongLong().

◆ SDL_ultoa()

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

Definition at line 741 of file SDL_string.c.

742 {
743 #if defined(HAVE__ULTOA)
744  return _ultoa(value, string, radix);
745 #else
746  char *bufp = string;
747 
748  if (value) {
749  while (value > 0) {
750  *bufp++ = ntoa_table[value % radix];
751  value /= radix;
752  }
753  } else {
754  *bufp++ = '0';
755  }
756  *bufp = '\0';
757 
758  /* The numbers went into the string backwards. :) */
759  SDL_strrev(string);
760 
761  return string;
762 #endif /* HAVE__ULTOA */
763 }

References ntoa_table, and SDL_strrev().

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

◆ SDL_utf8strlcpy()

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

Definition at line 513 of file SDL_string.c.

514 {
515  size_t src_bytes = SDL_strlen(src);
516  size_t bytes = SDL_min(src_bytes, dst_bytes - 1);
517  size_t i = 0;
518  char trailing_bytes = 0;
519  if (bytes)
520  {
521  unsigned char c = (unsigned char)src[bytes - 1];
522  if (UTF8_IsLeadByte(c))
523  --bytes;
524  else if (UTF8_IsTrailingByte(c))
525  {
526  for (i = bytes - 1; i != 0; --i)
527  {
528  c = (unsigned char)src[i];
529  trailing_bytes = UTF8_TrailingBytes(c);
530  if (trailing_bytes)
531  {
532  if (bytes - i != trailing_bytes + 1)
533  bytes = i;
534 
535  break;
536  }
537  }
538  }
539  SDL_memcpy(dst, src, bytes);
540  }
541  dst[bytes] = '\0';
542  return bytes;
543 }

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

◆ SDL_utf8strlen()

size_t SDL_utf8strlen ( const char *  str)

Definition at line 546 of file SDL_string.c.

547 {
548  size_t retval = 0;
549  const char *p = str;
550  char ch;
551 
552  while ((ch = *(p++))) {
553  /* if top two bits are 1 and 0, it's a continuation byte. */
554  if ((ch & 0xc0) != 0x80) {
555  retval++;
556  }
557  }
558 
559  return retval;
560 }

References retval.

◆ SDL_vsnprintf()

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

Definition at line 1610 of file SDL_string.c.

1611 {
1612  size_t left = maxlen;
1613  char *textstart = text;
1614 
1615  if (!fmt) {
1616  fmt = "";
1617  }
1618  while (*fmt && left > 1) {
1619  if (*fmt == '%') {
1621  size_t len = 0;
1622  SDL_bool check_flag;
1623  SDL_FormatInfo info;
1624  enum
1625  {
1626  DO_INT,
1627  DO_LONG,
1628  DO_LONGLONG
1629  } inttype = DO_INT;
1630 
1631  SDL_zero(info);
1632  info.radix = 10;
1633  info.precision = -1;
1634 
1635  check_flag = SDL_TRUE;
1636  while (check_flag) {
1637  ++fmt;
1638  switch (*fmt) {
1639  case '-':
1640  info.left_justify = SDL_TRUE;
1641  break;
1642  case '+':
1643  info.force_sign = SDL_TRUE;
1644  break;
1645  case '#':
1646  info.force_type = SDL_TRUE;
1647  break;
1648  case '0':
1649  info.pad_zeroes = SDL_TRUE;
1650  break;
1651  default:
1652  check_flag = SDL_FALSE;
1653  break;
1654  }
1655  }
1656 
1657  if (*fmt >= '0' && *fmt <= '9') {
1658  info.width = SDL_strtol(fmt, (char **)&fmt, 0);
1659  }
1660  else if (*fmt == '*') {
1661  ++fmt;
1662  info.width = va_arg(ap, int);
1663  }
1664 
1665  if (*fmt == '.') {
1666  ++fmt;
1667  if (*fmt >= '0' && *fmt <= '9') {
1668  info.precision = SDL_strtol(fmt, (char **)&fmt, 0);
1669  } else if (*fmt == '*') {
1670  ++fmt;
1671  info.precision = va_arg(ap, int);
1672  } else {
1673  info.precision = 0;
1674  }
1675  if (info.precision < 0) {
1676  info.precision = 0;
1677  }
1678  }
1679 
1680  while (!done) {
1681  switch (*fmt) {
1682  case '%':
1683  if (left > 1) {
1684  *text = '%';
1685  }
1686  len = 1;
1687  done = SDL_TRUE;
1688  break;
1689  case 'c':
1690  /* char is promoted to int when passed through (...) */
1691  if (left > 1) {
1692  *text = (char) va_arg(ap, int);
1693  }
1694  len = 1;
1695  done = SDL_TRUE;
1696  break;
1697  case 'h':
1698  /* short is promoted to int when passed through (...) */
1699  break;
1700  case 'l':
1701  if (inttype < DO_LONGLONG) {
1702  ++inttype;
1703  }
1704  break;
1705  case 'I':
1706  if (SDL_strncmp(fmt, "I64", 3) == 0) {
1707  fmt += 2;
1708  inttype = DO_LONGLONG;
1709  }
1710  break;
1711  case 'i':
1712  case 'd':
1713  if (info.precision >= 0) {
1714  info.pad_zeroes = SDL_FALSE;
1715  }
1716  switch (inttype) {
1717  case DO_INT:
1718  len = SDL_PrintLong(text, left, &info,
1719  (long) va_arg(ap, int));
1720  break;
1721  case DO_LONG:
1722  len = SDL_PrintLong(text, left, &info,
1723  va_arg(ap, long));
1724  break;
1725  case DO_LONGLONG:
1726  len = SDL_PrintLongLong(text, left, &info,
1727  va_arg(ap, Sint64));
1728  break;
1729  }
1730  done = SDL_TRUE;
1731  break;
1732  case 'p':
1733  case 'x':
1734  info.force_case = SDL_CASE_LOWER;
1735  /* Fall through to 'X' handling */
1736  case 'X':
1737  if (info.force_case == SDL_CASE_NOCHANGE) {
1738  info.force_case = SDL_CASE_UPPER;
1739  }
1740  if (info.radix == 10) {
1741  info.radix = 16;
1742  }
1743  if (*fmt == 'p') {
1744  inttype = DO_LONG;
1745  }
1746  /* Fall through to unsigned handling */
1747  case 'o':
1748  if (info.radix == 10) {
1749  info.radix = 8;
1750  }
1751  /* Fall through to unsigned handling */
1752  case 'u':
1753  info.force_sign = SDL_FALSE;
1754  if (info.precision >= 0) {
1755  info.pad_zeroes = SDL_FALSE;
1756  }
1757  switch (inttype) {
1758  case DO_INT:
1759  len = SDL_PrintUnsignedLong(text, left, &info,
1760  (unsigned long)
1761  va_arg(ap, unsigned int));
1762  break;
1763  case DO_LONG:
1764  len = SDL_PrintUnsignedLong(text, left, &info,
1765  va_arg(ap, unsigned long));
1766  break;
1767  case DO_LONGLONG:
1769  va_arg(ap, Uint64));
1770  break;
1771  }
1772  done = SDL_TRUE;
1773  break;
1774  case 'f':
1775  len = SDL_PrintFloat(text, left, &info, va_arg(ap, double));
1776  done = SDL_TRUE;
1777  break;
1778  case 'S':
1779  {
1780  /* In practice this is used on Windows for WCHAR strings */
1781  wchar_t *wide_arg = va_arg(ap, wchar_t *);
1782  char *arg = SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(wide_arg), (SDL_wcslen(wide_arg)+1)*sizeof(*wide_arg));
1783  info.pad_zeroes = SDL_FALSE;
1784  len = SDL_PrintString(text, left, &info, arg);
1785  SDL_free(arg);
1786  done = SDL_TRUE;
1787  }
1788  break;
1789  case 's':
1790  info.pad_zeroes = SDL_FALSE;
1791  len = SDL_PrintString(text, left, &info, va_arg(ap, char *));
1792  done = SDL_TRUE;
1793  break;
1794  default:
1795  done = SDL_TRUE;
1796  break;
1797  }
1798  ++fmt;
1799  }
1800  if (len >= left) {
1801  text += (left > 1) ? left - 1 : 0;
1802  left = SDL_min(left, 1);
1803  } else {
1804  text += len;
1805  left -= len;
1806  }
1807  } else {
1808  *text++ = *fmt++;
1809  --left;
1810  }
1811  }
1812  if (left > 0) {
1813  *text = '\0';
1814  }
1815  return (int)(text - textstart);
1816 }

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_free, SDL_iconv_string, SDL_min, SDL_PrintFloat(), SDL_PrintLong(), SDL_PrintLongLong(), SDL_PrintString(), SDL_PrintUnsignedLong(), SDL_PrintUnsignedLongLong(), SDL_strncmp(), SDL_strtol(), SDL_TRUE, SDL_wcslen(), SDL_zero, text, and SDL_FormatInfo::width.

Referenced by SDL_snprintf().

◆ SDL_vsscanf()

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

Definition at line 1052 of file SDL_string.c.

1053 {
1054  int retval = 0;
1055 
1056  if (!text || !*text) {
1057  return -1;
1058  }
1059 
1060  while (*fmt) {
1061  if (*fmt == ' ') {
1062  while (SDL_isspace((unsigned char) *text)) {
1063  ++text;
1064  }
1065  ++fmt;
1066  continue;
1067  }
1068  if (*fmt == '%') {
1070  long count = 0;
1071  int radix = 10;
1072  enum
1073  {
1074  DO_SHORT,
1075  DO_INT,
1076  DO_LONG,
1077  DO_LONGLONG
1078  } inttype = DO_INT;
1079  size_t advance;
1080  SDL_bool suppress = SDL_FALSE;
1081 
1082  ++fmt;
1083  if (*fmt == '%') {
1084  if (*text == '%') {
1085  ++text;
1086  ++fmt;
1087  continue;
1088  }
1089  break;
1090  }
1091  if (*fmt == '*') {
1092  suppress = SDL_TRUE;
1093  ++fmt;
1094  }
1095  fmt += SDL_ScanLong(fmt, 10, &count);
1096 
1097  if (*fmt == 'c') {
1098  if (!count) {
1099  count = 1;
1100  }
1101  if (suppress) {
1102  while (count--) {
1103  ++text;
1104  }
1105  } else {
1106  char *valuep = va_arg(ap, char *);
1107  while (count--) {
1108  *valuep++ = *text++;
1109  }
1110  ++retval;
1111  }
1112  continue;
1113  }
1114 
1115  while (SDL_isspace((unsigned char) *text)) {
1116  ++text;
1117  }
1118 
1119  /* FIXME: implement more of the format specifiers */
1120  while (!done) {
1121  switch (*fmt) {
1122  case '*':
1123  suppress = SDL_TRUE;
1124  break;
1125  case 'h':
1126  if (inttype > DO_SHORT) {
1127  ++inttype;
1128  }
1129  break;
1130  case 'l':
1131  if (inttype < DO_LONGLONG) {
1132  ++inttype;
1133  }
1134  break;
1135  case 'I':
1136  if (SDL_strncmp(fmt, "I64", 3) == 0) {
1137  fmt += 2;
1138  inttype = DO_LONGLONG;
1139  }
1140  break;
1141  case 'i':
1142  {
1143  int index = 0;
1144  if (text[index] == '-') {
1145  ++index;
1146  }
1147  if (text[index] == '0') {
1148  if (SDL_tolower((unsigned char) text[index + 1]) == 'x') {
1149  radix = 16;
1150  } else {
1151  radix = 8;
1152  }
1153  }
1154  }
1155  /* Fall through to %d handling */
1156  case 'd':
1157  if (inttype == DO_LONGLONG) {
1158  Sint64 value;
1159  advance = SDL_ScanLongLong(text, radix, &value);
1160  text += advance;
1161  if (advance && !suppress) {
1162  Sint64 *valuep = va_arg(ap, Sint64 *);
1163  *valuep = value;
1164  ++retval;
1165  }
1166  } else {
1167  long value;
1168  advance = SDL_ScanLong(text, radix, &value);
1169  text += advance;
1170  if (advance && !suppress) {
1171  switch (inttype) {
1172  case DO_SHORT:
1173  {
1174  short *valuep = va_arg(ap, short *);
1175  *valuep = (short) value;
1176  }
1177  break;
1178  case DO_INT:
1179  {
1180  int *valuep = va_arg(ap, int *);
1181  *valuep = (int) value;
1182  }
1183  break;
1184  case DO_LONG:
1185  {
1186  long *valuep = va_arg(ap, long *);
1187  *valuep = value;
1188  }
1189  break;
1190  case DO_LONGLONG:
1191  /* Handled above */
1192  break;
1193  }
1194  ++retval;
1195  }
1196  }
1197  done = SDL_TRUE;
1198  break;
1199  case 'o':
1200  if (radix == 10) {
1201  radix = 8;
1202  }
1203  /* Fall through to unsigned handling */
1204  case 'x':
1205  case 'X':
1206  if (radix == 10) {
1207  radix = 16;
1208  }
1209  /* Fall through to unsigned handling */
1210  case 'u':
1211  if (inttype == DO_LONGLONG) {
1212  Uint64 value = 0;
1213  advance = SDL_ScanUnsignedLongLong(text, radix, &value);
1214  text += advance;
1215  if (advance && !suppress) {
1216  Uint64 *valuep = va_arg(ap, Uint64 *);
1217  *valuep = value;
1218  ++retval;
1219  }
1220  } else {
1221  unsigned long value = 0;
1222  advance = SDL_ScanUnsignedLong(text, radix, &value);
1223  text += advance;
1224  if (advance && !suppress) {
1225  switch (inttype) {
1226  case DO_SHORT:
1227  {
1228  short *valuep = va_arg(ap, short *);
1229  *valuep = (short) value;
1230  }
1231  break;
1232  case DO_INT:
1233  {
1234  int *valuep = va_arg(ap, int *);
1235  *valuep = (int) value;
1236  }
1237  break;
1238  case DO_LONG:
1239  {
1240  long *valuep = va_arg(ap, long *);
1241  *valuep = value;
1242  }
1243  break;
1244  case DO_LONGLONG:
1245  /* Handled above */
1246  break;
1247  }
1248  ++retval;
1249  }
1250  }
1251  done = SDL_TRUE;
1252  break;
1253  case 'p':
1254  {
1255  uintptr_t value = 0;
1256  advance = SDL_ScanUintPtrT(text, 16, &value);
1257  text += advance;
1258  if (advance && !suppress) {
1259  void **valuep = va_arg(ap, void **);
1260  *valuep = (void *) value;
1261  ++retval;
1262  }
1263  }
1264  done = SDL_TRUE;
1265  break;
1266  case 'f':
1267  {
1268  double value;
1269  advance = SDL_ScanFloat(text, &value);
1270  text += advance;
1271  if (advance && !suppress) {
1272  float *valuep = va_arg(ap, float *);
1273  *valuep = (float) value;
1274  ++retval;
1275  }
1276  }
1277  done = SDL_TRUE;
1278  break;
1279  case 's':
1280  if (suppress) {
1281  while (!SDL_isspace((unsigned char) *text)) {
1282  ++text;
1283  if (count) {
1284  if (--count == 0) {
1285  break;
1286  }
1287  }
1288  }
1289  } else {
1290  char *valuep = va_arg(ap, char *);
1291  while (!SDL_isspace((unsigned char) *text)) {
1292  *valuep++ = *text++;
1293  if (count) {
1294  if (--count == 0) {
1295  break;
1296  }
1297  }
1298  }
1299  *valuep = '\0';
1300  ++retval;
1301  }
1302  done = SDL_TRUE;
1303  break;
1304  default:
1305  done = SDL_TRUE;
1306  break;
1307  }
1308  ++fmt;
1309  }
1310  continue;
1311  }
1312  if (*text == *fmt) {
1313  ++text;
1314  ++fmt;
1315  continue;
1316  }
1317  /* Text didn't match format specifier */
1318  break;
1319  }
1320 
1321  return retval;
1322 }

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_sscanf().

◆ SDL_wcscmp()

int SDL_wcscmp ( const wchar_t *  str1,
const wchar_t *  str2 
)

Definition at line 481 of file SDL_string.c.

482 {
483 #if defined(HAVE_WCSCMP)
484  return wcscmp(str1, str2);
485 #else
486  while (*str1 && *str2) {
487  if (*str1 != *str2)
488  break;
489  ++str1;
490  ++str2;
491  }
492  return (int)(*str1 - *str2);
493 #endif /* HAVE_WCSCMP */
494 }

◆ SDL_wcsdup()

wchar_t* SDL_wcsdup ( const wchar_t *  string)

Definition at line 425 of file SDL_string.c.

426 {
427  size_t len = ((SDL_wcslen(string) + 1) * sizeof(wchar_t));
428  wchar_t *newstr = (wchar_t *)SDL_malloc(len);
429  if (newstr) {
430  SDL_memcpy(newstr, string, len);
431  }
432  return newstr;
433 }

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

◆ SDL_wcslcat()

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

Definition at line 466 of file SDL_string.c.

467 {
468 #if defined(HAVE_WCSLCAT)
469  return wcslcat(dst, src, maxlen);
470 #else
471  size_t dstlen = SDL_wcslen(dst);
472  size_t srclen = SDL_wcslen(src);
473  if (dstlen < maxlen) {
474  SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen);
475  }
476  return dstlen + srclen;
477 #endif /* HAVE_WCSLCAT */
478 }

References SDL_wcslcpy(), and SDL_wcslen().

◆ SDL_wcslcpy()

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

Definition at line 450 of file SDL_string.c.

451 {
452 #if defined(HAVE_WCSLCPY)
453  return wcslcpy(dst, src, maxlen);
454 #else
455  size_t srclen = SDL_wcslen(src);
456  if (maxlen > 0) {
457  size_t len = SDL_min(srclen, maxlen - 1);
458  SDL_memcpy(dst, src, len * sizeof(wchar_t));
459  dst[len] = '\0';
460  }
461  return srclen;
462 #endif /* HAVE_WCSLCPY */
463 }

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

Referenced by SDL_wcslcat().

◆ SDL_wcslen()

size_t SDL_wcslen ( const wchar_t *  string)

Definition at line 436 of file SDL_string.c.

437 {
438 #if defined(HAVE_WCSLEN)
439  return wcslen(string);
440 #else
441  size_t len = 0;
442  while (*string++) {
443  ++len;
444  }
445  return len;
446 #endif /* HAVE_WCSLEN */
447 }

Referenced by SDL_vsnprintf(), SDL_wcsdup(), SDL_wcslcat(), and SDL_wcslcpy().

◆ UTF8_TrailingBytes()

static int UTF8_TrailingBytes ( unsigned char  c)
static

Definition at line 39 of file SDL_string.c.

40 {
41  if (c >= 0xC0 && c <= 0xDF)
42  return 1;
43  else if (c >= 0xE0 && c <= 0xEF)
44  return 2;
45  else if (c >= 0xF0 && c <= 0xF4)
46  return 3;
47  else
48  return 0;
49 }

Referenced by SDL_utf8strlcpy().

Variable Documentation

◆ ntoa_table

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 693 of file SDL_string.c.

Referenced by SDL_ulltoa(), and SDL_ultoa().

SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
SDL_PrintUnsignedLongLong
static size_t SDL_PrintUnsignedLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Uint64 value)
Definition: SDL_string.c:1497
SDL_memset
void * SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
Definition: SDL_string.c:266
SDL_strlcpy
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:497
end
GLuint GLuint end
Definition: SDL_opengl.h:1570
NULL
#define NULL
Definition: begin_code.h:167
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1109
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1571
SDL_PrintString
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
Definition: SDL_string.c:1379
SDL_PrintFloat
static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
Definition: SDL_string.c:1507
SDL_tolower
#define SDL_tolower
Definition: SDL_dynapi_overrides.h:385
SDL_FormatInfo::precision
int precision
Definition: SDL_string.c:1375
SDL_ScanUintPtrT
static size_t SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep)
Definition: SDL_string.c:126
SDL_FormatInfo::radix
int radix
Definition: SDL_string.c:1374
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1570
SDL_const_cast
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:139
SDL_PrintUnsignedLong
static size_t SDL_PrintUnsignedLong(char *text, size_t maxlen, SDL_FormatInfo *info, unsigned long value)
Definition: SDL_string.c:1473
memmove
#define memmove
Definition: SDL_qsort.c:59
num
GLuint num
Definition: SDL_opengl_glext.h:4956
SDL_strlwr
char * SDL_strlwr(char *string)
Definition: SDL_string.c:623
index
GLuint index
Definition: SDL_opengl_glext.h:660
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1109
v
const GLdouble * v
Definition: SDL_opengl.h:2063
memcpy
#define memcpy
Definition: SDL_malloc.c:630
length
GLuint GLsizei GLsizei * length
Definition: SDL_opengl_glext.h:669
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11093
s1
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
Definition: SDL_opengl_glext.h:8583
SDL_lltoa
char * SDL_lltoa(Sint64 value, char *string, int radix)
Definition: SDL_string.c:766
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2926
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179
done
int done
Definition: checkkeys.c:28
p
GLfloat GLfloat p
Definition: SDL_opengl_glext.h:11090
ntoa_table
static const char ntoa_table[]
Definition: SDL_string.c:693
retval
SDL_bool retval
Definition: testgamecontroller.c:65
SDL_FormatInfo::left_justify
SDL_bool left_justify
Definition: SDL_string.c:1368
SDL_IntPrecisionAdjust
static void SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *info)
Definition: SDL_string.c:1422
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDL_FormatInfo::force_type
SDL_bool force_type
Definition: SDL_string.c:1370
SDL_FALSE
Definition: SDL_stdinc.h:163
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:315
SDL_strtod
double SDL_strtod(const char *string, char **endp)
Definition: SDL_string.c:928
SDL_isdigit
#define SDL_isdigit
Definition: SDL_dynapi_overrides.h:382
SDL_islowerhex
#define SDL_islowerhex(X)
Definition: SDL_string.c:33
SDL_strlen
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:411
SDL_strtol
long SDL_strtol(const char *string, char **endp, int base)
Definition: SDL_string.c:828
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
SDL_ScanLong
static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
Definition: SDL_string.c:53
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
SDL_isspace
#define SDL_isspace
Definition: SDL_dynapi_overrides.h:383
SDL_PrintLongLong
static size_t SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
Definition: SDL_string.c:1483
SDL_strrev
char * SDL_strrev(char *string)
Definition: SDL_string.c:589
SDL_PrintLong
static size_t SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
Definition: SDL_string.c:1459
SDL_FormatInfo::width
int width
Definition: SDL_string.c:1373
SDL_letter_case
SDL_letter_case
Definition: SDL_string.c:1359
SDL_FormatInfo::force_sign
SDL_bool force_sign
Definition: SDL_string.c:1369
SDL_CASE_UPPER
Definition: SDL_string.c:1363
SDL_ScanLongLong
static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
Definition: SDL_string.c:158
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:450
SDL_ulltoa
char * SDL_ulltoa(Uint64 value, char *string, int radix)
Definition: SDL_string.c:785
SDL_toupper
#define SDL_toupper
Definition: SDL_dynapi_overrides.h:384
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:161
SDL_FormatInfo::pad_zeroes
SDL_bool pad_zeroes
Definition: SDL_string.c:1371
src
GLenum src
Definition: SDL_opengl_glext.h:1737
UTF8_IsTrailingByte
#define UTF8_IsTrailingByte(c)
Definition: SDL_string.c:37
memset
#define memset
Definition: SDL_malloc.c:627
UTF8_IsLeadByte
#define UTF8_IsLeadByte(c)
Definition: SDL_string.c:36
SDL_iconv_string
#define SDL_iconv_string
Definition: SDL_dynapi_overrides.h:441
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:722
Uint64
uint64_t Uint64
Definition: SDL_stdinc.h:216
SDL_ScanUnsignedLongLong
static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
Definition: SDL_string.c:199
SDL_CASE_LOWER
Definition: SDL_string.c:1362
SDL_TRUE
Definition: SDL_stdinc.h:164
left
GLint left
Definition: SDL_opengl_glext.h:1949
SDL_vsscanf
int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
Definition: SDL_string.c:1052
SDL_ultoa
char * SDL_ultoa(unsigned long value, char *string, int radix)
Definition: SDL_string.c:741
SDL_wcslen
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:436
SDL_isupperhex
#define SDL_isupperhex(X)
Definition: SDL_string.c:32
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:203
SDL_ScanFloat
static size_t SDL_ScanFloat(const char *text, double *valuep)
Definition: SDL_string.c:231
SDL_ScanUnsignedLong
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:94
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:1610
SDL_FormatInfo
Definition: SDL_string.c:1366
string
GLsizei const GLchar *const * string
Definition: SDL_opengl_glext.h:688
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:374
SDL_memmove
void * SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:368
size_t
unsigned int size_t
Definition: SDL_config_windows.h:68
SDL_strupr
char * SDL_strupr(char *string)
Definition: SDL_string.c:608
SDL_strncmp
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:961
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:50
SDL_CASE_NOCHANGE
Definition: SDL_string.c:1361
Sint64
int64_t Sint64
Definition: SDL_stdinc.h:210
SDL_FormatInfo::force_case
SDL_letter_case force_case
Definition: SDL_string.c:1372
UTF8_TrailingBytes
static int UTF8_TrailingBytes(unsigned char c)
Definition: SDL_string.c:39
uintptr_t
unsigned int uintptr_t
Definition: SDL_config_windows.h:70