Getting rid of that ugly switch statement

modified:   src/nms.c
This commit is contained in:
Brian Barto 2016-04-07 14:27:27 -04:00
parent 72bf59301a
commit 420987a544

View File

@ -29,20 +29,12 @@ int main(void) {
int c, x = 1, y = 1; int c, x = 1, y = 1;
bool first = true; bool first = true;
while ((c = getchar()) != EOF) { while ((c = getchar()) != EOF) {
switch (c) { if (c == NEWLINE) {
case '\n':
++y; ++y;
x = 1; x = 1;
break; } else if (isspace(c)) {
case ' ':
case '\t':
case '\f':
case '\r':
case '\v':
++x; ++x;
break; } else if (first) {
default:
if (first) {
start.source = c; start.source = c;
start.row = y; start.row = y;
start.col = x; start.col = x;
@ -64,9 +56,6 @@ int main(void) {
++x; ++x;
} }
break;
}
} }
clearTermWindow(termSizeRows, termSizeCols); clearTermWindow(termSizeRows, termSizeCols);