diff options
author | Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br> | 2009-01-12 20:09:07 -0200 |
---|---|---|
committer | Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br> | 2009-01-12 20:09:07 -0200 |
commit | dd6ca812a9e540ade4afd5db9dd13ea7ed3ea3ab (patch) | |
tree | c3e1491e12e511d463f827103ef6eb2fcd5c2a11 | |
parent | fd75efe1d9b57c483f7cedd9e2dce34b97eef75e (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.
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | Makefile.am | 24 | ||||
-rw-r--r-- | actions.c | 347 | ||||
-rw-r--r-- | actions.h | 94 | ||||
-rw-r--r-- | app-defaults/XCalc (renamed from app-defaults/XCalc.ad) | 0 | ||||
-rw-r--r-- | app-defaults/XCalc-color (renamed from app-defaults/XCalc-color.ad) | 0 | ||||
-rw-r--r-- | configure.ac | 15 | ||||
-rw-r--r-- | math.c | 119 | ||||
-rw-r--r-- | xcalc.c | 79 | ||||
-rw-r--r-- | xcalc.h | 42 |
10 files changed, 245 insertions, 479 deletions
@@ -20,3 +20,7 @@ stamp-h1 xcalc xcalc.1 *~ +*.o +xcalc-*.tar.* +ChangeLog +tags diff --git a/Makefile.am b/Makefile.am index 84fa6d9..22b95f5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,7 +26,6 @@ xcalc_LDADD = $(XCALC_LIBS) -lm xcalc_SOURCES = \ actions.c \ - actions.h \ math.c \ xcalc.c \ xcalc.h @@ -36,31 +35,22 @@ appman_PRE = \ # App default files (*.ad) -appdefaultdir = @appdefaultdir@ +DISTCHECK_CONFIGURE_FLAGS = --with-appdefaultdir=\$${datadir}/X11/app-defaults +appdefaultdir = @appdefaultdir@ -APPDEFAULTFILES = \ +dist_appdefault_DATA = \ app-defaults/XCalc \ app-defaults/XCalc-color -SUFFIXES = .ad - -.ad: - [ -d app-defaults ] || mkdir app-defaults - cp $< $@ - -appdefault_DATA = $(APPDEFAULTFILES) - -EXTRA_DIST = $(APPDEFAULTFILES:%=%.ad) ChangeLog autogen.sh - -CLEANFILES = $(APPDEFAULTFILES) +EXTRA_DIST = ChangeLog autogen.sh MAINTAINERCLEANFILES = ChangeLog .PHONY: ChangeLog ChangeLog: - (GIT_DIR=$(top_srcdir)/.git git-log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2) + $(CHANGELOG_CMD) dist-hook: ChangeLog @@ -69,7 +59,7 @@ appmandir = $(APP_MAN_DIR) appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) EXTRA_DIST += $(appman_PRE) -CLEANFILES += $(appman_DATA) +CLEANFILES = $(appman_DATA) SED = sed @@ -90,7 +80,7 @@ MAN_SUBSTS = \ -e 's|__miscmansuffix__|$(MISC_MAN_SUFFIX)|g' \ -e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g' -SUFFIXES += .$(APP_MAN_SUFFIX) .man +SUFFIXES = .$(APP_MAN_SUFFIX) .man .man.$(APP_MAN_SUFFIX): sed $(MAN_SUBSTS) < $< > $@ @@ -38,26 +38,109 @@ from the X Consortium. #include <X11/Intrinsic.h> #include <setjmp.h> #include "xcalc.h" -extern int rpn; -extern Atom wm_delete_window; -extern int pre_op(); -extern void post_op(), Quit(), ringbell(), do_select(); #ifndef IEEE -extern jmp_buf env; -extern void fail_op(); #define XCALC_PRE_OP(keynum) { if (pre_op(keynum)) return; \ if (setjmp (env)) {fail_op(); return;}} #else #define XCALC_PRE_OP(keynum) if (pre_op(keynum)) return; #endif -/*ARGSUSED*/ -void add(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void add(Widget w, XEvent *e, String *vector, Cardinal *count); +static void back(Widget w, XEvent *e, String *vector, Cardinal *count); +static void bell(Widget w, XEvent *e, String *vector, Cardinal *count); +static void clearit(Widget w, XEvent *e, String *vector, Cardinal *count); +static void cosine(Widget w, XEvent *e, String *vector, Cardinal *count); +static void decimal(Widget w, XEvent *e, String *vector, Cardinal *count); +static void degree(Widget w, XEvent *e, String *vector, Cardinal *count); +static void digit(Widget w, XEvent *e, String *vector, Cardinal *count); +static void divide(Widget w, XEvent *e, String *vector, Cardinal *count); +static void e(Widget w, XEvent *e, String *vector, Cardinal *count); +static void enter(Widget w, XEvent *e, String *vector, Cardinal *count); +static void epower(Widget w, XEvent *e, String *vector, Cardinal *count); +static void equal(Widget w, XEvent *e, String *vector, Cardinal *count); +static void exchange(Widget w, XEvent *e, String *vector, Cardinal *count); +static void factorial(Widget w, XEvent *e, String *vector, Cardinal *count); +static void inverse(Widget w, XEvent *e, String *vector, Cardinal *count); +static void leftParen(Widget w, XEvent *e, String *vector, Cardinal *count); +static void logarithm(Widget w, XEvent *e, String *vector, Cardinal *count); +static void multiply(Widget w, XEvent *e, String *vector, Cardinal *count); +static void naturalLog(Widget w, XEvent *e, String *vector, Cardinal *count); +static void factorial(Widget w, XEvent *e, String *vector, Cardinal *count); +static void negate(Widget w, XEvent *e, String *vector, Cardinal *count); +static void nop(Widget w, XEvent *e, String *vector, Cardinal *count); +static void off(Widget w, XEvent *e, String *vector, Cardinal *count); +static void pi(Widget w, XEvent *e, String *vector, Cardinal *count); +static void power(Widget w, XEvent *e, String *vector, Cardinal *count); +static void quit(Widget w, XEvent *e, String *vector, Cardinal *count); +static void recall(Widget w, XEvent *e, String *vector, Cardinal *count); +static void reciprocal(Widget w, XEvent *e, String *vector, Cardinal *count); +static void rightParen(Widget w, XEvent *e, String *vector, Cardinal *count); +static void roll(Widget w, XEvent *e, String *vector, Cardinal *count); +static void scientific(Widget w, XEvent *e, String *vector, Cardinal *count); +static void selection(Widget w, XEvent *e, String *vector, Cardinal *count); +static void sine(Widget w, XEvent *e, String *vector, Cardinal *count); +static void square(Widget w, XEvent *e, String *vector, Cardinal *count); +static void squareRoot(Widget w, XEvent *e, String *vector, Cardinal *count); +static void store(Widget w, XEvent *e, String *vector, Cardinal *count); +static void subtract(Widget w, XEvent *e, String *vector, Cardinal *count); +static void sum(Widget w, XEvent *e, String *vector, Cardinal *count); +static void tangent(Widget w, XEvent *e, String *vector, Cardinal *count); +static void tenpower(Widget w, XEvent *e, String *vector, Cardinal *count); +static void XexchangeY(Widget w, XEvent *e, String *vector, Cardinal *count); + +/* + * calculator action table + */ + +XtActionsRec Actions[] = { +{"add", add}, /* addition */ +{"back", back}, /* HP-specific backspace */ +{"bell", bell}, /* ring bell */ +{"clear", clearit}, /* TI-specific clear calculator state */ +{"cosine", cosine}, /* trigonometric function cosine */ +{"decimal", decimal}, /* decimal point */ +{"degree", degree}, /* degree, radian, grad switch */ +{"digit", digit}, /* numeric key */ +{"divide", divide}, /* division */ +{"e", e}, /* the natural number e */ +{"enter", enter}, /* HP-specific enter */ +{"epower", epower}, /* e raised to a power */ +{"equal", equal}, /* TI-specific = */ +{"exchange", exchange}, /* TI-specific exchange memory and display */ +{"factorial", factorial}, /* factorial function */ +{"inverse", inverse}, /* inverse */ +{"leftParen", leftParen}, /* TI-specific left parenthesis */ +{"logarithm", logarithm}, /* logarithm base 10 */ +{"multiply", multiply}, /* multiplication */ +{"naturalLog", naturalLog}, /* natural logarithm base e */ +{"negate", negate}, /* change sign */ +{"nop", nop}, /* no operation, rings bell */ +{"off", off}, /* clear state */ +{"pi", pi}, /* the number pi */ +{"power", power}, /* raise to an arbitrary power */ +{"quit", quit}, /* quit */ +{"recall", recall}, /* memory recall */ +{"reciprocal", reciprocal}, /* reciprocal function */ +{"rightParen", rightParen}, /* TI-specific left parenthesis */ +{"roll", roll}, /* HP-specific roll stack */ +{"scientific", scientific}, /* scientfic notation (EE) */ +{"selection", selection}, /* copy selection */ +{"sine", sine}, /* trigonometric function sine */ +{"square", square}, /* square */ +{"squareRoot", squareRoot}, /* square root */ +{"store", store}, /* memory store */ +{"subtract", subtract}, /* subtraction */ +{"sum", sum}, /* memory summation */ +{"tangent", tangent}, /* trigonometric function tangent */ +{"tenpower", tenpower}, /* 10 raised to to an arbitrary power */ +{"XexchangeY", XexchangeY} /* HP-specific exchange X and Y registers */ +}; + +int ActionsCount = XtNumber(Actions); + +/*ARGSUSED*/ +static void add(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kADD); rpn ? twof(kADD) : twoop(kADD); @@ -65,11 +148,7 @@ void add(w, e, vector, count) } /*ARGSUSED*/ -void back(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void back(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kBKSP); bkspf(); @@ -77,21 +156,13 @@ void back(w, e, vector, count) } /*ARGSUSED*/ -void bell(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void bell(Widget w, XEvent *e, String *vector, Cardinal *count) { ringbell(); } /*ARGSUSED*/ -void clearit(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void clearit(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kCLR); clearf(); @@ -99,11 +170,7 @@ void clearit(w, e, vector, count) } /*ARGSUSED*/ -void cosine(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void cosine(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kCOS); oneop(kCOS); @@ -111,11 +178,7 @@ void cosine(w, e, vector, count) } /*ARGSUSED*/ -void decimal(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void decimal(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kDEC); decf(); @@ -123,11 +186,7 @@ void decimal(w, e, vector, count) } /*ARGSUSED*/ -void degree(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void degree(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kDRG); drgf(); @@ -135,11 +194,7 @@ void degree(w, e, vector, count) } /*ARGSUSED*/ -void digit(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void digit(Widget w, XEvent *e, String *vector, Cardinal *count) { switch (vector[0][0]) { @@ -158,11 +213,7 @@ void digit(w, e, vector, count) } /*ARGSUSED*/ -void divide(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void divide(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kDIV); rpn ? twof(kDIV) : twoop(kDIV); @@ -170,11 +221,7 @@ void divide(w, e, vector, count) } /*ARGSUSED*/ -void e(w, ev, vector, count) - Widget w; - XEvent *ev; - String *vector; - Cardinal *count; +static void e(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kE); oneop(kE); @@ -182,11 +229,7 @@ void e(w, ev, vector, count) } /*ARGSUSED*/ -void enter(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void enter(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kENTR); entrf(); @@ -194,11 +237,7 @@ void enter(w, e, vector, count) } /*ARGSUSED*/ -void epower(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void epower(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kEXP); oneop(kEXP); @@ -206,11 +245,7 @@ void epower(w, e, vector, count) } /*ARGSUSED*/ -void equal(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void equal(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kEQU); equf(); @@ -218,11 +253,7 @@ void equal(w, e, vector, count) } /*ARGSUSED*/ -void exchange(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void exchange(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kEXC); oneop(kEXC); @@ -230,11 +261,7 @@ void exchange(w, e, vector, count) } /*ARGSUSED*/ -void factorial(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void factorial(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kFACT); oneop(kFACT); @@ -242,11 +269,7 @@ void factorial(w, e, vector, count) } /*ARGSUSED*/ -void inverse(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void inverse(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kINV); invf(); @@ -254,11 +277,7 @@ void inverse(w, e, vector, count) } /*ARGSUSED*/ -void leftParen(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void leftParen(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kLPAR); lparf(); @@ -266,11 +285,7 @@ void leftParen(w, e, vector, count) } /*ARGSUSED*/ -void logarithm(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void logarithm(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kLOG); oneop(kLOG); @@ -278,11 +293,7 @@ void logarithm(w, e, vector, count) } /*ARGSUSED*/ -void multiply(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void multiply(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kMUL); rpn ? twof(kMUL) : twoop(kMUL); @@ -290,11 +301,7 @@ void multiply(w, e, vector, count) } /*ARGSUSED*/ -void naturalLog(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void naturalLog(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kLN); oneop(kLN); @@ -302,11 +309,7 @@ void naturalLog(w, e, vector, count) } /*ARGSUSED*/ -void negate(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void negate(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kNEG); negf(); @@ -314,21 +317,13 @@ void negate(w, e, vector, count) } /*ARGSUSED*/ -void nop(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void nop(Widget w, XEvent *e, String *vector, Cardinal *count) { ringbell(); } /*ARGSUSED*/ -void off(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void off(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kOFF); offf(); @@ -336,11 +331,7 @@ void off(w, e, vector, count) } /*ARGSUSED*/ -void pi(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void pi(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kPI); oneop(kPI); @@ -348,11 +339,7 @@ void pi(w, e, vector, count) } /*ARGSUSED*/ -void power(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void power(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kPOW); rpn ? twof(kPOW) : twoop(kPOW); @@ -360,11 +347,7 @@ void power(w, e, vector, count) } /*ARGSUSED*/ -void quit(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void quit(Widget w, XEvent *e, String *vector, Cardinal *count) { if (e->type == ClientMessage && e->xclient.data.l[0] != wm_delete_window) ringbell(); @@ -373,11 +356,7 @@ void quit(w, e, vector, count) } /*ARGSUSED*/ -void recall(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void recall(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kRCL); rpn ? memf(kRCL) : oneop(kRCL); @@ -385,11 +364,7 @@ void recall(w, e, vector, count) } /*ARGSUSED*/ -void reciprocal(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void reciprocal(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kRECIP); oneop(kRECIP); @@ -397,11 +372,7 @@ void reciprocal(w, e, vector, count) } /*ARGSUSED*/ -void rightParen(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void rightParen(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kRPAR); rparf(); @@ -409,11 +380,7 @@ void rightParen(w, e, vector, count) } /*ARGSUSED*/ -void roll(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void roll(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kROLL); rollf(); @@ -421,11 +388,7 @@ void roll(w, e, vector, count) } /*ARGSUSED*/ -void scientific(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void scientific(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kEE); eef(); @@ -433,21 +396,13 @@ void scientific(w, e, vector, count) } /*ARGSUSED*/ -void selection(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void selection(Widget w, XEvent *e, String *vector, Cardinal *count) { do_select(((XButtonReleasedEvent *)e)->time); } /*ARGSUSED*/ -void sine(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void sine(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kSIN); oneop(kSIN); @@ -455,11 +410,7 @@ void sine(w, e, vector, count) } /*ARGSUSED*/ -void square(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void square(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kSQR); oneop(kSQR); @@ -467,11 +418,7 @@ void square(w, e, vector, count) } /*ARGSUSED*/ -void squareRoot(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void squareRoot(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kSQRT); oneop(kSQRT); @@ -479,11 +426,7 @@ void squareRoot(w, e, vector, count) } /*ARGSUSED*/ -void store(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void store(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kSTO); rpn ? memf(kSTO) : oneop(kSTO); @@ -491,11 +434,7 @@ void store(w, e, vector, count) } /*ARGSUSED*/ -void subtract(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void subtract(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kSUB); rpn ? twof(kSUB) : twoop(kSUB); @@ -503,11 +442,7 @@ void subtract(w, e, vector, count) } /*ARGSUSED*/ -void sum(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void sum(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kSUM); rpn ? memf(kSUM) : oneop(kSUM); @@ -515,11 +450,7 @@ void sum(w, e, vector, count) } /*ARGSUSED*/ -void tangent(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void tangent(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kTAN); oneop(kTAN); @@ -527,11 +458,7 @@ void tangent(w, e, vector, count) } /*ARGSUSED*/ -void tenpower(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void tenpower(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(k10X); oneop(k10X); @@ -539,11 +466,7 @@ void tenpower(w, e, vector, count) } /*ARGSUSED*/ -void XexchangeY(w, e, vector, count) - Widget w; - XEvent *e; - String *vector; - Cardinal *count; +static void XexchangeY(Widget w, XEvent *e, String *vector, Cardinal *count) { XCALC_PRE_OP(kXXY); twof(kXXY); diff --git a/actions.h b/actions.h deleted file mode 100644 index 69f1983..0000000 --- a/actions.h +++ /dev/null @@ -1,94 +0,0 @@ -/* $XConsortium: actions.h,v 1.6 94/04/17 20:43:31 rws Exp $ */ -/* - -Copyright (c) 1989 X Consortium - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the X Consortium shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from the X Consortium. - -*/ - -/* - * actions.h - action table declaring externally available procedures for xcalc - * - * Author: Donna Converse, MIT X Consortium - */ - -extern void - add(), back(), bell(), clearit(), cosine(), decimal(), - degree(), digit(), divide(), e(), enter(), epower(), equal(), - exchange(), factorial(), - inverse(), leftParen(), logarithm(), multiply(), naturalLog(), - negate(), nop(), off(), pi(), power(), quit(), recall(), - reciprocal(), rightParen(), roll(), scientific(), selection(), sine(), - square(), squareRoot(), store(), subtract(), sum(), - tangent(), tenpower(), XexchangeY(); - -/* - * calculator action table - */ - -XtActionsRec Actions[] = { -{"add", add}, /* addition */ -{"back", back}, /* HP-specific backspace */ -{"bell", bell}, /* ring bell */ -{"clear", clearit}, /* TI-specific clear calculator state */ -{"cosine", cosine}, /* trigonometric function cosine */ -{"decimal", decimal}, /* decimal point */ -{"degree", degree}, /* degree, radian, grad switch */ -{"digit", digit}, /* numeric key */ -{"divide", divide}, /* division */ -{"e", e}, /* the natural number e */ -{"enter", enter}, /* HP-specific enter */ -{"epower", epower}, /* e raised to a power */ -{"equal", equal}, /* TI-specific = */ -{"exchange", exchange}, /* TI-specific exchange memory and display */ -{"factorial", factorial}, /* factorial function */ -{"inverse", inverse}, /* inverse */ -{"leftParen", leftParen}, /* TI-specific left parenthesis */ -{"logarithm", logarithm}, /* logarithm base 10 */ -{"multiply", multiply}, /* multiplication */ -{"naturalLog", naturalLog}, /* natural logarithm base e */ -{"negate", negate}, /* change sign */ -{"nop", nop}, /* no operation, rings bell */ -{"off", off}, /* clear state */ -{"pi", pi}, /* the number pi */ -{"power", power}, /* raise to an arbitrary power */ -{"quit", quit}, /* quit */ -{"recall", recall}, /* memory recall */ -{"reciprocal", reciprocal}, /* reciprocal function */ -{"rightParen", rightParen}, /* TI-specific left parenthesis */ -{"roll", roll}, /* HP-specific roll stack */ -{"scientific", scientific}, /* scientfic notation (EE) */ -{"selection", selection}, /* copy selection */ -{"sine", sine}, /* trigonometric function sine */ -{"square", square}, /* square */ -{"squareRoot", squareRoot}, /* square root */ -{"store", store}, /* memory store */ -{"subtract", subtract}, /* subtraction */ -{"sum", sum}, /* memory summation */ -{"tangent", tangent}, /* trigonometric function tangent */ -{"tenpower", tenpower}, /* 10 raised to to an arbitrary power */ -{"XexchangeY", XexchangeY} /* HP-specific exchange X and Y registers */ -}; diff --git a/app-defaults/XCalc.ad b/app-defaults/XCalc index 31d553e..31d553e 100644 --- a/app-defaults/XCalc.ad +++ b/app-defaults/XCalc diff --git a/app-defaults/XCalc-color.ad b/app-defaults/XCalc-color index 6b26604..6b26604 100644 --- a/app-defaults/XCalc-color.ad +++ b/app-defaults/XCalc-color diff --git a/configure.ac b/configure.ac index e46af40..4b442c6 100644 --- a/configure.ac +++ b/configure.ac @@ -26,21 +26,32 @@ AC_INIT(xcalc,[1.0.2], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg] AM_INIT_AUTOMAKE([dist-bzip2]) AM_MAINTAINER_MODE +# Require xorg-macros: XORG_CWARNFLAGS, XORG_CHANGELOG +m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])]) +XORG_MACROS_VERSION(1.2) + AM_CONFIG_HEADER(config.h) AC_PROG_CC AC_PROG_INSTALL -PKG_CHECK_MODULES(XCALC, xaw7) +XORG_CWARNFLAGS +PKG_CHECK_MODULES(XCALC, xaw7) +XCALC_CFLAGS="$CWARNFLAGS $XCALC_CFLAGS" AC_SUBST(XCALC_CFLAGS) AC_SUBST(XCALC_LIBS) PKG_CHECK_MODULES(APPDEFS, xt) -appdefaultdir=$(pkg-config --variable=appdefaultdir xt) +xt_appdefaultdir=$(pkg-config --variable=appdefaultdir xt) +AC_ARG_WITH(appdefaultdir, + AC_HELP_STRING([--with-appdefaultdir=<pathname>], + [specify directory for app-defaults files (default is autodetected)]), + [appdefaultdir="$withval"], [appdefaultdir="${xt_appdefaultdir}"]) AC_SUBST(appdefaultdir) XORG_MANPAGE_SECTIONS XORG_RELEASE_VERSION +XORG_CHANGELOG AC_OUTPUT([Makefile]) @@ -20,17 +20,7 @@ * Geoffrey Coram fixed most of the HP mode bugs. */ -#include <stdio.h> -#include <X11/Xos.h> -#include <math.h> -#include <signal.h> -#if !defined(IEEE) && defined(SVR4) -#include <siginfo.h> -#endif -#include <setjmp.h> #include "xcalc.h" -#include <errno.h> -#include <X11/Xlocale.h> #ifdef _CRAY /* kludge around Cray STDC compiler */ double (*log_p)() = log; @@ -72,15 +62,8 @@ double (*pow_p)() = pow; #define True 1 #define False 0 -extern int rpn; -extern char dispstr[]; -extern void draw(); -extern void ringbell(); -extern void setflag(); -extern void Quit(); - #ifndef IEEE - jmp_buf env; +jmp_buf env; #endif @@ -88,7 +71,7 @@ extern void Quit(); * functions. Much of it is shared between the infix and rpn modes. */ -int flagINV, flagPAREN, flagM, drgmode; /* display flags */ +static int flagINV, flagPAREN, flagM, drgmode; /* display flags */ static double drg2rad=PI/180.0; /* Conversion factors for trig funcs */ static double rad2drg=180.0/PI; @@ -130,10 +113,7 @@ static int priority(int op); */ static void -parse_double (src, fmt, dp) - char *src; - char *fmt; - double *dp; +parse_double (char *src, char *fmt, double *dp) { int olderrno = errno; @@ -144,8 +124,7 @@ parse_double (src, fmt, dp) /*********************************/ -int pre_op(keynum) - int keynum; +int pre_op(int keynum) { if (keynum==-1) return(0); @@ -168,99 +147,44 @@ int pre_op(keynum) /* cannot assign result of setjmp under ANSI C, use global instead */ static volatile int SignalKind; -static volatile int SignalCode; -void fail_op() +void fail_op(void) { if (SignalKind == SIGFPE) - switch (SignalCode) { -#ifdef SVR4 - case FPE_INTDIV: /* integer divide by zero */ - case FPE_FLTDIV: /* floating point divide by zero */ - strcpy(dispstr, "divide by 0"); - break; - case FPE_INTOVF: /* integer overflow */ - case FPE_FLTOVF: /* floating point overflow */ - strcpy(dispstr, "overflow"); - break; - case FPE_FLTUND: /* floating point underflow */ - strcpy(dispstr, "underflow"); - break; - case FPE_FLTRES: /* floating point inexact result */ - strcpy(dispstr, "inexact result"); - break; - case FPE_FLTINV: /* invalid floating point operation */ - strcpy(dispstr, "invalid op"); - break; - case FPE_FLTSUB: /* subscript out of range */ - strcpy(dispstr, "out of range"); - break; - -#endif /*SVR4*/ - -#ifdef FPE_FLTDIV_TRAP - case FPE_FLTDIV_TRAP: strcpy(dispstr,"div by zero"); break; -#endif -#ifdef FPE_FLTDIV_FAULT - case FPE_FLTDIV_FAULT: strcpy(dispstr,"div by zero"); break; -#endif -#ifdef FPE_FLTOVF_TRAP - case FPE_FLTOVF_TRAP: strcpy(dispstr,"overflow"); break; -#endif -#ifdef FPE_FLTOVF_FAULT - case FPE_FLTOVF_FAULT: strcpy(dispstr,"overflow"); break; -#endif -#ifdef FPE_FLTUND_TRAP - case FPE_FLTUND_TRAP: strcpy(dispstr,"underflow"); break; -#endif -#ifdef FPE_FLTUND_FAULT - case FPE_FLTUND_FAULT: strcpy(dispstr,"underflow"); break; -#endif - default: strcpy(dispstr,"error"); - } - else - if (SignalKind == SIGILL) - strcpy(dispstr, "illegal operand"); + strcpy(dispstr, "math error"); + else if (SignalKind == SIGILL) + strcpy(dispstr, "illegal operand"); entered=3; DrawDisplay(); return; } - -/* keep SVR4 compiler from complaining about scope of arg declaration below */ -typedef struct sigcontext * sigcontextstructp; /*ARGSUSED*/ -signal_t fperr(sig,code,scp) - int sig,code; - sigcontextstructp scp; +signal_t fperr(int sig) { #if defined(SYSV) || defined(SVR4) || defined(linux) - signal(SIGFPE,(signal_t (*)())fperr); + signal(SIGFPE, fperr); #endif SignalKind = sig; - SignalCode = code; longjmp(env,1); } /* for VAX BSD4.3 */ /*ARGSUSED*/ -signal_t illerr(sig,code,scp) - int sig,code; - sigcontextstructp scp; +signal_t illerr(int sig) { /* not reset when caught? */ - signal(SIGILL,(signal_t (*)())illerr); + signal(SIGILL, illerr); SignalKind = sig; - SignalCode = code; longjmp(env,1); } #endif /* not IEEE */ -void post_op() +void post_op(void) { #ifdef DEBUG showstack("\0"); @@ -302,8 +226,7 @@ DrawDisplay(void) /*-------------------------------------------------------------------------*/ void -numeric(keynum) - int keynum; +numeric(int keynum) { char st[2]; int cell = 0; @@ -831,7 +754,7 @@ oneop(int keynum) entered=3; break; } - i=(int) (floor(dnum)); + dtmp = floor(dnum); i = dtmp; for (j=1,dnum=1.0; j<=i; j++) dnum*=(float) j; break; @@ -877,8 +800,7 @@ static int numsp; /*******/ static void -PushOp(op) - int op; +PushOp(int op) /*******/ { if (opsp==STACKMAX) {strcpy(dispstr,"stack error"); entered=3;} @@ -908,8 +830,7 @@ isopempty(void) #ifdef DEBUG static void -showstack(string) - char *string; +showstack(char *string) { fprintf(stderr, "%s: %lf %lf %lf\n", string, numstack[0], numstack[1], numstack[2]); @@ -918,8 +839,7 @@ showstack(string) /*******/ static void -PushNum(num) - double num; +PushNum(double num) /*******/ { if (rpn) { @@ -990,8 +910,7 @@ ClearStacks(void) /*******/ static int -priority(op) - int op; +priority(int op) /*******/ { switch (op) { @@ -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]; @@ -39,6 +39,21 @@ from the X Consortium. #ifndef _XCALC_H_ #define _XCALC_H_ +#include <X11/Intrinsic.h> +#include <X11/StringDefs.h> + +#include <stdio.h> +#include <X11/Xos.h> +#include <math.h> +#include <signal.h> +#if !defined(IEEE) && defined(SVR4) +#include <siginfo.h> +#endif +#include <setjmp.h> +#include <errno.h> +#include <X11/Xlocale.h> + + #ifdef SIGNALRETURNSINT #define signal_t int #else @@ -100,6 +115,17 @@ from the X Consortium. #define XCalc_GRADAM 4 /* grad indicator */ #define XCalc_PAREN 5 /* parenthesis indicator */ +/* actions.c */ +extern XtActionsRec Actions[]; +extern int ActionsCount; + +/* math.c */ +extern signal_t fperr(int sig); +extern signal_t illerr(int sig); +extern void fail_op(void); +extern int pre_op(int keynum); +extern void post_op(void); + extern void numeric(int keynum); extern void bkspf(void); extern void decf(void); @@ -120,4 +146,20 @@ extern void oneop(int keynum); extern void offf(void); extern void ResetCalc(void); +#ifndef IEEE +extern jmp_buf env; +#endif + +/* xcalc.c */ +extern void do_select(Time time); +extern void draw(char *string); +extern void Quit(void); +extern void ringbell(void); +extern void setflag(int indicator, Boolean on); + +extern int rpn; +#define LCD_STR_LEN 32 +extern char dispstr[LCD_STR_LEN]; +extern Atom wm_delete_window; + #endif |