Date: Wed, 2 Apr 2014 17:10:17 +0000 (UTC) From: Jaakko Heinonen <jh@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r264047 - stable/9/usr.bin/tail Message-ID: <201404021710.s32HAH2l076588@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jh Date: Wed Apr 2 17:10:17 2014 New Revision: 264047 URL: http://svnweb.freebsd.org/changeset/base/264047 Log: MFC r251565: Print file names without stdio buffering to avoid mixing buffered and unbuffered ouput. PR: bin/176886 Modified: stable/9/usr.bin/tail/extern.h stable/9/usr.bin/tail/forward.c stable/9/usr.bin/tail/misc.c stable/9/usr.bin/tail/tail.c Directory Properties: stable/9/usr.bin/tail/ (props changed) Modified: stable/9/usr.bin/tail/extern.h ============================================================================== --- stable/9/usr.bin/tail/extern.h Wed Apr 2 16:53:07 2014 (r264046) +++ stable/9/usr.bin/tail/extern.h Wed Apr 2 17:10:17 2014 (r264047) @@ -67,5 +67,6 @@ void ierr(const char *); void oerr(void); int mapprint(struct mapinfo *, off_t, off_t); int maparound(struct mapinfo *, off_t); +void printfn(const char *, int); extern int Fflag, fflag, qflag, rflag, rval, no_files; Modified: stable/9/usr.bin/tail/forward.c ============================================================================== --- stable/9/usr.bin/tail/forward.c Wed Apr 2 16:53:07 2014 (r264046) +++ stable/9/usr.bin/tail/forward.c Wed Apr 2 17:10:17 2014 (r264047) @@ -243,7 +243,7 @@ show(file_info_t *file) while ((ch = getc(file->fp)) != EOF) { if (last != file && no_files > 1) { if (!qflag) - (void)printf("\n==> %s <==\n", file->file_name); + printfn(file->file_name, 1); last = file; } if (putchar(ch) == EOF) @@ -320,7 +320,7 @@ follow(file_info_t *files, enum STYLE st active = 1; n++; if (no_files > 1 && !qflag) - (void)printf("\n==> %s <==\n", file->file_name); + printfn(file->file_name, 1); forward(file->fp, file->file_name, style, off, &file->st); if (Fflag && fileno(file->fp) != STDIN_FILENO) n++; Modified: stable/9/usr.bin/tail/misc.c ============================================================================== --- stable/9/usr.bin/tail/misc.c Wed Apr 2 16:53:07 2014 (r264046) +++ stable/9/usr.bin/tail/misc.c Wed Apr 2 17:10:17 2014 (r264047) @@ -113,3 +113,17 @@ maparound(struct mapinfo *mip, off_t off return (0); } + +/* + * Print the file name without stdio buffering. + */ +void +printfn(const char *fn, int print_nl) +{ + + if (print_nl) + WR("\n", 1); + WR("==> ", 4); + WR(fn, strlen(fn)); + WR(" <==\n", 5); +} Modified: stable/9/usr.bin/tail/tail.c ============================================================================== --- stable/9/usr.bin/tail/tail.c Wed Apr 2 16:53:07 2014 (r264046) +++ stable/9/usr.bin/tail/tail.c Wed Apr 2 17:10:17 2014 (r264047) @@ -203,10 +203,8 @@ main(int argc, char *argv[]) continue; } if (argc > 1 && !qflag) { - (void)printf("%s==> %s <==\n", - first ? "" : "\n", fn); + printfn(fn, !first); first = 0; - (void)fflush(stdout); } if (rflag)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404021710.s32HAH2l076588>