Thu Apr 16 13:34:14 2015 UTC ()
r1.180 from src: Explain what max is and handle i reaching it again.


(joerg)
diff -r1.14 -r1.15 pkgsrc/devel/bmake/files/job.c

cvs diff -r1.14 -r1.15 pkgsrc/devel/bmake/files/job.c (expand / switch to unified diff)

--- pkgsrc/devel/bmake/files/job.c 2015/04/16 11:40:43 1.14
+++ pkgsrc/devel/bmake/files/job.c 2015/04/16 13:34:14 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: job.c,v 1.14 2015/04/16 11:40:43 joerg Exp $ */ 1/* $NetBSD: job.c,v 1.15 2015/04/16 13:34:14 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -60,34 +60,34 @@ @@ -60,34 +60,34 @@
60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * SUCH DAMAGE. 69 * SUCH DAMAGE.
70 */ 70 */
71 71
72#ifndef MAKE_NATIVE 72#ifndef MAKE_NATIVE
73static char rcsid[] = "$NetBSD: job.c,v 1.14 2015/04/16 11:40:43 joerg Exp $"; 73static char rcsid[] = "$NetBSD: job.c,v 1.15 2015/04/16 13:34:14 joerg Exp $";
74#else 74#else
75#include <sys/cdefs.h> 75#include <sys/cdefs.h>
76#ifndef lint 76#ifndef lint
77#if 0 77#if 0
78static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; 78static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
79#else 79#else
80__RCSID("$NetBSD: job.c,v 1.14 2015/04/16 11:40:43 joerg Exp $"); 80__RCSID("$NetBSD: job.c,v 1.15 2015/04/16 13:34:14 joerg Exp $");
81#endif 81#endif
82#endif /* not lint */ 82#endif /* not lint */
83#endif 83#endif
84 84
85/*- 85/*-
86 * job.c -- 86 * job.c --
87 * handle the creation etc. of our child processes. 87 * handle the creation etc. of our child processes.
88 * 88 *
89 * Interface: 89 * Interface:
90 * Job_Make Start the creation of the given target. 90 * Job_Make Start the creation of the given target.
91 * 91 *
92 * Job_CatchChildren Check for and handle the termination of any 92 * Job_CatchChildren Check for and handle the termination of any
93 * children. This must be called reasonably 93 * children. This must be called reasonably
@@ -1883,30 +1883,38 @@ end_loop: @@ -1883,30 +1883,38 @@ end_loop:
1883 if (!beSilent && job->node != lastNode) { 1883 if (!beSilent && job->node != lastNode) {
1884 MESSAGE(stdout, job->node); 1884 MESSAGE(stdout, job->node);
1885 lastNode = job->node; 1885 lastNode = job->node;
1886 } 1886 }
1887#ifdef USE_META 1887#ifdef USE_META
1888 if (useMeta) { 1888 if (useMeta) {
1889 meta_job_output(job, cp, gotNL ? "\n" : ""); 1889 meta_job_output(job, cp, gotNL ? "\n" : "");
1890 } 1890 }
1891#endif 1891#endif
1892 (void)fprintf(stdout, "%s%s", cp, gotNL ? "\n" : ""); 1892 (void)fprintf(stdout, "%s%s", cp, gotNL ? "\n" : "");
1893 (void)fflush(stdout); 1893 (void)fflush(stdout);
1894 } 1894 }
1895 } 1895 }
1896 assert(i < max); 1896 /*
1897 /* shift the remaining characters down */ 1897 * max is the last offset still in the buffer. Move any remaining
1898 (void)memmove(job->outBuf, &job->outBuf[i + 1], max - (i + 1)); 1898 * characters to the start of the buffer and update the end marker
1899 job->curPos = max - (i + 1); 1899 * curPos.
 1900 */
 1901 if (i < max) {
 1902 (void)memmove(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
 1903 job->curPos = max - (i + 1);
 1904 } else {
 1905 assert(i == max);
 1906 job->curPos = 0;
 1907 }
1900 } 1908 }
1901 if (finish) { 1909 if (finish) {
1902 /* 1910 /*
1903 * If the finish flag is true, we must loop until we hit 1911 * If the finish flag is true, we must loop until we hit
1904 * end-of-file on the pipe. This is guaranteed to happen 1912 * end-of-file on the pipe. This is guaranteed to happen
1905 * eventually since the other end of the pipe is now closed 1913 * eventually since the other end of the pipe is now closed
1906 * (we closed it explicitly and the child has exited). When 1914 * (we closed it explicitly and the child has exited). When
1907 * we do get an EOF, finish will be set FALSE and we'll fall 1915 * we do get an EOF, finish will be set FALSE and we'll fall
1908 * through and out. 1916 * through and out.
1909 */ 1917 */
1910 goto end_loop; 1918 goto end_loop;
1911 } 1919 }
1912} 1920}