Sanitize format - Zero terminate so extra characters after format (e.g. "%f123") don't confuse atof/atoi - stb_sprintf.h supports several new modifiers which format numbers in a way that also makes them incompatible atof/atoi.
| 2175 | // - Zero terminate so extra characters after format (e.g. "%f123") don't confuse atof/atoi |
| 2176 | // - stb_sprintf.h supports several new modifiers which format numbers in a way that also makes them incompatible atof/atoi. |
| 2177 | static void SanitizeFormatString(const char* fmt, char* fmt_out, size_t fmt_out_size) |
| 2178 | { |
| 2179 | IM_UNUSED(fmt_out_size); |
| 2180 | const char* fmt_end = ImParseFormatFindEnd(fmt); |
| 2181 | IM_ASSERT((size_t)(fmt_end - fmt + 1) < fmt_out_size); // Format is too long, let us know if this happens to you! |
| 2182 | while (fmt < fmt_end) |
| 2183 | { |
| 2184 | char c = *(fmt++); |
| 2185 | if (c != '\'' && c != '$' && c != '_') // Custom flags provided by stb_sprintf.h. POSIX 2008 also supports '. |
| 2186 | *(fmt_out++) = c; |
| 2187 | } |
| 2188 | *fmt_out = 0; // Zero-terminate |
| 2189 | } |
| 2190 | |
| 2191 | template<typename TYPE, typename SIGNEDTYPE> |
| 2192 | TYPE ImGui::RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, TYPE v) |
no test coverage detected