[gs-cvs] rev 6949 - trunk/gs/src
lpd at ghostscript.com
lpd at ghostscript.com
Wed Aug 2 11:05:32 PDT 2006
Author: lpd
Date: 2006-08-02 11:05:32 -0700 (Wed, 02 Aug 2006)
New Revision: 6949
Modified:
trunk/gs/src/iutil.c
Log:
Changes cvs for reals: '<int>e<expt>' is no longer changed to
'<int>.0e<expt>', and 0.0001 (a boundary case) now converts to '0.0001'
rather than '1.0e+04'. THIS IS A NON-BACKWARD-COMPATIBLE CHANGE for
compatibility with Adobe interpreters.
Modified: trunk/gs/src/iutil.c
===================================================================
--- trunk/gs/src/iutil.c 2006-08-02 12:29:12 UTC (rev 6948)
+++ trunk/gs/src/iutil.c 2006-08-02 18:05:32 UTC (rev 6949)
@@ -471,7 +471,17 @@
break;
}
case t_real:
- sprintf(buf, "%g", op->value.realval);
+ /*
+ * The value 0.0001 is a boundary case that the Adobe interpreters
+ * print in f-format but at least some gs versions print in
+ * e-format, presumably because of differences in the underlying C
+ * library implementation. Work around this here.
+ */
+ if (op->value.realval == (float)0.0001) {
+ strcpy(buf, "0.0001");
+ } else {
+ sprintf(buf, "%g", op->value.realval);
+ }
ensure_dot(buf);
break;
default:
@@ -486,25 +496,14 @@
return (size > len);
}
/*
- * Make sure the converted form of a real number has a decimal point. This
- * is needed for compatibility with Adobe (and other) interpreters.
+ * Make sure the converted form of a real number has at least one of an 'e'
+ * or a decimal point, so it won't be mistaken for an integer.
*/
private void
ensure_dot(char *buf)
{
- if (strchr(buf, '.') == NULL) {
- char *ept = strchr(buf, 'e');
-
- if (ept == NULL)
- strcat(buf, ".0");
- else {
- /* Insert the .0 before the exponent. What a nuisance! */
- char buf1[30];
-
- strcpy(buf1, ept);
- strcpy(ept, ".0");
- strcat(ept, buf1);
- }
+ if (strchr(buf, '.') == NULL && strchr(buf, 'e') == NULL) {
+ strcat(buf, ".0");
}
}
More information about the gs-cvs
mailing list