diff options
author | zlg <zlg@zlg.space> | 2016-06-16 10:15:33 -0700 |
---|---|---|
committer | zlg <zlg@zlg.space> | 2016-06-16 10:15:33 -0700 |
commit | f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7 (patch) | |
tree | e37b327d7f93435e93a57427600d2b91fbb0cd87 /ch5/5-11_entab-remixed.c | |
parent | Solve Exercise 7-2: Format arbitrary input (diff) | |
download | knr-f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7.tar.gz knr-f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7.tar.bz2 knr-f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7.tar.xz knr-f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7.zip |
The massive astyle sweep!
Code style should be consistent now. All future commits will be run through
astyle or they will be amended.
Diffstat (limited to 'ch5/5-11_entab-remixed.c')
-rw-r--r-- | ch5/5-11_entab-remixed.c | 8 |
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; } |