Bug 29247

Summary: fmt should not expand tabs.
Product: Base System Reporter: Ayan George <ayan>
Component: binAssignee: ru <ru>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
p none

Description Ayan George 2001-07-26 20:50:01 UTC
	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.

Fix: 

Minor code revision or the reintroduction of the old fmt program.
	Why did we change it anyway?
How-To-Repeat: 
	Type something tabbed over with vi, then pipe it through fmt thusly:

:!}fmt
Comment 1 ru freebsd_committer freebsd_triage 2001-08-06 10:35:35 UTC
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
Comment 2 ru freebsd_committer freebsd_triage 2001-08-06 15:00:33 UTC
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
Comment 3 iedowse 2001-08-06 15:40:35 UTC
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
Comment 4 ru freebsd_committer freebsd_triage 2001-08-14 14:20:18 UTC
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
Comment 5 iedowse 2001-08-14 17:29:45 UTC
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
Comment 6 ru freebsd_committer freebsd_triage 2001-08-15 15:52:43 UTC
State Changed
From-To: open->closed

The default behavior has been changed to ``-l 8''. 


Comment 7 ru freebsd_committer freebsd_triage 2001-08-15 15:52:43 UTC
Responsible Changed
From-To: freebsd-bugs->ru