X-Git-Url: https://git.sthu.org/?p=shuber-gentoo-overlay.git;a=blobdiff_plain;f=media-gfx%2Fipe%2Ffiles%2Fipe-outputprecision.patch;fp=media-gfx%2Fipe%2Ffiles%2Fipe-outputprecision.patch;h=eb257021c34cecb5055360e76db0e705d56a0909;hp=0000000000000000000000000000000000000000;hb=c941ca354618ece70d9135e9206b85b8bb427418;hpb=0cf1c0b7e22a368cad15e253fd09bc4636bfe5d3 diff --git a/media-gfx/ipe/files/ipe-outputprecision.patch b/media-gfx/ipe/files/ipe-outputprecision.patch new file mode 100644 index 0000000..eb25702 --- /dev/null +++ b/media-gfx/ipe/files/ipe-outputprecision.patch @@ -0,0 +1,63 @@ +diff --git a/src/ipelib/ipebase.cpp b/src/ipelib/ipebase.cpp +index 63de035..f4f102e 100644 +--- a/src/ipelib/ipebase.cpp ++++ b/src/ipelib/ipebase.cpp +@@ -557,55 +557,9 @@ Stream &Stream::operator<<(int i) + //! Output double. + Stream &Stream::operator<<(double d) + { +- char buf[30]; +- if (d < 0.0) { +- putChar('-'); +- d = -d; +- } +- if (d >= 1e9) { +- // PDF will not be able to read this, but we have to write something. +- // Such large numbers should only happen if something is wrong. +- std::sprintf(buf, "%g", d); +- putCString(buf); +- } else if (d < 1e-8) { +- putChar('0'); +- } else { +- // Print six significant digits, but omit trailing zeros. +- // Probably I'll want to have adjustable precision later. +- int factor; +- if (d > 1000.0) +- factor = 100L; +- else if (d > 100.0) +- factor = 1000L; +- else if (d > 10.0) +- factor = 10000L; +- else if (d > 1.0) +- factor = 100000L; +- else if (d > 0.1) +- factor = 1000000L; +- else if (d > 0.01) +- factor = 10000000L; +- else +- factor = 100000000L; +- double dd = trunc(d); +- int intpart = int(dd + 0.5); +- // 10^9 < 2^31 +- int v = int(factor * (d - dd) + 0.5); +- if (v >= factor) { +- ++intpart; +- v -= factor; +- } +- std::sprintf(buf, "%d", intpart); +- putCString(buf); +- int mask = factor / 10; +- if (v != 0) { +- putChar('.'); +- while (v != 0) { +- putChar('0' + v / mask); +- v = (10 * v) % factor; +- } +- } +- } ++ char buf[101]; ++ std::snprintf(buf, 100, "%.20g", d); ++ putCString(buf); + return *this; + } +