1
0

actually use macros

This commit is contained in:
dtb 2022-10-16 18:43:27 -04:00
parent e1805936ef
commit 74e69d6c56

View File

@ -47,8 +47,6 @@ static char alpha_upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM";
static char alpha_lower[] = "abcdefghijklmnopqrstuvwxyzabcdefghijklm"; static char alpha_lower[] = "abcdefghijklmnopqrstuvwxyzabcdefghijklm";
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
char *a; /* easier than doing freaky math */
CHARACTER c;
if(argc > 1){ if(argc > 1){
fprintf(stderr, "Usage: %s\n", fprintf(stderr, "Usage: %s\n",
@ -57,12 +55,17 @@ int main(int argc, char *argv[]){
return EX_USAGE; return EX_USAGE;
} }
while((c = getc(stdin)) != EOF) { /* rot13 */
if(isalpha(c)){ char *a; /* easier than doing freaky math */
a = isupper(c) ? alpha_upper : alpha_lower; CHARACTER c;
putc(a[c - a[0] + 13], stdout);
}else while((c = GETC(stdin)) != ENDOFFILE)
putc(c, stdout); if(isalpha(c)){
a = isupper(c) ? alpha_upper : alpha_lower;
PUTC(a[c - a[0] + 13], stdout);
}else
PUTC(c, stdout);
}
return EX_OK; return EX_OK;
} }