Commit d679701d6e4e5f46bdbdac985ee442bc01bcba4a

Thomas de Grivel 2022-05-31T11:14:44

remove size

diff --git a/Makefile b/Makefile
index b6f24c1..1da873d 100644
--- a/Makefile
+++ b/Makefile
@@ -7,21 +7,13 @@ git_nif_SRC = c_src/git_nif.c
 git_nif_SRC_O = c_src/git_nif.o
 git_nif_LIBS = -lgit2
 
-size = bin/size
-size_SRC = c_src/size.c
-size_SRC_O = c_src/size.o
-size_LIBS =
-
-PROGS = ${git_nif} ${size}
+PROGS = ${git_nif}
 
 all: ${PROGS}
 
 ${git_nif}: ${git_nif_SRC_O}
 	${CC} -fPIC -shared ${LDFLAGS} ${git_nif_SRC_O} ${git_nif_LIBS} -o ${git_nif}
 
-${size}: ${size_SRC_O}
-	${CC} ${CFLAGS} ${LDFLAGS} ${size_SRC_O} ${size_LIBS} -o ${size}
-
 .c.o:
 	${CC} ${CPPFLAGS} ${CFLAGS} -c $< -o $@
 
diff --git a/c_src/size.c b/c_src/size.c
deleted file mode 100644
index bdd49f2..0000000
--- a/c_src/size.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* size - truncate standard input by size */
-
-#include <err.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define BUFSIZE 8192
-
-int usage(char *argv0)
-{
-  fprintf(stderr, "Usage: %s SIZE COMMAND [ARGS ...]\n", argv0);
-  return 1;
-}
-
-int main (int argc, char **argv)
-{
-  char *a;
-  char cmd[BUFSIZE];
-  char *c = cmd;
-  char buf[BUFSIZE];
-  int i = 0;
-  size_t pos = 0;
-  ssize_t r;
-  unsigned long size;
-  FILE *pipe;
-  size_t len;
-  if (argc < 3)
-    return usage(argv[0]);
-  size = strtoul(argv[1], NULL, 10);
-  for (i = 2; i < argc; i++) {
-    a = argv[i];
-    while ((*c++ = *a++))
-      ;
-    c--;
-    *c++ = ' ';
-  }
-  *c = 0;
-  pipe = popen(cmd, "w");
-  len = pos + BUFSIZE < size ? BUFSIZE : size - pos;
-  while (pos < size && (r = fread(buf, 1, len, stdin)) > 0) {
-    if (fwrite(buf, r, 1, pipe) != 1)
-      err(1, "fwrite");
-    pos += r;
-    len = pos + BUFSIZE < size ? BUFSIZE : size - pos;
-  }
-  if (r < 0)
-      err(1, "fread");
-  pclose(pipe);
-  return 0;
-}