Add splint support to the makefile. Sync support between ME and MP

utilities.
This commit is contained in:
Mid Favila 2022-09-07 16:48:25 -04:00
parent 8fdb8b090e
commit cd3f05e0b8
4 changed files with 16 additions and 12 deletions

7
README
View File

@ -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.

View File

@ -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)

View File

@ -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 <stdlib.h>
#include <stdio.h>
@ -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);)
{

View File

@ -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);
}
}