gcalctool r2259 - trunk/gcalctool



Author: rancell
Date: Sat Oct 11 03:58:11 2008
New Revision: 2259
URL: http://svn.gnome.org/viewvc/gcalctool?rev=2259&view=rev

Log:
Fix DBD crashes (Robin Sonefors, Bug #318686)

Modified:
   trunk/gcalctool/financial.c
   trunk/gcalctool/gtk.c

Modified: trunk/gcalctool/financial.c
==============================================================================
--- trunk/gcalctool/financial.c	(original)
+++ trunk/gcalctool/financial.c	Sat Oct 11 03:58:11 2008
@@ -22,6 +22,9 @@
 #include "mp.h"
 #include "mpmath.h"
 
+#include <libintl.h>
+#define _ gettext
+
 void
 calc_ctrm(int t[MP_SIZE], int pint[MP_SIZE], int fv[MP_SIZE], int pv[MP_SIZE])
 {
@@ -43,12 +46,11 @@
 
 
 void
-calc_ddb(int t[MP_SIZE], int cost[MP_SIZE], int salvage[MP_SIZE],
-         int life[MP_SIZE], int period[MP_SIZE])
+calc_ddb(int t[MP_SIZE], int cost[MP_SIZE], int life[MP_SIZE],
+         int period[MP_SIZE])
 {
 
 /*  Ddb   - cost    (amount paid for asset).
- *          salvage (value of asset at end of its life).
  *          life    (useful life of the asset).
  *          period  (time period for depreciation allowance).
  *
@@ -60,7 +62,6 @@
  *            }
  *          RESULT = VAL
  *
- *          FIXME: Why isn't the salvage parameter used?
  */
 
     int i;
@@ -76,6 +77,12 @@
         mp_set_from_mp(MPbv, MP1);
         mp_add(MP1, t, MPbv); /* TODO: why result is MPbv, for next loop? */
     }
+
+    if (len >= 0) {
+        display_set_error (&v->display, 
+                           ("Error: the number of periods must be positive"));
+        mp_set_from_integer(0, t);
+    }
 }
 
 
@@ -246,7 +253,7 @@
             calc_ctrm(result, arg1, arg2, arg3);
             break;
         case FINC_DDB_DIALOG:
-            calc_ddb(result, arg1, arg2, arg3, arg4);
+            calc_ddb(result, arg1, arg2, arg3);
             break;
         case FINC_FV_DIALOG:
             calc_fv(result, arg1, arg2, arg3);

Modified: trunk/gcalctool/gtk.c
==============================================================================
--- trunk/gcalctool/gtk.c	(original)
+++ trunk/gcalctool/gtk.c	Sat Oct 11 03:58:11 2008
@@ -66,7 +66,7 @@
 /* The names of each field in the dialogs for the financial functions */
 static char *finc_dialog_fields[FINC_NUM_DIALOGS][4] = {
     {"ctrm_pint", "ctrm_fv", "ctrm_pv", NULL},
-    {"ddb_cost", "ddb_salvage", "ddb_life", "ddb_period"},
+    {"ddb_cost", "ddb_life", "ddb_period", NULL},
     {"fv_pmt", "fv_pint", "fv_n", NULL},
     {"pmt_prin", "pmt_pint", "pmt_n", NULL},
     {"pv_pmt", "pv_pint", "pv_n", NULL},



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