From 11e13bdf2bdc6cdc7f7d27427016eaf8c9ad48c3 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Pereira de Andrade Date: Mon, 12 Jan 2009 18:53:19 -0200 Subject: Ansification and compile warning fixes. This also uses XORG_CHANGELOG and XORG_CWARNFLAGS, corrects make distcheck and all gcc 4.3 and sparse warnings. --- .gitignore | 4 +++ Clock-color.ad | 6 ---- Clock.c | 72 ++++++++++++++---------------------------------- Makefile.am | 27 ++++++------------ app-defaults/Clock-color | 6 ++++ configure.ac | 14 +++++++++- oclock.c | 16 +++-------- transform.c | 39 ++++++++------------------ 8 files changed, 68 insertions(+), 116 deletions(-) delete mode 100644 Clock-color.ad create mode 100644 app-defaults/Clock-color diff --git a/.gitignore b/.gitignore index 091032e..1eaaa20 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,7 @@ oclock oclock.1 stamp-h1 *~ +*.o +oclock-*.tar.* +ChangeLog +tags diff --git a/Clock-color.ad b/Clock-color.ad deleted file mode 100644 index 00e87f4..0000000 --- a/Clock-color.ad +++ /dev/null @@ -1,6 +0,0 @@ -! $Xorg: Clock-col.ad,v 1.3 2000/08/17 19:53:59 cpqbld Exp $ -Clock*Background: grey -Clock*BorderColor: light blue -Clock*hour: yellow -Clock*jewel: yellow -Clock*minute: yellow diff --git a/Clock.c b/Clock.c index 66fea36..812ce43 100644 --- a/Clock.c +++ b/Clock.c @@ -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/app-defaults/Clock-color b/app-defaults/Clock-color new file mode 100644 index 0000000..00e87f4 --- /dev/null +++ b/app-defaults/Clock-color @@ -0,0 +1,6 @@ +! $Xorg: Clock-col.ad,v 1.3 2000/08/17 19:53:59 cpqbld Exp $ +Clock*Background: grey +Clock*BorderColor: light blue +Clock*hour: yellow +Clock*jewel: yellow +Clock*minute: yellow 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=], + [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]) diff --git a/oclock.c b/oclock.c index cb2fc8d..92db51e 100644 --- a/oclock.c +++ b/oclock.c @@ -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; -- cgit v1.2.3