X-Git-Url: https://git.sthu.org/?p=shuber-gentoo-overlay.git;a=blobdiff_plain;f=media-gfx%2Fipe%2Ffiles%2Fipe-outputprecision.patch;h=62346a366d610611cdf32274319dbd453099d086;hp=eb257021c34cecb5055360e76db0e705d56a0909;hb=78ae50321cdeed21e344b05d85fc8ce70455c7b9;hpb=c941ca354618ece70d9135e9206b85b8bb427418 diff --git a/media-gfx/ipe/files/ipe-outputprecision.patch b/media-gfx/ipe/files/ipe-outputprecision.patch index eb25702..62346a3 100644 --- a/media-gfx/ipe/files/ipe-outputprecision.patch +++ b/media-gfx/ipe/files/ipe-outputprecision.patch @@ -1,8 +1,8 @@ diff --git a/src/ipelib/ipebase.cpp b/src/ipelib/ipebase.cpp -index 63de035..f4f102e 100644 +index 63de035..19226ad 100644 --- a/src/ipelib/ipebase.cpp +++ b/src/ipelib/ipebase.cpp -@@ -557,55 +557,9 @@ Stream &Stream::operator<<(int i) +@@ -557,55 +557,50 @@ Stream &Stream::operator<<(int i) //! Output double. Stream &Stream::operator<<(double d) { @@ -10,7 +10,19 @@ index 63de035..f4f102e 100644 - if (d < 0.0) { - putChar('-'); - d = -d; -- } ++ // Maximum number of digits in total ++ const unsigned maxdigits=14; ++ ++ const unsigned bufsize=511; ++ char buf[bufsize+1]; ++ ++ // The number of digits left of '.' ++ int intpartsize = 0; ++ if( fabs(d)>=1.0 ) ++ { ++ snprintf(buf, bufsize, "%.0f", fabs(d)); ++ intpartsize = strlen(buf); + } - 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. @@ -53,10 +65,36 @@ index 63de035..f4f102e 100644 - putChar('0' + v / mask); - v = (10 * v) % factor; - } -- } -- } -+ char buf[101]; -+ std::snprintf(buf, 100, "%.20g", d); ++ ++ // The nubmer of digits right of '.' ++ int respartsize = maxdigits-intpartsize; ++ if( respartsize < 0 ) ++ respartsize = 0; ++ ++ // Building the format string and get the string conversion of d ++ char fmt[256]; ++ snprintf(fmt, 255, "%%%d.%df", intpartsize, respartsize); ++ snprintf(buf, bufsize, fmt, d); ++ ++ ++ // Truncate redundant zeros and '.' from the right ++ for(int i = strlen(buf)-1; i>=intpartsize; i--) ++ { ++ // Truncate all zeros from right-hand ++ if( buf[i] == '0' ) ++ { ++ buf[i] = '\0'; ++ continue; + } ++ ++ // Remove decimal dot without decimal digits ++ if( buf[i] == '.' ) ++ buf[i] = '\0'; ++ ++ break; + } ++ ++ + putCString(buf); return *this; }