summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorepoch <epoch@hack.thebackupbox.net>2022-02-18 19:25:51 +0000
committerepoch <epoch@hack.thebackupbox.net>2022-02-18 19:25:51 +0000
commit4a64590196a02952c2e02b11d97109ede5bd277f (patch)
tree04bd08babda6992ecf2284315038a03a5841b165
parente13e0930a8c12a483dd8fa49c1d2209b3616acbd (diff)
downloadsegfault-master.tar.gz
segfault-master.zip
added spacifyHEADmaster
-rw-r--r--Makefile5
-rw-r--r--spacify.c19
2 files changed, 22 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 4e755c7..9d4e4d6 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,14 @@
PREFIX:=/usr/local
-LDFLAGS=-L/usr/local/lib -L$(PREFIX)/lib -lirc -lhashtable -lgcc_s -lidc -ldl
CFLAGS=-pedantic -Wall -ggdb -I/usr/local/include -I$(PREFIX)/include
-all: segfault libhack.so
+all: segfault libhack.so spacify
libhack.so: libhack.o
ld -shared -o libhack.so libhack.o
again: clean all
+segfault: LDFLAGS=-L/usr/local/lib -L$(PREFIX)/lib -lirc -lhashtable -lgcc_s -lidc -ldl
segfault: segfault.c access.h
clean:
@@ -16,3 +16,4 @@ clean:
install: all
install segfault /usr/local/bin/
+ install spacify /usr/local/bin/
diff --git a/spacify.c b/spacify.c
new file mode 100644
index 0000000..a02ba31
--- /dev/null
+++ b/spacify.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc,char *argv[]) {
+ int in,i,left,col=0,tabsize=8;
+ for(left=0;(in=fgetc(stdin)) != -1;left++) {
+ if(in == '\t') {
+ col++;
+ if(argc > col) tabsize=atoi(argv[col]);
+ if(!tabsize) tabsize=8;//they did something dumb. force it to not do that.
+ for(i=left%tabsize;i<tabsize;i++) putchar(' ');
+ left=-1;
+ continue;
+ }
+ if(in == '\n') { left=-1; col=0; }
+ putchar(in);
+ }
+ return 0;
+}