MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / SDL_PrintString

Function SDL_PrintString

deps/SDL2/src/stdlib/SDL_string.c:1411–1455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1409} SDL_FormatInfo;
1410
1411static size_t
1412SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
1413{
1414 size_t length = 0;
1415 size_t slen, sz;
1416
1417 if (string == NULL) {
1418 string = "(null)";
1419 }
1420
1421 sz = SDL_strlen(string);
1422 if (info && info->width > 0 && (size_t)info->width > sz) {
1423 const char fill = info->pad_zeroes ? '0' : ' ';
1424 size_t width = info->width - sz;
1425 size_t filllen;
1426
1427 if (info->precision >= 0 && (size_t)info->precision < sz)
1428 width += sz - (size_t)info->precision;
1429
1430 filllen = SDL_min(width, maxlen);
1431 SDL_memset(text, fill, filllen);
1432 text += filllen;
1433 length += filllen;
1434 maxlen -= filllen;
1435 }
1436
1437 slen = SDL_strlcpy(text, string, maxlen);
1438 length += SDL_min(slen, maxlen);
1439
1440 if (info) {
1441 if (info->precision >= 0 && (size_t)info->precision < sz) {
1442 slen = (size_t)info->precision;
1443 if (slen < maxlen) {
1444 text[slen] = 0;
1445 length -= (sz - slen);
1446 }
1447 }
1448 if (info->force_case == SDL_CASE_LOWER) {
1449 SDL_strlwr(text);
1450 } else if (info->force_case == SDL_CASE_UPPER) {
1451 SDL_strupr(text);
1452 }
1453 }
1454 return length;
1455}
1456
1457static void
1458SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *info)

Callers 5

SDL_PrintLongFunction · 0.85
SDL_PrintUnsignedLongFunction · 0.85
SDL_PrintLongLongFunction · 0.85
SDL_vsnprintfFunction · 0.85

Calls 5

SDL_strlenFunction · 0.85
SDL_memsetFunction · 0.85
SDL_strlcpyFunction · 0.85
SDL_strlwrFunction · 0.85
SDL_struprFunction · 0.85

Tested by

no test coverage detected