Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH] more: fix control character display bug
@ 2015-01-30  8:54 Sami Kerola
  2015-01-30 16:05 ` Sami Kerola
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sami Kerola @ 2015-01-30  8:54 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

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@iki.fi>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-02-20 11:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-30  8:54 [PATCH] more: fix control character display bug Sami Kerola
2015-01-30 16:05 ` Sami Kerola
2015-02-02 10:35   ` Karel Zak
2015-01-30 20:18 ` Benno Schulenberg
2015-02-01 22:41   ` [PATCH 2/2] more: fix get_line() indentation Sami Kerola
2015-02-20 10:29 ` [PATCH] more: fix control character display bug Karel Zak
2015-02-20 11:06   ` Sami Kerola

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox