GNU bug report logs - #9680
fmt: -f <unlimited> should be supported

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Severity: wishlist; Reported by: Jim Meyering <jim@HIDDEN>; dated Thu, 6 Oct 2011 06:40:02 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.
Changed bug title to 'fmt: -f <unlimited> should be supported' from '[Bug 868747] Re: fmt -f <unlimited> should be supported' Request was from Assaf Gordon <assafgordon@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Severity set to 'wishlist' from 'normal' Request was from Assaf Gordon <assafgordon@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 6 Oct 2011 06:40:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 06 02:40:01 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1RBhcd-0000k3-IT
	for submit <at> debbugs.gnu.org; Thu, 06 Oct 2011 02:40:01 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <jim@HIDDEN>) id 1RBhca-0000jp-Gp
	for submit <at> debbugs.gnu.org; Thu, 06 Oct 2011 02:39:58 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@HIDDEN>) id 1RBhcM-0002w3-VW
	for submit <at> debbugs.gnu.org; Thu, 06 Oct 2011 02:39:44 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD
	autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([140.186.70.17]:42598)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@HIDDEN>) id 1RBhcM-0002vz-Pq
	for submit <at> debbugs.gnu.org; Thu, 06 Oct 2011 02:39:42 -0400
Received: from eggs.gnu.org ([140.186.70.92]:52419)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@HIDDEN>) id 1RBhcK-0006iP-5w
	for bug-coreutils@HIDDEN; Thu, 06 Oct 2011 02:39:42 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@HIDDEN>) id 1RBhcJ-0002vl-76
	for bug-coreutils@HIDDEN; Thu, 06 Oct 2011 02:39:40 -0400
Received: from mx.meyering.net ([88.168.87.75]:60939)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@HIDDEN>) id 1RBhcI-0002vb-PA
	for bug-coreutils@HIDDEN; Thu, 06 Oct 2011 02:39:39 -0400
Received: from rho.meyering.net (localhost.localdomain [127.0.0.1])
	by rho.meyering.net (Acme Bit-Twister) with ESMTP id 41E5F6007C;
	Thu,  6 Oct 2011 08:39:37 +0200 (CEST)
From: Jim Meyering <jim@HIDDEN>
To: Bug 868747 <868747@HIDDEN>
Subject: Re: [Bug 868747] Re: fmt -f <unlimited> should be supported
In-Reply-To: <20111005215957.26464.67334.malone@HIDDEN>
	(jimav's message of "Wed, 05 Oct 2011 21:59:54 -0000")
References: <20111005215955.26464.50560.malonedeb@HIDDEN>
	<20111005215957.26464.67334.malone@HIDDEN>
Date: Thu, 06 Oct 2011 08:39:37 +0200
Message-ID: <87zkhe1v4m.fsf@HIDDEN>
Lines: 60
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -4.9 (----)
X-Debbugs-Envelope-To: submit
Cc: bug-coreutils@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.0 (-----)

jimav wrote:
>   Strictly speaking this is an enhancement request.
>
>   fmt imposes an artificial limit on the maximum output line length
>   controlled by the -f option, which prevents using this tool to "join"

You meant -w, not -f, throughout.

Thanks for the suggestion.  Note that the code has this:

    /* Size of paragraph buffer, in words and characters.  Longer paragraphs
       are handled neatly (cf. flush_paragraph()), so long as these values
       are considerably greater than required by the width.  These values
       cannot be extended indefinitely: doing so would run into size limits
       and/or cause more overflows in cost calculations.  FIXME: Remove these
       arbitrary limits.  */

    #define MAXWORDS	1000
    #define MAXCHARS	5000

where MAXCHARS/2 specifies the largest width.
I.e., fmt -w 2500 works, but not 2501.

We agree that there should not be such a limit.
But the internals of fmt are not pretty -- significantly less
so than most other parts of the coreutils, and as the comment says
we cannot easily increase them arbitrarily.

In the mean time what can you do if you want truly unlimited-length
paragraphs?  It's not trivial since you want to retain paragraph delimiters.
This perl command should do the trick.
It processes your input a paragraph at a time, replacing each newline
(and spaces before/after) with a single space:

    perl -00ple 's/\s*\n\s*/ /g'

E.g., given this input,

1
2
3
4

1
2
3
4
5

It prints this:

    $ (seq 4; echo; seq 5) | perl -00ple 's/\s*\n\s*/ /g'
    1 2 3 4

    1 2 3 4 5

It doesn't preserve indentation, but if you're just going to
paste it into libreoffice, that should be fine.

I've Cc'd the upstream bug-tracker, so we'll have a bug number there, too.




Acknowledgement sent to Jim Meyering <jim@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#9680; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.