MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / ImStrTrimBlanks

Function ImStrTrimBlanks

KBotExt/imgui/imgui.cpp:1822–1835  ·  view source on GitHub ↗

Trim str by offsetting contents when there's leading data + writing a \0 at the trailing position. We use this in situation where the cost is negligible.

Source from the content-addressed store, hash-verified

1820
1821// Trim str by offsetting contents when there's leading data + writing a \0 at the trailing position. We use this in situation where the cost is negligible.
1822void ImStrTrimBlanks(char* buf)
1823{
1824 char* p = buf;
1825 while (p[0] == ' ' || p[0] == '\t') // Leading blanks
1826 p++;
1827 char* p_start = p;
1828 while (*p != 0) // Find end of string
1829 p++;
1830 while (p > p_start && (p[-1] == ' ' || p[-1] == '\t')) // Trailing blanks
1831 p--;
1832 if (p_start != buf) // Copy memory if we had leading blanks
1833 memmove(buf, p_start, p - p_start);
1834 buf[p - p_start] = 0; // Zero terminate
1835}
1836
1837const char* ImStrSkipBlank(const char* str)
1838{

Callers 1

TempInputScalarMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected