Skip to content
Browse files

removed code duplication with the tradoff of non ISO C preprocessor m…

…agic
  • Loading branch information...
1 parent 4fd7ac2 commit 569639b21b4df4cc5057d3176104e790a8e9123f @rck rck committed
Showing with 3 additions and 13 deletions.
  1. +1 −1 Makefile
  2. +2 −12 xrectsel.c
View
2 Makefile
@@ -9,7 +9,7 @@ PREFIX ?= /usr
MANPREFIX ?= ${PREFIX}/share/man
CPPFLAGS := -DVERSION=\"${VERSION}\" ${CPPFLAGS}
-CFLAGS := --std=c99 -g -pedantic -Wall -Wextra ${CFLAGS}
+CFLAGS := --std=c99 -g -pedantic -Wall -Wextra -Wno-variadic-macros ${CFLAGS}
LDFLAGS := -lX11 ${LDFLAGS}
all: ${OUT}
View
14 xrectsel.c
@@ -7,6 +7,8 @@
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
+#define die(args...) do {error(args); exit(EXIT_FAILURE); } while(0)
+
typedef struct Region Region;
struct Region {
Window root;
@@ -20,7 +22,6 @@ struct Region {
unsigned int d; /* depth */
};
-static void die(const char *errstr, ...);
static void error(const char *errstr, ...);
static int print_region_attr(const char *fmt, Region region);
static int select_region(Display *dpy, Window root, Region *region);
@@ -53,17 +54,6 @@ int main(int argc, const char *argv[])
return EXIT_SUCCESS;
}
-static void die(const char *errstr, ...)
-{
- va_list ap;
-
- fprintf(stderr, "xrectsel: ");
- va_start(ap, errstr);
- vfprintf(stderr, errstr, ap);
- va_end(ap);
- exit(EXIT_FAILURE);
-}
-
static void error(const char *errstr, ...)
{
va_list ap;

0 comments on commit 569639b

Please sign in to comment.
Something went wrong with that request. Please try again.