gcalctool r2038 - in trunk: . gcalctool



Author: rancell
Date: Mon Mar 24 09:54:46 2008
New Revision: 2038
URL: http://svn.gnome.org/viewvc/gcalctool?rev=2038&view=rev

Log:
Bug #524091 - First patch from Klaus Niederkrueger applied.


Modified:
   trunk/ChangeLog
   trunk/gcalctool/display.c
   trunk/gcalctool/functions.c
   trunk/gcalctool/mpmath.c

Modified: trunk/gcalctool/display.c
==============================================================================
--- trunk/gcalctool/display.c	(original)
+++ trunk/gcalctool/display.c	Mon Mar 24 09:54:46 2008
@@ -121,12 +121,9 @@
 void
 clear_display(int initialise)
 {
-    int i;
-    
     v->pointed = 0;
     v->toclear = 1;
-    i = 0;
-    mpcim(&i, v->MPdisp_val);
+    do_zero(v->MPdisp_val);
     STRNCPY(v->display, make_number(v->MPdisp_val, v->base, FALSE), 
             MAXLINE - 1);
     ui_set_display(v->display, -1);
@@ -145,15 +142,12 @@
 void
 initialise()
 {
-    int i;
- 
     v->error         = 0;           /* Currently no display error. */
     v->cur_op        = -1;         /* No arithmetic operator defined yet. */
     v->old_cal_value = -1;
-    i = 0;
-    mpcim(&i, v->MPresult);         /* No previous result yet. */
-    mpcim(&i, v->MPdisp_val);         
-    mpcim(&i, v->MPlast_input);
+    do_zero(v->MPresult);         /* No previous result yet. */
+    do_zero(v->MPdisp_val);         
+    do_zero(v->MPlast_input);
   
     v->new_input = 1;               /* Value zero is on calculator display */
 
@@ -176,8 +170,7 @@
  
     optr = str;
     mpabs(MPnumber, MPval);
-    n = 0;
-    mpcim(&n, MP1);
+    do_zero(MP1);
     if (mplt(MPnumber, MP1)) {
         *optr++ = '-';
     }
@@ -290,8 +283,7 @@
     }
     optr = v->snum;
     mpabs(MPnumber, MPval);
-    n = 0;
-    mpcim(&n, MP1);
+    do_zero(MP1);
     if (mplt(MPnumber, MP1)) {
         *optr++ = '-';
     }
@@ -308,8 +300,7 @@
     mpcim(&n, MP1);
     mpdiv(MP1, MP10base, MPatmp);
 
-    n = 0;
-    mpcim(&n, MP1);
+    do_zero(MP1);
     if (!mpeq(MPmant, MP1)) {
         while (!eng && mpge(MPmant, MP10base)) {
             exp += 10;
@@ -393,8 +384,7 @@
     char *lnp = ui_get_localized_numeric_point();
     assert(lnp);
 
-    i = 0;
-    mpcim(&i, MPval);
+    do_zero(MPval);
     mpcim(&basevals[(int) base], MPbase);
 
     optr = str;
@@ -458,7 +448,7 @@
 void
 paren_disp(int key)
 {
-    int i, n;
+    int n;
     char *text;
 
 /*  If the character is a Delete, clear the whole line, and exit parenthesis
@@ -478,8 +468,7 @@
     case KEY_CLEAR:
         v->noparens = v->numsptr = 0;
         v->cur_op = -1;
-        i = 0;
-        mpcim(&i, v->MPdisp_val);
+        do_zero(v->MPdisp_val);
         show_display(v->MPdisp_val);
         return;
     case KEY_BACKSPACE:

Modified: trunk/gcalctool/functions.c
==============================================================================
--- trunk/gcalctool/functions.c	(original)
+++ trunk/gcalctool/functions.c	Mon Mar 24 09:54:46 2008
@@ -689,15 +689,12 @@
                 ui_set_statusbar(_("Error, operands must be integers"),
                                  "gtk-dialog-error");
             } else {
-                int val;
-
                 mpdiv(v->MPresult, v->MPdisp_val, MP1);
                 mpcmim(MP1, MP1);
                 mpmul(MP1, v->MPdisp_val, MP2);
                 mpsub(v->MPresult, MP2, v->MPresult);
 
-                val = 0;
-                mpcim(&val, MP1);
+                do_zero(MP1);
                 if ((mplt(v->MPdisp_val, MP1) && mpgt(v->MPresult, MP1)) ||
                     mplt(v->MPresult, MP1)) { 
                     mpadd(v->MPresult, v->MPdisp_val, v->MPresult);
@@ -1075,8 +1072,7 @@
 
     mpstr(MPval, MPa);
     mpcmim(MPval, MP1);
-    i = 0;
-    mpcim(&i, MP2);
+    do_zero(MP2);
     if (mpeq(MPval, MP1) && mpge(MPval, MP2)) {   /* Only positive integers. */
         i = 1;
         if (mpeq(MP1, MP2)) {                     /* Special case for 0! */

Modified: trunk/gcalctool/mpmath.c
==============================================================================
--- trunk/gcalctool/mpmath.c	(original)
+++ trunk/gcalctool/mpmath.c	Mon Mar 24 09:54:46 2008
@@ -170,8 +170,7 @@
 {
     int MP0[MP_SIZE], val;
 
-    val = 0;
-    mpcim(&val, MP0);
+    do_zero(MP0);
 
     /* Check if both x and y are zero. If yes, then just return 1.
      * See gcalctool bug #451286.
@@ -212,7 +211,7 @@
 	     int op2[MP_SIZE], 
 	     int result[MP_SIZE])
 {
-    int MP1[MP_SIZE], MP2[MP_SIZE], val;
+    int MP1[MP_SIZE], MP2[MP_SIZE];
 
     if (!is_integer(op1) || !is_integer(op2)) {
         return -EINVAL;
@@ -223,8 +222,7 @@
     mpmul(MP1, op2, MP2);
     mpsub(op1, MP2, result);
 
-    val = 0;
-    mpcim(&val, MP1);
+    do_zero(MP1);
     if ((mplt(op2, MP1) && mpgt(result, MP1)) || mplt(result, MP1)) { 
         mpadd(result, op2, result);
     }
@@ -361,8 +359,7 @@
     int MPn1[MP_SIZE], MPpi[MP_SIZE], MPy[MP_SIZE], val;
 
     mppi(MPpi);
-    val = 0;
-    mpcim(&val, MP0);
+    do_zero(MP0);
     val = 1;
     mpcim(&val, MP1);
     val = -1;
@@ -409,8 +406,7 @@
     mpcim(&val, MP1);
     if (mplt(MPx, MP1)) {
         doerr(_("Error"));
-        val = 0;
-        mpcim(&val, MPretval);
+        do_zero(MPretval);
     } else {
         mpmul(MPx, MPx, MP1);
         val = -1;
@@ -455,8 +451,7 @@
     int MP3[MP_SIZE], MPn1[MP_SIZE];
     int val;
 
-    val = 0;
-    mpcim(&val, MP0);
+    do_zero(MP0);
     val = 1;
     mpcim(&val, MP1);
     val = -1;
@@ -539,8 +534,7 @@
     int val;
     int MPbv[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE];
 
-    i = 0;
-    mpcim(&i, MPbv);
+    do_zero(MPbv);
     mpcmi(v->MPmvals[3], &len);
     for (i = 0; i < len; i++) {
         mpsub(v->MPmvals[0], MPbv, MP1);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]