summaryrefslogtreecommitdiff
path: root/xcalc.c
diff options
context:
space:
mode:
authorPaulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>2009-01-12 20:09:07 -0200
committerPaulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>2009-01-12 20:09:07 -0200
commitdd6ca812a9e540ade4afd5db9dd13ea7ed3ea3ab (patch)
treec3e1491e12e511d463f827103ef6eb2fcd5c2a11 /xcalc.c
parentfd75efe1d9b57c483f7cedd9e2dce34b97eef75e (diff)
Ansification and compile warning fixes.
This also uses XORG_CHANGELOG and XORG_CWARNFLAGS, corrects make distcheck and all gcc 4.3 and sparse warnings.
Diffstat (limited to 'xcalc.c')
-rw-r--r--xcalc.c79
1 files changed, 25 insertions, 54 deletions
diff --git a/xcalc.c b/xcalc.c
index 0f94311..0796448 100644
--- a/xcalc.c
+++ b/xcalc.c
@@ -40,10 +40,9 @@ from the X Consortium.
*/
#include <stdio.h>
+#include <stdlib.h>
#include <math.h>
#include <signal.h>
-#include <X11/Intrinsic.h>
-#include <X11/StringDefs.h>
#include <X11/Xatom.h>
#include <X11/Shell.h>
#include <X11/Xaw/Cardinals.h>
@@ -53,18 +52,20 @@ from the X Consortium.
#include <X11/Xaw/Toggle.h>
#include <X11/cursorfont.h>
#include "xcalc.h"
-#include "actions.h"
-#ifndef IEEE
-extern signal_t fperr();
-extern signal_t illerr();
-#endif
+static Boolean convert(Widget w, Atom *selection, Atom *target, Atom *type,
+ XtPointer *value, unsigned long *length, int *format);
+static void create_keypad(Widget parent);
+static void create_display(Widget parent);
+static void create_calculator(Widget shell);
+static void done(Widget w, Atom *selection, Atom *target);
+static void lose(Widget w, Atom *selection);
+static void Syntax(int argc, char **argv);
/*
* global data
*/
int rpn = 0; /* Reverse Polish Notation (HP mode) flag */
-#define LCD_STR_LEN 32
char dispstr[LCD_STR_LEN]; /* string to show up in the LCD */
Atom wm_delete_window; /* see ICCCM section 5.2.2 */
@@ -112,16 +113,10 @@ static XtResource Resources[] = {
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char **argv)
{
Arg args[3];
- void create_calculator();
- void Quit(), Syntax();
-
-
XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);
toplevel = XtAppInitialize(&xtcontext, "XCalc", Options, XtNumber(Options),
@@ -136,7 +131,7 @@ main(argc, argv)
create_calculator(toplevel);
- XtAppAddActions(xtcontext, Actions, XtNumber(Actions));
+ XtAppAddActions(xtcontext, Actions, ActionsCount);
XtOverrideTranslations(toplevel,
XtParseTranslationTable("<Message>WM_PROTOCOLS: quit()\n"));
@@ -172,12 +167,8 @@ main(argc, argv)
return 0;
}
-void create_calculator(shell)
- Widget shell;
+static void create_calculator(Widget shell)
{
- void create_display();
- void create_keypad();
-
rpn = appResources.rpn;
calculator = XtCreateManagedWidget(rpn ? "hp" : "ti", formWidgetClass,
shell, (ArgList) NULL, ZERO);
@@ -189,8 +180,7 @@ void create_calculator(shell)
/*
* Do the calculator data display widgets.
*/
-void create_display(parent)
- Widget parent;
+static void create_display(Widget parent)
{
Widget bevel, screen;
static Arg args[] = {
@@ -242,8 +232,7 @@ void create_display(parent)
* these defaults in an environment-specific resource file.
*/
-void create_keypad(parent)
- Widget parent;
+static void create_keypad(Widget parent)
{
static char *Keyboard[] = {
"button1", "button2", "button3", "button4", "button5",
@@ -272,8 +261,7 @@ void create_keypad(parent)
/*
* called by math routines to write to the liquid crystal display.
*/
-void draw(string)
- char *string;
+void draw(char *string)
{
Arg args[1];
@@ -283,9 +271,7 @@ void draw(string)
/*
* called by math routines to turn on and off the display indicators.
*/
-void setflag(indicator, on)
- int indicator;
- Boolean on;
+void setflag(int indicator, Boolean on)
{
if (on) XtMapWidget(ind[indicator]);
else XtUnmapWidget(ind[indicator]);
@@ -294,7 +280,7 @@ void setflag(indicator, on)
/*
* ring the bell.
*/
-void ringbell()
+void ringbell(void)
{
XBell(dpy, 0);
}
@@ -302,9 +288,8 @@ void ringbell()
/*
* die.
*/
-void Quit()
+void Quit(void)
{
- extern void exit();
XtDestroyApplicationContext(xtcontext);
exit(0);
}
@@ -312,12 +297,10 @@ void Quit()
/*
* recite and die.
*/
-void Syntax(argc, argv)
- int argc;
- char **argv;
+static void Syntax(int argc, char **argv)
{
register int i;
- extern void exit();
+
(void) fprintf(stderr, "%s: unknown options:", argv[0]);
for (i=1; i <argc; i++)
(void) fprintf(stderr, " %s", argv[i]);
@@ -339,14 +322,8 @@ void Syntax(argc, argv)
*/
/*ARGSUSED*/
-Boolean convert(w, selection, target, type, value, length, format)
- Widget w;
- Atom *selection;
- Atom *target;
- Atom *type;
- XtPointer *value;
- unsigned long *length;
- int *format;
+static Boolean convert(Widget w, Atom *selection, Atom *target, Atom *type,
+ XtPointer *value, unsigned long *length, int *format)
{
if (*target == XA_STRING)
{
@@ -364,9 +341,7 @@ Boolean convert(w, selection, target, type, value, length, format)
* called when xcalc loses ownership of the selection.
*/
/*ARGSUSED*/
-void lose(w, selection)
- Widget w;
- Atom *selection;
+static void lose(Widget w, Atom *selection)
{
XawToggleUnsetCurrent(LCD);
}
@@ -375,10 +350,7 @@ void lose(w, selection)
* called when some other client got the selection.
*/
/*ARGSUSED*/
-void done(w, selection, target)
- Widget w;
- Atom *selection;
- Atom *target;
+static void done(Widget w, Atom *selection, Atom *target)
{
selstr[0] = '\0';
}
@@ -386,8 +358,7 @@ void done(w, selection, target)
/*
* called by the selection() action routine, in response to user action.
*/
-void do_select(time)
- Time time;
+void do_select(Time time)
{
Boolean state;
Arg args[1];