From 14e1a4e1ff70aff36db3f5d2a8b806efd0134d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= Date: Thu, 18 Oct 2012 16:43:28 +0200 Subject: utf8: fix off-by-one wrapping of text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wrapping logic in strbuf_add_wrapped_text() does currently not allow lines that entirely fill the allowed width, instead it wraps the line one character too early. For example, the text "This is the sixth commit." formatted via "%w(11,1,2)" (wrap at 11 characters, 1 char indent of first line, 2 char indent of following lines) results in four lines: " This is", " the", " sixth", " commit." This is wrong, because " the sixth" is exactly 11 characters long, and thus allowed. Fix this by allowing the (width+1) character of a line to be a valid wrapping point if it is a whitespace character. Signed-off-by: Jan H. Schönherr Signed-off-by: Junio C Hamano --- utf8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utf8.c') diff --git a/utf8.c b/utf8.c index 8acbc660d3..523a78a651 100644 --- a/utf8.c +++ b/utf8.c @@ -353,7 +353,7 @@ retry: c = *text; if (!c || isspace(c)) { - if (w < width || !space) { + if (w <= width || !space) { const char *start = bol; if (!c && text == start) return w; -- cgit v1.2.3