From 0688887fb40488b5bbd70acbc168b5eb9eb44a11 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Fri, 28 Jan 2022 19:11:53 +0800 Subject: 5.11 --- 5/11.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/5/11.c b/5/11.c index 1d08bd5..6d31f33 100644 --- a/5/11.c +++ b/5/11.c @@ -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++; -- cgit v1.2.3