# HG changeset patch # User Chris Cannam # Date 1480095224 0 # Node ID 4a2bc07ec0fb2d4415fb2eb69db2f652404eef3d # Parent 838a45cff62d8305484f23854c03ece7d3c900bd Make CSV feature writer produce the same output with Qt 5.6 and 5.7+ diff -r 838a45cff62d -r 4a2bc07ec0fb transform/CSVFeatureWriter.cpp --- a/transform/CSVFeatureWriter.cpp Fri Nov 25 17:33:12 2016 +0000 +++ b/transform/CSVFeatureWriter.cpp Fri Nov 25 17:33:44 2016 +0000 @@ -276,7 +276,20 @@ } for (unsigned int j = 0; j < f.values.size(); ++j) { - stream << m_separator << QString("%1").arg(f.values[j], 0, 'g', m_digits); + + QString number = QString("%1").arg(f.values[j], 0, 'g', m_digits); + + // Qt pre-5.6 zero pads single-digit exponents to two digits; + // Qt 5.7+ doesn't by default. But we want both to produce the + // same output. Getting the new behaviour from standard APIs + // in Qt 5.6 isn't possible I think; getting the old behaviour + // from Qt 5.7 is possible but fiddly, involving setting up an + // appropriate locale and using the %L specifier. We could + // doubtless do it with sprintf but Qt is a known quantity at + // this point. Let's just convert the old format to the new. + number.replace("e-0", "e-"); + + stream << m_separator << number; } if (f.label != "") {