diff options
author | Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br> | 2009-01-12 18:53:19 -0200 |
---|---|---|
committer | Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br> | 2009-01-12 18:53:19 -0200 |
commit | 11e13bdf2bdc6cdc7f7d27427016eaf8c9ad48c3 (patch) | |
tree | 36961b4b43bcb098d72a983e655971f019118791 | |
parent | 8509d5cc01607e19590571b4e0d941b0e5900052 (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-- | Clock.c | 72 | ||||
-rw-r--r-- | Makefile.am | 27 | ||||
-rw-r--r-- | app-defaults/Clock-color (renamed from Clock-color.ad) | 0 | ||||
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | oclock.c | 16 | ||||
-rw-r--r-- | transform.c | 39 |
7 files changed, 62 insertions, 110 deletions
@@ -19,3 +19,7 @@ oclock oclock.1 stamp-h1 *~ +*.o +oclock-*.tar.* +ChangeLog +tags @@ -130,7 +130,7 @@ ClockClassRec clockClassRec = { } }; -static void ClassInitialize() +static void ClassInitialize(void) { XtAddConverter( XtRString, XtRBackingStore, XmuCvtStringToBackingStore, NULL, 0 ); @@ -139,10 +139,8 @@ static void ClassInitialize() WidgetClass clockWidgetClass = (WidgetClass) &clockClassRec; /* ARGSUSED */ -static void Initialize (greq, gnew, args, num_args) - Widget greq, gnew; - ArgList args; - Cardinal *num_args; +static void Initialize (Widget greq, Widget gnew, + ArgList args, Cardinal *num_args) { ClockWidget w = (ClockWidget)gnew; XtGCMask valuemask; @@ -178,14 +176,13 @@ static void Initialize (greq, gnew, args, num_args) &shape_error_base)) w->clock.shape_window = False; w->clock.shape_mask = 0; - w->clock.shapeGC = 0; + w->clock.shapeGC = NULL; w->clock.shape_width = 0; w->clock.shape_height = 0; w->clock.polys_valid = 0; } -static void Resize (widget) - Widget widget; +static void Resize (Widget widget) { ClockWidget w = (ClockWidget) widget; XGCValues xgcv; @@ -344,11 +341,9 @@ static void Resize (widget) -WINDOW_HEIGHT(w)/2, WINDOW_HEIGHT(w)/2); } } - -static void Realize (gw, valueMask, attrs) - Widget gw; - XtValueMask *valueMask; - XSetWindowAttributes *attrs; + +static void Realize (Widget gw, XtValueMask *valueMask, + XSetWindowAttributes *attrs) { ClockWidget w = (ClockWidget)gw; @@ -366,11 +361,10 @@ static void Realize (gw, valueMask, attrs) *valueMask, attrs ); if (!w->clock.transparent) Resize (gw); - new_time ((XtPointer) gw, 0); + new_time ((XtPointer) gw, NULL); } -static void Destroy (gw) - Widget gw; +static void Destroy (Widget gw) { ClockWidget w = (ClockWidget)gw; if (w->clock.interval_id) XtRemoveTimeOut (w->clock.interval_id); @@ -387,10 +381,7 @@ static void Destroy (gw) } /* ARGSUSED */ -static void Redisplay(gw, event, region) - Widget gw; - XEvent *event; - Region region; +static void Redisplay(Widget gw, XEvent *event, Region region) { ClockWidget w; @@ -417,8 +408,7 @@ static void Redisplay(gw, event, region) */ static double -clock_to_angle (clock) -double clock; +clock_to_angle (double clock) { if (clock >= .75) clock -= 1.0; @@ -426,9 +416,7 @@ double clock; } /* ARGSUSED */ -static void new_time (client_data, id) - XtPointer client_data; - XtIntervalId *id; /* unused */ +static void new_time (XtPointer client_data, XtIntervalId *id) { ClockWidget w = (ClockWidget)client_data; Time_t now; @@ -463,10 +451,7 @@ static void new_time (client_data, id) } /* new_time */ void -paint_jewel (w, d, gc) -ClockWidget w; -Drawable d; -GC gc; +paint_jewel (ClockWidget w, Drawable d, GC gc) { if (JEWEL_SIZE(w) > 0.0) { @@ -483,9 +468,7 @@ GC gc; * check to see if the polygon intersects the circular jewel */ int -check_jewel_poly (w, poly) -ClockWidget w; -TPoint poly[POLY_SIZE]; +check_jewel_poly (ClockWidget w, TPoint poly[POLY_SIZE]) { double a2, b2, c2, d2; double x, y, size; @@ -517,10 +500,7 @@ TPoint poly[POLY_SIZE]; } void -check_jewel (w, d, gc) -ClockWidget w; -Drawable d; -GC gc; +check_jewel (ClockWidget w, Drawable d, GC gc) { if (!w->clock.polys_valid || JEWEL_SIZE(w) <= 0.0) return; @@ -538,10 +518,8 @@ GC gc; * This is represented with a five sided polygon. */ void -compute_hand (w, a, l, width, poly) -ClockWidget w; -double a, l, width; -TPoint poly[POLY_SIZE]; +compute_hand (ClockWidget w, double a, double l, double width, + TPoint poly[POLY_SIZE]) { double c, s; @@ -562,8 +540,7 @@ TPoint poly[POLY_SIZE]; } void -compute_hands (w) -ClockWidget w; +compute_hands (ClockWidget w) { compute_hand (w, w->clock.minute_angle, MINUTE_LENGTH(w), MINUTE_WIDTH(w), w->clock.minute_poly); @@ -573,21 +550,14 @@ ClockWidget w; } void -paint_hand (w, d, gc, poly) -ClockWidget w; -Drawable d; -GC gc; -TPoint poly[POLY_SIZE]; +paint_hand (ClockWidget w, Drawable d, GC gc, TPoint poly[POLY_SIZE]) { TFillPolygon (XtDisplay (w), d, gc, &w->clock.t, poly, POLY_SIZE, Convex, CoordModeOrigin); } void -paint_hands (w, d, minute_gc, hour_gc) -ClockWidget w; -Drawable d; -GC minute_gc, hour_gc; +paint_hands (ClockWidget w, Drawable d, GC minute_gc, GC hour_gc) { if (w->clock.polys_valid) { paint_hand (w, d, hour_gc, w->clock.hour_poly); diff --git a/Makefile.am b/Makefile.am index 399d71b..4281007 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,7 @@ bin_PROGRAMS = oclock -oclock_CFLAGS = $(OCLOCK_CFLAGS) +AM_CFLAGS = $(OCLOCK_CFLAGS) oclock_LDADD = $(OCLOCK_LIBS) -lm oclock_SOURCES = \ @@ -37,30 +37,21 @@ appman_PRE = \ # App default files (*.ad) -appdefaultdir = @appdefaultdir@ - - -APPDEFAULTFILES = \ - Clock-color - -SUFFIXES = .ad +DISTCHECK_CONFIGURE_FLAGS = --with-appdefaultdir=\$${datadir}/X11/app-defaults -.ad: - cp $< $@ - -appdefault_DATA = $(APPDEFAULTFILES) - -EXTRA_DIST = $(APPDEFAULTFILES:%=%.ad) oclock.bit oclmask.bit +appdefaultdir = @appdefaultdir@ -CLEANFILES = $(APPDEFAULTFILES) +dist_appdefault_DATA = \ + app-defaults/Clock-color +EXTRA_DIST = oclock.bit oclmask.bit appmandir = $(APP_MAN_DIR) appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) EXTRA_DIST += $(appman_PRE) -CLEANFILES += $(appman_DATA) +CLEANFILES = $(appman_DATA) SED = sed @@ -81,7 +72,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) < $< > $@ @@ -92,6 +83,6 @@ 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 diff --git a/Clock-color.ad b/app-defaults/Clock-color index 00e87f4..00e87f4 100644 --- a/Clock-color.ad +++ b/app-defaults/Clock-color diff --git a/configure.ac b/configure.ac index 1329057..3975851 100644 --- a/configure.ac +++ b/configure.ac @@ -26,21 +26,33 @@ AC_INIT(oclock,[1.0.1], [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 +XORG_CWARNFLAGS + # Checks for pkg-config packages PKG_CHECK_MODULES(OCLOCK, x11 xmu xext) +OCLOCK_CFLAGS="$CWARNFLAGS $OCLOCK_CFLAGS" AC_SUBST(OCLOCK_CFLAGS) AC_SUBST(OCLOCK_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]) @@ -54,24 +54,20 @@ static XtActionsRec actions[] = { static Atom wm_delete_window; -static void die(w, client_data, call_data) - Widget w; - XtPointer client_data, call_data; +static void die(Widget w, XtPointer client_data, XtPointer call_data) { XCloseDisplay(XtDisplay(w)); exit(0); } -static void save(w, client_data, call_data) - Widget w; - XtPointer client_data, call_data; +static void save(Widget w, XtPointer client_data, XtPointer call_data) { return; /* stateless */ } /* Exit with message describing command line format */ -static void usage() +static void usage(void) { fprintf(stderr, "usage: oclock\n"); @@ -153,11 +149,7 @@ main(int argc, char *argv[]) exit(0); } -static void quit(w, event, params, num_params) - Widget w; - XEvent *event; - String *params; - Cardinal *num_params; +static void quit(Widget w, XEvent *event, String *params, Cardinal *num_params) { Arg arg; diff --git a/transform.c b/transform.c index 2b662d2..8b900fb 100644 --- a/transform.c +++ b/transform.c @@ -47,7 +47,7 @@ TranslatePoints(TPoint *points, int n_points, xpoints = (XPoint *) malloc ((unsigned)n_points * sizeof (*xpoints)); if (!xpoints) - return 0; + return NULL; for (i = 0; i < n_points; i++) { xpoints[i].x = Xx(points[i].x + xoff, points[i].y + yoff, t); xpoints[i].y = Xy(points[i].x + xoff, points[i].y + yoff, t); @@ -60,15 +60,8 @@ TranslatePoints(TPoint *points, int n_points, } void -TFillPolygon (dpy, d, gc, t, points, n_points, shape, mode) -register Display *dpy; -Drawable d; -GC gc; -Transform *t; -TPoint *points; -int n_points; -int shape; -int mode; +TFillPolygon (register Display *dpy, Drawable d, GC gc, Transform *t, + TPoint *points, int n_points, int shape, int mode) { XPoint *xpoints; @@ -81,13 +74,9 @@ int mode; } void -TDrawArc (dpy, d, gc, t, x, y, width, height, angle1, angle2) - register Display *dpy; - Drawable d; - GC gc; - Transform *t; - double x, y, width, height; - int angle1, angle2; +TDrawArc (register Display *dpy, Drawable d, GC gc, Transform *t, + double x, double y, double width, double height, + int angle1, int angle2) { int xx, xy, xw, xh; @@ -107,13 +96,9 @@ TDrawArc (dpy, d, gc, t, x, y, width, height, angle1, angle2) } void -TFillArc (dpy, d, gc, t, x, y, width, height, angle1, angle2) - register Display *dpy; - Drawable d; - GC gc; - Transform *t; - double x, y, width, height; - int angle1, angle2; +TFillArc (register Display *dpy, Drawable d, GC gc, Transform *t, + double x, double y, double width, double height, + int angle1, int angle2) { int xx, xy, xw, xh; @@ -133,10 +118,8 @@ TFillArc (dpy, d, gc, t, x, y, width, height, angle1, angle2) } void -SetTransform (t, xx1, xx2, xy1, xy2, tx1, tx2, ty1, ty2) -Transform *t; -int xx1, xx2, xy1, xy2; -double tx1, tx2, ty1, ty2; +SetTransform (Transform *t, int xx1, int xx2, int xy1, int xy2, + double tx1, double tx2, double ty1, double ty2) { t->mx = ((double) xx2 - xx1) / (tx2 - tx1); t->bx = ((double) xx1) - t->mx * tx1; |