PERFORCE change 155903 for review
Gabor Kovesdan
gabor at FreeBSD.org
Sat Jan 10 04:08:59 PST 2009
http://perforce.freebsd.org/chv.cgi?CH=155903
Change 155903 by gabor at 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;
More information about the p4-projects
mailing list