1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

dtcalc: Resolve 82 warnings causing by enabling -Wall

This commit is contained in:
Peter Howkins 2012-11-20 14:49:40 +00:00
parent b64f79b1b8
commit ea96eb624d
9 changed files with 55 additions and 22 deletions

View file

@ -509,10 +509,8 @@ get_key_val(char *val, char *str)
void
get_label(int n)
{
int val ;
char *temp;
val = buttons[n].value ;
if (v->tstate)
temp = buttons[n].str2;
else
@ -696,7 +694,6 @@ get_options(int argc, char *argv[])
case 'v' : usage(v->progname) ;
break ;
default :
toolarg : /* Pick up generic tool arguments. */
usage(v->progname) ;
}
INC ;
@ -1146,7 +1143,7 @@ make_number(int *MPnumber, BOOLEAN mkFix)
val = fabs(number) ;
if (v->error) return(vstrs[(int) V_ERROR]) ;
if (v->dtype == ENG || v->dtype == SCI ||
v->dtype == FIX && val != 0.0 && (val > max_fix[(int) v->base]))
(v->dtype == FIX && val != 0.0 && (val > max_fix[(int) v->base])))
return(make_eng_sci(MPnumber)) ;
else if (v->dtype == FIX && val != 0.0 && mkFix)
{
@ -1220,6 +1217,10 @@ make_number(int *MPnumber, BOOLEAN mkFix)
else
return(make_fixed(MPnumber, MAX_DIGITS)) ;
}
else
{
return(make_fixed(MPnumber, MAX_DIGITS)) ;
}
}
else
return(make_fixed(MPnumber, MAX_DIGITS)) ;
@ -1503,6 +1504,9 @@ process_item(int n)
set_item(OPITEM, vstrs[(int) V_CLR]) ;
else
set_item(OPITEM, "") ;
break;
default:
break;
}
(*buttons[n].func)() ;
@ -1712,6 +1716,8 @@ write_rcfile(enum menu_type mtype, int exists, int cfno, char *val, char *commen
if (!strncmp(str, sval, 2)) FPUTS("#", tmpfd) ;
sval[0] = 'F' ;
if (!strncmp(str, sval, 2)) FPUTS("#", tmpfd) ;
break;
default: break;
}
}
FPRINTF(tmpfd, "%s", str) ;
@ -1726,6 +1732,8 @@ write_rcfile(enum menu_type mtype, int exists, int cfno, char *val, char *commen
case M_FUN :
if(strcmp(val, "") != 0)
FPRINTF(tmpfd, "\nF%1d %s %s\n", cfno, val, comment) ;
break;
default: break;
}
UNLINK(rcname) ;
rcfd = fopen(rcname, "w") ;

View file

@ -637,6 +637,7 @@ void do_none P(()) ;
void do_number P(()) ;
void do_numtype P(()) ;
void do_paren P(()) ;
void set_numtype P((enum num_type dtype));
void do_nothing P(()) ;
void do_pending P(()) ;
void do_point P(()) ;
@ -687,6 +688,7 @@ void save_cmdline P((int, char **)) ;
void save_pending_values P((int)) ;
void save_resources P((char *)) ;
void blank_display P(()) ;
void ErrorDialog P((char *string));
void set_item P((enum item_type, char *)) ;
void set_title P((enum fcp_type, char *)) ;
void show_ascii_frame P(()) ;

View file

@ -63,4 +63,7 @@ int ds_force_popup_on_screen P((Widget, int *, int *)) ;
void ds_get_screen_size P((Widget, int *, int *)) ;
void _DtGenericMapWindow P((Widget shell, Widget parent ));
void _DtChildPosition P((Widget w, Widget parent, Position *newX, Position *newY));
#endif /*!_ds_popup_h*/

View file

@ -82,5 +82,7 @@ set_text_str(struct tW_struct *w, enum text_type ttype, char *str)
XmStringFree(cstr) ;
break ;
case T_VALUE : XmTextFieldSetString(w->textfield, str) ;
break ;
default : break ;
}
}

View file

@ -35,6 +35,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/param.h>
#include <sys/stat.h>
#include "ds_xlib.h"

View file

@ -57,6 +57,7 @@ double mods[] = { 1.0, 1.0e-1, 1.0e-2, 1.0e-3, 1.0e-4,
1.0e-15, 1.0e-16, 1.0e-17, 1.0e-18, 1.0e-19 };
static void compute_i(double *target);
static int count_sign_changes(double *cf, int count);
void
@ -472,12 +473,15 @@ do_calc(void) /* Perform arithmetic calculation and display result. */
/* the financial state is false - last key was not a fin. key */
v->funstate = 0;
if (!(v->opsptr && !v->show_paren)) /* Don't do if processing parens. */
if (IS_KEY(v->current, KEY_EQ) && IS_KEY(v->old_cal_value, KEY_EQ))
if (v->new_input)
if (!(v->opsptr && !v->show_paren)) { /* Don't do if processing parens. */
if (IS_KEY(v->current, KEY_EQ) && IS_KEY(v->old_cal_value, KEY_EQ)) {
if (v->new_input) {
mpstr(v->MPdisp_val, v->MPresult) ;
else
} else {
mpstr(v->MPlast_input, v->MPdisp_val) ;
}
}
}
if (!IS_KEY(v->current, KEY_EQ) && IS_KEY(v->old_cal_value, KEY_EQ))
v->cur_op = '?' ;
@ -934,6 +938,7 @@ do_numtype(void) /* Set number type (engineering, fixed or scientific). */
set_numtype(v->dtype);
}
void
set_numtype(enum num_type dtype)
{
v->pending = 0 ;
@ -1734,7 +1739,7 @@ do_round(double result, int ndigits)
if (!temp)
return (temp > 0) ? HUGE : -HUGE;
#else
if (temp = isinf(result)) return (temp > 0) ? HUGE : -HUGE;
if ((temp = isinf(result))) return (temp > 0) ? HUGE : -HUGE;
#endif /* USL or __uxp__ */
#endif /* _AIX or __osf__ */
@ -1829,6 +1834,7 @@ try_compute_i(double guess, double *result, int method)
switch (method)
{
default:
case 1:
f = lsp - lsn;
f_prime = sum_pos_prime / sum_pos - sum_neg_prime / sum_neg;
@ -1856,7 +1862,7 @@ try_compute_i(double guess, double *result, int method)
#endif
#endif /* _AIX or __osf__ */
if (new_w == w || w != 0.0 && fabs((new_w - w) / w) < FIN_EPSILON)
if (new_w == w || (w != 0.0 && fabs((new_w - w) / w) < FIN_EPSILON))
break;
w = new_w;
@ -1933,7 +1939,7 @@ compute_i(double *target)
doerr(GETMESSAGE(5, 1, "ERROR: Computation Failed"));
}
int
static int
count_sign_changes(double *cf, int count)
{
int i, curr_sign = 0, result = 0;

View file

@ -37,6 +37,7 @@
#include <Xm/MessageB.h>
#include <Dt/Dt.h>
#include <Dt/Wsm.h>
#include <Dt/HelpDialog.h>
#include "calctool.h"

View file

@ -38,6 +38,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <signal.h>
#include <sys/param.h>
@ -229,7 +230,6 @@ static void event_proc P((Widget, XtPointer, XEvent *, Boolean *)) ;
static void frame_interpose P((Widget, XtPointer, XEvent *, Boolean *)) ;
static void menu_handler P((Widget, XtPointer, XEvent *, Boolean *)) ;
static void popupHandler P((Widget, XtPointer, XEvent *, Boolean *)) ;
static void make_mode_frame P((enum mode_type)) ;
static void new_cf_value P((Widget, XtPointer, XtPointer)) ;
static void do_memory P((Widget, XtPointer, XtPointer)) ;
static void switch_mode P((enum mode_type)) ;
@ -1770,6 +1770,8 @@ event_proc(Widget widget, XtPointer client_data, XEvent *event, Boolean *continu
v->cur_ch == KEY_E ||
v->cur_ch == KEY_F)
return;
default: /* HEX, allow all keys */
break;
}
}
@ -1869,7 +1871,7 @@ static int
get_next_event(Widget widget, int ev_action, XEvent *xevent)
{
char *tmpStr, chs[2] ;
int cval, down, nextc, up ;
int cval = 0, down, nextc, up ;
KeySym ksym;
XKeyPressedEvent *key_event ;
@ -2514,7 +2516,7 @@ set_item(enum item_type itemno, char *str)
void
set_title(enum fcp_type fcptype, char *str)
{
Widget w ;
Widget w;
XmString cstr ;
@ -2526,6 +2528,10 @@ set_title(enum fcp_type fcptype, char *str)
w = X->frframe ;
else if (fcptype == FCP_MODE)
w = X->mframe[(int) v->modetype] ;
else {
fprintf(stderr, "Unknown fcptype %d in set_title\n", fcptype);
return;
}
if (fcptype == FCP_KEY)
XtVaSetValues(w, XmNtitle, str, NULL) ;
@ -3127,6 +3133,8 @@ update_cf_value(void)
}
else
STRCPY(v->fun_names[X->cfno], "");
break;
default : break;
}
XtDestroyWidget(X->menus[(int) X->CFtype]) ;
@ -3142,6 +3150,8 @@ update_cf_value(void)
case M_FUN :
write_rcfile(X->CFtype, X->cfexists, X->cfno,
X->vval, X->dval) ;
break ;
default : break;
}
ignore_event = True;
@ -3154,7 +3164,7 @@ update_cf_value(void)
void
win_display(enum fcp_type fcptype, int state)
{
Widget widget ;
Widget widget = NULL;
Position newX, newY;
Arg args[3];
@ -3244,6 +3254,8 @@ write_cf_value(Widget widget, XtPointer client_data, XtPointer call_data)
case M_CON : X->cfexists = 1 ; /* Always the default constants. */
break ;
case M_FUN : if (strlen(v->fun_vals[X->cfno])) X->cfexists = 1 ;
break;
default : break;
}
if (X->cfexists)
{
@ -3769,7 +3781,7 @@ create_popup(Widget parent)
char *mnemonic;
XmString label;
Widget dummyHelp1, dummyHelp2, memRegs;
Widget help, helpI, helpToc, helpT, helpR, helpO, helpU, helpV;
Widget helpI, helpToc, helpT, helpR, helpO, helpU, helpV;
X->popupMenu = XmCreatePopupMenu(parent, "popup", NULL, 0) ;
XtCreateManagedWidget(GETMESSAGE(2, 46,"Calculator Popup"),
@ -3966,7 +3978,7 @@ create_popup(Widget parent)
mnemonic = GETMESSAGE(2, 17, "H");
label = XmStringCreateLocalized ( GETMESSAGE(2, 18, "Help") );
help = XtVaCreateManagedWidget("help",
XtVaCreateManagedWidget("help",
xmCascadeButtonGadgetClass, X->popupMenu,
XmNsubMenuId, dummyHelp2,
XmNmnemonic, XStringToKeysym( mnemonic ),
@ -4086,11 +4098,9 @@ map_popup(Widget widget, XtPointer client_data, XtPointer call_data)
{
XmAnyCallbackStruct * callback;
XEvent * event;
XKeyPressedEvent *key_event ;
callback = (XmAnyCallbackStruct *) call_data;
event = (XEvent *) callback->event;
key_event = (XKeyPressedEvent *) event ;
if(event->type != KeyRelease)
return;

View file

@ -621,7 +621,7 @@ L10:
L20:
if (MP.r[i3] < 0) goto L30 ;
if (MP.r[i3] == 0 && MP.r[i3 + 1] + 1 << 1 <= MP.b)
if (MP.r[i3] == 0 && (MP.r[i3 + 1] + 1) << 1 <= MP.b)
goto L30 ;
q <<= 1 ;
@ -3478,7 +3478,7 @@ L40:
/* RETURN IF NEWTON ITERATION WAS CONVERGING */
L50:
if (MP.r[i3 - 1] == 0 || MP.r[i2] - MP.r[i3] << 1 >=
if (MP.r[i3 - 1] == 0 || (MP.r[i2] - MP.r[i3]) << 1 >=
MP.t - it0)
goto L70 ;
@ -3676,7 +3676,7 @@ L130:
*/
L140:
if (MP.r[i3 - 1] == 0 || MP.r[i2] - MP.r[i3] << 1 >=
if (MP.r[i3 - 1] == 0 || (MP.r[i2] - MP.r[i3]) << 1 >=
MP.t - it0)
goto L160 ;