From eff466d77d6318c99f51a2e25ed2f34bf5bf44f8 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 13 Mar 2015 13:38:58 +0000 Subject: [PATCH] Fixed parsing of decimal precision back from format string when using %% --- imgui.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index e29e3185..f2f3b89d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4735,9 +4735,10 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c // Parse display precision back from the display format string int decimal_precision = 3; - if (const char* p = strchr(display_format, '%')) + for (const char* p = display_format; p = strchr(p, '%'); ) { p++; + if (p[0] == '%') { p ++; continue; } // Ignore "%%" while (*p >= '0' && *p <= '9') p++; if (*p == '.') @@ -4746,6 +4747,7 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c if (decimal_precision < 0 || decimal_precision > 10) decimal_precision = 3; } + break; } const ImVec2 label_size = CalcTextSize(label, NULL, true);