- For scanning we need to remove all width and precision fields and flags "%+3.7f" -> "%f". BUT don't strip types like "%I64d" which includes digits. ! "%07I64d" -> "%I64d"
| 3306 | |
| 3307 | // - For scanning we need to remove all width and precision fields and flags "%+3.7f" -> "%f". BUT don't strip types like "%I64d" which includes digits. ! "%07I64d" -> "%I64d" |
| 3308 | const char* ImParseFormatSanitizeForScanning(const char* fmt_in, char* fmt_out, size_t fmt_out_size) |
| 3309 | { |
| 3310 | const char* fmt_end = ImParseFormatFindEnd(fmt_in); |
| 3311 | const char* fmt_out_begin = fmt_out; |
| 3312 | IM_UNUSED(fmt_out_size); |
| 3313 | IM_ASSERT((size_t)(fmt_end - fmt_in + 1) < fmt_out_size); // Format is too long, let us know if this happens to you! |
| 3314 | bool has_type = false; |
| 3315 | while (fmt_in < fmt_end) |
| 3316 | { |
| 3317 | char c = *fmt_in++; |
| 3318 | if (!has_type && ((c >= '0' && c <= '9') || c == '.' || c == '+' || c == '#')) |
| 3319 | continue; |
| 3320 | has_type |= ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); // Stop skipping digits |
| 3321 | if (c != '\'' && c != '$' && c != '_') // Custom flags provided by stb_sprintf.h. POSIX 2008 also supports '. |
| 3322 | *(fmt_out++) = c; |
| 3323 | } |
| 3324 | *fmt_out = 0; // Zero-terminate |
| 3325 | return fmt_out_begin; |
| 3326 | } |
| 3327 | |
| 3328 | template<typename TYPE> |
| 3329 | static const char* ImAtoi(const char* src, TYPE* output) |
no test coverage detected