From: Shlomi Fish Date: Wed, 14 Dec 2016 15:34:30 +0000 (+0200) Subject: Refactor and correct rot.c. X-Git-Tag: fortune-mod-1.99.3~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5be82532bd5e07cbe48f40efe5940ad79629264f;p=fortune-mod Refactor and correct rot.c. --- diff --git a/fortune-mod/util/rot.c b/fortune-mod/util/rot.c index acab56d..316580d 100644 --- a/fortune-mod/util/rot.c +++ b/fortune-mod/util/rot.c @@ -9,17 +9,15 @@ int main(void) { - char a, b; + int a; while ((a = getchar()) != EOF) { - if (isupper(a)) - b = 'A' + (a - 'A' + 13) % 26; - else if (islower(a)) - b = 'a' + (a - 'a' + 13) % 26; - else - b = a; - putchar(b); + putchar( + isupper(a) ? ('A' + (a - 'A' + 13) % 26) + : islower(a) ? ('a' + (a - 'a' + 13) % 26) + : a + ); } exit(0); }