summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-09-12 06:41:01 +0000
committerJim Meyering <jim@meyering.net>2001-09-12 06:41:01 +0000
commit484ce2d8de1a493b10aa5c6c16d18a22f6747f0d (patch)
tree6062e6cdd9b5982828e38a8b6281c2658e32e4e5 /src
parentcaa75371a8b623e987d68242be0bb08105b26577 (diff)
downloadcoreutils-484ce2d8de1a493b10aa5c6c16d18a22f6747f0d.tar.xz
The command `echo foo| fmt -w 100000' would cause fmt to segfault.
[struct Word]: Declare members length, space, and line_length to be of type `int', not short. (MAXCOST): Define using TYPE_MAXIMUM.
Diffstat (limited to 'src')
-rw-r--r--src/fmt.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/fmt.c b/src/fmt.c
index c958c69ab..85b347f9a 100644
--- a/src/fmt.c
+++ b/src/fmt.c
@@ -58,7 +58,7 @@
typedef long COST;
-#define MAXCOST (~(((unsigned long) 1) << (8 * sizeof (COST) -1)))
+#define MAXCOST TYPE_MAXIMUM (COST)
#define SQR(n) ((n) * (n))
#define EQUIV(n) SQR ((COST) (n))
@@ -132,8 +132,8 @@ struct Word
/* Static attributes determined during input. */
const char *text; /* the text of the word */
- short length; /* length of this word */
- short space; /* the size of the following space */
+ int length; /* length of this word */
+ int space; /* the size of the following space */
bool paren:1; /* starts with open paren */
bool period:1; /* ends in [.?!])* */
bool punct:1; /* ends in punctuation */
@@ -141,7 +141,7 @@ struct Word
/* The remaining fields are computed during the optimization. */
- short line_length; /* length of the best line starting here */
+ int line_length; /* length of the best line starting here */
COST best_cost; /* cost of best paragraph starting here */
WORD *next_break; /* break which achieves best_cost */
};