From owner-p4-projects@FreeBSD.ORG Sat Aug 9 13:40:16 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A5F891065677; Sat, 9 Aug 2008 13:40:16 +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 6A6BA106564A for ; Sat, 9 Aug 2008 13:40:16 +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 586298FC0A for ; Sat, 9 Aug 2008 13:40:16 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m79DeGpR084814 for ; Sat, 9 Aug 2008 13:40:16 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m79DeGrT084812 for perforce@freebsd.org; Sat, 9 Aug 2008 13:40:16 GMT (envelope-from gabor@freebsd.org) Date: Sat, 9 Aug 2008 13:40:16 GMT Message-Id: <200808091340.m79DeGrT084812@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 146988 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, 09 Aug 2008 13:40:17 -0000 http://perforce.freebsd.org/chv.cgi?CH=146988 Change 146988 by gabor@gabor_server on 2008/08/09 13:40:04 - Check in a working and hopefully GNU compatible version of binary detecting Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/file.c#33 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/file.c#33 (text+ko) ==== @@ -119,32 +119,19 @@ { int i = 0; char ch; - size_t size; - wchar_t wbinbuf[BUFSIZ]; - const char *src = binbuf; - mbstate_t mbs; /* Fill in the buffer if it is empty. */ if (binbufptr == NULL) { /* Only pre-read to the buffer if we need the binary check. */ if (binbehave != BINFILE_TEXT) { - for (; i < sizeof(wbinbuf) && !grep_feof(f); i++) { + for (; i < sizeof(binbuf) && !grep_feof(f); i++) { ch = grep_fgetc(f); if (ch != EOF) binbuf[i] = ch; else break; } - /* Convert at most (BUFSIZ * sizeof(wint_t)) characters or - (BUFSIZ - 1) bytes to wide character string. */ - size = mbsnrtowcs(wbinbuf, &src, sizeof(wbinbuf), BUFSIZ - 1, &mbs); - f->binary = 0; - for (; size > 0; size--) - if (iswbinary(wbinbuf[size])) { - f->binary = 1; - break; - } - + f->binary = memchr(binbuf, (filebehave != FILE_GZIP) ? '\0' : '\200', i - 1) != 0; } binbufsiz = i; binbufptr = binbuf;