Wednesday, January 27, 2010

part of original file [ fmt.c ]


/* GNU fmt -- simple text formatter.
Copyright (C) 1994-2006, 2008-2009 Free Software Foundation, Inc.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see . */

/* Written by Ross Paterson . */


/* FIXME: "fmt" misbehaves given large inputs or options. One
possible workaround for part of the problem is to change COST to be
a floating-point type. There are other problems besides COST,
though; see MAXWORDS below. */

typedef long int COST;

#define MAXCOST TYPE_MAXIMUM (COST)

#define SQR(n) ((n) * (n))
#define EQUIV(n) SQR ((COST) (n))

/* Cost of a filled line n chars longer or shorter than best_width. */
#define SHORT_COST(n) EQUIV ((n) * 10)

/* Cost of the difference between adjacent filled lines. */
#define RAGGED_COST(n) (SHORT_COST (n) / 2)

http://en.wikipedia.org/wiki/Indentation
http://en.wikipedia.org/wiki/Fmt