add program for doing shouty caps

This commit is contained in:
randomuser 2020-12-31 18:24:47 -06:00
parent 89dcb1ec50
commit cec737e0f8
2 changed files with 40 additions and 3 deletions

View File

@ -1,8 +1,11 @@
install: man sh install: man sh c
man: man:
mkdir -p $(DESTDIR)$(PREFIX)/man1 mkdir -p $(DESTDIR)$(PREFIX)/man1
cp -f *.1 $(DESTDIR)$(PREFIX)/man1 cp -f *.1 $(DESTDIR)$(PREFIX)/man1
sh: sh:
mkdir -p $(DESTDIR)$(PREFIX)/bin mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f paste $(DESTDIR)$(PREFIX)/bin cp -f scripts/paste $(DESTDIR)$(PREFIX)/bin
cp -f bat $(DESTDIR)$(PREFIX)/bin cp -f scripts/bat $(DESTDIR)$(PREFIX)/bin
c:
cc progs/scream.c -o progs/scream
cp -f progs/scream $(DESTDIR)$(PREFIX)/bin

34
progs/scream.c Normal file
View File

@ -0,0 +1,34 @@
#include <stdio.h>
#include <ctype.h>
/* written on new year's eve 2020
* good night and good riddance */
char newchar(char c, int i) {
switch(i) {
case 0:
if(isupper(c)) return c + 32;
if(c == 33) return -2;
else return c;
case 1:
if(islower(c)) return c - 32;
if(c == 33) return -2;
else return c;
default: return -1;
}
}
int advi(int i) {
switch(i) {
case 0: return 1;
case 1: return 0;
default: return -1;
}
}
int main(void) {
char c;
int i = 0;
while((c = getchar()) != EOF) {
putchar(newchar(c, i));
i = advi(i);
}
}