summaryrefslogtreecommitdiffstats
path: root/lib/mbsalign.c
diff options
context:
space:
mode:
authorKarel Zak2016-01-13 10:08:13 +0100
committerKarel Zak2016-01-13 10:08:13 +0100
commit6426f926ee3d23fe416cd82e0325f249ba973798 (patch)
tree51d4422c639fcbc3ea7fa27f5a517040c75a69c7 /lib/mbsalign.c
parentlibblkid: use internally uint64_t for offsets and sizes (diff)
downloadkernel-qcow2-util-linux-6426f926ee3d23fe416cd82e0325f249ba973798.tar.gz
kernel-qcow2-util-linux-6426f926ee3d23fe416cd82e0325f249ba973798.tar.xz
kernel-qcow2-util-linux-6426f926ee3d23fe416cd82e0325f249ba973798.zip
lib/mbsalign: fix warnings when compile without widechars
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/mbsalign.c')
-rw-r--r--lib/mbsalign.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/mbsalign.c b/lib/mbsalign.c
index 052fec611..2816cebbf 100644
--- a/lib/mbsalign.c
+++ b/lib/mbsalign.c
@@ -301,7 +301,7 @@ mbs_truncate(char *str, size_t *width)
done:
free(wcs);
#else
- if (*width < bytes)
+ if (bytes >= 0 && *width < (size_t) bytes)
bytes = *width;
#endif
if (bytes >= 0)
@@ -350,10 +350,11 @@ mbsalign (const char *src, char *dest, size_t dest_size,
size_t n_cols = src_size - 1;
size_t n_used_bytes = n_cols; /* Not including NUL */
size_t n_spaces = 0, space_left;
+
+#ifdef HAVE_WIDECHAR
bool conversion = false;
bool wc_enabled = false;
-#ifdef HAVE_WIDECHAR
/* In multi-byte locales convert to wide characters
to allow easy truncation. Also determine number
of screen columns used. */
@@ -407,9 +408,9 @@ mbsalign (const char *src, char *dest, size_t dest_size,
n_cols = wc_truncate (str_wc, *width);
n_used_bytes = wcstombs (newstr, str_wc, src_size);
}
-#endif
mbsalign_unibyte:
+#endif
if (n_cols > *width) /* Unibyte truncation required. */
{
@@ -456,9 +457,9 @@ mbsalign_unibyte:
dest = mempcpy (dest, str_to_print, min (n_used_bytes, space_left));
mbs_align_pad (dest, dest_end, end_spaces);
}
-
+#ifdef HAVE_WIDECHAR
mbsalign_cleanup:
-
+#endif
free (str_wc);
free (newstr);