From owner-freebsd-arch Wed Dec 20 15:34: 1 2000 From owner-freebsd-arch@FreeBSD.ORG Wed Dec 20 15:33:59 2000 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from netau1.alcanet.com.au (ntp.alcanet.com.au [203.62.196.27]) by hub.freebsd.org (Postfix) with ESMTP id F0FB237B400 for ; Wed, 20 Dec 2000 15:33:57 -0800 (PST) Received: from mfg1.cim.alcatel.com.au (mfg1.cim.alcatel.com.au [139.188.23.1]) by netau1.alcanet.com.au (8.9.3 (PHNE_18979)/8.9.3) with ESMTP id KAA06921; Thu, 21 Dec 2000 10:29:57 +1100 (EDT) Received: from gsmx07.alcatel.com.au by cim.alcatel.com.au (PMDF V5.2-32 #37641) with ESMTP id <01JXYOCTGIZ4EMWM0J@cim.alcatel.com.au>; Thu, 21 Dec 2000 10:30:04 +1100 Received: (from jeremyp@localhost) by gsmx07.alcatel.com.au (8.11.0/8.11.0) id eBKNTrX72877; Thu, 21 Dec 2000 10:29:53 +1100 (EST envelope-from jeremyp) Content-return: prohibited Date: Thu, 21 Dec 2000 10:29:53 +1100 From: Peter Jeremy Subject: Re: gensetdefs using sh(1),sed(1),grep(1) and awk(1) In-reply-to: <3A405A43.5C10697C@cup.hp.com>; from marcel@cup.hp.com on Tue, Dec 19, 2000 at 11:05:39PM -0800 To: Marcel Moolenaar Cc: arch@FreeBSD.ORG Mail-followup-to: Marcel Moolenaar , arch@FreeBSD.ORG Message-id: <20001221102952.O54775@gsmx07.alcatel.com.au> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-disposition: inline User-Agent: Mutt/1.2.5i References: <3A405A43.5C10697C@cup.hp.com> Sender: jeremyp@gsmx07.alcatel.com.au Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 2000-Dec-19 23:05:39 -0800, Marcel Moolenaar wrote: >Read and weep :-) I'll go on record as thinking the perl version is more legible and more maintainable. The base system includes a number of Turing-equivalent languages: [c]sh builtins, awk, perl, C, C++, FORTH (if you include the loader), groff and (I believe) sed. gensetdefs could be written in any of these languages. If someone really wants to minimise the number of build tools, they are free to write gensetdefs using sh builtins only. One reason why the base system includes some many functionally equivalent tools is that they are targeted for different purposes. Rather than the adopt a one tool suits all purposes, I believe it's worthwhile looking at the requirements and then selecting the most appropriate tool. In this case, the need for getsetdefs to be MI whilst processing MD objects suggests that using objdump is better than directly reading the raw objects. Given the speed of both scripted versions, there isn't any need to go to a compiled language for performance reasons. Since this tool is primarily text processing, awk or perl are probably better choices than C. >I think it can do better if we can avoid the "system()" calls... The fgrep, both sed's and the sort could be done trivially in awk. Handling the "2**N" output could be done with a simple expression parser. Getting rid of the system("echo | dc") would be the hardest bit - but still isn't that difficult. Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message