From owner-freebsd-bugs Mon Apr 2 1:40: 5 2001 Delivered-To: freebsd-bugs@freebsd.org Received: from ringworld.nanolink.com (ringworld.nanolink.com [195.24.48.13]) by hub.freebsd.org (Postfix) with SMTP id 3400A37B71C for ; Mon, 2 Apr 2001 01:40:00 -0700 (PDT) (envelope-from roam@orbitel.bg) Received: (qmail 1355 invoked by uid 1000); 2 Apr 2001 08:38:51 -0000 Date: Mon, 2 Apr 2001 11:38:51 +0300 From: Peter Pentchev To: David Malone Cc: freebsd-bugs@FreeBSD.org Subject: Re: bin/26283: column coredumps on specific input Message-ID: <20010402113850.B462@ringworld.oblivion.bg> Mail-Followup-To: David Malone , freebsd-bugs@FreeBSD.org References: <200104020820.f328K3j22505@freefall.freebsd.org> <20010402092621.A78914@lanczos.maths.tcd.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010402092621.A78914@lanczos.maths.tcd.ie>; from dwmalone@maths.tcd.ie on Mon, Apr 02, 2001 at 09:26:21AM +0100 Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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 #include +#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