mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-27 17:52:43 +00:00
Print file names without stdio buffering to avoid mixing buffered and
unbuffered ouput. PR: bin/176886 Reviewed by: mjg
This commit is contained in:
parent
2a82581d9b
commit
849d265d53
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=251565
@ -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;
|
||||
|
@ -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 style, off_t off)
|
||||
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++;
|
||||
|
@ -113,3 +113,17 @@ maparound(struct mapinfo *mip, off_t offset)
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user