diff options
Diffstat (limited to 'job.c')
| -rw-r--r-- | job.c | 39 |
1 files changed, 15 insertions, 24 deletions
@@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.453 2022/05/07 08:01:20 rillig Exp $ */ +/* $NetBSD: job.c,v 1.457 2023/01/17 21:35:19 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -155,7 +155,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.453 2022/05/07 08:01:20 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.457 2023/01/17 21:35:19 christos Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -525,7 +525,7 @@ JobDeleteTarget(GNode *gn) return; file = GNode_Path(gn); - if (unlink_file(file)) + if (unlink_file(file) == 0) Error("*** %s removed", file); } @@ -745,7 +745,8 @@ ParseCommandFlags(char **pp, CommandFlags *out_cmdFlags) out_cmdFlags->ignerr = true; else if (*p == '+') out_cmdFlags->always = true; - else + else if (!ch_isspace(*p)) + /* Ignore whitespace for compatibility with gnu make */ break; p++; } @@ -1851,46 +1852,36 @@ again: if (nRead < 0) { if (errno == EAGAIN) return; - if (DEBUG(JOB)) { + if (DEBUG(JOB)) perror("CollectOutput(piperead)"); - } nr = 0; - } else { + } else nr = (size_t)nRead; - } + + if (nr == 0) + finish = false; /* stop looping */ /* * If we hit the end-of-file (the job is dead), we must flush its * remaining output, so pretend we read a newline if there's any * output remaining in the buffer. - * Also clear the 'finish' flag so we stop looping. */ if (nr == 0 && job->curPos != 0) { job->outBuf[job->curPos] = '\n'; nr = 1; - finish = false; - } else if (nr == 0) { - finish = false; } - /* - * Look for the last newline in the bytes we just got. If there is - * one, break out of the loop with 'i' as its index and gotNL set - * true. - */ max = job->curPos + nr; + for (i = job->curPos; i < max; i++) + if (job->outBuf[i] == '\0') + job->outBuf[i] = ' '; + + /* Look for the last newline in the bytes we just got. */ for (i = job->curPos + nr - 1; i >= job->curPos && i != (size_t)-1; i--) { if (job->outBuf[i] == '\n') { gotNL = true; break; - } else if (job->outBuf[i] == '\0') { - /* - * FIXME: The null characters are only replaced with - * space _after_ the last '\n'. Everywhere else they - * hide the rest of the command output. - */ - job->outBuf[i] = ' '; } } |
