diff options
| author | Sadeep Madurange <smadurange@users.noreply.github.com> | 2022-01-28 19:11:53 +0800 |
|---|---|---|
| committer | Sadeep Madurange <smadurange@users.noreply.github.com> | 2022-01-28 19:11:53 +0800 |
| commit | 0688887fb40488b5bbd70acbc168b5eb9eb44a11 (patch) | |
| tree | b71c8efffb1f0170e361002bf33de767edeb620c /5 | |
| parent | eb5053b050ec1d03d1f5307f8b45abdfc614b9fa (diff) | |
| download | k&r-exercises-0688887fb40488b5bbd70acbc168b5eb9eb44a11.tar.gz | |
5.11
Diffstat (limited to '5')
| -rw-r--r-- | 5/11.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -109,12 +109,13 @@ void entab(char *s, char *t, int *tablist, int tablistc) { t[j] = 0; } else { - for (i = 0, j = 0, k = 0; i < tablistc && s[j] != 0; j++) { + for (i = 0, j = 0, k = 0, l = 1; i < tablistc && s[j] != 0; j++) { if (s[j] != ' ') { t[k++] = s[j]; - if (s[j] == '\n') - l = 0; - else + if (s[j] == '\n') { + l = 1; + i = 0; + } else l++; } else { for (m = j; m <= tablist[i] && s[m] == ' '; m++) @@ -122,6 +123,8 @@ void entab(char *s, char *t, int *tablist, int tablistc) { if (m == tablist[i]) { t[k++] = '\t'; l = m + 1; + for (i += 1; i < tablistc && tablist[i] >= l; i++) + ; } else { t[k++] = s[j]; l++; |
