diff --git a/README b/README index 4a511b0..742cd63 100644 --- a/README +++ b/README @@ -6,10 +6,11 @@ highly portable and to cover common problems that can't be easily solved with shell. - -strcmp: Exits with 0 if the provided pair of strings differs. Otherwise, 1. - -vis: Replaces non-printing and non-ASCII characters with octal values. + -strcmp: Exits with 0 if the provided pair of strings differs. Otherwise, 1. [done] + -vis: Replaces non-printing and non-ASCII characters with octal values. [done] -unfold: Exactly what it sounds like. unfold will attempt to merge lines with fewer than the provided number of characters with the next line, so long as it doesn't cause a word-split. - -overwrite: Reads stdin and writes it to the provided file. + -overwrite: Reads stdin and writes it to the provided file. [done] + -shuf: Accepts an arbitrary number of arguments; returns one at random. diff --git a/src/Makefile b/src/Makefile index 1ebdd75..90464b2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -16,6 +16,9 @@ install: all clean: rm *.o $(BINS) *~ a.out +check: + splint +checks +posix-strict-lib +showsummary +forcehints +showscan +showsourceloc +toctou +its4low +its4moderate +its4risky +its4veryrisky +its4mostrisky +bufferoverflow *.c *.h + .SUFFIX: .c.o: cc -c -o $< $(CFLAGS) $(LDFLAGS) diff --git a/src/overwrite.c b/src/overwrite.c index 14aa99a..76cdb71 100644 --- a/src/overwrite.c +++ b/src/overwrite.c @@ -1,4 +1,4 @@ -/* overwrite.c -- program to exhaust stdin, then write it to a file */ +/* Overwrite.c -- program to exhaust stdin, then write it to a file */ #include #include @@ -10,7 +10,9 @@ int main(int argc, char **argv) { int buflen, strlen; + int c; char *buf; + FILE *fp; strlen = 0; buflen = 0; /* arbitrary */ @@ -23,9 +25,7 @@ int main(int argc, char **argv) if((buf = malloc(buflen))) { - int c; c = 0; - FILE *fp; for(;((c = getchar()) != EOF);) { diff --git a/src/support.h b/src/support.h index a00f932..b655b5e 100644 --- a/src/support.h +++ b/src/support.h @@ -44,17 +44,17 @@ void throw(long unsigned int condition, void *info) { switch(condition) { - case UNKNOWN_FAIL: fprintf(stderr, "unknown failure\n"); + case UNKNOWN_FAIL: printf("unknown failure\n"); exit(UNKNOWN_FAIL); - case MALLOC_FAIL: fprintf(stderr, "malloc failure\n"); + case MALLOC_FAIL: printf("malloc failure\n"); exit(MALLOC_FAIL); - case NEEDARG_FAIL: fprintf(stderr, "usage: %s\n", (char *) info); + case NEEDARG_FAIL: printf("usage: %s\n", (char *) info); exit(NEEDARG_FAIL); - case FOPEN_FAIL: fprintf(stderr, "failed to open: %s\n", (char *) info); + case FOPEN_FAIL: printf("failed to open: %s\n", (char *) info); exit(FOPEN_FAIL); - case WRITE_FAIL: fprintf(stderr, "failed to write: %s\n", (char *) info); + case WRITE_FAIL: printf("failed to write: %s\n", (char *) info); exit(WRITE_FAIL); - default: fprintf(stderr, "You shouldn't be seeing this.\nSomething is very wrong.\n"); + default: printf("You shouldn't be seeing this.\nSomething is very wrong.\n"); exit(-256); } }