Add Makefile. Remove empty unfold.c.

This commit is contained in:
Mid Favila 2022-09-06 18:23:51 -04:00
parent a3a3b901a8
commit 8fdb8b090e
4 changed files with 33 additions and 14 deletions

21
src/Makefile Normal file
View File

@ -0,0 +1,21 @@
.POSIX:
.SUFFIX:
PREFIX = /usr
BINS = \
overwrite \
strcmp \
vis
all: $(BINS)
install: all
install -Dm755 $(BINS) $(DESTDIR)/$(PREFIX)/bin/
clean:
rm *.o $(BINS) *~ a.out
.SUFFIX:
.c.o:
cc -c -o $< $(CFLAGS) $(LDFLAGS)

View File

@ -44,17 +44,17 @@ void throw(long unsigned int condition, void *info)
{
switch(condition)
{
case UNKNOWN_FAIL: printf("unknown failure\n");
case UNKNOWN_FAIL: fprintf(stderr, "unknown failure\n");
exit(UNKNOWN_FAIL);
case MALLOC_FAIL: printf("malloc failure\n");
case MALLOC_FAIL: fprintf(stderr, "malloc failure\n");
exit(MALLOC_FAIL);
case NEEDARG_FAIL: printf("usage: %s\n", (char *) info);
case NEEDARG_FAIL: fprintf(stderr, "usage: %s\n", (char *) info);
exit(NEEDARG_FAIL);
case FOPEN_FAIL: printf("failed to open: %s\n", (char *) info);
case FOPEN_FAIL: fprintf(stderr, "failed to open: %s\n", (char *) info);
exit(FOPEN_FAIL);
case WRITE_FAIL: printf("failed to write: %s\n", (char *) info);
case WRITE_FAIL: fprintf(stderr, "failed to write: %s\n", (char *) info);
exit(WRITE_FAIL);
default: printf("You shouldn't be seeing this.\nSomething is very wrong.\n");
default: fprintf(stderr, "You shouldn't be seeing this.\nSomething is very wrong.\n");
exit(-256);
}
}

View File

@ -1 +0,0 @@
#

View File

@ -8,19 +8,18 @@
int main(int argc, char **argv)
{
int i, c;
FILE *fp;
i = c = 0;
int c;
c = 0;
for(;(c = getchar()) != EOF; i++)
for(;(c = getchar()) != EOF;)
{
if(isascii(c) && (c != ' ' && c != '\n' && c != '\t'))
if(isascii(c) && !(c == ' ' || c == '\n' || c == '\t'))
{
printf("%c", c);
putc(c, stdout);
}
else
{
printf("%.3o", c);
fprintf(stdout, "%.3o", c);
}
}