summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak2018-01-12 11:59:22 +0100
committerKarel Zak2018-01-12 11:59:22 +0100
commitbc9ca775a2027a4b587a0fddffb18068e2803199 (patch)
treead67c5aad997c62b17eeeb51ba77e938caa39464 /lib
parentinclude/debug: don't print pointer address for SUID programs (diff)
parenttests: mark mbsencode as KNOWN_FAIL (diff)
downloadkernel-qcow2-util-linux-bc9ca775a2027a4b587a0fddffb18068e2803199.tar.gz
kernel-qcow2-util-linux-bc9ca775a2027a4b587a0fddffb18068e2803199.tar.xz
kernel-qcow2-util-linux-bc9ca775a2027a4b587a0fddffb18068e2803199.zip
Merge branch 'mbsencode' of https://github.com/yontalcar/util-linux
* 'mbsencode' of https://github.com/yontalcar/util-linux: tests: mark mbsencode as KNOWN_FAIL tests: mbsencode - test for HAVE_WIDECHAR lib/mbsalign: Fix escaping nonprintable multibyte characters tests: mbsencode - removed emoji, added control unicode character tests: add tests for encode functions from lib/mbsalign.c lib/mbsalign: escape "\x" when HAVE_WIDECHAR not defined
Diffstat (limited to 'lib')
-rw-r--r--lib/mbsalign.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/mbsalign.c b/lib/mbsalign.c
index 07fc313b8..8fdab9ee9 100644
--- a/lib/mbsalign.c
+++ b/lib/mbsalign.c
@@ -168,7 +168,7 @@ char *mbs_safe_encode_to_buffer(const char *s, size_t *width, char *buf, const c
} else if (!iswprint(wc)) {
size_t i;
for (i = 0; i < len; i++) {
- sprintf(r, "\\x%02x", (unsigned char) *p);
+ sprintf(r, "\\x%02x", (unsigned char) p[i]);
r += 4;
*width += 4;
}
@@ -223,6 +223,9 @@ char *mbs_invalid_encode_to_buffer(const char *s, size_t *width, char *buf)
#ifdef HAVE_WIDECHAR
wchar_t wc;
size_t len = mbrtowc(&wc, p, MB_CUR_MAX, &st);
+#else
+ size_t len = 1;
+#endif
if (len == 0)
break; /* end of string */
@@ -251,10 +254,6 @@ char *mbs_invalid_encode_to_buffer(const char *s, size_t *width, char *buf)
*width += wcwidth(wc);
}
p += len;
-#else
- *r++ = *p++;
- (*width)++;
-#endif
}
*r = '\0';