From owner-freebsd-bugs Mon Jan 18 00:03:57 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id AAA06359 for freebsd-bugs-outgoing; Mon, 18 Jan 1999 00:03:57 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id AAA06351 for ; Mon, 18 Jan 1999 00:03:56 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id XAA26080; Sun, 17 Jan 1999 23:50:01 -0800 (PST) Received: from fep2-orange.clear.net.nz (fep2-orange.clear.net.nz [203.97.32.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA05341 for ; Sun, 17 Jan 1999 23:49:49 -0800 (PST) (envelope-from jabley@buddha.clear.net.nz) Received: from buddha.clear.net.nz (buddha.clear.net.nz [192.168.24.106]) by fep2-orange.clear.net.nz (1.5/1.9) with ESMTP id UAA04463; Mon, 18 Jan 1999 20:49:43 +1300 (NZDT) Received: (from jabley@localhost) by buddha.clear.net.nz (8.9.2/8.9.1) id UAA15682; Mon, 18 Jan 1999 20:49:43 +1300 (NZDT) (envelope-from jabley) Message-Id: <199901180749.UAA15682@buddha.clear.net.nz> Date: Mon, 18 Jan 1999 20:49:43 +1300 (NZDT) From: jabley@patho.gen.nz Reply-To: jabley@buddha.clear.net.nz To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: kern/9551: replacement of perl in sys/boot with awk Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 9551 >Category: kern >Synopsis: replacement of perl in sys/boot with awk >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Jan 17 23:50:01 PST 1999 >Closed-Date: >Last-Modified: >Originator: Joe Abley >Release: FreeBSD 3.0-CURRENT i386 >Organization: CLEAR Communications >Environment: 3.0-CURRENT >Description: sys/boot contains perl. This seems to be considered a bad thing. Here is some awk. >How-To-Repeat: Not applicable >Fix: Following unified diff patches Makefiles in sys/boot to call awk instead of perl: diff -U3 -r ./old/sys/boot/alpha/boot2/Makefile ./new/sys/boot/alpha/boot2/Makefile --- ./old/sys/boot/alpha/boot2/Makefile Tue Jan 12 20:34:15 1999 +++ ./new/sys/boot/alpha/boot2/Makefile Mon Jan 18 20:33:55 1999 @@ -47,7 +47,7 @@ vers.o ${LIBSTAND} ${LIBALPHA} ${LIBSTAND} >${.OBJDIR}/${BASE}.list ${BASE}.help: help.common help.alpha - perl ${.CURDIR}/../../common/merge_help.pl ${.ALLSRC} > ${.TARGET} + cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} beforeinstall: .if exists(${.OBJDIR}/loader.help) Only in ./new/sys/boot/common: merge_help.awk Only in ./old/sys/boot/common: merge_help.pl diff -U3 -r ./old/sys/boot/ficl/Makefile ./new/sys/boot/ficl/Makefile --- ./old/sys/boot/ficl/Makefile Fri Nov 6 07:36:26 1998 +++ ./new/sys/boot/ficl/Makefile Mon Jan 18 20:34:18 1999 @@ -16,8 +16,8 @@ .PATH: ${.CURDIR}/softwords CFLAGS+= -I${.CURDIR} -softcore.c: ${SOFTWORDS} softcore.pl - (cd ${.CURDIR}/softwords; perl softcore.pl ${SOFTWORDS}) > ${.TARGET} +softcore.c: ${SOFTWORDS} softcore.awk + (cd ${.CURDIR}/softwords; cat ${SOFTWORDS} | awk -f softcore.awk) > ${.TARGET} .include Only in ./new/sys/boot/ficl/softwords: softcore.awk Only in ./old/sys/boot/ficl/softwords: softcore.pl diff -U3 -r ./old/sys/boot/i386/loader/Makefile ./new/sys/boot/i386/loader/Makefile --- ./old/sys/boot/i386/loader/Makefile Tue Jan 12 20:34:37 1999 +++ ./new/sys/boot/i386/loader/Makefile Mon Jan 18 20:35:23 1999 @@ -79,7 +79,7 @@ strip ${.TARGET} ${BASE}.help: help.common help.i386 - perl ${.CURDIR}/../../common/merge_help.pl ${.ALLSRC} > ${.TARGET} + cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} beforeinstall: .if exists(${DESTDIR}/boot/loader) Following is sys/ficl/softwords/softcore.awk: #!/usr/bin/awk -f # Convert forth source files to a giant C string # Joe Abley , 12 January 1999 BEGIN \ { printf "/***************************************************************\n"; printf "** s o f t c o r e . c\n"; printf "** Forth Inspired Command Language -\n"; printf "** Words from CORE set written in FICL\n"; printf "** Author: John Sadler (john_sadler@alum.mit.edu)\n"; printf "** Created: 27 December 1997\n"; printf "** Last update: %s\n", strftime(); printf "***************************************************************/\n"; printf "\n/*\n"; printf "** This file contains definitions that are compiled into the\n"; printf "** system dictionary by the first virtual machine to be created.\n"; printf "** Created automagically by ficl/softwords/softcore.awk\n"; printf "*/\n"; printf "\n#include \"ficl.h\"\n"; printf "\nstatic char softWords[] =\n"; commenting = 0; } # some general early substitutions { gsub("\t", " "); # replace each tab with 4 spaces gsub("\"", "\\\""); # escape quotes gsub("\\\\[[:space:]]+$", ""); # toss empty comments } # strip out empty lines /^ *$/ \ { next; } # emit / ** lines as multi-line C comments /^\\[[:space:]]\*\*/ && (commenting == 0) \ { sub("^\\\\[[:space:]]", ""); printf "/*\n%s\n", $0; commenting = 1; next; } /^\\[[:space:]]\*\*/ \ { sub("^\\\\[[:space:]]", ""); printf "%s\n", $0; next; } # function to close a comment, used later function end_comments() { commenting = 0; printf "*/\n"; } # pass commented preprocessor directives /^\\[[:space:]]#/ \ { if (commenting) end_comments(); sub("^\\\\[[:space:]]", ""); printf "%s\n", $0; next; } # toss all other full-line comments /^\\/ \ { if (commenting) end_comments(); next; } # emit all other lines as quoted string fragments { if (commenting) end_comments(); sub("\\\\[[:space:]]+.*$", ""); # lop off trailing \ comments sub("[[:space:]]+$", ""); # remove trailing spaces printf " \"%s \\n\"\n", $0; next; } END \ { if (commenting) end_comments(); printf " \"quit \";\n"; printf "\n\nvoid ficlCompileSoftCore(FICL_VM *pVM)\n"; printf "{\n"; printf " assert(ficlExec(pVM, softWords) != VM_ERREXIT);\n"; printf "}\n"; } Following is sys/boot/common/merge_help.awk: #!/usr/bin/awk -f # # $Id: mergehelp.awk,v 1.3 1999/01/13 20:06:52 jabley Exp $ # # Merge two boot loader help files for FreeBSD 3.0 # Joe Abley BEGIN \ { state = 0; first = 0; ind = 0; } # beginning of first command /^###/ && (state == 0) \ { state = 1; next; } # entry header /^# T[[:graph:]]+ (S[[:graph:]]+ )*D[[:graph:]][[:print:]]*$/ && (state == 1) \ { match($0, " T[[:graph:]]+"); T = substr($0, RSTART + 2, RLENGTH - 2); match($0, " S[[:graph:]]+"); S = (RLENGTH == -1) ? "" : substr($0, RSTART + 2, RLENGTH - 2); match($0, " D[[:graph:]][[:print:]]*$"); D = substr($0, RSTART + 2); # find a suitable place to store this one... ind++; if (ind == 1) { first = ind; help[ind, "T"] = T; help[ind, "S"] = S; help[ind, "link"] = -1; } else { i = first; j = -1; while (help[i, "T"] help[i, "S"] < T S) { j = i; i = help[i, "link"]; if (i == -1) break; } if (i == -1) { help[j, "link"] = ind; help[ind, "link"] = -1; } else { help[ind, "link"] = i; if (j == -1) first = ind; else help[j, "link"] = ind; } } help[ind, "T"] = T; help[ind, "S"] = S; help[ind, "D"] = D; # set our state state = 2; help[ind, "text"] = 0; next; } # end of last command, beginning of next one /^###/ && (state == 2) \ { state = 1; } (state == 2) \ { sub("[[:blank:]]+$", ""); if (help[ind, "text"] == 0 && $0 ~ /^[[:blank:]]*$/) next; help[ind, "text", help[ind, "text"]] = $0; help[ind, "text"]++; next; } # show them what we have (it's already sorted in help[]) END \ { node = first; while (node != -1) { printf "################################################################################\n"; printf "# T%s ", help[node, "T"]; if (help[node, "S"] != "") printf "S%s ", help[node, "S"]; printf "D%s\n\n", help[node, "D"]; for (i = 0; i < help[node, "text"]; i++) printf "%s\n", help[node, "text", i]; node = help[node, "link"]; } printf "################################################################################\n"; } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message