summaryrefslogtreecommitdiff
path: root/devel
diff options
context:
space:
mode:
authorjoerg <joerg>2015-04-16 13:34:14 +0000
committerjoerg <joerg>2015-04-16 13:34:14 +0000
commit5586648d8b1d0a3b4ac6a962888f6b6558e12613 (patch)
tree8af735f5f8efb1956e497f94591a54d14aaca4a2 /devel
parent5be96f03c2ee665e19949a9899f020b99847b897 (diff)
downloadpkgsrc-5586648d8b1d0a3b4ac6a962888f6b6558e12613.tar.gz
r1.180 from src: Explain what max is and handle i reaching it again.
Diffstat (limited to 'devel')
-rw-r--r--devel/bmake/files/job.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/devel/bmake/files/job.c b/devel/bmake/files/job.c
index a8179588605..924af8829bb 100644
--- a/devel/bmake/files/job.c
+++ b/devel/bmake/files/job.c
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.14 2015/04/16 11:40:43 joerg Exp $ */
+/* $NetBSD: job.c,v 1.15 2015/04/16 13:34:14 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.14 2015/04/16 11:40:43 joerg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.15 2015/04/16 13:34:14 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: job.c,v 1.14 2015/04/16 11:40:43 joerg Exp $");
+__RCSID("$NetBSD: job.c,v 1.15 2015/04/16 13:34:14 joerg Exp $");
#endif
#endif /* not lint */
#endif
@@ -1893,10 +1893,18 @@ end_loop:
(void)fflush(stdout);
}
}
- assert(i < max);
- /* shift the remaining characters down */
- (void)memmove(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
- job->curPos = max - (i + 1);
+ /*
+ * max is the last offset still in the buffer. Move any remaining
+ * characters to the start of the buffer and update the end marker
+ * curPos.
+ */
+ if (i < max) {
+ (void)memmove(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
+ job->curPos = max - (i + 1);
+ } else {
+ assert(i == max);
+ job->curPos = 0;
+ }
}
if (finish) {
/*