summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--5/11.c11
1 files 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++;