From unknown Wed Sep 10 09:11:03 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#6769 <6769@debbugs.gnu.org> To: bug#6769 <6769@debbugs.gnu.org> Subject: Status: df (GNU coreutils) 7.4 Dutch output misalignment Reply-To: bug#6769 <6769@debbugs.gnu.org> Date: Wed, 10 Sep 2025 16:11:03 +0000 retitle 6769 df (GNU coreutils) 7.4 Dutch output misalignment reassign 6769 coreutils submitter 6769 Erik Quaeghebeur severity 6769 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 31 20:48:30 2010 Received: (at submit) by debbugs.gnu.org; 1 Aug 2010 00:48:30 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OfMj7-00055V-Hv for submit@debbugs.gnu.org; Sat, 31 Jul 2010 20:48:30 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OfMS3-0004xR-69 for submit@debbugs.gnu.org; Sat, 31 Jul 2010 20:30:51 -0400 Received: from lists.gnu.org ([199.232.76.165]:41067) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OfMSM-0006nY-R5 for submit@debbugs.gnu.org; Sat, 31 Jul 2010 20:31:10 -0400 Received: from [140.186.70.92] (port=48501 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OfMSL-0000D3-Cb for bug-coreutils@gnu.org; Sat, 31 Jul 2010 20:31:10 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OfMSK-0005Ku-1o for bug-coreutils@gnu.org; Sat, 31 Jul 2010 20:31:09 -0400 Received: from out1.smtp.messagingengine.com ([66.111.4.25]:45907) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OfMSJ-0005Kj-V4 for bug-coreutils@gnu.org; Sat, 31 Jul 2010 20:31:08 -0400 Received: from compute2.internal (compute2.internal [10.202.2.42]) by gateway1.messagingengine.com (Postfix) with ESMTP id 7B00017591C for ; Sat, 31 Jul 2010 20:31:01 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute2.internal (MEProxy); Sat, 31 Jul 2010 20:31:01 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=date:from:to:subject:message-id:mime-version:content-type; s=smtpout; bh=maKclg+H2BS+YInT2EWdOO/T7kk=; b=eBd13ElpzT6Ek/LW0Ow0sqmxBHNT8GRg/4L0riAQ6p4TVBZjDEjaleOTei/xWZoaswwPqtT0UXVF2MhlfMYquYIDjd1/qAKc8rUq922eahxjpb2n/O9+w6brX3aZKv1aztYhOddqEjwwQ1pCq4sFq725/OA84P87pHh4dfcrQqs= X-Sasl-enc: U9qS8Ciya+XApPgw+PeSWiEY9dgISjsDsQX4R9HEXw1i 1280622661 Received: from sysopweg.local (c-24-3-244-168.hsd1.pa.comcast.net [24.3.244.168]) by mail.messagingengine.com (Postfix) with ESMTPSA id 1D7EF48114 for ; Sat, 31 Jul 2010 20:31:01 -0400 (EDT) Date: Sat, 31 Jul 2010 20:30:59 -0400 (EDT) From: Erik Quaeghebeur To: bug-coreutils@gnu.org Subject: df (GNU coreutils) 7.4 Dutch output misalignment Message-ID: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -3.3 (---) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 31 Jul 2010 20:48:27 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.6 (----) Dear df-maintainer, I observed a misalignment of the output of df (GNU coreutils) 7.4 in a Dutch locale: from the second column onward, the column header in the first row is too far to the right (by six spaces, in the cases I investigated). Sample output (please use a fixed-width font): $ df Bestandssysteem 1K-blokken Gebruikt Beschikbr Geb% Aangekoppeld op /dev/sda7 15306620 6146768 8382308 43% / none 1019676 364 1019312 1% /dev none 1024188 1728 1022460 1% /dev/shm none 1024188 276 1023912 1% /var/run none 1024188 0 1024188 0% /var/lock none 1024188 0 1024188 0% /lib/init/rw /dev/sda3 75272 19297 51959 28% /boot /dev/sda5 40132520 17351692 20742184 46% /home $ df -h Bestandssysteem Grtte Gebr Besch Geb% Aangekoppeld op /dev/sda7 15G 5,9G 8,0G 43% / none 996M 364K 996M 1% /dev none 1001M 1,7M 999M 1% /dev/shm none 1001M 276K 1000M 1% /var/run none 1001M 0 1001M 0% /var/lock none 1001M 0 1001M 0% /lib/init/rw /dev/sda3 74M 19M 51M 28% /boot /dev/sda5 39G 17G 20G 46% /home $ df -P Bestandssysteem 1024-blokken Gebruikt Beschikbr Vulgraad Aangekoppeld op /dev/sda7 15306620 6146768 8382308 43% / none 1019676 364 1019312 1% /dev none 1024188 1728 1022460 1% /dev/shm none 1024188 276 1023912 1% /var/run none 1024188 0 1024188 0% /var/lock none 1024188 0 1024188 0% /lib/init/rw /dev/sda3 75272 19297 51959 28% /boot /dev/sda5 40132520 17352604 20741272 46% /home No reply necessary. I appreciate your effort and very much understand that this minor issue does not have high priority. Sincerely, Erik Quaeghebeur From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 08 20:48:11 2010 Received: (at 6769) by debbugs.gnu.org; 9 Aug 2010 00:48:11 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OiGXD-0000Hv-DB for submit@debbugs.gnu.org; Sun, 08 Aug 2010 20:48:11 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OiGXB-0000Ho-FO for 6769@debbugs.gnu.org; Sun, 08 Aug 2010 20:48:10 -0400 Received: (qmail 86944 invoked from network); 9 Aug 2010 00:48:48 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 9 Aug 2010 00:48:48 -0000 Message-ID: <4C5F502F.8090007@draigBrady.com> Date: Mon, 09 Aug 2010 01:47:43 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: Erik Quaeghebeur Subject: Re: bug#6769: df (GNU coreutils) 7.4 Dutch output misalignment References: In-Reply-To: X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 6769 Cc: 6769@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) On 01/08/10 01:30, Erik Quaeghebeur wrote: > Dear df-maintainer, > > > I observed a misalignment of the output of df (GNU coreutils) 7.4 in a > Dutch locale: from the second column onward, the column header in the > first row is too far to the right (by six spaces, in the cases I > investigated). This is a common annoyance. I'm looking at fixing this with the mbsalign module. Note this will probably break translations for a while. cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 20 16:21:32 2010 Received: (at 6769) by debbugs.gnu.org; 20 Oct 2010 20:21:32 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P8fAC-000725-4l for submit@debbugs.gnu.org; Wed, 20 Oct 2010 16:21:32 -0400 Received: from out1.smtp.messagingengine.com ([66.111.4.25]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P8fA9-000720-2q for 6769@debbugs.gnu.org; Wed, 20 Oct 2010 16:21:29 -0400 Received: from compute2.internal (compute2.nyi.mail.srv.osa [10.202.2.42]) by gateway1.messagingengine.com (Postfix) with ESMTP id E5527532 for <6769@debbugs.gnu.org>; Wed, 20 Oct 2010 16:25:17 -0400 (EDT) Received: from web1.messagingengine.com ([10.202.2.211]) by compute2.internal (MEProxy); Wed, 20 Oct 2010 16:25:17 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=message-id:from:to:mime-version:content-transfer-encoding:content-type:subject:date; s=smtpout; bh=uUgbnIyd5cNjf21yDAaVYnfZUW0=; b=bWWzpY8rAFnTiIWLFzNqt1/jqlxMLhm32ccF8IXQwPcWct6grcPRropJ7Ar9iePJeoRChKnZBvqPMUrrSu095dxblgmssNLFasmUyKtuFbOPyioy8JEsrixno+pPGrfafDSq34X60XTMxmXxVlBimIcRsR/xJ2YjpVU8G0Fri4M= Received: by web1.messagingengine.com (Postfix, from userid 99) id C5EA5B415F6; Wed, 20 Oct 2010 16:25:17 -0400 (EDT) Message-Id: <1287606317.1683.1401107193@webmail.messagingengine.com> X-Sasl-Enc: +hlcl4W+4TxNasFbrbt8aOUVo2UtI9K2ShF5zPG3CFaj 1287606317 From: "Benno Schulenberg" To: 6769@debbugs.gnu.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii" X-Mailer: MessagingEngine.com Webmail Interface Subject: translation misalignment in 'df' is specific to Ubuntu Date: Wed, 20 Oct 2010 22:25:17 +0200 X-Spam-Score: -4.5 (----) X-Debbugs-Envelope-To: 6769 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.4 (----) Hello Erik, Most likely you were using a version of Ubuntu (or a derivative); the misalignment is due to a longstanding bug in Launchpad/Rosetta (https://bugs.launchpad.net/rosetta/+bug/30358). For Ubuntu 10.10 I've tried to alleviate the problem by reducing the word "Bestandssysteem" to "Bstndsystm" -- but just for Ubuntu, not for the official coreutils PO file at the Translation Project (http://translationproject.org/domain/coreutils.html). If you have more comments about translation deficiences, please direct them to the vertaling mailing list at vrijschrift (see the Dutch team page at the TP). Regards, Benno -- http://www.fastmail.fm - A fast, anti-spam email service. From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 22 10:09:20 2011 Received: (at 6769) by debbugs.gnu.org; 22 Mar 2011 14:09:20 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q22Gt-0003bS-8x for submit@debbugs.gnu.org; Tue, 22 Mar 2011 10:09:19 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1Q22Gq-0003bA-2L for 6769@debbugs.gnu.org; Tue, 22 Mar 2011 10:09:17 -0400 Received: (qmail 4131 invoked from network); 22 Mar 2011 14:09:09 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 22 Mar 2011 14:09:09 -0000 Message-ID: <4D88AD02.8030606@draigBrady.com> Date: Tue, 22 Mar 2011 14:06:58 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: 6769@debbugs.gnu.org Subject: Re: bug#6769: df (GNU coreutils) 7.4 Dutch output misalignment References: In-Reply-To: X-Enigmail-Version: 1.0.1 Content-Type: multipart/mixed; boundary="------------020901050808070303000603" X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 6769 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) This is a multi-part message in MIME format. --------------020901050808070303000603 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit On 01/08/10 01:30, Erik Quaeghebeur wrote: > Dear df-maintainer, > > > I observed a misalignment of the output of df (GNU coreutils) 7.4 in a > Dutch locale: from the second column onward, the column header in the > first row is too far to the right (by six spaces, in the cases I > investigated). Here's a proposed fix for all these alignment issues. A good command to compare before and after is: df --all -T -P -B\'1 cheers, Pádraig. --------------020901050808070303000603 Content-Type: text/x-patch; name="df-align.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="df-align.diff" >From 29cc6da1e23d5a08b8ab24c60455fb8543e4d31b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Mon, 19 Apr 2010 08:41:50 +0100 Subject: [PATCH] df: fix alignment of columns * src/df.c (alloc_table_row): A new function to allocate storage for a row of strings. (print_table): A new function to interate over all collected strings in the table, and apply alignment as perthe max width of each column. (get_header): Renamed from print_header, and adjusted accordingly. (get_dev): Renamed from show_dev. Note this was changed to remove the auto wrapping of the first column feature, as this is now less of an issue as headers will still be correctly aligned. This feature is also a common gotcha for scripts parsing the output from df. --- src/df.c | 431 +++++++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 272 insertions(+), 159 deletions(-) diff --git a/src/df.c b/src/df.c index 4523c44..5e0080f 100644 --- a/src/df.c +++ b/src/df.c @@ -22,11 +22,14 @@ #include #include #include +#include #include "system.h" #include "error.h" #include "fsusage.h" #include "human.h" +#include "mbsalign.h" +#include "mbswidth.h" #include "mountlist.h" #include "quote.h" #include "find-mount-point.h" @@ -112,6 +115,50 @@ static bool print_grand_total; /* Grand total data. */ static struct fs_usage grand_fsu; +enum { DEFAULT_MODE, INODES_MODE, HUMAN_MODE, POSIX_MODE, NMODES }; +static int header_mode = DEFAULT_MODE; + +enum +{ + DEV_FIELD, /* file system */ + TYPE_FIELD, /* FS type */ + TOTAL_FIELD, /* blocks or inodes */ + USED_FIELD, /* ditto */ + FREE_FIELD, /* ditto */ + PCENT_FIELD, /* percent used */ + MNT_FIELD, /* mount point */ + NFIELDS +}; + +/* Header strings for the above fields in each mode. + NULL means to use the header for the default mode. */ +static const char *headers[NFIELDS][NMODES] = { +/* DEFAULT_MODE INODES_MODE HUMAN_MODE POSIX_MODE */ + { N_("Filesystem"), NULL, NULL, NULL }, + { N_("Type"), NULL, NULL, NULL }, + { N_("blocks"), N_("Inodes"), N_("Size"), NULL }, + { N_("Used"), N_("IUsed"), NULL, NULL }, + { N_("Available"), N_("IFree"), N_("Avail"), NULL }, + { N_("Use%"), N_("IUse%"), NULL, N_("Capacity") }, + { N_("Mounted on"), NULL, NULL, NULL } +}; + +/* Alignments for the 3 textual and 4 numeric fields. */ +static mbs_align_t alignments[NFIELDS] = { + MBS_ALIGN_LEFT, MBS_ALIGN_LEFT, + MBS_ALIGN_RIGHT, MBS_ALIGN_RIGHT, MBS_ALIGN_RIGHT, MBS_ALIGN_RIGHT, + MBS_ALIGN_LEFT +}; + +/* Auto adjusted (up) widths used to align columns. */ +static size_t widths[NFIELDS] = { 14, 4, 5, 5, 5, 4, 0 }; + +/* Storage for pointers for each string (cell of table). */ +static char ***table; + +/* The current number of processed rows (including header). */ +static size_t nrows; + /* For long options that have no equivalent short option, use a non-character as a pseudo short option, starting with CHAR_MAX + 1. */ enum @@ -142,69 +189,125 @@ static struct option const long_options[] = }; static void -print_header (void) +alloc_table_row (void) { - char buf[MAX (LONGEST_HUMAN_READABLE + 1, INT_BUFSIZE_BOUND (uintmax_t))]; + nrows++; + table = xrealloc (table, nrows * sizeof (char *)); + table[nrows-1] = xmalloc (NFIELDS * sizeof (char *)); +} - if (print_type) - /* TRANSLATORS: - For best results (df header/column alignment), ensure that - your translation has the same length as the original. */ - fputs (_("Filesystem Type"), stdout); - else - fputs (_("Filesystem "), stdout); +static void +print_table (void) +{ + size_t field, row; - if (inode_format) - /* TRANSLATORS: - For best results (df header/column alignment), ensure that - your translation has the same length as the original. - Also, each column name translation should end at the same - column as the corresponding original. */ - fputs (_(" Inodes IUsed IFree IUse%"), stdout); - else if (human_output_opts & human_autoscale) + for (row = 0; row < nrows; row ++) { - if (human_output_opts & human_base_1024) - fputs (_(" Size Used Avail Use%"), stdout); - else - fputs (_(" Size Used Avail Use%"), stdout); + for (field = 0; field < NFIELDS; field++) + { + size_t width = widths[field]; + char *cell = table[row][field]; + if (!cell) + continue; + if (field != 0) + putchar (' '); + if (field != NFIELDS - 1) + { + cell = ambsalign (table[row][field], &width, + alignments[field], MBA_UNIBYTE_FALLBACK); + fputs (cell, stdout); + IF_LINT (free (cell)); + } + else + fputs (cell, stdout); + IF_LINT (free (table[row][field])); + } + putchar ('\n'); + IF_LINT (free (table[row])); } - else if (posix_format) - printf (_(" %s-blocks Used Available Capacity"), - umaxtostr (output_block_size, buf)); - else + + IF_LINT (free (table)); +} + +static void +get_header (void) +{ + size_t field; + + alloc_table_row (); + + for (field = 0; field < NFIELDS; field++) { - int opts = (human_suppress_point_zero - | human_autoscale | human_SI - | (human_output_opts - & (human_group_digits | human_base_1024 | human_B))); + if (field == TYPE_FIELD && !print_type) + { + table [nrows-1][field] = NULL; + continue; + } + + char *header = _(headers[field][header_mode]); + if (!header) + header = _(headers[field][DEFAULT_MODE]); - /* Prefer the base that makes the human-readable value more exact, - if there is a difference. */ + if (header_mode == DEFAULT_MODE && field == TOTAL_FIELD) + { + char buf[LONGEST_HUMAN_READABLE + 1]; - uintmax_t q1000 = output_block_size; - uintmax_t q1024 = output_block_size; - bool divisible_by_1000; - bool divisible_by_1024; + int opts = (human_suppress_point_zero + | human_autoscale | human_SI + | (human_output_opts + & (human_group_digits | human_base_1024 | human_B))); - do + /* Prefer the base that makes the human-readable value more exact, + if there is a difference. */ + + uintmax_t q1000 = output_block_size; + uintmax_t q1024 = output_block_size; + bool divisible_by_1000; + bool divisible_by_1024; + + do + { + divisible_by_1000 = q1000 % 1000 == 0; q1000 /= 1000; + divisible_by_1024 = q1024 % 1024 == 0; q1024 /= 1024; + } + while (divisible_by_1000 & divisible_by_1024); + + if (divisible_by_1000 < divisible_by_1024) + opts |= human_base_1024; + if (divisible_by_1024 < divisible_by_1000) + opts &= ~human_base_1024; + if (! (opts & human_base_1024)) + opts |= human_B; + + char *num = human_readable (output_block_size, buf, opts, 1, 1); + + char *nheader; + if (asprintf (&nheader, "%s-%s", num, header) == -1) + header = NULL; + else + header = nheader; + } + else if (header_mode == POSIX_MODE && field == TOTAL_FIELD) { - divisible_by_1000 = q1000 % 1000 == 0; q1000 /= 1000; - divisible_by_1024 = q1024 % 1024 == 0; q1024 /= 1024; + char buf[INT_BUFSIZE_BOUND (uintmax_t)]; + char *num = umaxtostr (output_block_size, buf); + + char *nheader; + if (asprintf (&nheader, "%s-%s", num, header) == -1) + header = NULL; + else + header = nheader; } - while (divisible_by_1000 & divisible_by_1024); + else + header = strdup (header); - if (divisible_by_1000 < divisible_by_1024) - opts |= human_base_1024; - if (divisible_by_1024 < divisible_by_1000) - opts &= ~human_base_1024; - if (! (opts & human_base_1024)) - opts |= human_B; + if (!header) + error (EXIT_FAILURE, errno, _("generating header")); - printf (_(" %4s-blocks Used Available Use%%"), - human_readable (output_block_size, buf, opts, 1, 1)); - } + table [nrows-1][field] = header; - fputs (_(" Mounted on\n"), stdout); + widths[field] = MAX (widths[field], mbswidth (header, 0)); + } } /* Is FSTYPE a type of file system that should be listed? */ @@ -319,16 +422,13 @@ add_uint_with_neg_flag (uintmax_t *dest, bool *dest_neg, ME_DUMMY and ME_REMOTE are the mount entry flags. */ static void -show_dev (char const *disk, char const *mount_point, - char const *stat_file, char const *fstype, - bool me_dummy, bool me_remote, - const struct fs_usage *force_fsu) +get_dev (char const *disk, char const *mount_point, + char const *stat_file, char const *fstype, + bool me_dummy, bool me_remote, + const struct fs_usage *force_fsu) { struct fs_usage fsu; - char buf[3][LONGEST_HUMAN_READABLE + 2]; - int width; - int col1_adjustment = 0; - int use_width; + char buf[LONGEST_HUMAN_READABLE + 2]; uintmax_t input_units; uintmax_t output_units; uintmax_t total; @@ -338,6 +438,8 @@ show_dev (char const *disk, char const *mount_point, uintmax_t used; bool negate_used; double pct = -1; + char* cell; + size_t field; if (me_remote && show_local_fs) return; @@ -370,39 +472,18 @@ show_dev (char const *disk, char const *mount_point, if (! file_systems_processed) { file_systems_processed = true; - print_header (); + get_header (); } + alloc_table_row (); + if (! disk) disk = "-"; /* unknown */ if (! fstype) fstype = "-"; /* unknown */ - /* df.c reserved 5 positions for fstype, - but that does not suffice for type iso9660 */ - if (print_type) - { - size_t disk_name_len = strlen (disk); - size_t fstype_len = strlen (fstype); - if (disk_name_len + fstype_len < 18) - printf ("%s%*s ", disk, 18 - (int) disk_name_len, fstype); - else if (!posix_format) - printf ("%s\n%18s ", disk, fstype); - else - printf ("%s %s", disk, fstype); - } - else - { - if (strlen (disk) > 20 && !posix_format) - printf ("%s\n%20s", disk, ""); - else - printf ("%-20s", disk); - } - if (inode_format) { - width = 7; - use_width = 5; input_units = output_units = 1; total = fsu.fsu_files; available = fsu.fsu_ffree; @@ -416,22 +497,6 @@ show_dev (char const *disk, char const *mount_point, } else { - if (human_output_opts & human_autoscale) - width = 5 + ! (human_output_opts & human_base_1024); - else - { - width = 9; - if (posix_format) - { - uintmax_t b; - col1_adjustment = -3; - for (b = output_block_size; 9 < b; b /= 10) - col1_adjustment++; - } - } - use_width = ((posix_format - && ! (human_output_opts & human_autoscale)) - ? 8 : 4); input_units = fsu.fsu_blocksize; output_units = output_block_size; total = fsu.fsu_blocks; @@ -458,67 +523,106 @@ show_dev (char const *disk, char const *mount_point, negate_used = (total < available_to_root); } - printf (" %*s %*s %*s ", - width + col1_adjustment, - df_readable (false, total, - buf[0], input_units, output_units), - width, df_readable (negate_used, used, - buf[1], input_units, output_units), - width, df_readable (negate_available, available, - buf[2], input_units, output_units)); - - if (! known_value (used) || ! known_value (available)) - ; - else if (!negate_used - && used <= TYPE_MAXIMUM (uintmax_t) / 100 - && used + available != 0 - && (used + available < used) == negate_available) + for (field = 0; field < NFIELDS; field++) { - uintmax_t u100 = used * 100; - uintmax_t nonroot_total = used + available; - pct = u100 / nonroot_total + (u100 % nonroot_total != 0); - } - else - { - /* The calculation cannot be done easily with integer - arithmetic. Fall back on floating point. This can suffer - from minor rounding errors, but doing it exactly requires - multiple precision arithmetic, and it's not worth the - aggravation. */ - double u = negate_used ? - (double) - used : used; - double a = negate_available ? - (double) - available : available; - double nonroot_total = u + a; - if (nonroot_total) + switch (field) { - long int lipct = pct = u * 100 / nonroot_total; - double ipct = lipct; + case DEV_FIELD: + /* TODO: maybe support putting disk on own line + if !posix_format and strlen (disk) > 20 */ + cell = xstrdup (disk); + break; - /* Like `pct = ceil (dpct);', but avoid ceil so that - the math library needn't be linked. */ - if (ipct - 1 < pct && pct <= ipct + 1) - pct = ipct + (ipct < pct); - } - } + case TYPE_FIELD: + cell = print_type ? xstrdup (fstype) : NULL; + break; - if (0 <= pct) - printf ("%*.0f%%", use_width - 1, pct); - else - printf ("%*s", use_width, "- "); + case TOTAL_FIELD: + cell = xstrdup (df_readable (false, total, buf, + input_units, output_units)); + break; + case USED_FIELD: + cell = xstrdup (df_readable (negate_used, used, buf, + input_units, output_units)); + break; + case FREE_FIELD: + cell = xstrdup (df_readable (negate_available, available, buf, + input_units, output_units)); + break; - if (mount_point) - { + case PCENT_FIELD: + if (! known_value (used) || ! known_value (available)) + ; + else if (!negate_used + && used <= TYPE_MAXIMUM (uintmax_t) / 100 + && used + available != 0 + && (used + available < used) == negate_available) + { + uintmax_t u100 = used * 100; + uintmax_t nonroot_total = used + available; + pct = u100 / nonroot_total + (u100 % nonroot_total != 0); + } + else + { + /* The calculation cannot be done easily with integer + arithmetic. Fall back on floating point. This can suffer + from minor rounding errors, but doing it exactly requires + multiple precision arithmetic, and it's not worth the + aggravation. */ + double u = negate_used ? - (double) - used : used; + double a = negate_available ? - (double) - available : available; + double nonroot_total = u + a; + if (nonroot_total) + { + long int lipct = pct = u * 100 / nonroot_total; + double ipct = lipct; + + /* Like `pct = ceil (dpct);', but avoid ceil so that + the math library needn't be linked. */ + if (ipct - 1 < pct && pct <= ipct + 1) + pct = ipct + (ipct < pct); + } + } + + if (0 <= pct) + { + if (asprintf (&cell, "%.0f%%", pct) == -1) + cell = NULL; + } + else + cell = strdup ("-"); + + if (!cell) + error (EXIT_FAILURE, errno, _("generating dev info")); + + break; + + case MNT_FIELD: + if (mount_point) + { #ifdef HIDE_AUTOMOUNT_PREFIX - /* Don't print the first directory name in MOUNT_POINT if it's an - artifact of an automounter. This is a bit too aggressive to be - the default. */ - if (strncmp ("/auto/", mount_point, 6) == 0) - mount_point += 5; - else if (strncmp ("/tmp_mnt/", mount_point, 9) == 0) - mount_point += 8; + /* Don't print the first directory name in MOUNT_POINT if it's an + artifact of an automounter. This is a bit too aggressive to be + the default. */ + if (strncmp ("/auto/", mount_point, 6) == 0) + mount_point += 5; + else if (strncmp ("/tmp_mnt/", mount_point, 9) == 0) + mount_point += 8; #endif - printf (" %s", mount_point); + cell = xstrdup (mount_point); + } + else + cell = NULL; + break; + + default: + assert (!"unhandled field"); + } + + if (cell) + widths[field] = MAX (widths[field], mbswidth (cell, 0)); + table[nrows-1][field] = cell; } - putchar ('\n'); } /* If DISK corresponds to a mount point, show its usage @@ -535,9 +639,9 @@ show_disk (char const *disk) if (best_match) { - show_dev (best_match->me_devname, best_match->me_mountdir, NULL, - best_match->me_type, best_match->me_dummy, - best_match->me_remote, NULL); + get_dev (best_match->me_devname, best_match->me_mountdir, NULL, + best_match->me_type, best_match->me_dummy, + best_match->me_remote, NULL); return true; } @@ -621,9 +725,9 @@ show_point (const char *point, const struct stat *statp) } if (best_match) - show_dev (best_match->me_devname, best_match->me_mountdir, point, - best_match->me_type, best_match->me_dummy, best_match->me_remote, - NULL); + get_dev (best_match->me_devname, best_match->me_mountdir, point, + best_match->me_type, best_match->me_dummy, best_match->me_remote, + NULL); else { /* We couldn't find the mount entry corresponding to POINT. Go ahead and @@ -634,7 +738,7 @@ show_point (const char *point, const struct stat *statp) char *mp = find_mount_point (point, statp); if (mp) { - show_dev (NULL, mp, NULL, NULL, false, false, NULL); + get_dev (NULL, mp, NULL, NULL, false, false, NULL); free (mp); } } @@ -662,7 +766,7 @@ show_all_entries (void) struct mount_entry *me; for (me = mount_list; me; me = me->me_next) - show_dev (me->me_devname, me->me_mountdir, NULL, me->me_type, + get_dev (me->me_devname, me->me_mountdir, NULL, me->me_type, me->me_dummy, me->me_remote, NULL); } @@ -862,6 +966,13 @@ main (int argc, char **argv) &human_output_opts, &output_block_size); } + if (inode_format) + header_mode = INODES_MODE; + else if (human_output_opts & human_autoscale) + header_mode = HUMAN_MODE; + else if (posix_format) + header_mode = POSIX_MODE; + /* Fail if the same file system type was both selected and excluded. */ { bool match = false; @@ -948,9 +1059,11 @@ main (int argc, char **argv) { if (inode_format) grand_fsu.fsu_blocks = 1; - show_dev ("total", NULL, NULL, NULL, false, false, &grand_fsu); + get_dev ("total", NULL, NULL, NULL, false, false, &grand_fsu); } + print_table (); + if (! file_systems_processed) error (EXIT_FAILURE, 0, _("no file systems processed")); -- 1.7.4 --------------020901050808070303000603-- From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 22 18:24:54 2011 Received: (at 6769) by debbugs.gnu.org; 22 Mar 2011 22:24:54 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q2A0T-00070c-W6 for submit@debbugs.gnu.org; Tue, 22 Mar 2011 18:24:54 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1Q2A0S-00070P-0A for 6769@debbugs.gnu.org; Tue, 22 Mar 2011 18:24:53 -0400 Received: (qmail 89633 invoked from network); 22 Mar 2011 22:24:43 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 22 Mar 2011 22:24:43 -0000 Message-ID: <4D892126.3080407@draigBrady.com> Date: Tue, 22 Mar 2011 22:22:30 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: 6769@debbugs.gnu.org Subject: Re: bug#6769: df (GNU coreutils) 7.4 Dutch output misalignment References: <4D88AD02.8030606@draigBrady.com> In-Reply-To: <4D88AD02.8030606@draigBrady.com> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 6769 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) On 22/03/11 14:06, Pádraig Brady wrote: > On 01/08/10 01:30, Erik Quaeghebeur wrote: >> Dear df-maintainer, >> >> >> I observed a misalignment of the output of df (GNU coreutils) 7.4 in a >> Dutch locale: from the second column onward, the column header in the >> first row is too far to the right (by six spaces, in the cases I >> investigated). > > Here's a proposed fix for all these alignment issues. > A good command to compare before and after is: > > df --all -T -P -B\'1 Here's the lastest version with a few inconsequential tweaks, and a NEWS entry http://www.pixelbeat.org/patches/df-align.diff cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 23 06:48:58 2011 Received: (at 6769) by debbugs.gnu.org; 23 Mar 2011 10:48:59 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q2LcX-00080T-UY for submit@debbugs.gnu.org; Wed, 23 Mar 2011 06:48:58 -0400 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q2LcV-000809-0Q for 6769@debbugs.gnu.org; Wed, 23 Mar 2011 06:48:56 -0400 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id C5A7B600DA; Wed, 23 Mar 2011 11:48:47 +0100 (CET) From: Jim Meyering To: =?iso-8859-1?Q?P=E1draig?= Brady Subject: Re: bug#6769: df (GNU coreutils) 7.4 Dutch output misalignment In-Reply-To: <4D892126.3080407@draigBrady.com> (=?iso-8859-1?Q?=22P=E1drai?= =?iso-8859-1?Q?g?= Brady"'s message of "Tue, 22 Mar 2011 22:22:30 +0000") References: <4D88AD02.8030606@draigBrady.com> <4D892126.3080407@draigBrady.com> Date: Wed, 23 Mar 2011 11:48:47 +0100 Message-ID: <87zkomf6y8.fsf@rho.meyering.net> Lines: 56 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: 6769 Cc: 6769@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) P=E1draig Brady wrote: > On 22/03/11 14:06, P=E1draig Brady wrote: >> On 01/08/10 01:30, Erik Quaeghebeur wrote: >>> Dear df-maintainer, >>> >>> I observed a misalignment of the output of df (GNU coreutils) 7.4 in a >>> Dutch locale: from the second column onward, the column header in the >>> first row is too far to the right (by six spaces, in the cases I >>> investigated). >> >> Here's a proposed fix for all these alignment issues. >> A good command to compare before and after is: >> >> df --all -T -P -B\'1 I like it. > Here's the lastest version with a few inconsequential tweaks, > and a NEWS entry > > http://www.pixelbeat.org/patches/df-align.diff Thanks. I've tried to compile with that, and saw some new warnings (using F14's gcc 4.5.1 20100924). Fixing them, I also removed some stray spaces in "table [= ...": diff --git a/src/df.c b/src/df.c index 7c67620..df31611 100644 --- a/src/df.c +++ b/src/df.c @@ -254,11 +254,11 @@ get_header (void) { if (field =3D=3D TYPE_FIELD && !print_type) { - table [nrows-1][field] =3D NULL; + table[nrows-1][field] =3D NULL; continue; } - char *header =3D _(headers[field][header_mode]); + char const *header =3D _(headers[field][header_mode]); if (!header) header =3D _(headers[field][DEFAULT_MODE]); @@ -318,7 +318,7 @@ get_header (void) if (!header) xalloc_die (); - table [nrows-1][field] =3D header; + table[nrows-1][field] =3D (char *) header; widths[field] =3D MAX (widths[field], mbswidth (header, 0)); } Having a test that exhibits the change in behavior would be nice, but is probably not worth the trouble. From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 23 20:05:05 2011 Received: (at 6769-done) by debbugs.gnu.org; 24 Mar 2011 00:05:06 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q2Y2z-00028c-It for submit@debbugs.gnu.org; Wed, 23 Mar 2011 20:05:05 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1Q2Y2x-000288-6l for 6769-done@debbugs.gnu.org; Wed, 23 Mar 2011 20:05:03 -0400 Received: (qmail 32783 invoked from network); 24 Mar 2011 00:04:57 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 24 Mar 2011 00:04:57 -0000 Message-ID: <4D8A8A1E.1030302@draigBrady.com> Date: Thu, 24 Mar 2011 00:02:38 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: 6769-done@debbugs.gnu.org Subject: Re: bug#6769: df (GNU coreutils) 7.4 Dutch output misalignment References: <4D88AD02.8030606@draigBrady.com> <4D892126.3080407@draigBrady.com> <87zkomf6y8.fsf@rho.meyering.net> In-Reply-To: <87zkomf6y8.fsf@rho.meyering.net> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 6769-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) On 23/03/11 10:48, Jim Meyering wrote: > I've tried to compile with that, and saw some new warnings (using F14's gcc > 4.5.1 20100924). > > - char *header = _(headers[field][header_mode]); > + char const *header = _(headers[field][header_mode]); I've fixed that up and pushed the result. Closing this bug... thanks, Pádraig. From unknown Wed Sep 10 09:11:03 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 21 Apr 2011 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator