1
Description: <short summary of the patch>
2
TODO: Put a short summary on the line above and replace this paragraph
3
with a longer explanation of this change. Complete the meta-information
4
with other relevant fields (see below for details). To make it easier, the
5
information below has been extracted from the changelog. Adjust it or drop
8
gcl (2.6.7a-1) unstable; urgency=high
10
* Accept Non-maintainer upload. (thanks David Prévot <taffit@debian.org>)
11
* Remove unused and non DFSG-compliant gmp3/gmp.* from source. (Closes: #695721)
12
* Show translated debconf templates, thanks to Denis Barbier for the
13
analysis and the proposed fixes. (Closes: #691946)
14
* trim excess digits from printed floats
15
Author: Camm Maguire <camm@debian.org>
16
Bug-Debian: http://bugs.debian.org/691946
17
Bug-Debian: http://bugs.debian.org/695721
20
The information above should follow the Patch Tagging Guidelines, please
21
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
22
are templates for supplementary fields that you might want to add:
24
Origin: <vendor|upstream|other>, <url of original patch>
25
Bug: <url in upstream bugtracker>
26
Bug-Debian: http://bugs.debian.org/<bugnumber>
27
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
28
Forwarded: <no|not-needed|url proving that it has been forwarded>
29
Reviewed-By: <name and email of someone who approved the patch>
30
Last-Update: <YYYY-MM-DD>
32
--- gcl-2.6.7a.orig/o/print.d
33
+++ gcl-2.6.7a/o/print.d
34
@@ -303,76 +303,99 @@ write_base(void)
36
object sSAprint_nansA;
41
+char_inc(char *b,char *p) {
46
+ memmove(p+1,p,strlen(p)+1);
49
+ } else if (*p=='9') {
60
+#define COMP(a_,b_,c_,d_) ((d_) ? strtod((a_),(b_))==(c_) : strtof((a_),(b_))==(float)(c_))
63
+truncate_double(char *b,double d,int dp) {
65
+ char c[FPRC+9],c1[FPRC+9],*p,*pp,*n;
72
+ for (p=c1;*p && *p!='e';p++);
73
+ pp=p>c1 && p[-1]!='.' ? p-1 : p;
74
+ for (;pp>c1 && pp[-1]=='0';pp--);
76
+ if (pp!=p && COMP(c1,&pp,d,dp))
77
+ k=truncate_double(n=c1,d,dp);
80
+ for (p=c;*p && *p!='e';p++);
81
+ if (p[-1]!='.' && char_inc(c,p-1) && COMP(c,&pp,d,dp)) {
82
+ j=truncate_double(c,d,dp);
89
+ if (n!=b) strcpy(b,n);
95
-edit_double(n, d, sp, s, ep)
102
- char *p, buff[FPRC + 9];
104
+edit_double(int n, double d, int *sp, char *s, int *ep) {
107
-/* if ((*((int *)&d +HIND) & 0x7ff00000) == 0x7ff00000)*/
109
- {if (sSAprint_nansA->s.s_dbind !=Cnil)
110
- {sprintf(s, "%e",d);
115
- FEerror("Can't print a non-number.",
118
- sprintf(buff, "%*.*e",FPRC+8,FPRC, d);
119
- if (buff[FPRC+3] != 'e') {
120
- sprintf(buff, "%*.*e",FPRC+7,FPRC,d);
121
- *ep = (buff[FPRC+5]-'0')*10 + (buff[FPRC+6]-'0');
123
- *ep = (buff[FPRC+5]-'0')*100 +
124
- (buff[FPRC+6]-'0')*10 + (buff[FPRC+7]-'0');
126
- if (buff[0] == '-')
129
- sprintf(buff, "%*.*e",FPRC+7,FPRC, d);
130
- /* "-D.MMMMMMMMMMMMMMMe+EE" */
131
- /* 0123456789012345678901 */
133
- if (buff[0] == '-')
135
- *ep = (buff[FPRC+5]-'0')*10 + (buff[FPRC+6]-'0');
138
- if (buff[FPRC+4] == '-')
144
- for (i = n - 1; i >= 0; --i)
156
- for (i = 0; i < n; i++)
159
- for (i = 0; i < FPRC+1; i++)
165
+ char *p, b[FPRC + 9];
168
+ if (!ISFINITE(d)) {
169
+ if (sSAprint_nansA->s.s_dbind !=Cnil) {
170
+ sprintf(s, "%e",d);
175
+ FEerror("Can't print a non-number.",0);}
177
+ sprintf(b, "%*.*e",FPRC+8,FPRC, d);
178
+ if (b[FPRC+3] != 'e') {
179
+ sprintf(b, "%*.*e",FPRC+7,FPRC,d);
180
+ *ep = (b[FPRC+5]-'0')*10 + (b[FPRC+6]-'0');
182
+ *ep = (b[FPRC+5]-'0')*100 + (b[FPRC+6]-'0')*10 + (b[FPRC+7]-'0');
186
+ if (b[FPRC+4] == '-')
189
+ truncate_double(b,d,n!=7);
191
+ if (b[2]=='0') (*ep)++;
194
+ for (i=0;i<n && i<FPRC+1 && isdigit(p[i]);i++)
202
@@ -405,7 +428,7 @@ bool shortp;
203
for (i = 0; i < exp; i++)
206
- if (buff[n-1] != '0')
207
+ if (buff[n-1] != '0' && buff[n-1])
209
if (exp == 0 && n == 0)
211
@@ -425,7 +448,7 @@ bool shortp;
215
- if (buff[n-1] != '0')
216
+ if (buff[n-1] != '0' && buff[n-1])
220
@@ -436,7 +459,7 @@ bool shortp;
224
- if (buff[n-1] != '0')
225
+ if (buff[n-1] != '0' && buff[n-1])
227
for (i = 2; i < n; i++)