aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile10
-rw-r--r--config.mk6
-rw-r--r--loc.c5
3 files changed, 14 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index c8ef546..cded8f3 100644
--- a/Makefile
+++ b/Makefile
@@ -3,11 +3,15 @@
CONFIGFILE = config.mk
include $(CONFIGFILE)
+
all: loc
loc.o: loc.c arg.h
-loc: loc.o
- $(CC) -o $@ loc.o $(LDFLAGS)
+.c.o:
+ $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
+
+.o:
+ $(CC) -o $@ $< $(LDFLAGS)
check: loc
test "$$(./loc < tests/0)" = 0
@@ -67,7 +71,7 @@ uninstall:
-rm -f -- "$(DESTDIR)$(MANPREFIX)/man1/loc.1"
clean:
- -rm -f -- loc.o loc
+ -rm -f -- *.o *.su loc
.SUFFIXES:
.SUFFIXES: .o .c
diff --git a/config.mk b/config.mk
index a61c851..aa81003 100644
--- a/config.mk
+++ b/config.mk
@@ -1,6 +1,8 @@
-PREFIX = /usr
+PREFIX = /usr
MANPREFIX = $(PREFIX)/share/man
+CC = cc
+
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700
-CFLAGS = -std=c99 -Wall -O2 $(CPPFLAGS)
+CFLAGS = -std=c99 -Wall -O2
LDFLAGS = -s
diff --git a/loc.c b/loc.c
index 855ad5b..1f309c8 100644
--- a/loc.c
+++ b/loc.c
@@ -11,6 +11,7 @@
#include "arg.h"
+
char *argv0;
struct result {
@@ -168,7 +169,7 @@ main(int argc, char *argv[])
else
ret = 1;
} else {
- if (!(res = calloc(argc, sizeof(struct result))))
+ if (!(res = calloc((size_t)argc, sizeof(struct result))))
fprintf(stderr, "%s: out of memory\n", argv0), exit(1);
for (i = 0; i < argc; i++) {
if (!strcmp(argv[i], "-")) {
@@ -182,7 +183,7 @@ main(int argc, char *argv[])
if (res[i].n >= 0) {
left = strwidth(argv[i]);
maxleft = left > maxleft ? left : maxleft;
- right = zuwidth(res[i].n);
+ right = zuwidth((size_t)res[i].n);
maxright = right > maxright ? right : maxright;
res[i].width = left + right;
}