=================================================================== RCS file: /cvs/mandoc/main.c,v retrieving revision 1.276 retrieving revision 1.278 diff -u -p -r1.276 -r1.278 --- mandoc/main.c 2016/09/18 15:22:08 1.276 +++ mandoc/main.c 2017/01/09 01:37:03 1.278 @@ -1,7 +1,7 @@ -/* $Id: main.c,v 1.276 2016/09/18 15:22:08 schwarze Exp $ */ +/* $Id: main.c,v 1.278 2017/01/09 01:37:03 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons - * Copyright (c) 2010-2012, 2014-2016 Ingo Schwarze + * Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze * Copyright (c) 2010 Joerg Sonnenberger * * Permission to use, copy, modify, and distribute this software for any @@ -781,6 +781,7 @@ parse(struct curparse *curp, int fd, const char *file) break; } } + mparse_updaterc(curp->mp, &rc); } static void @@ -820,11 +821,17 @@ passthrough(const char *file, int fd, int synopsis_onl const char *syscall; char *line, *cp; size_t linesz; + ssize_t len, written; int print; line = NULL; linesz = 0; + if (fflush(stdout) == EOF) { + syscall = "fflush"; + goto fail; + } + if ((stream = fdopen(fd, "r")) == NULL) { close(fd); syscall = "fdopen"; @@ -832,14 +839,16 @@ passthrough(const char *file, int fd, int synopsis_onl } print = 0; - while (getline(&line, &linesz, stream) != -1) { + while ((len = getline(&line, &linesz, stream)) != -1) { cp = line; if (synopsis_only) { if (print) { if ( ! isspace((unsigned char)*cp)) goto done; - while (isspace((unsigned char)*cp)) + while (isspace((unsigned char)*cp)) { cp++; + len--; + } } else { if (strcmp(cp, synb) == 0 || strcmp(cp, synr) == 0) @@ -847,9 +856,11 @@ passthrough(const char *file, int fd, int synopsis_onl continue; } } - if (fputs(cp, stdout)) { + for (; len > 0; len -= written) { + if ((written = write(STDOUT_FILENO, cp, len)) != -1) + continue; fclose(stream); - syscall = "fputs"; + syscall = "write"; goto fail; } }