aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-06-21 00:25:35 -0500
committerRob Landley <rob@landley.net>2018-06-21 00:25:35 -0500
commitf8c93b1ec6f9c8356e5c368cbf9963ce0900b35d (patch)
tree3a214135809b304883530a0afc0a6ed34a57af1d
parent84015ca09da250e8ea46f2e212efa51274af4124 (diff)
downloadtoybox-f8c93b1ec6f9c8356e5c368cbf9963ce0900b35d.tar.gz
Tweak fmt width calculation.
-rw-r--r--toys/pending/fmt.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/toys/pending/fmt.c b/toys/pending/fmt.c
index 64df69da..a3d30f02 100644
--- a/toys/pending/fmt.c
+++ b/toys/pending/fmt.c
@@ -74,15 +74,15 @@ static void fmt_line(char **pline, long len)
while (idx<len && !isspace(line[idx])) idx++;
line[idx++] = 0;
count = utf8len(word);
- if (TT.pos+count>=TT.width) newline();
+ if (TT.pos+count+!!TT.pos>=TT.width) newline();
// When indenting a new line, preserve tab/space mixture of input
if (!TT.pos) {
- TT.pos = TT.level-1;
+ TT.pos = TT.level;
if (indent) printf("%.*s", indent, line);
- }
- printf(" %s"+!(TT.pos!=TT.level-1), word);
- TT.pos += count+1;
+ } else count++;
+ printf(" %s"+!(TT.pos!=TT.level), word);
+ TT.pos += count;
while (isspace(line[idx])) idx++;
}
}