Fix log_output(); just pass in a string and a length.
This commit is contained in:
13
script.c
13
script.c
@@ -302,8 +302,8 @@ script_duplow(fd)
|
|||||||
|
|
||||||
/* Update output and timing files. */
|
/* Update output and timing files. */
|
||||||
static void
|
static void
|
||||||
log_output(output, n, then, now, ofile, tfile)
|
log_output(buf, n, then, now, ofile, tfile)
|
||||||
struct script_buf *output;
|
char *buf;
|
||||||
int n;
|
int n;
|
||||||
struct timeval *then;
|
struct timeval *then;
|
||||||
struct timeval *now;
|
struct timeval *now;
|
||||||
@@ -312,7 +312,7 @@ log_output(output, n, then, now, ofile, tfile)
|
|||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
fwrite(output->buf + output->off, 1, n, ofile);
|
fwrite(buf, 1, n, ofile);
|
||||||
timersub(now, then, &tv);
|
timersub(now, then, &tv);
|
||||||
fprintf(tfile, "%f %d\n",
|
fprintf(tfile, "%f %d\n",
|
||||||
tv.tv_sec + ((double)tv.tv_usec / 1000000), n);
|
tv.tv_sec + ((double)tv.tv_usec / 1000000), n);
|
||||||
@@ -471,10 +471,11 @@ script_execv(path, argv)
|
|||||||
} else {
|
} else {
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
break; /* got EOF */
|
break; /* got EOF */
|
||||||
output.len += n;
|
|
||||||
|
|
||||||
/* Update output and timing files. */
|
/* Update output and timing files. */
|
||||||
log_output(&output, n, &then, &now, ofile, tfile);
|
log_output(output.buf + output.len, n, &then, &now, ofile, tfile);
|
||||||
|
|
||||||
|
output.len += n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (FD_ISSET(STDOUT_FILENO, fdsw)) {
|
if (FD_ISSET(STDOUT_FILENO, fdsw)) {
|
||||||
@@ -510,9 +511,9 @@ script_execv(path, argv)
|
|||||||
n = read(script_fds[SFD_MASTER], output.buf, sizeof(output.buf));
|
n = read(script_fds[SFD_MASTER], output.buf, sizeof(output.buf));
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
break;
|
break;
|
||||||
|
log_output(output.buf, n, &then, &now, ofile, tfile);
|
||||||
output.off = 0;
|
output.off = 0;
|
||||||
output.len = n;
|
output.len = n;
|
||||||
log_output(&output, output.len, &then, &now, ofile, tfile);
|
|
||||||
do {
|
do {
|
||||||
n = write(STDOUT_FILENO, output.buf + output.off,
|
n = write(STDOUT_FILENO, output.buf + output.off,
|
||||||
output.len - output.off);
|
output.len - output.off);
|
||||||
|
Reference in New Issue
Block a user