/[gentoo-alt]/trunk/gnome-extra/gcalctool/files/gcalctool-5.5.42-hexdec-fix.patch
Gentoo

Contents of /trunk/gnome-extra/gcalctool/files/gcalctool-5.5.42-hexdec-fix.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 669 - (show annotations) (download)
Wed Aug 24 12:25:12 2005 UTC (9 years, 1 month ago) by flameeyes
File size: 4268 byte(s)
Fix for gcalctool under fbsd. See bug #103574.

1 --- gcalctool-5.5.42/gcalctool/functions.c 2005-03-14 14:08:33.000000000 -0500
2 +++ gcalctool-5.5.42.new/gcalctool/functions.c 2005-06-11 08:55:23.000000000 -0400
3 @@ -63,21 +63,6 @@
4 }
5 }
6
7 -
8 -void
9 -do_base(enum base_type b) /* Change the current base setting. */
10 -{
11 - v->base = b;
12 - put_resource(R_BASE, Rbstr[(int) v->base]);
13 - grey_buttons(v->base);
14 - refresh_display();
15 - v->pending = 0;
16 - if (v->rstate) {
17 - make_registers();
18 - }
19 -}
20 -
21 -
22 void
23 do_business() /* Perform special business mode calculations. */
24 {
25 @@ -614,7 +599,6 @@
26 } else assert(0);
27
28 return(do_tfunc(s, t, tfunc));
29 -
30 }
31
32
33 @@ -629,72 +613,25 @@
34 int
35 do_tfunc(int s[MP_SIZE], int t[MP_SIZE], enum trig_func tfunc)
36 {
37 - enum mode {
38 - normal = 0,
39 - inv = 1,
40 - hyp = 2,
41 - invhyp = 3,
42 - } mode;
43 -
44 - int inverse;
45 - int hyperbolic;
46 -
47 - if (!v->current) {
48 - return(-EINVAL);
49 - }
50 -
51 - inverse = (v->inverse) ? inv : 0;
52 - hyperbolic = (v->hyperbolic) ? hyp : 0;
53 -
54 - mode = (inverse | hyperbolic);
55 -
56 - switch (mode) {
57 - case normal:
58 - if (tfunc & SIN) {
59 - calc_trigfunc(sin_t, s, t);
60 - } else if (tfunc & COS) {
61 - calc_trigfunc(cos_t, s, t);
62 - } else if (tfunc & TAN) {
63 - calc_trigfunc(tan_t, s, t);
64 - }
65 - break;
66 -
67 - case inv:
68 - if (tfunc & SIN) {
69 - calc_trigfunc(asin_t, s, t);
70 - } else if (tfunc & COS) {
71 - calc_trigfunc(acos_t, s, t);
72 - } else if (tfunc & TAN) {
73 - calc_trigfunc(atan_t, s, t);
74 - }
75 - break;
76 -
77 - case hyp:
78 - if (tfunc & SIN) {
79 - calc_trigfunc(sinh_t, s, t);
80 - } else if (tfunc & COS) {
81 - calc_trigfunc(cosh_t, s, t);
82 - } else if (tfunc & TAN) {
83 - calc_trigfunc(tanh_t, s, t);
84 - }
85 - break;
86 -
87 - case invhyp:
88 - if (tfunc & SIN) {
89 - calc_trigfunc(asinh_t, s, t);
90 - } else if (tfunc & COS) {
91 - calc_trigfunc(acosh_t, s, t);
92 - } else if (tfunc & TAN) {
93 - calc_trigfunc(atanh_t, s, t);
94 - }
95 - break;
96 -
97 - default:
98 - assert(0);
99 - }
100 -
101 -
102 - return(0);
103 + // Assumes the SIN=0, COS=1, TAN=2
104 +
105 + assert(tfunc < 3);
106 +
107 + enum trig_func conv_table[3][4] = {
108 + {sin_t, asin_t, sinh_t, asinh_t},
109 + {cos_t, acos_t, cosh_t, acosh_t},
110 + {tan_t, atan_t, tanh_t, atanh_t},
111 + };
112 +
113 + int inverse = (v->inverse) ? 1 : 0;
114 + int hyperbolic = (v->hyperbolic) ? 2 : 0;
115 + int mode = (inverse | hyperbolic);
116 +
117 + if (!v->current) return -EINVAL;
118 +
119 + calc_trigfunc(conv_table[tfunc][mode], s, t);
120 +
121 + return 0;
122 }
123
124
125 @@ -715,6 +652,43 @@
126 clear_display(FALSE);
127 }
128
129 +void
130 +do_base(enum base_type b) /* Change the current base setting. */
131 +{
132 + v->base = b;
133 + put_resource(R_BASE, Rbstr[(int) v->base]);
134 + grey_buttons(v->base);
135 +
136 + switch (v->syntax) {
137 + case npa:
138 + v->pending = 0;
139 + if (v->rstate) {
140 + make_registers();
141 + }
142 + break;
143 +
144 + case exprs: {
145 + int MP[MP_SIZE];
146 + int ret = usable_num(MP);
147 + if (ret) {
148 + update_statusbar(_("No sane value to convert"),
149 + "gtk-dialog-error");
150 + } else {
151 + mpstr(v->e.ans, v->e.ansbak);
152 + mpstr(MP, v->e.ans);
153 + exp_replace("Ans");
154 + v->e.calc_complete = 1;
155 + make_registers();
156 + }
157 + }
158 + break;
159 +
160 + default:
161 + assert(0);
162 + }
163 +
164 + refresh_display();
165 +}
166
167 static void
168 do_constant()
169 @@ -778,8 +752,8 @@
170 static void
171 do_exchange() /* Exchange display with memory register. */
172 {
173 - int MPtemp[MP_SIZE];
174 - int MPexpr[MP_SIZE];
175 + int MPtemp[MP_SIZE];
176 + int MPexpr[MP_SIZE];
177
178 switch (v->syntax) {
179 case npa:
180 @@ -804,6 +778,10 @@
181 mpstr(MPtemp, v->e.ans);
182 // TODO: duplicated code in do_expression
183 mpstr(v->e.ans, v->e.ansbak);
184 + if (v->e.expbak) {
185 + free(v->e.expbak);
186 + v->e.expbak = NULL;
187 + }
188 v->e.expbak = gc_strdup(v->expression);
189 exp_replace("Ans");
190 v->e.calc_complete = 1;

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20