From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 6304C385802D; Fri, 30 Apr 2021 19:05:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6304C385802D Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] format_proc_swaps: ensure space between fields for clarity X-Act-Checkin: newlib-cygwin X-Git-Author: Brian Inglis X-Git-Refname: refs/heads/master X-Git-Oldrev: 715c4208e47395bbe021c67f5bf86d08cb802905 X-Git-Newrev: 6914b40c146081f0c59a3666b1dcc2993ffa0402 Message-Id: <20210430190558.6304C385802D@sourceware.org> Date: Fri, 30 Apr 2021 19:05:58 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Apr 2021 19:05:58 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=6914b40c146081f0c59a3666b1dcc2993ffa0402 commit 6914b40c146081f0c59a3666b1dcc2993ffa0402 Author: Brian Inglis Date: Fri Apr 30 07:19:20 2021 -0600 format_proc_swaps: ensure space between fields for clarity page/swap space name >= 40 or size/used >= 8 leaves no space between fields; ensure a space after name and add extra tabs after size and used fields; output appears like Linux 5.8 after changes to mm/swapfile(swap_show); proc-swaps-space-before.log: ==> /proc/swaps <== Filename Type Size Used Priority /mnt/c/pagefile.sys file 11567748292920 0 /mnt/d/pagefile.sys file 12582912205960 0 proc-swaps-space-after.log: ==> /proc/swaps <== Filename Type Size Used Priority /mnt/c/pagefile.sys file 11567748 241024 0 /mnt/d/pagefile.sys file 12582912 182928 0 Diff: --- winsup/cygwin/fhandler_proc.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 7cd0b3af0..eb4efb07d 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -1920,7 +1920,7 @@ format_proc_swaps (void *, char *&destbuf) } bufptr += __small_sprintf (bufptr, - "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n"); + "Filename\t\t\t\tType\t\tSize\t\tUsed\t\tPriority\n"); if (spi && NT_SUCCESS (status)) { @@ -1932,8 +1932,17 @@ format_proc_swaps (void *, char *&destbuf) used = (unsigned long long) spp->TotalUsed * wincap.page_size (); cygwin_conv_path (CCP_WIN_W_TO_POSIX, spp->FileName.Buffer, filename, NT_MAX_PATH); - bufptr += sprintf (bufptr, "%-40s%-16s%-8llu%-8llu%-8d\n", - filename, "file", total >> 10, used >> 10, 0); + /* ensure space between fields for clarity */ + size_t tabo = strlen (filename) / 8; /* offset tabs to space name */ + bufptr += sprintf (bufptr, "%s%s%s\t\t%llu%s\t%llu%s\t%d\n", + filename, + tabo < 5 ? "\t\t\t\t\t" + tabo : " ", + "file", + total >> 10, + total < 10000000000 ? "\t" : "", + used >> 10, + used < 10000000000 ? "\t" : "", + 0); } while (spp->NextEntryOffset && (spp = (PSYSTEM_PAGEFILE_INFORMATION)