From ayan@tyra.durocom.com  Thu Jul 26 12:47:50 2001
Return-Path: <ayan@tyra.durocom.com>
Received: from tyra.durocom.com (tyra.durocom.com [216.53.180.209])
	by hub.freebsd.org (Postfix) with ESMTP id 5594037B40C
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 26 Jul 2001 12:47:49 -0700 (PDT)
	(envelope-from ayan@tyra.durocom.com)
Received: (from ayan@localhost)
	by tyra.durocom.com (8.11.4/8.11.4) id f6QJl6521799;
	Thu, 26 Jul 2001 15:47:06 -0400 (EDT)
	(envelope-from ayan)
Message-Id: <200107261947.f6QJl6521799@tyra.durocom.com>
Date: Thu, 26 Jul 2001 15:47:06 -0400 (EDT)
From: Ayan George <ayan@tyra.durocom.com>
Reply-To: Ayan George <ayan@tyra.durocom.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: fmt should not expand tabs.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         29247
>Category:       bin
>Synopsis:       fmt should not expand tabs.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 26 12:50:01 PDT 2001
>Closed-Date:    Wed Aug 15 07:52:43 PDT 2001
>Last-Modified:  Wed Aug 15 07:54:06 PDT 2001
>Originator:     Ayan George
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
none
>Environment:
System: FreeBSD tyra.durocom.com 5.0-CURRENT FreeBSD 5.0-CURRENT #3: Thu Jul 19 13:07:57 EDT 2001 root@tyra.durocom.com:/usr/obj/usr/src/sys/TYRA_KERNEL i386


>Description:
	The new  fmt command expands tabs to spaces by default.  This is completely
	broken compared with the behavior of the old fmt.

	Please fix it.

>How-To-Repeat:

	Type something tabbed over with vi, then pipe it through fmt thusly:

:!}fmt

>Fix:

	Minor code revision or the reintroduction of the old fmt program.
	Why did we change it anyway?
>Release-Note:
>Audit-Trail:

From: Ruslan Ermilov <ru@FreeBSD.ORG>
To: Ayan George <ayan@tyra.durocom.com>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/29247: fmt should not expand tabs.
Date: Mon, 6 Aug 2001 12:35:35 +0300

 On Thu, Jul 26, 2001 at 03:47:06PM -0400, Ayan George wrote:
 > 
 > The new fmt command expands tabs to spaces by default.  This is completely
 > broken compared with the behavior of the old fmt.
 >
 The old fmt(1) did that too.  Could you please send me an example where
 the old fmt does do this for you?
 
 > Why did we change it anyway?
 > 
 Because it was way too broken.
 
 
 Cheers,
 -- 
 Ruslan Ermilov		Oracle Developer/DBA,
 ru@sunbay.com		Sunbay Software AG,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.512.251	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age

From: Ruslan Ermilov <ru@FreeBSD.org>
To: Ian Dowse <iedowse@maths.tcd.ie>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/29247: fmt should not expand tabs.
Date: Mon, 6 Aug 2001 17:00:33 +0300

 On Mon, Aug 06, 2001 at 01:19:26PM +0100, Ian Dowse wrote:
 > In message <200108060940.f769e1671337@freefall.freebsd.org>, Ruslan Ermilov wri
 > tes:
 > > >
 > > The old fmt(1) did that too.  Could you please send me an example where
 > > the old fmt does do this for you?
 > 
 > Here's a quick example:
 > 
 > begin 644 fmttest
 > M"F8*"68@:"!H(&AH(&@@:"!H(&IH(&IH(&ML9R!H9VMH9VIK9R!K:F@@:"!K
 > M9V@@:V<@:VIH(&MJ9R!K:FAG(&MG:B!K:FAG(&MH9R!K:F=H(&MJ9R!K9R!K
 > A9V@@:V=H(&MG(&MH(&MG:"!K;&=H(`H)9@IF"@IF"@H*
 > `
 > end
 > 
 > --- fmttest.old	Mon Aug  6 13:16:39 2001
 > +++ fmttest.new	Mon Aug  6 13:16:43 2001
 > @@ -1,7 +1,8 @@
 >  
 >  f
 > -	f h h hh h h h jh jh klg hgkhgjkg kjh h kgh kg kjh kjg kjhg
 > -	kgj kjhg khg kjgh kjg kg kgh kgh kg kh kgh klgh f f
 > +        f h h hh h h h jh jh klg hgkhgjkg kjh h kgh kg kjh kjg kjhg
 > +        kgj kjhg khg kjgh kjg kg kgh kgh kg kh kgh klgh f
 > +f
 >  
 >  f
 > 
 Ah, that.  That could be achieved by `fmt -l 8'.  Don't take it wrong!
 fmt(1) always replaces spaces by tabs first.  The old fmt(1) then did
 what new `-l 8' currently does, unconditionally, i.e., replaces every
 8 leading spaces by a single tab character.
 
 > It also deals differently with the 'f' after the long line, but that's
 > probably unimportant.
 > 
 Yes, this is due to the:
 
 : -p      Allow indented paragraphs.  Without the -p flag, any change in
 :         the amount of whitespace at the start of a line results in a new
 :         paragraph being begun.
 
 
 Cheers,
 -- 
 Ruslan Ermilov		Oracle Developer/DBA,
 ru@sunbay.com		Sunbay Software AG,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.512.251	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age

From: Ian Dowse <iedowse@maths.tcd.ie>
To: Ruslan Ermilov <ru@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/29247: fmt should not expand tabs. 
Date: Mon, 06 Aug 2001 15:40:35 +0100

 In message <20010806170033.A44549@sunbay.com>, Ruslan Ermilov writes:
 >Ah, that.  That could be achieved by `fmt -l 8'.  Don't take it wrong!
 >fmt(1) always replaces spaces by tabs first.  The old fmt(1) then did
 >what new `-l 8' currently does, unconditionally, i.e., replaces every
 >8 leading spaces by a single tab character.
 
 Ok, I didn't understand fully why it worked, but a "!}fmt" in vi
 has always left a tab-indented paragraph with tabs in the indentation,
 and now it doesn't. This is the only way I ever use fmt, so the
 new behaviour is quite annoying, and I don't think I'll just get
 used to typing "!}fmt -l 8" instead :-).
 
 I agree that the old behaviour was not an ideal way to achieve the
 effect of keeping tab indents, but the outcome for me was the same
 as if it had not expanded the tabs in the first place. I think that
 to avoid this unwanted change in behaviour, either fmt needs to
 remember whether the indentation used tabs, or it should default
 to -l 8...
 
 >> It also deals differently with the 'f' after the long line, but that's
 >> probably unimportant.
 >> 
 >Yes, this is due to the:
 >
 >: -p      Allow indented paragraphs.
 
 That's fine. It's an improvement on the old behaviour.
 
 Ian

From: Ruslan Ermilov <ru@FreeBSD.org>
To: Ian Dowse <iedowse@maths.tcd.ie>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/29247: fmt should not expand tabs.
Date: Tue, 14 Aug 2001 16:20:18 +0300

 --7JfCtLOvnd9MIVvH
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Mon, Aug 06, 2001 at 03:40:35PM +0100, Ian Dowse wrote:
 > In message <20010806170033.A44549@sunbay.com>, Ruslan Ermilov writes:
 > >Ah, that.  That could be achieved by `fmt -l 8'.  Don't take it wrong!
 > >fmt(1) always replaces spaces by tabs first.  The old fmt(1) then did
 > >what new `-l 8' currently does, unconditionally, i.e., replaces every
 > >8 leading spaces by a single tab character.
 > 
 > Ok, I didn't understand fully why it worked, but a "!}fmt" in vi
 > has always left a tab-indented paragraph with tabs in the indentation,
 > and now it doesn't. This is the only way I ever use fmt, so the
 > new behaviour is quite annoying, and I don't think I'll just get
 > used to typing "!}fmt -l 8" instead :-).
 > 
 > I agree that the old behaviour was not an ideal way to achieve the
 > effect of keeping tab indents, but the outcome for me was the same
 > as if it had not expanded the tabs in the first place. I think that
 > to avoid this unwanted change in behaviour, either fmt needs to
 > remember whether the indentation used tabs, or it should default
 > to -l 8...
 > 
 OK, how about the following?
 
 
 Cheers,
 -- 
 Ruslan Ermilov		Oracle Developer/DBA,
 ru@sunbay.com		Sunbay Software AG,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.512.251	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age
 
 --7JfCtLOvnd9MIVvH
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=p
 
 Index: fmt.1
 ===================================================================
 RCS file: /home/ncvs/src/usr.bin/fmt/fmt.1,v
 retrieving revision 1.8
 diff -u -p -r1.8 fmt.1
 --- fmt.1	2001/06/06 10:17:05	1.8
 +++ fmt.1	2001/08/14 13:20:10
 @@ -115,8 +115,13 @@ escaped to protect them from your shell.
  .It Fl l Ar number
  Replace multiple spaces with tabs at the start of each output
  line, if possible.
 +Each
  .Ar number
  spaces will be replaced with one tab.
 +The default is 8.
 +If
 +.Ar number
 +is 0, spaces are preserved.
  .It Fl t Ar number
  Assume that the input files' tabs assume
  .Ar number
 Index: fmt.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.bin/fmt/fmt.c,v
 retrieving revision 1.15
 diff -u -p -r1.15 fmt.c
 --- fmt.c	2001/08/11 00:49:11	1.15
 +++ fmt.c	2001/08/14 13:20:11
 @@ -202,6 +202,15 @@ get_positive(const char *s, const char *
    return (size_t) result;
  }
  
 +static size_t
 +get_nonnegative(const char *s, const char *err_mess, int fussyP) {
 +  char *t;
 +  long result = strtol(s,&t,0);
 +  if (*t) { if (fussyP) goto Lose; else return 0; }
 +  if (result<0) { Lose: errx(EX_USAGE, "%s", err_mess); }
 +  return (size_t) result;
 +}
 +
  /* Global variables */
  
  static int centerP=0;		/* Try to center lines? */
 @@ -210,7 +219,7 @@ static size_t max_length=0;	/* Maximum l
  static int coalesce_spaces_P=0;	/* Coalesce multiple whitespace -> ' ' ? */
  static int allow_indented_paragraphs=0;	/* Can first line have diff. ind.? */
  static int tab_width=8;		/* Number of spaces per tab stop */
 -static size_t output_tab_width=0;	/* Ditto, when squashing leading spaces */
 +static size_t output_tab_width=8;	/* Ditto, when squashing leading spaces */
  static const char *sentence_enders=".?!";	/* Double-space after these */
  static int grok_mail_headers=0;	/* treat embedded mail headers magically? */
  
 @@ -258,7 +267,7 @@ main(int argc, char *argv[]) {
        continue;
      case 'l':
        output_tab_width
 -        = get_positive(optarg, "output tab width must be positive", 1);
 +        = get_nonnegative(optarg, "output tab width must be non-negative", 1);
        continue;
      case 'm':
        grok_mail_headers = 1;
 
 --7JfCtLOvnd9MIVvH--

From: Ian Dowse <iedowse@maths.tcd.ie>
To: Ruslan Ermilov <ru@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/29247: fmt should not expand tabs. 
Date: Tue, 14 Aug 2001 17:29:45 +0100

 In message <200108141330.f7EDU2259139@freefall.freebsd.org>, Ruslan Ermilov wri
 tes:
 > > 
 > OK, how about the following?
 
 That looks great! I just tried it and it works as expected.
 
 Thanks,
 
 Ian
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Wed Aug 15 07:52:43 PDT 2001 
State-Changed-Why:  
The default behavior has been changed to ``-l 8''. 


Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Wed Aug 15 07:52:43 PDT 2001 
Responsible-Changed-Why:  

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