summaryrefslogtreecommitdiffstats
path: root/5/11.c
diff options
context:
space:
mode:
Diffstat (limited to '5/11.c')
-rw-r--r--5/11.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/5/11.c b/5/11.c
index 22560d9..72fe92f 100644
--- a/5/11.c
+++ b/5/11.c
@@ -90,7 +90,7 @@ int gettablist(char *s, int *t) {
}
void entab(char *s, char *t, int *tablist, int tablistc) {
- int i, j, k;
+ int i, j, k, col;
if (tablistc == 1) {
for (i = 0, j = 0; j < MAXTEXT && (t[j] = s[i]) != 0; i++) {
@@ -101,7 +101,19 @@ void entab(char *s, char *t, int *tablist, int tablistc) {
j++;
}
} else {
- // todo
+ col = 1;
+ for (i = 0, j = 0, k = 0; k < MAXTEXT && s[i] != 0 && j <= tablistc; i++) {
+ if (s[i] != '\t') {
+ t[k++] = s[i];
+ if (s[i] == '\n')
+ col = 1;
+ else
+ col++;
+ } else {
+ for (; col <= tablist[j++] && k < MAXTEXT; col++)
+ t[k++] = ' ';
+ }
+ }
}
t[j] = 0;