aboutsummaryrefslogtreecommitdiff
path: root/src/xz
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2019-05-01 18:43:10 +0300
committerLasse Collin <lasse.collin@tukaani.org>2019-05-01 18:43:10 +0300
commit4ed339606156bd313ed99237485cb8ed0362d64f (patch)
treee3ec1ea2b3b5afa0025926499e970ef7b7613ced /src/xz
parentxz: Fix xz -lvv column alignment to look at the translated strings. (diff)
downloadxz-4ed339606156bd313ed99237485cb8ed0362d64f.tar.xz
xz: In xz -lvv look at the widths of the check names too.
Now the widths of the check names is used to adjust the width of the Check column. This way there no longer is a need to restrict the widths of the check names to be at most ten terminal-columns.
Diffstat (limited to 'src/xz')
-rw-r--r--src/xz/list.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/xz/list.c b/src/xz/list.c
index a6cc4c34..7d7ad98f 100644
--- a/src/xz/list.c
+++ b/src/xz/list.c
@@ -160,15 +160,15 @@ enum {
/// Check ID to string mapping
static const char check_names[LZMA_CHECK_ID_MAX + 1][12] = {
// TRANSLATORS: Indicates that there is no integrity check.
- // This string is used in tables, so the width must not
- // exceed ten columns with a fixed-width font.
+ // This string is used in tables. In older xz version this
+ // string was limited to ten columns in a fixed-width font, but
+ // nowadays there is no strict length restriction anymore.
N_("None"),
"CRC32",
// TRANSLATORS: Indicates that integrity check name is not known,
- // but the Check ID is known (here 2). This and other "Unknown-N"
- // strings are used in tables, so the width must not exceed ten
- // columns with a fixed-width font. It's OK to omit the dash if
- // you need space for one extra letter, but don't use spaces.
+ // but the Check ID is known (here 2). In older xz version these
+ // strings were limited to ten columns in a fixed-width font, but
+ // nowadays there is no strict length restriction anymore.
N_("Unknown-2"),
N_("Unknown-3"),
"CRC64",
@@ -256,6 +256,26 @@ init_colon_strs(void)
static void
init_headings(void)
{
+ // Before going through the heading strings themselves, treat
+ // the Check heading specially: Look at the widths of the various
+ // check names and increase the width of the Check column if neeeded.
+ // The width of the heading name "Check" will then be handled normally
+ // with other heading names in the second loop in this function.
+ for (unsigned i = 0; i < ARRAY_SIZE(check_names); ++i) {
+ size_t len;
+ size_t w = tuklib_mbstr_width(_(check_names[i]), &len);
+
+ // Error handling like in init_colon_strs().
+ assert(w != (size_t)-1);
+ if (w == (size_t)-1)
+ w = len;
+
+ // If the translated string is wider than the minimum width
+ // set at compile time, increase the width.
+ if ((size_t)(headings[HEADING_CHECK].columns) < w)
+ headings[HEADING_CHECK].columns = w;
+ }
+
for (unsigned i = 0; i < ARRAY_SIZE(headings); ++i) {
size_t len;
size_t w = tuklib_mbstr_width(_(headings[i].str), &len);