FreeBSD Bugzilla – Attachment 189747 Details for
Bug 224552
'od -c' show wrong char when it is a non-printable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Restore the original character if we peeked ahead, but still can't complete
0001-Restore-the-original-character-if-we-peeked-ahead-bu.patch (text/plain), 1.76 KB, created by
Yuri Pankov
on 2018-01-15 13:11:56 UTC
(
hide
)
Description:
Restore the original character if we peeked ahead, but still can't complete
Filename:
MIME Type:
Creator:
Yuri Pankov
Created:
2018-01-15 13:11:56 UTC
Size:
1.76 KB
patch
obsolete
>From 21b8589cb2dfc5f75202cae6ad0453cf3bcd2737 Mon Sep 17 00:00:00 2001 >From: Yuri Pankov <yuripv@icloud.com> >Date: Mon, 15 Jan 2018 16:07:41 +0300 >Subject: [PATCH] Restore the original character if we peeked ahead, but still > can't complete. > >While here, make the number of characters we peek ahead to be (MB_CUR_MAX - 1) >-- we already got one, there's no point in getting more than needed. >--- > usr.bin/hexdump/conv.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > >diff --git a/usr.bin/hexdump/conv.c b/usr.bin/hexdump/conv.c >index 95a1becb2dc0..131cfd66b577 100644 >--- a/usr.bin/hexdump/conv.c >+++ b/usr.bin/hexdump/conv.c >@@ -55,7 +55,8 @@ conv_c(PR *pr, u_char *p, size_t bufsize) > wchar_t wc; > size_t clen, oclen; > int converr, pad, width; >- u_char peekbuf[MB_LEN_MAX]; >+ u_char peekbuf[MB_LEN_MAX - 1]; >+ u_char *op; > > if (pr->mbleft > 0) { > str = "**"; >@@ -107,6 +108,13 @@ conv_c(PR *pr, u_char *p, size_t bufsize) > else if (clen == (size_t)-1 || (clen == (size_t)-2 && > p == peekbuf)) { > memset(&pr->mbstate, 0, sizeof(pr->mbstate)); >+ if (p == peekbuf) { >+ /* >+ * We peeked ahead, but still can't complete; >+ * restore original character. >+ */ >+ p = op; >+ } > wc = *p; > clen = 1; > converr = 1; >@@ -116,7 +124,8 @@ conv_c(PR *pr, u_char *p, size_t bufsize) > * can complete it. > */ > oclen = bufsize; >- bufsize = peek(p = peekbuf, MB_CUR_MAX); >+ op = p; >+ bufsize = peek(p = peekbuf, MB_CUR_MAX - 1); > goto retry; > } > clen += oclen; >@@ -128,7 +137,7 @@ conv_c(PR *pr, u_char *p, size_t bufsize) > if (!odmode) { > *pr->cchar = 'c'; > (void)printf(pr->fmt, (int)wc); >- } else { >+ } else { > *pr->cchar = 'C'; > assert(strcmp(pr->fmt, "%3C") == 0); > width = wcwidth(wc); >-- >2.15.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 224552
:
189747
|
189748