From owner-p4-projects@FreeBSD.ORG Sat Jan 10 12:08:57 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B3F7E1065688; Sat, 10 Jan 2009 12:08:56 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4DA091065679 for ; Sat, 10 Jan 2009 12:08:56 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 39B608FC16 for ; Sat, 10 Jan 2009 12:08:56 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n0AC8uYh045769 for ; Sat, 10 Jan 2009 12:08:56 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n0AC8up2045767 for perforce@freebsd.org; Sat, 10 Jan 2009 12:08:56 GMT (envelope-from gabor@freebsd.org) Date: Sat, 10 Jan 2009 12:08:56 GMT Message-Id: <200901101208.n0AC8up2045767@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gabor@freebsd.org using -f From: Gabor Kovesdan To: Perforce Change Reviews Cc: Subject: PERFORCE change 155903 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 12:08:59 -0000 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;