Date: Sat, 10 Jan 2009 12:08:56 GMT From: Gabor Kovesdan <gabor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 155903 for review Message-ID: <200901101208.n0AC8up2045767@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=155903 Change 155903 by gabor@gabor_server on 2009/01/10 12:08:38 - Fix a bug in stdin handling, which was introduced in a change of buffering Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/file.c#38 edit .. //depot/projects/soc2008/gabor_textproc/grep/grep.h#44 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/file.c#38 (text+ko) ==== @@ -132,8 +132,10 @@ /* Only pre-read to the buffer if we need the binary check. */ if (binbehave != BINFILE_TEXT) { - if (stat(fname, &st) != 0) - errx(2, NULL); + if (f->stdin == 1) + st.st_size = 0; + else if (stat(fname, &st) != 0) + err(2, NULL); bufsiz = (MAXBUFSIZ > (st.st_size * PREREAD_M)) ? (st.st_size / 2) : MAXBUFSIZ; @@ -183,8 +185,10 @@ f = grep_malloc(sizeof *f); - if ((f->f = fdopen(STDIN_FILENO, "r")) != NULL) + if ((f->f = fdopen(STDIN_FILENO, "r")) != NULL) { + f->stdin = 1; return (f); + } free(f); return (NULL); @@ -202,6 +206,7 @@ f = grep_malloc(sizeof *f); + f->stdin = 0; switch (filebehave) { case FILE_STDIO: if ((f->f = fopen(path, "r")) != NULL) ==== //depot/projects/soc2008/gabor_textproc/grep/grep.h#44 (text+ko) ==== @@ -72,6 +72,7 @@ struct file { int binary; + int stdin; FILE *f; struct mmfile *mmf; gzFile *gzf;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901101208.n0AC8up2045767>