aboutsummaryrefslogtreecommitdiff
path: root/ch5/5-11_entab-remixed.c
diff options
context:
space:
mode:
Diffstat (limited to 'ch5/5-11_entab-remixed.c')
-rw-r--r--ch5/5-11_entab-remixed.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/ch5/5-11_entab-remixed.c b/ch5/5-11_entab-remixed.c
index 8f6f7d4..d517365 100644
--- a/ch5/5-11_entab-remixed.c
+++ b/ch5/5-11_entab-remixed.c
@@ -21,17 +21,14 @@
int main(int argc, char *argv[]) {
int column, c, spaces, tabnum, stop;
spaces = column = 0;
-
if (argc > 1) {
tabnum = 1;
stop = atoi(argv[tabnum]);
} else {
tabnum = 0;
}
-
while ((c = getchar()) != EOF) {
column++;
-
if (c == ' ') {
spaces++;
if (argc > 1) {
@@ -43,11 +40,11 @@ int main(int argc, char *argv[]) {
putchar('\t');
spaces = 0;
}
- } else if (column > stop && tabnum < (argc -1)) {
+ } else if (column > stop && tabnum < (argc - 1)) {
stop = atoi(argv[++tabnum]);
}
} else {
- // we need to do default tabstopping
+ // we need to do default tabstopping
if (column % TABWIDTH == 0 && spaces > 1) {
putchar('\t');
spaces = 0;
@@ -71,6 +68,5 @@ int main(int argc, char *argv[]) {
putchar(c);
}
}
-
return 0;
}