From: Kevin McCarthy Date: Wed, 15 Nov 2017 22:53:24 +0000 (-0800) Subject: Remove useless else branch in the $smart_wrap code. (see #3857) X-Git-Tag: mutt-1-10-rel~116 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=78d2c197e8eb79b67e07c44a9a740d4d865ed96a;p=mutt Remove useless else branch in the $smart_wrap code. (see #3857) Thanks to Vincent Lefèvre for noticing the nested else was redundant, since buf_ptr is already set to "buf + cnt" after the format_line() call. This allows us to merge the inner and outer if statement, resulting in simpler code. --- diff --git a/pager.c b/pager.c index c7712443..4a9ac6a2 100644 --- a/pager.c +++ b/pager.c @@ -1462,27 +1462,23 @@ display_line (FILE *f, LOFF_T *last_pos, struct line_t **lineInfo, int n, /* move the break point only if smart_wrap is set */ if (option (OPTWRAP)) { - if (cnt < b_read) + if (cnt < b_read && + ch != -1 && + buf[cnt] != ' ' && buf[cnt] != '\t' && buf[cnt] != '\n' && buf[cnt] != '\r') { - if (ch != -1 && - buf[cnt] != ' ' && buf[cnt] != '\t' && buf[cnt] != '\n' && buf[cnt] != '\r') - { - buf_ptr = buf + ch; - /* skip trailing blanks */ - while (ch && (buf[ch] == ' ' || buf[ch] == '\t' || buf[ch] == '\r')) - ch--; - /* A very long word with leading spaces causes infinite - * wrapping when MUTT_PAGER_NSKIP is set. A folded header - * with a single long word shouldn't be smartwrapped - * either. So just disable smart_wrap if it would wrap at the - * beginning of the line. */ - if (!ch) - buf_ptr = buf + cnt; - else - cnt = ch + 1; - } + buf_ptr = buf + ch; + /* skip trailing blanks */ + while (ch && (buf[ch] == ' ' || buf[ch] == '\t' || buf[ch] == '\r')) + ch--; + /* A very long word with leading spaces causes infinite + * wrapping when MUTT_PAGER_NSKIP is set. A folded header + * with a single long word shouldn't be smartwrapped + * either. So just disable smart_wrap if it would wrap at the + * beginning of the line. */ + if (!ch) + buf_ptr = buf + cnt; else - buf_ptr = buf + cnt; /* a very long word... */ + cnt = ch + 1; } if (!(flags & MUTT_PAGER_NSKIP)) /* skip leading blanks on the next line too */