1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

dtcalc: Further remove K&R function prototypes and replace with ANSI.

This commit is contained in:
Peter Howkins 2012-11-19 14:28:52 +00:00
parent f4339cd58e
commit e56e3f74e6
2 changed files with 49 additions and 69 deletions

View file

@ -674,7 +674,7 @@ void MPstr_to_num P((char *, enum base_type, int *)) ;
void paren_disp P((char)) ; void paren_disp P((char)) ;
void process_event P((int)) ; void process_event P((int)) ;
void process_item P((int)) ; void process_item P((int)) ;
void process_parens P((int)) ; void process_parens P((char)) ;
void process_stack P((int, int, int)) ; void process_stack P((int, int, int)) ;
void process_str P((char *, enum menu_type)) ; void process_str P((char *, enum menu_type)) ;
void push_num P((int *)) ; void push_num P((int *)) ;

View file

@ -56,9 +56,11 @@ double mods[] = { 1.0, 1.0e-1, 1.0e-2, 1.0e-3, 1.0e-4,
1.0e-10, 1.0e-11, 1.0e-12, 1.0e-13, 1.0e-14, 1.0e-10, 1.0e-11, 1.0e-12, 1.0e-13, 1.0e-14,
1.0e-15, 1.0e-16, 1.0e-17, 1.0e-18, 1.0e-19 }; 1.0e-15, 1.0e-16, 1.0e-17, 1.0e-18, 1.0e-19 };
static void compute_i(double *target);
void void
do_accuracy() /* Set display accuracy. */ do_accuracy(void) /* Set display accuracy. */
{ {
int i ; int i ;
@ -74,14 +76,14 @@ do_accuracy() /* Set display accuracy. */
void void
do_ascii() /* Convert ASCII value. */ do_ascii(void) /* Convert ASCII value. */
{ {
show_ascii_frame() ; show_ascii_frame() ;
} }
void void
do_base() /* Change the current base setting. */ do_base(void) /* Change the current base setting. */
{ {
if (v->current == BASE_BIN) v->base = BIN ; if (v->current == BASE_BIN) v->base = BIN ;
else if (v->current == BASE_OCT) v->base = OCT ; else if (v->current == BASE_OCT) v->base = OCT ;
@ -93,8 +95,7 @@ do_base() /* Change the current base setting. */
} }
void void
set_base(base) set_base(enum base_type base)
enum base_type base ;
{ {
grey_buttons(v->base) ; grey_buttons(v->base) ;
show_display(v->MPdisp_val) ; show_display(v->MPdisp_val) ;
@ -105,7 +106,7 @@ enum base_type base ;
} }
void void
do_business() /* Perform special business mode calculations. */ do_business(void) /* Perform special business mode calculations. */
{ {
Boolean need_show = TRUE; Boolean need_show = TRUE;
char *display_number = NULL; char *display_number = NULL;
@ -463,7 +464,7 @@ do_business() /* Perform special business mode calculations. */
void void
do_calc() /* Perform arithmetic calculation and display result. */ do_calc(void) /* Perform arithmetic calculation and display result. */
{ {
double dval, dres ; double dval, dres ;
int MP1[MP_SIZE] ; int MP1[MP_SIZE] ;
@ -559,7 +560,7 @@ do_calc() /* Perform arithmetic calculation and display result. */
void void
do_clear() /* Clear the calculator display and re-initialise. */ do_clear(void) /* Clear the calculator display and re-initialise. */
{ {
clear_display() ; clear_display() ;
if (v->error) set_item(DISPLAYITEM, "") ; if (v->error) set_item(DISPLAYITEM, "") ;
@ -568,7 +569,7 @@ do_clear() /* Clear the calculator display and re-initialise. */
void void
do_constant() do_constant(void)
{ {
if (v->current >= '0' && v->current <= '9') if (v->current >= '0' && v->current <= '9')
{ {
@ -579,7 +580,7 @@ do_constant()
void void
do_delete() /* Remove the last numeric character typed. */ do_delete(void) /* Remove the last numeric character typed. */
{ {
if (strlen(v->display)) if (strlen(v->display))
v->display[strlen(v->display)-1] = '\0' ; v->display[strlen(v->display)-1] = '\0' ;
@ -608,7 +609,7 @@ do_delete() /* Remove the last numeric character typed. */
void void
do_exchange() /* Exchange display with memory register. */ do_exchange(void) /* Exchange display with memory register. */
{ {
int i, MPtemp[MP_SIZE] ; int i, MPtemp[MP_SIZE] ;
@ -625,7 +626,7 @@ do_exchange() /* Exchange display with memory register. */
void void
do_expno() /* Get exponential number. */ do_expno(void) /* Get exponential number. */
{ {
/* the financial state is false - last key was not a fin. key */ /* the financial state is false - last key was not a fin. key */
v->funstate = 0; v->funstate = 0;
@ -651,8 +652,7 @@ do_expno() /* Get exponential number. */
void void
do_factorial(MPval, MPres) /* Calculate the factorial of MPval. */ do_factorial(int *MPval, int *MPres) /* Calculate the factorial of MPval. */
int *MPval, *MPres ;
{ {
double val ; double val ;
int i, MPa[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE] ; int i, MPa[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE] ;
@ -696,13 +696,13 @@ int *MPval, *MPres ;
void void
do_frame() /* Exit dtcalc. */ do_frame(void) /* Exit dtcalc. */
{ {
exit(0) ; exit(0) ;
} }
void void
do_function() /* Perform a user defined function. */ do_function(void) /* Perform a user defined function. */
{ {
enum fcp_type scurwin ; enum fcp_type scurwin ;
int fno, scolumn, srow ; int fno, scolumn, srow ;
@ -724,7 +724,7 @@ do_function() /* Perform a user defined function. */
void void
do_immed() do_immed(void)
{ {
double dval, dval2 ; double dval, dval2 ;
int i, MP1[MP_SIZE], MP2[MP_SIZE] ; int i, MP1[MP_SIZE], MP2[MP_SIZE] ;
@ -854,14 +854,14 @@ do_immed()
void void
do_keys() /* Display/undisplay the dtcalc key values. */ do_keys(void) /* Display/undisplay the dtcalc key values. */
{ {
v->tstate = !v->tstate ; v->tstate = !v->tstate ;
redraw_buttons() ; redraw_buttons() ;
} }
void void
do_mode() /* Set special calculator mode. */ do_mode(void) /* Set special calculator mode. */
{ {
if (v->current == MODE_FIN) v->modetype = FINANCIAL ; if (v->current == MODE_FIN) v->modetype = FINANCIAL ;
else if (v->current == MODE_LOG) v->modetype = LOGICAL ; else if (v->current == MODE_LOG) v->modetype = LOGICAL ;
@ -873,13 +873,13 @@ do_mode() /* Set special calculator mode. */
void void
do_none() /* Null routine for empty buttons. */ do_none(void) /* Null routine for empty buttons. */
{ {
} }
void void
do_number() do_number(void)
{ {
char nextchar ; char nextchar ;
int len, n ; int len, n ;
@ -924,7 +924,7 @@ do_number()
void void
do_numtype() /* Set number type (engineering, fixed or scientific). */ do_numtype(void) /* Set number type (engineering, fixed or scientific). */
{ {
if (v->current == DISP_ENG) v->dtype = ENG ; if (v->current == DISP_ENG) v->dtype = ENG ;
else if (v->current == DISP_FIX) v->dtype = FIX ; else if (v->current == DISP_FIX) v->dtype = FIX ;
@ -934,8 +934,7 @@ do_numtype() /* Set number type (engineering, fixed or scientific). */
set_numtype(v->dtype); set_numtype(v->dtype);
} }
set_numtype( dtype ) set_numtype(enum num_type dtype)
enum num_type dtype ;
{ {
v->pending = 0 ; v->pending = 0 ;
show_display(v->MPdisp_val) ; show_display(v->MPdisp_val) ;
@ -945,7 +944,7 @@ enum num_type dtype ;
} }
void void
do_paren() do_paren(void)
{ {
char *ptr ; char *ptr ;
double tmpdb; double tmpdb;
@ -1042,7 +1041,7 @@ do_paren()
} }
void void
do_pending() do_pending(void)
{ {
/* the financial state is false - last key was not a fin. key */ /* the financial state is false - last key was not a fin. key */
@ -1111,7 +1110,7 @@ do_pending()
void void
do_point() /* Handle numeric point. */ do_point(void) /* Handle numeric point. */
{ {
/* the financial state is false - last key was not a fin. key */ /* the financial state is false - last key was not a fin. key */
v->funstate = 0; v->funstate = 0;
@ -1134,7 +1133,7 @@ do_point() /* Handle numeric point. */
void void
do_portion() do_portion(void)
{ {
int MP1[MP_SIZE] ; int MP1[MP_SIZE] ;
@ -1161,7 +1160,7 @@ do_portion()
void void
do_shift() /* Perform bitwise shift on display value. */ do_shift(void) /* Perform bitwise shift on display value. */
{ {
int MPtemp[MP_SIZE], shift ; int MPtemp[MP_SIZE], shift ;
BOOLEAN temp ; BOOLEAN temp ;
@ -1189,7 +1188,7 @@ do_shift() /* Perform bitwise shift on display value. */
void void
do_sto_rcl() /* Save/restore value to/from memory register. */ do_sto_rcl(void) /* Save/restore value to/from memory register. */
{ {
int i, MPn[MP_SIZE], n ; int i, MPn[MP_SIZE], n ;
@ -1240,7 +1239,7 @@ do_sto_rcl() /* Save/restore value to/from memory register. */
void void
do_trig() /* Perform all trigonometric functions. */ do_trig(void) /* Perform all trigonometric functions. */
{ {
int i, MPtemp[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE] ; int i, MPtemp[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE] ;
double cval ; double cval ;
@ -1349,7 +1348,7 @@ do_trig() /* Perform all trigonometric functions. */
void void
do_trigtype() /* Change the current trigonometric type. */ do_trigtype(void) /* Change the current trigonometric type. */
{ {
if (v->current == TRIG_DEG) v->ttype = DEG ; if (v->current == TRIG_DEG) v->ttype = DEG ;
else if (v->current == TRIG_GRA) v->ttype = GRAD ; else if (v->current == TRIG_GRA) v->ttype = GRAD ;
@ -1369,8 +1368,7 @@ do_trigtype() /* Change the current trigonometric type. */
BOOLEAN BOOLEAN
ibool(x) ibool(double x)
double x ;
{ {
BOOLEAN p ; BOOLEAN p ;
@ -1386,8 +1384,7 @@ double x ;
} }
BOOLEAN BOOLEAN
ibool2(x) ibool2(double x)
double x ;
{ {
BOOLEAN p ; BOOLEAN p ;
@ -1425,8 +1422,7 @@ double x ;
*/ */
void void
mpacos(MPx, MPretval) mpacos(int *MPx, int *MPretval)
int *MPx, *MPretval ;
{ {
int MP0[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE] ; int MP0[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE] ;
int MPn1[MP_SIZE], MPpi[MP_SIZE], MPy[MP_SIZE], val ; int MPn1[MP_SIZE], MPpi[MP_SIZE], MPy[MP_SIZE], val ;
@ -1472,8 +1468,7 @@ int *MPx, *MPretval ;
*/ */
void void
mpacosh(MPx, MPretval) mpacosh(int *MPx, int *MPretval)
int *MPx, *MPretval ;
{ {
int MP1[MP_SIZE], val ; int MP1[MP_SIZE], val ;
@ -1503,8 +1498,7 @@ int *MPx, *MPretval ;
*/ */
void void
mpasinh(MPx, MPretval) mpasinh(int *MPx, int *MPretval)
int *MPx, *MPretval ;
{ {
int MP1[MP_SIZE], val ; int MP1[MP_SIZE], val ;
@ -1525,8 +1519,7 @@ int *MPx, *MPretval ;
*/ */
void void
mpatanh(MPx, MPretval) mpatanh(int *MPx, int *MPretval)
int *MPx, *MPretval ;
{ {
int MP0[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE] ; int MP0[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE] ;
int MP3[MP_SIZE], MPn1[MP_SIZE], val ; int MP3[MP_SIZE], MPn1[MP_SIZE], val ;
@ -1561,8 +1554,7 @@ int *MPx, *MPretval ;
*/ */
void void
mplog10(MPx, MPretval) mplog10(int *MPx, int *MPretval)
int *MPx, *MPretval ;
{ {
int MP1[MP_SIZE], MP2[MP_SIZE], n ; int MP1[MP_SIZE], MP2[MP_SIZE], n ;
@ -1575,8 +1567,7 @@ int *MPx, *MPretval ;
void void
process_parens(current) process_parens(char current)
char current ;
{ {
int i ; int i ;
int last_lpar ; /* Position in stack of last left paren. */ int last_lpar ; /* Position in stack of last left paren. */
@ -1660,8 +1651,7 @@ char current ;
void void
push_num(MPval) /* Try to push value onto the numeric stack. */ push_num(int *MPval) /* Try to push value onto the numeric stack. */
int *MPval ;
{ {
if (v->numsptr < 0) return ; if (v->numsptr < 0) return ;
if (v->numsptr >= MAXSTACK) if (v->numsptr >= MAXSTACK)
@ -1683,8 +1673,7 @@ int *MPval ;
void void
push_op(val) /* Try to push value onto the operand stack. */ push_op(int val) /* Try to push value onto the operand stack. */
int val ;
{ {
if (v->opsptr < 0) return ; if (v->opsptr < 0) return ;
if (v->opsptr >= MAXSTACK) if (v->opsptr >= MAXSTACK)
@ -1699,8 +1688,7 @@ int val ;
void void
save_pending_values(val) save_pending_values(int val)
int val ;
{ {
int n ; int n ;
@ -1717,8 +1705,7 @@ int val ;
double double
setbool(p) setbool(BOOLEAN p)
BOOLEAN p ;
{ {
BOOLEAN q ; BOOLEAN q ;
double val ; double val ;
@ -1731,9 +1718,7 @@ BOOLEAN p ;
} }
double double
do_round(result, ndigits) do_round(double result, int ndigits)
double result;
int ndigits;
{ {
char buf2[40], buffer[100]; char buf2[40], buffer[100];
int temp; int temp;
@ -1765,10 +1750,7 @@ int ndigits;
} }
BOOLEAN BOOLEAN
try_compute_i(guess, result, method) try_compute_i(double guess, double *result, int method)
double guess;
double *result;
int method;
{ {
double sum_pos, sum_pos_prime, sum_neg, sum_neg_prime, w = guess; double sum_pos, sum_pos_prime, sum_neg, sum_neg_prime, w = guess;
double new_w; double new_w;
@ -1887,8 +1869,8 @@ int method;
return TRUE; return TRUE;
} }
compute_i(target) static void
double *target; compute_i(double *target)
{ {
double p[3]; double p[3];
double first_period, last_period; double first_period, last_period;
@ -1952,9 +1934,7 @@ double *target;
} }
int int
count_sign_changes(cf, count) count_sign_changes(double *cf, int count)
double *cf;
int count;
{ {
int i, curr_sign = 0, result = 0; int i, curr_sign = 0, result = 0;