From sven@copei.research.devcon.net  Sun Sep  9 13:54:27 2001
Return-Path: <sven@copei.research.devcon.net>
Received: from copei.research.devcon.net (sec-01.bi.devcon.net [212.15.192.30])
	by hub.freebsd.org (Postfix) with ESMTP id 2FD4637B403
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  9 Sep 2001 13:54:26 -0700 (PDT)
Received: (from sven@localhost)
	by copei.research.devcon.net (8.11.6/8.11.4) id f89L74X96593;
	Sun, 9 Sep 2001 23:07:05 +0200 (CEST)
	(envelope-from sven)
Message-Id: <200109092107.f89L74X96593@copei.research.devcon.net>
Date: Sun, 9 Sep 2001 23:07:05 +0200 (CEST)
From: Sven Klose <sven@devcon.net>
Reply-To: sven@devcon.net
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject:
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         30467
>Category:       bin
>Synopsis:       rs crashes when option -z is used without -t.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 09 14:00:03 PDT 2001
>Closed-Date:    Mon Sep 10 04:42:46 PDT 2001
>Last-Modified:  Mon Sep 10 04:44:19 PDT 2001
>Originator:     Sven Klose
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD copei.research.devcon.net 5.0-CURRENT FreeBSD 5.0-CURRENT #6: Sun Sep 9 14:40:04 CEST 2001 root@copei.research.devcon.net:/usr/src/sys/i386/compile/COPEI i386


>Description:

When trying to find out the maximum column width in prepfile() the element
pointer ep is not initialised in case the -z option is used without -t.

>How-To-Repeat:
    ls | rs -z
>Fix:

    This fix inserts the missing pointer initialisation and removes misplaced
    debugging code.

*** rs.c.orig	Sun Sep  9 22:38:48 2001
--- rs.c	Sun Sep  9 22:33:22 2001
***************
*** 289,312 ****
  				colwidths[i] = max + gutter;
  			}
  		else
! 			for (i = 0; i < ocols; i++) {
  				for (j = i; j < nelem; j += ocols)
  					if ((n = strlen(ep[j])) > max)
  						max = n;
  				colwidths[i] = max + gutter;
  			}
  	}
- 	/*	for (i = 0; i < orows; i++) {
- 			for (j = i; j < nelem; j += orows)
- 				prints(ep[j], (j - i) / orows);
- 			putchar('\n');
- 		}
- 	else
- 		for (i = 0; i < orows; i++) {
- 			for (j = 0; j < ocols; j++)
- 				prints(*ep++, j);
- 			putchar('\n');
- 		}*/
  	else
  		for (i = 0; i < ocols; i++)
  			colwidths[i] = colw;
--- 289,301 ----
  				colwidths[i] = max + gutter;
  			}
  		else
! 			for (ep = elem, i = 0; i < ocols; i++) {
  				for (j = i; j < nelem; j += ocols)
  					if ((n = strlen(ep[j])) > max)
  						max = n;
  				colwidths[i] = max + gutter;
  			}
  	}
  	else
  		for (i = 0; i < ocols; i++)
  			colwidths[i] = colw;
***************
*** 319,326 ****
  	n = orows * ocols;
  	if (n > nelem && (flags & RECYCLE))
  		nelem = n;
- 	/*for (i = 0; i < ocols; i++)
- 		warnx("%d is colwidths, nelem %d", colwidths[i], nelem);*/
  }
  
  #define	BSIZE	2048
--- 308,313 ----
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Mon Sep 10 04:42:46 PDT 2001 
State-Changed-Why:  
Fixed in 5.0-CURRENT, usr.bin/rs/rs.c,v 1.6, thanks! 
I've ordered an MFC approval for this. 


Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Mon Sep 10 04:42:46 PDT 2001 
Responsible-Changed-Why:  

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=30467 
>Unformatted:
