Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Apr 2001 11:38:51 +0300
From:      Peter Pentchev <roam@orbitel.bg>
To:        David Malone <dwmalone@maths.tcd.ie>
Cc:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/26283: column coredumps on specific input
Message-ID:  <20010402113850.B462@ringworld.oblivion.bg>
In-Reply-To: <20010402092621.A78914@lanczos.maths.tcd.ie>; from dwmalone@maths.tcd.ie on Mon, Apr 02, 2001 at 09:26:21AM %2B0100
References:  <200104020820.f328K3j22505@freefall.freebsd.org> <20010402092621.A78914@lanczos.maths.tcd.ie>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Apr 02, 2001 at 09:26:21AM +0100, David Malone wrote:
> On Mon, Apr 02, 2001 at 01:20:03AM -0700, Peter Pentchev wrote:
> 
> >  Could you try the following patch?  It works for me..
> >  (As a side point, maybe the tab-size should be configurable.. but that's
> >   another battle ;)
> 
> I think that this leaves the problem open in some other cases.
> Try:
> 
> 	echo "aaaaaaaaaaaa" | ./column -c 15
> 
> maxlength probably needs to be rounded up to the nearest tabstop
> before the test is carried out.

Yes, that was my first idea; I can't really remember what was wrong
with it, why didn't I fix it that way :)

Updated patch follows..

As another side point, column -t (table mode) seems to just ignore
the terminal size.. is that The Right Thing (tm)?

G'luck,
Peter

-- 
.siht ekil ti gnidaer eb d'uoy ,werbeH ni erew ecnetnes siht fI

Index: src/usr.bin/column/column.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/column/column.c,v
retrieving revision 1.4
diff -u -r1.4 column.c
--- src/usr.bin/column/column.c	1998/12/06 22:58:18	1.4
+++ src/usr.bin/column/column.c	2001/04/02 08:37:21
@@ -52,6 +52,8 @@
 #include <string.h>
 #include <unistd.h>
 
+#define	TAB	8
+
 void  c_columnate __P((void));
 void *emalloc __P((int));
 void  input __P((FILE *));
@@ -120,6 +122,7 @@
 	if (!entries)
 		exit(eval);
 
+	maxlength = (maxlength + TAB) & ~(TAB - 1);
 	if (tflag)
 		maketbl();
 	else if (maxlength >= termwidth)
@@ -131,14 +134,12 @@
 	exit(eval);
 }
 
-#define	TAB	8
 void
 c_columnate()
 {
 	int chcnt, col, cnt, endcol, numcols;
 	char **lp;
 
-	maxlength = (maxlength + TAB) & ~(TAB - 1);
 	numcols = termwidth / maxlength;
 	endcol = maxlength;
 	for (chcnt = col = 0, lp = list;; ++lp) {
@@ -166,7 +167,6 @@
 {
 	int base, chcnt, cnt, col, endcol, numcols, numrows, row;
 
-	maxlength = (maxlength + TAB) & ~(TAB - 1);
 	numcols = termwidth / maxlength;
 	numrows = entries / numcols;
 	if (entries % numcols)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010402113850.B462>