Commit 75b2a034 authored by Arturo Espinosa's avatar Arturo Espinosa
Browse files

Remove all spaces before the ';'.



Remove all spaces before the ';'.

Miguel
parent 994e67cc
......@@ -59,28 +59,22 @@ Future value interest factor of annuities
double calculate_pvif (double rate, double nper)
{
return ( pow ( 1 + rate, nper) );
return (pow (1+rate, nper));
}
double calculate_fvif (double rate, double nper)
{
return ( 1.0 / calculate_pvif(rate,nper) );
return (1.0 / calculate_pvif (rate,nper));
}
double calculate_pvifa (double rate, double nper)
{
return ( ( 1.0 / rate ) - ( 1.0 / ( rate * pow(1+rate, nper) ))) ;
return ((1.0 / rate) - (1.0 / (rate * pow (1+rate, nper))));
}
double calculate_fvifa (double rate, double nper)
{
return ( (pow(1+rate, nper) - 1) / rate);
return ((pow (1+rate, nper) - 1) / rate);
}
/*
......@@ -93,21 +87,20 @@ PR(x) = PR(0) * ( 1 + rate ) ^ x + PMT * ( ( 1 + rate ) ^ x - 1 ) / rate )
double calculate_principal (double starting_principal, double payment, double rate, double period)
{
return ( starting_principal * pow( 1.0 + rate, period ) + payment * ( ( pow(1+rate, period) - 1 ) / rate ));
return (starting_principal * pow (1.0 + rate, period) + payment *
((pow(1+rate, period) - 1) / rate));
}
double calculate_pmt (double rate, double nper, double pv, double fv, int type){
double calculate_pmt (double rate, double nper, double pv, double fv, int type)
{
double pvif, fvifa;
double pvif, fvifa;
/* Calculate the PVIF and FVIFA */
pvif = calculate_pvif(rate,nper);
fvifa = calculate_fvifa(rate,nper);
return (( (-1.0) * pv * pvif - fv ) / ( ( 1.0 + rate * type) * fvifa ));
pvif = calculate_pvif (rate,nper);
fvifa = calculate_fvifa (rate,nper);
return (((-1.0) * pv * pvif - fv ) / ((1.0 + rate * type) * fvifa));
}
......@@ -234,7 +227,7 @@ gnumeric_sln (struct FunctionDefinition *i, Value *argv [], char **error_string)
return NULL;
}
return value_new_float ( (cost - salvage_value) / life ) ;
return value_new_float ((cost - salvage_value) / life);
}
......@@ -267,7 +260,7 @@ gnumeric_syd (struct FunctionDefinition *i, Value *argv [], char **error_string)
life = value_get_as_float (argv [2]);
period = value_get_as_float (argv [3]);
return value_new_float ( ( (cost - salvage_value) * (life-period+1) * 2 ) / ( life * (life + 1.0) )) ;
return value_new_float (((cost - salvage_value) * (life - period + 1) * 2) / (life * (life + 1.0)));
}
......@@ -290,11 +283,11 @@ gnumeric_dollarde (struct FunctionDefinition *i, Value *argv [], char **error_st
int fraction, n, tmp;
float_t floored, rest;
fractional_dollar = value_get_as_float (argv [0]) ;
fraction = value_get_as_int (argv [1]) ;
fractional_dollar = value_get_as_float (argv [0]);
fraction = value_get_as_int (argv [1]);
if (fraction <= 0) {
*error_string = _("#NUM!") ;
*error_string = _("#NUM!");
return NULL;
}
......@@ -307,7 +300,7 @@ gnumeric_dollarde (struct FunctionDefinition *i, Value *argv [], char **error_st
rest = fractional_dollar - floored;
tmp = (int) (rest * pow(10, n));
return value_new_float (floored + ((float_t) tmp / fraction)) ;
return value_new_float (floored + ((float_t) tmp / fraction));
}
static char *help_dollarfr = {
......@@ -329,11 +322,11 @@ gnumeric_dollarfr (struct FunctionDefinition *i, Value *argv [], char **error_st
int fraction, n, tmp;
float_t floored, rest;
fractional_dollar = value_get_as_float (argv [0]) ;
fraction = value_get_as_int (argv [1]) ;
fractional_dollar = value_get_as_float (argv [0]);
fraction = value_get_as_int (argv [1]);
if (fraction <= 0) {
*error_string = _("#NUM!") ;
*error_string = _("#NUM!");
return NULL;
}
......@@ -346,7 +339,7 @@ gnumeric_dollarfr (struct FunctionDefinition *i, Value *argv [], char **error_st
rest = fractional_dollar - floored;
tmp = (int) (rest * fraction);
return value_new_float (floored + ((float_t) tmp / pow(10, n))) ;
return value_new_float (floored + ((float_t) tmp / pow(10, n)));
}
......@@ -390,10 +383,10 @@ static char *help_npv = {
};
typedef struct {
int first ;
guint32 num ;
float_t rate ;
float_t sum ;
int first;
guint32 num;
float_t rate;
float_t sum;
} financial_npv_t;
static int
......@@ -407,20 +400,20 @@ callback_function_npv (Sheet *sheet, Value *value, char **error_string, void *cl
mm->rate = value->v.v_int;
else
mm->sum += value->v.v_int / pow(1+mm->rate, mm->num);
mm->num++ ;
mm->num++;
break;
case VALUE_FLOAT:
if (mm->first == TRUE)
mm->rate = value->v.v_float;
else
mm->sum += value->v.v_float / pow(1+mm->rate, mm->num);
mm->num++ ;
break ;
mm->num++;
break;
default:
/* ignore strings */
break;
}
mm->first = FALSE ;
mm->first = FALSE;
return TRUE;
}
......@@ -462,11 +455,10 @@ gnumeric_fv (struct FunctionDefinition *i, Value *argv [], char **error_string)
pv = value_get_as_float (argv [3]);
type = value_get_as_int (argv [4]);
pvif = calculate_pvif(rate,nper);
fvifa = calculate_fvifa(rate,nper);
return value_new_float ( -1.0 * ( ( pv * pvif ) + pmt * ( 1.0 + rate * type ) * fvifa ) );
pvif = calculate_pvif (rate, nper);
fvifa = calculate_fvifa (rate, nper);
return value_new_float (-1.0 * ((pv * pvif) + pmt * (1.0 + rate * type) * fvifa));
}
......@@ -490,8 +482,7 @@ gnumeric_pmt (struct FunctionDefinition *i, Value *argv [], char **error_string)
fv = value_get_as_float (argv [3]);
type = value_get_as_int (argv [4]);
return value_new_float ( calculate_pmt(rate,nper,pv,fv,type) );
return value_new_float (calculate_pmt (rate, nper, pv, fv, type));
}
......@@ -529,12 +520,12 @@ gnumeric_ipmt (struct FunctionDefinition *i, Value *argv [], char **error_string
/* First calculate the payment */
pmt = calculate_pmt(rate,nper,pv,fv,type);
pmt = calculate_pmt (rate, nper, pv, fv, type);
/* Now we need to calculate the amount of money going towards the
principal */
return value_new_float ( calculate_principal(pv,pmt,rate,per-1) * rate * (-1.0) );
return value_new_float (calculate_principal (pv, pmt, rate, per-1) * rate * (-1.0));
}
......@@ -577,12 +568,14 @@ gnumeric_ppmt (struct FunctionDefinition *i, Value *argv [], char **error_string
/* This piece of code was copied from gnumeric_ppmt */
/* Now we need to calculate the amount of money going towards the
principal */
/*
* Now we need to calculate the amount of money going towards the
* principal
*/
ipmt = ( calculate_principal(pv,pmt,rate,per-1) * rate * (-1.0) );
ipmt = (calculate_principal (pv, pmt, rate, per-1) * rate * (-1.0));
return value_new_float ( pmt - ipmt );
return value_new_float (pmt - ipmt);
}
......@@ -606,7 +599,9 @@ gnumeric_nper (struct FunctionDefinition *i, Value *argv [], char **error_string
fv = value_get_as_float (argv [3]);
type = value_get_as_int (argv [4]);
return value_new_float ( log (( pmt * ( 1.0 + rate * type ) - fv * rate ) / ( pv * rate + pmt * ( 1.0 + rate * type ) ) ) / log ( 1.0 + rate ));
return value_new_float (
log ((pmt * (1.0 + rate * type) - fv * rate) /
(pv * rate + pmt * (1.0 + rate * type))) / log (1.0 + rate));
}
......@@ -637,7 +632,7 @@ gnumeric_duration (struct FunctionDefinition *i, Value *argv [], char **error_st
return NULL;
}
return value_new_float ( log( fv / pv ) / log(1.0 + rate) );
return value_new_float (log (fv / pv) / log (1.0 + rate));
}
......
......@@ -615,14 +615,14 @@ gnumeric_ceiling (struct FunctionDefinition *i,
if (!VALUE_IS_NUMBER(argv[0]) ||
!VALUE_IS_NUMBER(argv[1])) {
*error_string = _("#VALUE!") ;
*error_string = _("#VALUE!");
return NULL;
}
x = value_get_as_float (argv[0]);
significance = value_get_as_float (argv[1]);
if ((x < 0.0 && significance > 0.0) ||
(x > 0.0 && significance < 0.0)) {
*error_string = _("#NUM!") ;
*error_string = _("#NUM!");
return NULL;
}
if (significance < 0) {
......@@ -1040,28 +1040,29 @@ gnumeric_mod (struct FunctionDefinition *i,
{
int a,b;
a = value_get_as_int (argv[0]) ;
b = value_get_as_int (argv[1]) ;
a = value_get_as_int (argv[0]);
b = value_get_as_int (argv[1]);
/* Obscure handling of C's mod function */
if (a<0) a = -a ;
if (a<0) { /* -0 */
*error_string = _("#NUM!") ;
return NULL ;
if (a<0) a = -a;
if (a < 0){ /* -0 */
*error_string = _("#NUM!");
return NULL;
}
if (b<0) {
a = -a ;
b = -b ;
if (b < 0){
a = -a;
b = -b;
}
if (b<0) { /* -0 */
*error_string = _("#NUM!") ;
return NULL ;
if (b < 0) { /* -0 */
*error_string = _("#NUM!");
return NULL;
}
if (b==0) {
*error_string = _("#DIV/0!") ;
return NULL ;
if (b == 0) {
*error_string = _("#DIV/0!");
return NULL;
}
return value_new_int (a%b) ;
return value_new_int (a % b);
}
static char *help_radians = {
......@@ -1164,12 +1165,13 @@ static Value *
gnumeric_sqrt (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
float_t x = value_get_as_float (argv[0]) ;
if (x<0) {
*error_string = _("#NUM!") ;
return NULL ;
float_t x = value_get_as_float (argv [0]);
if (x < 0){
*error_string = _("#NUM!");
return NULL;
}
return value_new_float (sqrt(x)) ;
return value_new_float (sqrt (x));
}
static char *help_sum = {
......@@ -1670,11 +1672,12 @@ gnumeric_factdouble (struct FunctionDefinition *i,
number = value_get_as_int (argv[0]);
if (number < 0) {
*error_string = _("#NUM!") ;
return NULL ;
*error_string = _("#NUM!");
return NULL;
}
for (n=number; n > 0; n-=2)
for (n = number; n > 0; n-= 2)
product *= n;
return value_new_int (product);
}
......@@ -1772,8 +1775,8 @@ gnumeric_randbetween (struct FunctionDefinition *i,
bottom = value_get_as_int (argv[0]);
top = value_get_as_int (argv[1]);
if (bottom > top) {
*error_string = _("#NUM!") ;
return NULL ;
*error_string = _("#NUM!");
return NULL;
}
r = bottom + floor ((top + 1.0 - bottom) * random_01 ());
......@@ -2011,47 +2014,47 @@ gnumeric_roman (struct FunctionDefinition *fd,
form = value_get_as_int (argv[1]);
if (n < 0 || n > 3999) {
*error_string = _("#VALUE!") ;
return NULL ;
*error_string = _("#VALUE!");
return NULL;
}
if (n == 0)
return value_new_string ("");
if (form < 0 || form > 4) {
*error_string = _("#NUM!") ;
return NULL ;
*error_string = _("#NUM!");
return NULL;
}
if (form > 0) {
*error_string = _("#Unimplemented!") ;
return NULL ;
*error_string = _("#Unimplemented!");
return NULL;
}
for (i=j=0; dec > 1; dec/=10, j+=2) {
for ( ; n>0; i++) {
if (n >= dec) {
buf[i] = letter[j];
for (i = j = 0; dec > 1; dec /= 10, j+=2){
for (; n > 0; i++){
if (n >= dec){
buf[i] = letter [j];
n -= dec;
} else if (n >= dec - dec/10) {
buf[i++] = letter[j+2];
buf[i] = letter[j];
} else if (n >= dec - dec/10){
buf [i++] = letter [j+2];
buf [i] = letter [j];
n -= dec - dec/10;
} else if (n >= dec/2) {
buf[i] = letter[j+1];
} else if (n >= dec/2){
buf [i] = letter [j+1];
n -= dec/2;
} else if (n >= dec/2 - dec/10) {
buf[i++] = letter[j+2];
buf[i] = letter[j+1];
} else if (n >= dec/2 - dec/10){
buf [i++] = letter [j+2];
buf [i] = letter [j+1];
n -= dec/2 - dec/10;
} else if (dec == 10) {
buf[i] = letter[j+2];
} else if (dec == 10){
buf [i] = letter [j+2];
n--;
} else
break;
}
}
buf[i] = '\0';
buf [i] = '\0';
return value_new_string (buf);
}
......
......@@ -646,13 +646,13 @@ cell_set_text_simple (Cell *cell, const char *text)
while (isspace (*p)) p++;
l = strtol (p, &end, 10);
if (p != end && *end == 0) {
if (p != end && *end == 0){
/* It is an int. FIXME: long/int confusion here. */
cell->value = value_new_int (l);
} else {
double d;
d = strtod (p, &end);
if (p != end && *end == 0) {
if (p != end && *end == 0){
/* It is a floating point number. */
cell->value = value_new_float ((float_t)d);
} else {
......@@ -728,7 +728,7 @@ cell_set_formula_tree_simple (Cell *cell, ExprTree *formula)
cell_modified (cell);
if (cell->parsed_node) {
if (cell->parsed_node){
sheet_cell_formula_unlink (cell);
expr_tree_unref (cell->parsed_node);
}
......
......@@ -19,7 +19,7 @@ static GHashTable *dependency_hash;
void
cell_eval (Cell *cell)
{
char *error_msg = _("ERROR") ;
char *error_msg = _("ERROR");
Value *v;
g_return_if_fail (cell != NULL);
......@@ -298,7 +298,7 @@ cell_drop_dependencies (Cell *cell)
if (remove_list){
GList *l = remove_list;
for (; l ; l = l->next){
for (; l; l = l->next){
g_hash_table_remove (dependency_hash, l->data);
g_free (l->data);
}
......@@ -520,7 +520,7 @@ workbook_recalc (Workbook *wb)
cell_eval (cell);
deps = cell_get_dependencies (cell->sheet, cell->col->pos, cell->row->pos);
for (l = deps ; l; l = l->next){
for (l = deps; l; l = l->next){
Cell *one_cell;
one_cell = l->data;
......
......@@ -19,7 +19,7 @@ static GHashTable *dependency_hash;
void
cell_eval (Cell *cell)
{
char *error_msg = _("ERROR") ;
char *error_msg = _("ERROR");
Value *v;
g_return_if_fail (cell != NULL);
......@@ -298,7 +298,7 @@ cell_drop_dependencies (Cell *cell)
if (remove_list){
GList *l = remove_list;
for (; l ; l = l->next){
for (; l; l = l->next){
g_hash_table_remove (dependency_hash, l->data);
g_free (l->data);
}
......@@ -520,7 +520,7 @@ workbook_recalc (Workbook *wb)
cell_eval (cell);
deps = cell_get_dependencies (cell->sheet, cell->col->pos, cell->row->pos);
for (l = deps ; l; l = l->next){
for (l = deps; l; l = l->next){
Cell *one_cell;
one_cell = l->data;
......
......@@ -492,7 +492,7 @@ value_array_resize (Value *v, guint width, guint height)
tmp = v->v.array.vals;
v->v.array.vals = newval->v.array.vals;
newval->v.array.vals = tmp ;
newval->v.array.vals = tmp;
value_release (newval);
v->v.array.x = width;
......
......@@ -59,28 +59,22 @@ Future value interest factor of annuities
double calculate_pvif (double rate, double nper)
{
return ( pow ( 1 + rate, nper) );
return (pow (1+rate, nper));
}
double calculate_fvif (double rate, double nper)
{
return ( 1.0 / calculate_pvif(rate,nper) );
return (1.0 / calculate_pvif (rate,nper));
}
double calculate_pvifa (double rate, double nper)
{
return ( ( 1.0 / rate ) - ( 1.0 / ( rate * pow(1+rate, nper) ))) ;
return ((1.0 / rate) - (1.0 / (rate * pow (1+rate, nper))));
}
double calculate_fvifa (double rate, double nper)
{
return ( (pow(1+rate, nper) - 1) / rate);
return ((pow (1+rate, nper) - 1) / rate);
}
/*
......@@ -93,21 +87,20 @@ PR(x) = PR(0) * ( 1 + rate ) ^ x + PMT * ( ( 1 + rate ) ^ x - 1 ) / rate )
double calculate_principal (double starting_principal, double payment, double rate, double period)
{
return ( starting_principal * pow( 1.0 + rate, period ) + payment * ( ( pow(1+rate, period) - 1 ) / rate ));
return (starting_principal * pow (1.0 + rate, period) + payment *
((pow(1+rate, period) - 1) / rate));
}
double calculate_pmt (double rate, double nper, double pv, double fv, int type){
double calculate_pmt (double rate, double nper, double pv, double fv, int type)
{
double pvif, fvifa;
double pvif, fvifa;
/* Calculate the PVIF and FVIFA */
pvif = calculate_pvif(rate,nper);
fvifa = calculate_fvifa(rate,nper);
return (( (-1.0) * pv * pvif - fv ) / ( ( 1.0 + rate * type) * fvifa ));
pvif = calculate_pvif (rate,nper);
fvifa = calculate_fvifa (rate,nper);
return (((-1.0) * pv * pvif - fv ) / ((1.0 + rate * type) * fvifa));
}
......@@ -234,7 +227,7 @@ gnumeric_sln (struct FunctionDefinition *i, Value *argv [], char **error_string)
return NULL;
}
return value_new_float ( (cost - salvage_value) / life ) ;
return value_new_float ((cost - salvage_value) / life);
}
......@@ -267,7 +260,7 @@ gnumeric_syd (struct FunctionDefinition *i, Value *argv [], char **error_string)
life = value_get_as_float (argv [2]);
period = value_get_as_float (argv [3]);
return value_new_float ( ( (cost - salvage_value) * (life-period+1) * 2 ) / ( life * (life + 1.0) )) ;
return value_new_float (((cost - salvage_value) * (life - period + 1) * 2) / (life * (life + 1.0)));
}
......@@ -290,11 +283,11 @@ gnumeric_dollarde (struct FunctionDefinition *i, Value *argv [], char **error_st
int fraction, n, tmp;
float_t floored, rest;
fractional_dollar = value_get_as_float (argv [0]) ;
fraction = value_get_as_int (argv [1]) ;
fractional_dollar = value_get_as_float (argv [0]);
fraction = value_get_as_int (argv [1]);
if (fraction <= 0) {
*error_string = _("#NUM!") ;
*error_string = _("#NUM!");
return NULL;
}
......@@ -307,7 +300,7 @@ gnumeric_dollarde (struct FunctionDefinition *i, Value *argv [], char **error_st
rest = fractional_dollar - floored;
tmp = (int) (rest * pow(10, n));
return value_new_float (floored + ((float_t) tmp / fraction)) ;
return value_new_float (floored + ((float_t) tmp / fraction));
}
static char *help_dollarfr = {
......@@ -329,11 +322,11 @@ gnumeric_dollarfr (struct FunctionDefinition *i, Value *argv [], char **error_st