Improve dh's fix:

- make sure i is initialized
	- don't subtract 1 in comparison, add 1 to the other side
This commit is contained in:
christos 2008-02-15 20:08:11 +00:00
parent 4498b1fe25
commit 4b3df4502b
1 changed files with 6 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.137 2008/02/15 08:55:31 dholland Exp $ */ /* $NetBSD: job.c,v 1.138 2008/02/15 20:08:11 christos Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California. * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/ */
#ifndef MAKE_NATIVE #ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: job.c,v 1.137 2008/02/15 08:55:31 dholland Exp $"; static char rcsid[] = "$NetBSD: job.c,v 1.138 2008/02/15 20:08:11 christos Exp $";
#else #else
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else #else
__RCSID("$NetBSD: job.c,v 1.137 2008/02/15 08:55:31 dholland Exp $"); __RCSID("$NetBSD: job.c,v 1.138 2008/02/15 20:08:11 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
#endif #endif
@ -1807,7 +1807,8 @@ end_loop:
job->outBuf[i] = ' '; job->outBuf[i] = ' ';
} }
} }
} } else
i = job->curPos - 1;
if (!gotNL) { if (!gotNL) {
job->curPos += nr; job->curPos += nr;
@ -1851,7 +1852,7 @@ end_loop:
(void)fflush(stdout); (void)fflush(stdout);
} }
} }
if (i < max - 1) { if (i + 1 < max) {
/* shift the remaining characters down */ /* shift the remaining characters down */
(void)memcpy(job->outBuf, &job->outBuf[i + 1], max - (i + 1)); (void)memcpy(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
job->curPos = max - (i + 1); job->curPos = max - (i + 1);