MCPcopy Create free account
hub / github.com/RenderKit/embree / ImStrTrimBlanks

Function ImStrTrimBlanks

tutorials/common/imgui/imgui.cpp:1717–1730  ·  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

1715
1716// 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.
1717void ImStrTrimBlanks(char* buf)
1718{
1719 char* p = buf;
1720 while (p[0] == ' ' || p[0] == '\t') // Leading blanks
1721 p++;
1722 char* p_start = p;
1723 while (*p != 0) // Find end of string
1724 p++;
1725 while (p > p_start && (p[-1] == ' ' || p[-1] == '\t')) // Trailing blanks
1726 p--;
1727 if (p_start != buf) // Copy memory if we had leading blanks
1728 memmove(buf, p_start, p - p_start);
1729 buf[p - p_start] = 0; // Zero terminate
1730}
1731
1732const char* ImStrSkipBlank(const char* str)
1733{

Callers 1

TempInputScalarMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected