summaryrefslogtreecommitdiffstats
path: root/text-utils/more.c
diff options
context:
space:
mode:
authorKarel Zak2007-08-14 11:51:19 +0200
committerKarel Zak2007-08-14 11:51:19 +0200
commit99bd8154adb07352e5bdd9821f612c07d97b8522 (patch)
tree661cec7cde87c22485ba7b6078bdd174da0bcb7c /text-utils/more.c
parentlogin: replace /usr/spool/mail with /var/spool/main in man page (diff)
downloadkernel-qcow2-util-linux-99bd8154adb07352e5bdd9821f612c07d97b8522.tar.gz
kernel-qcow2-util-linux-99bd8154adb07352e5bdd9821f612c07d97b8522.tar.xz
kernel-qcow2-util-linux-99bd8154adb07352e5bdd9821f612c07d97b8522.zip
more: fix underlining for multibyte chars
Try: $ printf "aaa _\bŽ_\bŽ_\bŽ bbb\n" | more aaa ŽŽŽ bbb (ŽŽŽ has to be three underlined chars on terminal). Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils/more.c')
-rw-r--r--text-utils/more.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/text-utils/more.c b/text-utils/more.c
index db2fa4d20..19c441789 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -1052,7 +1052,23 @@ void prbuf (register char *s, register int n)
my_putstring(state ? ULenter : ULexit);
}
if (c != ' ' || pstate == 0 || state != 0 || ulglitch == 0)
+#ifdef ENABLE_WIDECHAR
+ {
+ wchar_t wc;
+ size_t mblength;
+ mbstate_t state;
+ memset (&state, '\0', sizeof (mbstate_t));
+ s--; n++;
+ mblength = mbrtowc (&wc, s, n, &state);
+ if (mblength == (size_t) -2 || mblength == (size_t) -1)
+ mblength = 1;
+ while (mblength--)
+ putchar (*s++);
+ n += mblength;
+ }
+#else
putchar(c);
+#endif /* ENABLE_WIDECHAR */
if (state && *chUL) {
putsout(chBS);
my_putstring(chUL);