Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/fmt fix problem introduced when the computation was ...



details:   https://anonhg.NetBSD.org/src/rev/2bc80112939f
branches:  trunk
changeset: 586884:2bc80112939f
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jan 04 20:44:57 2006 +0000

description:
fix problem introduced when the computation was changed to unsigned. If
we've exceeded the goal length already the negative number turned into
a large positive one...

diffstat:

 usr.bin/fmt/fmt.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r 186b9a85166f -r 2bc80112939f usr.bin/fmt/fmt.c
--- a/usr.bin/fmt/fmt.c Wed Jan 04 20:44:26 2006 +0000
+++ b/usr.bin/fmt/fmt.c Wed Jan 04 20:44:57 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fmt.c,v 1.21 2005/12/16 04:20:09 christos Exp $        */
+/*     $NetBSD: fmt.c,v 1.22 2006/01/04 20:44:57 christos Exp $        */
 
 /*
  * Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)fmt.c      8.1 (Berkeley) 7/20/93";
 #endif
-__RCSID("$NetBSD: fmt.c,v 1.21 2005/12/16 04:20:09 christos Exp $");
+__RCSID("$NetBSD: fmt.c,v 1.22 2006/01/04 20:44:57 christos Exp $");
 #endif /* not lint */
 
 #include <ctype.h>
@@ -382,8 +382,8 @@
         */
        s = outbuf.ptr - outbuf.bptr;
        t = wlen + s;
-       if ((t <= goal_length) ||
-           ((t <= max_length) && (t - goal_length <= goal_length - s))) {
+       if ((t <= goal_length) || ((t <= max_length) &&
+           (s <= goal_length) && (t - goal_length <= goal_length - s))) {
                /*
                 * In like flint! 
                 */



Home | Main Index | Thread Index | Old Index