commit e32611cbf2489deac5a965ab21a77b11ffb94632
Author: Dimitris Zervas <[email protected]>
Date: Thu Jul 24 00:10:55 2014 +0300
Applied Evil_Bob's patch
diff --git a/LICENSE b/LICENSE
index 5227375..9beeacd 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,8 +1,9 @@
MIT/X Consortium License
-© 2011 Rafael Garcia <[email protected]>
+© 2014 Rafael Garcia <[email protected]>
Raquel Garcia <[email protected]>
Dimitris Zervas <[email protected]>
+ Hiltjo Posthuma <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
diff --git a/Makefile b/Makefile
index 1e6b26a..c73a52b 100644
--- a/Makefile
+++ b/Makefile
@@ -3,58 +3,68 @@
include config.mk
+.POSIX:
+.SUFFIXES: .c .o
+
+HDR = arg.h
+
SRC = sandy.c
-OBJ = ${SRC:.c=.o}
+
+OBJ = $(SRC:.c=.o)
all: options sandy
options:
@echo sandy build options:
- @echo "CFLAGS = ${CFLAGS}"
- @echo "LDFLAGS = ${LDFLAGS}"
- @echo "CC = ${CC}"
+ @echo "CFLAGS = $(CFLAGS)"
+ @echo "LDFLAGS = $(LDFLAGS)"
+ @echo "CC = $(CC)"
+
+$(OBJ): config.h config.mk
+
+.o:
+ @echo LD $@
+ @$(LD) -o $@ $< $(LDFLAGS)
.c.o:
@echo CC $<
- @${CC} -c ${CFLAGS} $<
-
-${OBJ}: config.h config.mk
+ @$(CC) -c -o $@ $< $(CFLAGS)
config.h:
@echo creating $@ from config.def.h
@cp config.def.h $@
-sandy: ${OBJ}
+sandy: $(OBJ)
@echo CC -o $@
- @${CC} -o $@ sandy.o ${LDFLAGS}
+ @$(CC) -o $@ $(OBJ) $(LDFLAGS)
clean:
@echo cleaning
- @rm -f sandy ${OBJ} sandy-${VERSION}.tar.gz
+ @rm -f sandy $(OBJ) sandy-$(VERSION).tar.gz
dist: clean
@echo creating dist tarball
- @mkdir -p sandy-${VERSION}
+ @mkdir -p sandy-$(VERSION)
@cp -R LICENSE Makefile config.mk config.def.h \
- README TODO sandy.1 ${SRC} sandy-${VERSION}
- @tar -cf sandy-${VERSION}.tar sandy-${VERSION}
- @gzip sandy-${VERSION}.tar
- @rm -rf sandy-${VERSION}
+ README TODO sandy.1 $(HDR) $(SRC) sandy-$(VERSION)
+ @tar -cf sandy-$(VERSION).tar sandy-$(VERSION)
+ @gzip sandy-$(VERSION).tar
+ @rm -rf sandy-$(VERSION)
install: all
- @echo installing executable file to ${DESTDIR}${PREFIX}/bin
- @mkdir -p ${DESTDIR}${PREFIX}/bin
- @cp -f sandy ${DESTDIR}${PREFIX}/bin
- @chmod 755 ${DESTDIR}${PREFIX}/bin/sandy
- @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
- @mkdir -p ${DESTDIR}${MANPREFIX}/man1
- @sed "s/VERSION/${VERSION}/g" < sandy.1 >
${DESTDIR}${MANPREFIX}/man1/sandy.1
- @chmod 644 ${DESTDIR}${MANPREFIX}/man1/sandy.1
+ @echo installing executable file to $(DESTDIR)$(PREFIX)/bin
+ @mkdir -p $(DESTDIR)$(PREFIX)/bin
+ @cp -f sandy $(DESTDIR)$(PREFIX)/bin
+ @chmod 755 $(DESTDIR)$(PREFIX)/bin/sandy
+ @echo installing manual page to $(DESTDIR)$(MANPREFIX)/man1
+ @mkdir -p $(DESTDIR)$(MANPREFIX)/man1
+ @sed "s/VERSION/$(VERSION)/g" < sandy.1 >
$(DESTDIR)$(MANPREFIX)/man1/sandy.1
+ @chmod 644 $(DESTDIR)$(MANPREFIX)/man1/sandy.1
uninstall:
- @echo removing executable file from ${DESTDIR}${PREFIX}/bin
- @rm -f ${DESTDIR}${PREFIX}/bin/sandy
- @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
- @rm -f ${DESTDIR}${MANPREFIX}/man1/sandy.1
+ @echo removing executable file from $(DESTDIR)$(PREFIX)/bin
+ @rm -f $(DESTDIR)$(PREFIX)/bin/sandy
+ @echo removing manual page from $(DESTDIR)$(MANPREFIX)/man1
+ @rm -f $(DESTDIR)$(MANPREFIX)/man1/sandy.1
.PHONY: all options clean dist install uninstall
diff --git a/arg.h b/arg.h
new file mode 100644
index 0000000..4ea4216
--- /dev/null
+++ b/arg.h
@@ -0,0 +1,61 @@
+/*
+ * Copy me if you can.
+ * by 20h
+ */
+
+#ifndef ARG_H__
+#define ARG_H__
+
+extern char *argv0;
+
+/* use main(int argc, char *argv[]) */
+#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
+ argv[0] && argv[0][1]\
+ && argv[0][0] == '-';\
+ argc--, argv++) {\
+ char argc_;\
+ char **argv_;\
+ int brk_;\
+ if (argv[0][1] == '-' && argv[0][2] == '