Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit improve on the listing display by printing only ...



details:   https://anonhg.NetBSD.org/src/rev/23b43a1653a4
branches:  trunk
changeset: 750370:23b43a1653a4
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Dec 28 21:55:38 2009 +0000

description:
improve on the listing display by printing only one character after the
filename not two, and no trailing blanks. I will revisit this when I write
the ls-F code.

diffstat:

 lib/libedit/filecomplete.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (34 lines):

diff -r fc06fbd8e9ca -r 23b43a1653a4 lib/libedit/filecomplete.c
--- a/lib/libedit/filecomplete.c        Mon Dec 28 21:54:21 2009 +0000
+++ b/lib/libedit/filecomplete.c        Mon Dec 28 21:55:38 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecomplete.c,v 1.15 2009/02/16 00:15:45 christos Exp $       */
+/*     $NetBSD: filecomplete.c,v 1.16 2009/12/28 21:55:38 christos Exp $       */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.15 2009/02/16 00:15:45 christos Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.16 2009/12/28 21:55:38 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -359,9 +359,12 @@
 
        idx = 1;
        for(; count > 0; count--) {
-               for(i = 0; i < limit && matches[idx]; i++, idx++)
-                       (void)fprintf(el->el_outfile, "%-*s  ", (int)max,
-                           matches[idx]);
+               int more = limit > 0 && matches[0];
+               for(i = 0; more; i++, idx++) {
+                       more = ++i < limit && matches[idx + 1];
+                       (void)fprintf(el->el_outfile, "%-*s%s", (int)max,
+                           matches[idx], more ? " " : "");
+               }
                (void)fprintf(el->el_outfile, "\n");
        }
 }



Home | Main Index | Thread Index | Old Index