[PATCH] more: fix control character display bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This removes isprint(c) column++ from get_line() that made underlining,
bold, and other control characters to cause more display to wrap lines
incorrectly.  Easiest way to see the difference is to run following
before and after compiling this change.

PAGER=./more man man

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 text-utils/more.c | 59 +++++++++++++++++++++++++------------------------------
 1 file changed, 27 insertions(+), 32 deletions(-)

diff --git a/text-utils/more.c b/text-utils/more.c
index 94b0455..a8e9254 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -997,41 +997,36 @@ int get_line(register FILE *f, int *length)
 		} else if (c == EOF) {
 			*length = p - Line;
 			return (column);
-		} else {
+		}
 #ifdef HAVE_WIDECHAR
-			if (fold_opt && MB_CUR_MAX > 1) {
-				memset(mbc, '\0', MB_LEN_MAX);
-				mbc_pos = 0;
-				mbc[mbc_pos++] = c;
-				state_bak = state;
-
-				mblength = mbrtowc(&wc, mbc, mbc_pos, &state);
-				/* The value of mblength is always less than 2 here. */
-				switch (mblength) {
-				case (size_t)-2:
-					p--;
-					file_pos_bak = Ftell(f) - 1;
-					state = state_bak;
-					use_mbc_buffer_flag = 1;
-					break;
-
-				case (size_t)-1:
-					state = state_bak;
-					column++;
-					break;
-
-				default:
-					wc_width = wcwidth(wc);
-					if (wc_width > 0)
-						column += wc_width;
-				}
-			} else
-#endif	/* HAVE_WIDECHAR */
-			{
-				if (isprint(c))
-					column++;
+		else if (fold_opt && MB_CUR_MAX > 1) {
+			memset(mbc, '\0', MB_LEN_MAX);
+			mbc_pos = 0;
+			mbc[mbc_pos++] = c;
+			state_bak = state;
+
+			mblength = mbrtowc(&wc, mbc, mbc_pos, &state);
+			/* The value of mblength is always less than 2 here. */
+			switch (mblength) {
+			case (size_t)-2:
+				p--;
+				file_pos_bak = Ftell(f) - 1;
+				state = state_bak;
+				use_mbc_buffer_flag = 1;
+				break;
+
+			case (size_t)-1:
+				state = state_bak;
+				column++;
+				break;
+
+			default:
+				wc_width = wcwidth(wc);
+				if (wc_width > 0)
+					column += wc_width;
 			}
 		}
+#endif	/* HAVE_WIDECHAR */
 
 		if (column >= Mcol && fold_opt)
 			break;
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux