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.
| 2121 | // - Zero terminate so extra characters after format (e.g. "%f123") don't confuse atof/atoi |
| 2122 | // - stb_sprintf.h supports several new modifiers which format numbers in a way that also makes them incompatible atof/atoi. |
| 2123 | static void SanitizeFormatString(const char* fmt, char* fmt_out, size_t fmt_out_size) |
| 2124 | { |
| 2125 | IM_UNUSED(fmt_out_size); |
| 2126 | const char* fmt_end = ImParseFormatFindEnd(fmt); |
| 2127 | IM_ASSERT((size_t)(fmt_end - fmt + 1) < fmt_out_size); // Format is too long, let us know if this happens to you! |
| 2128 | while (fmt < fmt_end) |
| 2129 | { |
| 2130 | char c = *(fmt++); |
| 2131 | if (c != '\'' && c != '$' && c != '_') // Custom flags provided by stb_sprintf.h. POSIX 2008 also supports '. |
| 2132 | *(fmt_out++) = c; |
| 2133 | } |
| 2134 | *fmt_out = 0; // Zero-terminate |
| 2135 | } |
| 2136 | |
| 2137 | template<typename TYPE, typename SIGNEDTYPE> |
| 2138 | TYPE ImGui::RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, TYPE v) |
no test coverage detected