]> git.lyx.org Git - features.git/blobdiff - src/support/lstrings.cpp
Revert "Amend 3093789e for cmake build"
[features.git] / src / support / lstrings.cpp
index ad19d7f35da9ba00d6a7c9ef4e0023f42b641df4..9aac66a7542616023220622b19c741130a7c5dc8 100644 (file)
@@ -1446,8 +1446,8 @@ std::string formatFPNumber(double x)
        os << std::fixed;
        // Prevent outputs of 23.4200000000000017 but output small numbers
        // with at least 6 significant digits.
-       double const logarithm = log10(fabs(x));
-       os << std::setprecision(max(6 - iround(logarithm), 0)) << x;
+       int const precision = (x == 0.0) ? 0 : max(6 - iround(log10(fabs(x))), 0);
+       os << std::setprecision(precision) << x;
        string result = os.str();
        if (result.find('.') != string::npos) {
                result = rtrim(result, "0");
@@ -1544,11 +1544,7 @@ docstring bformat(docstring const & fmt, docstring const & arg1, int arg2)
 
 docstring bformat(docstring const & fmt, char const * arg1, docstring const & arg2)
 {
-       LATTEST(contains(fmt, from_ascii("%1$s")));
-       LATTEST(contains(fmt, from_ascii("%2$s")));
-       docstring str = subst(fmt, from_ascii("%1$s"), from_ascii(arg1));
-       str = subst(str, from_ascii("%2$s"), arg2);
-       return subst(str, from_ascii("%%"), from_ascii("%"));
+       return bformat(fmt, from_ascii(arg1), arg2);
 }