View | Details | Raw Unified | Return to bug 224552 | Differences between
and this patch

Collapse All | Expand All

(-)b/usr.bin/hexdump/conv.c (-4 / +12 lines)
Lines 55-61 conv_c(PR *pr, u_char *p, size_t bufsize) Link Here
55
	wchar_t wc;
55
	wchar_t wc;
56
	size_t clen, oclen;
56
	size_t clen, oclen;
57
	int converr, pad, width;
57
	int converr, pad, width;
58
	u_char peekbuf[MB_LEN_MAX];
58
	u_char peekbuf[MB_LEN_MAX - 1];
59
	u_char *op;
59
60
60
	if (pr->mbleft > 0) {
61
	if (pr->mbleft > 0) {
61
		str = "**";
62
		str = "**";
Lines 107-112 conv_c(PR *pr, u_char *p, size_t bufsize) Link Here
107
		else if (clen == (size_t)-1 || (clen == (size_t)-2 &&
108
		else if (clen == (size_t)-1 || (clen == (size_t)-2 &&
108
		    p == peekbuf)) {
109
		    p == peekbuf)) {
109
			memset(&pr->mbstate, 0, sizeof(pr->mbstate));
110
			memset(&pr->mbstate, 0, sizeof(pr->mbstate));
111
			if (p == peekbuf) {
112
				/*
113
				 * We peeked ahead, but still can't complete;
114
				 * restore original character.
115
				 */
116
				p = op;
117
			}
110
			wc = *p;
118
			wc = *p;
111
			clen = 1;
119
			clen = 1;
112
			converr = 1;
120
			converr = 1;
Lines 116-122 conv_c(PR *pr, u_char *p, size_t bufsize) Link Here
116
			 * can complete it.
124
			 * can complete it.
117
			 */
125
			 */
118
			oclen = bufsize;
126
			oclen = bufsize;
119
			bufsize = peek(p = peekbuf, MB_CUR_MAX);
127
			op = p;
128
			bufsize = peek(p = peekbuf, MB_CUR_MAX - 1);
120
			goto retry;
129
			goto retry;
121
		}
130
		}
122
		clen += oclen;
131
		clen += oclen;
Lines 128-134 conv_c(PR *pr, u_char *p, size_t bufsize) Link Here
128
		if (!odmode) {
137
		if (!odmode) {
129
			*pr->cchar = 'c';
138
			*pr->cchar = 'c';
130
			(void)printf(pr->fmt, (int)wc);
139
			(void)printf(pr->fmt, (int)wc);
131
		} else {	
140
		} else {
132
			*pr->cchar = 'C';
141
			*pr->cchar = 'C';
133
			assert(strcmp(pr->fmt, "%3C") == 0);
142
			assert(strcmp(pr->fmt, "%3C") == 0);
134
			width = wcwidth(wc);
143
			width = wcwidth(wc);
135
- 

Return to bug 224552