From owner-freebsd-hackers Sat Jul 3 12:18:31 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from majordomo2.umd.edu (majordomo2.umd.edu [128.8.10.7]) by hub.freebsd.org (Postfix) with ESMTP id 4F28414DD2 for ; Sat, 3 Jul 1999 12:18:14 -0700 (PDT) (envelope-from howardjp@wam.umd.edu) Received: from rac9.wam.umd.edu (root@rac9.wam.umd.edu [128.8.10.149]) by majordomo2.umd.edu (8.9.3/8.9.3) with ESMTP id PAA10651; Sat, 3 Jul 1999 15:18:09 -0400 (EDT) Received: from rac9.wam.umd.edu (sendmail@localhost [127.0.0.1]) by rac9.wam.umd.edu (8.9.3/8.9.3) with SMTP id PAA17777; Sat, 3 Jul 1999 15:18:08 -0400 (EDT) Received: from localhost by rac9.wam.umd.edu (8.9.3/8.9.3) with ESMTP id PAA17773; Sat, 3 Jul 1999 15:18:08 -0400 (EDT) X-Authentication-Warning: rac9.wam.umd.edu: howardjp owned process doing -bs Date: Sat, 3 Jul 1999 15:18:07 -0400 (EDT) From: Jamie Howard To: freebsd-hackers@freebsd.org, tech-userlevel@netbsd.org, tech@openbsd.org Subject: Repalcement for grep(1) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I have used FreeBSD for a couple years now. It is the only OS on my desktop. I have learnt many things from its source. I felt it was time to give something back. A few minutes later I decided to offer it to all BSDs. I also will offer it to the DaemonLinux group, Apple, the Darwin group, and Tenon Systems, after public acceptence. If there is anyone else out there using a BSD base and GNU grep, they can have it too. Looking aroud, I thought it would be great to try to replace one of the GNU utilites included in the base with a version which is freely redistributable. I figured a compiler was beyond me, but a a couple of the simpler utilities caught my eye. Grep was first. All of the code is original except for binary.c. It is used with the -a option to prevent searching binary files. binary.c is extricated from less-332's binary checking code. I was just that lazy. I made the version in FreeBSD 4.0 my target except for -A num, -B num, -C, -num, and -Z. These are not required by the Single Unix Specification or POSIX and I felt they would bloat my code too significantly. I added the -o option from 4.4BSD-Lite2's implementation of egrep. I also stole it's man page. One of the primary concerns was simplicity. Looking through the code, you should nobody should have any difficuly understanding the code. Regex does all the heavy work. The object code is about 16% of the size of GNU grep. I also do not use mmap(), I treat the file as a simple stream instead. My code is also a bit slower on larger files, but a bit faster on smaller files. Sometimes I am an order of magnitude slower. I am never that much faster. I think not using mmap is the reason, but I do not know for certain. Now, I am having a problem though. I cannot figure out how to implement -w and -x. For -x, I tried modifying the regular expression (foo) into ^(foo)$ before compiling, but that did not work. I intended to do something similar with -w. Anyway, I am probably missing the obvious, but does anyone have any ideas regarding how I should implement -w and -x? If anyone can help with the -w and -x problems, would like to test, or has any other comments, let me know. I'd also like advice on the speed issue. Also, since I am at it, if you want anything added, lay it on me, either code or ideas. :) The source code can be found at ftp://ftp.wam.umd.edu/pub/howardjp/grep-0.2.tar.gz The source was written and tested on a FreeBSD 3.2 system. I have also compiled under BSDi 3.1. It should work on any BSD and most any Unix. The Makefile is written in the style of the rest of the FreeBSD utilites so that it can be dropped right into /usr/src/usr.bin someday. Only minor modifications should be needed for BSDi, NetBSD, and OpenBSD. I have not built this on either NetBSD or OpenBSD but expect no problems. If anyone does have problems please let me know. Fixes are even better. Thank you everyone, Jamie To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message