From 2adaa64746939a006800e3f1bbf9eb4f2f69ddce Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 29 Aug 2023 19:33:19 +1000 Subject: [PATCH] rfc822header: only include one space after , in a list There is no need to copy all spaces after a comma verbatim. Precisely one is what we want for the wrap point. Signed-off-by: NeilBrown --- lib-rfc822header.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib-rfc822header.c b/lib-rfc822header.c index 8030c84a..11dbae80 100644 --- a/lib-rfc822header.c +++ b/lib-rfc822header.c @@ -300,22 +300,18 @@ static void copy_header(struct pane *doc safe, b[i] = ' '; call("doc:replace", p, 1, NULL, b, 0, point); if (ch == ',' && is_list) { - /* This comma is no in a quoted word, so it really marks - * part of a list, and together with following spaces - * is a wrap-point. + /* This comma is not in a quoted word, so it really marks + * part of a list, and so is a wrap-point. Consume any + * following spaces and include just one space in + * the result. */ struct mark *p2 = mark_dup(point); - int cnt = 1; doc_prev(p, p2); - while ((ch = doc_following(doc, m)) == ' ') { - call("doc:replace", p, 1, NULL, " ", 0, point); + while ((ch = doc_following(doc, m)) == ' ') doc_next(doc, m); - cnt += 1; - } - if (ch == '\n' || ch == '\r') - cnt += 1; - snprintf(buf, sizeof(buf), "%d", cnt); - call("doc:set-attr", p, 1, p2, "render:rfc822header-wrap", 0, NULL, buf); + call("doc:replace", p, 1, NULL, " ", 0, point); + call("doc:set-attr", p, 1, p2, + "render:rfc822header-wrap", 0, NULL, "2"); mark_free(p2); } } -- 2.39.5