xref: /minix3/distrib/common/parselist.awk (revision 77e79d33746fa2b709086b9caa51b1415d66c801)
19152e1c5SLionel Sambuc#	$NetBSD: parselist.awk,v 1.16 2009/04/10 16:16:12 apb Exp $
29152e1c5SLionel Sambuc#
39152e1c5SLionel Sambuc# Copyright (c) 2002 The NetBSD Foundation, Inc.
49152e1c5SLionel Sambuc# All rights reserved.
59152e1c5SLionel Sambuc#
69152e1c5SLionel Sambuc# This code is derived from software contributed to The NetBSD Foundation
79152e1c5SLionel Sambuc# by Luke Mewburn of Wasabi Systems.
89152e1c5SLionel Sambuc#
99152e1c5SLionel Sambuc# Redistribution and use in source and binary forms, with or without
109152e1c5SLionel Sambuc# modification, are permitted provided that the following conditions
119152e1c5SLionel Sambuc# are met:
129152e1c5SLionel Sambuc# 1. Redistributions of source code must retain the above copyright
139152e1c5SLionel Sambuc#    notice, this list of conditions and the following disclaimer.
149152e1c5SLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright
159152e1c5SLionel Sambuc#    notice, this list of conditions and the following disclaimer in the
169152e1c5SLionel Sambuc#    documentation and/or other materials provided with the distribution.
179152e1c5SLionel Sambuc#
189152e1c5SLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
199152e1c5SLionel Sambuc# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
209152e1c5SLionel Sambuc# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
219152e1c5SLionel Sambuc# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
229152e1c5SLionel Sambuc# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
239152e1c5SLionel Sambuc# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
249152e1c5SLionel Sambuc# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
259152e1c5SLionel Sambuc# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
269152e1c5SLionel Sambuc# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
279152e1c5SLionel Sambuc# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
289152e1c5SLionel Sambuc# POSSIBILITY OF SUCH DAMAGE.
299152e1c5SLionel Sambuc#
309152e1c5SLionel Sambuc
319152e1c5SLionel Sambuc#
329152e1c5SLionel Sambuc# awk -f parselist.awk -v mode=MODE [var=val ...] file1 [...]
339152e1c5SLionel Sambuc#
349152e1c5SLionel Sambuc#	Parse list files file1 [...], generating different output,
359152e1c5SLionel Sambuc#	depending upon the value of MODE:
369152e1c5SLionel Sambuc#
379152e1c5SLionel Sambuc#	    crunch	crunchgen(1) config
389152e1c5SLionel Sambuc#
399152e1c5SLionel Sambuc#	    install	make(1) Makefile to install commands into ${TARGETDIR},
409152e1c5SLionel Sambuc#			with an `install' target.
419152e1c5SLionel Sambuc#			The following environment variables need to be set:
429152e1c5SLionel Sambuc#			    TARGETDIR	Directory to populate
439152e1c5SLionel Sambuc#
449152e1c5SLionel Sambuc#	    mtree	mtree(8) specfile
459152e1c5SLionel Sambuc#
469152e1c5SLionel Sambuc#	    populate	sh(1) commands to populate ${TARGETDIR} from ${CURDIR}
479152e1c5SLionel Sambuc#			The following environment variables need to be set:
489152e1c5SLionel Sambuc#			    CURDIR	Source directory; make(1)'s ${.CURDIR}
499152e1c5SLionel Sambuc#			    TARGETDIR	Directory to populate
509152e1c5SLionel Sambuc#
519152e1c5SLionel Sambuc#	The following environment variables need to be set for all modes:
529152e1c5SLionel Sambuc#	    CRUNCHBIN	Name of crunchgen(1) target binary
539152e1c5SLionel Sambuc#	    OBJDIR	Object directory; make(1)'s ${.OBJDIR}
549152e1c5SLionel Sambuc#
559152e1c5SLionel Sambuc# 	Each line of the input is either a comment (starts with `#'),
569152e1c5SLionel Sambuc#	or contains one of the following keywords and arguments.
579152e1c5SLionel Sambuc#
589152e1c5SLionel Sambuc#	Before each line is parsed for a keyword, words surrounded by
599152e1c5SLionel Sambuc#	"${" and "}", and containing only letters, numbers, and `_'
609152e1c5SLionel Sambuc#	will be replaced by the value of the environment variable of
619152e1c5SLionel Sambuc#	the same name.  I.e., "${MACHINE_ARCH}" will be replaced with the
629152e1c5SLionel Sambuc#	value of ENVIRON["MACHINE_ARCH"].
639152e1c5SLionel Sambuc#
649152e1c5SLionel Sambuc#	mode key	operation
659152e1c5SLionel Sambuc#	--------	---------
669152e1c5SLionel Sambuc#	C		crunch
679152e1c5SLionel Sambuc#	I		install
689152e1c5SLionel Sambuc#	M		mtree
699152e1c5SLionel Sambuc#	P		populate
709152e1c5SLionel Sambuc#
719152e1c5SLionel Sambuc#	mode	keyword arg1 [...]	description
729152e1c5SLionel Sambuc#	----	------------------	-----------
739152e1c5SLionel Sambuc#
749152e1c5SLionel Sambuc#	C	ARGVLN	prog link	as per crunchgen(1) `ln'
759152e1c5SLionel Sambuc#
769152e1c5SLionel Sambuc#	P	CMD	arg1 [...]	run CMD as a shell command
779152e1c5SLionel Sambuc#
789152e1c5SLionel Sambuc#	IMP	COPY	src dest [perm]	copy src to dest. perm defaults to 0444
799152e1c5SLionel Sambuc#
809152e1c5SLionel Sambuc#	IMP	COPYDIR	src dest	recursively copy files under src to
819152e1c5SLionel Sambuc#					dest.  for M, dest is listed first,
829152e1c5SLionel Sambuc#					followed by the subdirectories in src.
839152e1c5SLionel Sambuc#					copied directories have mode 0755.
849152e1c5SLionel Sambuc#					copied files have mode 0444.
859152e1c5SLionel Sambuc#
869152e1c5SLionel Sambuc#	C	LIBS	libspec ...	as per crunchgen(1) `libs'
879152e1c5SLionel Sambuc#
889152e1c5SLionel Sambuc#	IMP	LINK	src d1 [d2 ...]	hard link src to d1, d2, ...
899152e1c5SLionel Sambuc#
909152e1c5SLionel Sambuc#	M	MTREE	arg1 [...]	output arguments `as-is' to specfile
919152e1c5SLionel Sambuc#
929152e1c5SLionel Sambuc#	CIMP	PROG	prog [links...]	program(s) to crunch/mtree/populate.
939152e1c5SLionel Sambuc#					for I, M & P, the first prog listed
949152e1c5SLionel Sambuc#					is copied from ${OBJDIR}/${CRUNCHBIN}
959152e1c5SLionel Sambuc#					and then used as the name to link
969152e1c5SLionel Sambuc#					all other PROG entries to.
979152e1c5SLionel Sambuc#
989152e1c5SLionel Sambuc#	C	SPECIAL	prog cmd ...	as per crunchgen(1) `special'
999152e1c5SLionel Sambuc#
1009152e1c5SLionel Sambuc#	C	SRCDIRS	dirname ...	as per crunchgen(1) `srcdirs'
1019152e1c5SLionel Sambuc#
1029152e1c5SLionel Sambuc#	IMP	SYMLINK src dest [...]	symlink src to dest, [...]
1039152e1c5SLionel Sambuc#
1049152e1c5SLionel Sambuc
1059152e1c5SLionel SambucBEGIN \
1069152e1c5SLionel Sambuc{
1079152e1c5SLionel Sambuc	crunchprog = "";
1089152e1c5SLionel Sambuc
1099152e1c5SLionel Sambuc	if (mode != "crunch" && mode != "install" &&
1109152e1c5SLionel Sambuc	    mode != "mtree" && mode != "populate")
1119152e1c5SLionel Sambuc		errx("Unknown parselist mode '" mode "'");
1129152e1c5SLionel Sambuc
1139152e1c5SLionel Sambuc	needvars["CRUNCHBIN"]++
1149152e1c5SLionel Sambuc	needvars["OBJDIR"]++
1159152e1c5SLionel Sambuc	if (mode == "install") {
1169152e1c5SLionel Sambuc		needvars["TARGETDIR"]++
1179152e1c5SLionel Sambuc	}
1189152e1c5SLionel Sambuc	else if (mode == "populate") {
1199152e1c5SLionel Sambuc		needvars["CURDIR"]++
1209152e1c5SLionel Sambuc	}
1219152e1c5SLionel Sambuc	for (nv in needvars) {
1229152e1c5SLionel Sambuc		if (! (nv in ENVIRON))
1239152e1c5SLionel Sambuc			errx("Environment variable " nv " not defined");
1249152e1c5SLionel Sambuc	}
1259152e1c5SLionel Sambuc
1269152e1c5SLionel Sambuc	print "#";
1279152e1c5SLionel Sambuc	print "# This file is automatically generated by";
1289152e1c5SLionel Sambuc	print "#\tparselist mode=" mode;
1299152e1c5SLionel Sambuc	print "#";
1309152e1c5SLionel Sambuc	print "";
1319152e1c5SLionel Sambuc	if (mode == "install") {
1329152e1c5SLionel Sambuc		print ".include <bsd.own.mk>"
1339152e1c5SLionel Sambuc		print "install:"
1349152e1c5SLionel Sambuc	} else if (mode == "mtree") {
1359152e1c5SLionel Sambuc		print "/unset\tall";
136*77e79d33SDavid van Moolenbroek		print "/set\ttype=file uname=root gname=wheel";
1379152e1c5SLionel Sambuc		print;
1389152e1c5SLionel Sambuc	} else if (mode == "populate") {
1399152e1c5SLionel Sambuc		print "cd " ENVIRON["CURDIR"];
1409152e1c5SLionel Sambuc		print;
1419152e1c5SLionel Sambuc	}
1429152e1c5SLionel Sambuc}
1439152e1c5SLionel Sambuc
1449152e1c5SLionel Sambuc/^$/ || /^#/ \
1459152e1c5SLionel Sambuc{
1469152e1c5SLionel Sambuc	print;
1479152e1c5SLionel Sambuc	next;
1489152e1c5SLionel Sambuc}
1499152e1c5SLionel Sambuc
1509152e1c5SLionel Sambuc#	replace ${FOO} with ENVIRON["FOO"]
1519152e1c5SLionel Sambuc#
1529152e1c5SLionel Sambuc/\$\{[A-Za-z0-9_]+\}/ \
1539152e1c5SLionel Sambuc{
1549152e1c5SLionel Sambuc	while (match($0, /\$\{[A-Za-z0-9_]+\}/) > 0) {
1559152e1c5SLionel Sambuc		v = substr($0, RSTART + 2, RLENGTH - 3);
1569152e1c5SLionel Sambuc		if (! (v in ENVIRON))
1579152e1c5SLionel Sambuc			err("Variable " v " is not in the environment");
1589152e1c5SLionel Sambuc		else
1599152e1c5SLionel Sambuc			sub(/\$\{[A-Za-z0-9_]+\}/, ENVIRON[v]);
1609152e1c5SLionel Sambuc	}
1619152e1c5SLionel Sambuc}
1629152e1c5SLionel Sambuc
1639152e1c5SLionel Sambuc$1 == "COPY" \
1649152e1c5SLionel Sambuc{
1659152e1c5SLionel Sambuc	if (NF < 3 || NF > 4)
1669152e1c5SLionel Sambuc		err("Usage: COPY src dest [perm]");
1679152e1c5SLionel Sambuc	if (mode == "install" || mode == "mtree" || mode == "populate")
1689152e1c5SLionel Sambuc		copy($2, $3, $4);
1699152e1c5SLionel Sambuc	next;
1709152e1c5SLionel Sambuc}
1719152e1c5SLionel Sambuc
1729152e1c5SLionel Sambuc$1 == "COPYDIR" \
1739152e1c5SLionel Sambuc{
1749152e1c5SLionel Sambuc	if (NF != 3)
1759152e1c5SLionel Sambuc		err("Usage: COPYDIR src dest");
1769152e1c5SLionel Sambuc	srcdir=$2;
1779152e1c5SLionel Sambuc	destdir=$3;
1789152e1c5SLionel Sambuc	if (mode == "mtree") {
1799152e1c5SLionel Sambuc		printf("./%s type=dir mode=755\n", destdir);
1809152e1c5SLionel Sambuc		command="cd " srcdir " && find . -type d -print"
1819152e1c5SLionel Sambuc		while (command | getline dir) {
1829152e1c5SLionel Sambuc			gsub(/^\.\//, "", dir);
1839152e1c5SLionel Sambuc			if (dir == ".")
1849152e1c5SLionel Sambuc				continue;
1859152e1c5SLionel Sambuc			printf("./%s/%s type=dir mode=755\n", destdir, dir);
1869152e1c5SLionel Sambuc		}
1879152e1c5SLionel Sambuc		close(command);
1889152e1c5SLionel Sambuc	}
1899152e1c5SLionel Sambuc	if (mode == "install" || mode == "mtree" || mode == "populate") {
1909152e1c5SLionel Sambuc		command="cd " srcdir " && find . -type f -print"
1919152e1c5SLionel Sambuc		while (command | getline srcfile) {
1929152e1c5SLionel Sambuc			gsub(/^\.\//, "", srcfile);
1939152e1c5SLionel Sambuc			copy(srcdir "/" srcfile, destdir "/" srcfile, "");
1949152e1c5SLionel Sambuc		}
1959152e1c5SLionel Sambuc		close(command);
1969152e1c5SLionel Sambuc	}
1979152e1c5SLionel Sambuc	next;
1989152e1c5SLionel Sambuc}
1999152e1c5SLionel Sambuc
2009152e1c5SLionel Sambuc$1 == "LIBS" || $1 == "SPECIAL" || $1 == "SRCDIRS" \
2019152e1c5SLionel Sambuc{
2029152e1c5SLionel Sambuc	if (NF < 2)
2039152e1c5SLionel Sambuc		err("Usage: " $1 " args...");
2049152e1c5SLionel Sambuc	if (mode == "crunch") {
2059152e1c5SLionel Sambuc		$1 = tolower($1);
2069152e1c5SLionel Sambuc		print;
2079152e1c5SLionel Sambuc	}
2089152e1c5SLionel Sambuc	next;
2099152e1c5SLionel Sambuc}
2109152e1c5SLionel Sambuc
2119152e1c5SLionel Sambuc$1 == "PROG" \
2129152e1c5SLionel Sambuc{
2139152e1c5SLionel Sambuc	if (NF < 2)
2149152e1c5SLionel Sambuc		err("Usage: PROG prog [link ...]");
2159152e1c5SLionel Sambuc	if (mode == "crunch") {
2169152e1c5SLionel Sambuc		prog = basename($2);
2179152e1c5SLionel Sambuc		print "progs " prog;
2189152e1c5SLionel Sambuc		for (i = 3; i <= NF; i++)
2199152e1c5SLionel Sambuc			print "ln " prog " " basename($i);
2209152e1c5SLionel Sambuc	} else {
2219152e1c5SLionel Sambuc		for (i = 2; i <= NF; i++) {
2229152e1c5SLionel Sambuc			if (crunchprog == "") {
2239152e1c5SLionel Sambuc				crunchprog = $i;
2249152e1c5SLionel Sambuc				copy(ENVIRON["OBJDIR"] "/" ENVIRON["CRUNCHBIN"],
2259152e1c5SLionel Sambuc				    crunchprog, 555);
2269152e1c5SLionel Sambuc				continue;
2279152e1c5SLionel Sambuc			}
2289152e1c5SLionel Sambuc			link(crunchprog, $i, 555);
2299152e1c5SLionel Sambuc		}
2309152e1c5SLionel Sambuc	}
2319152e1c5SLionel Sambuc	next;
2329152e1c5SLionel Sambuc}
2339152e1c5SLionel Sambuc
2349152e1c5SLionel Sambuc$1 == "ARGVLN" \
2359152e1c5SLionel Sambuc{
2369152e1c5SLionel Sambuc	if (NF != 3)
2379152e1c5SLionel Sambuc		err("Usage: ARGVLN prog link");
2389152e1c5SLionel Sambuc	if (mode == "crunch") {
2399152e1c5SLionel Sambuc		$1 = "ln";
2409152e1c5SLionel Sambuc		print;
2419152e1c5SLionel Sambuc	}
2429152e1c5SLionel Sambuc	next;
2439152e1c5SLionel Sambuc}
2449152e1c5SLionel Sambuc
2459152e1c5SLionel Sambuc$1 == "LINK" \
2469152e1c5SLionel Sambuc{
2479152e1c5SLionel Sambuc	if (NF < 3)
2489152e1c5SLionel Sambuc		err("Usage: LINK prog link [...]");
2499152e1c5SLionel Sambuc	if (mode == "install" || mode == "mtree" || mode == "populate") {
2509152e1c5SLionel Sambuc		for (i = 3; i <= NF; i++)
2519152e1c5SLionel Sambuc			link($2, $i, 444);
2529152e1c5SLionel Sambuc	}
2539152e1c5SLionel Sambuc	next;
2549152e1c5SLionel Sambuc}
2559152e1c5SLionel Sambuc
2569152e1c5SLionel Sambuc$1 == "SYMLINK" \
2579152e1c5SLionel Sambuc{
2589152e1c5SLionel Sambuc	if (NF < 3)
2599152e1c5SLionel Sambuc		err("Usage: SYMLINK prog link [...]");
2609152e1c5SLionel Sambuc	if (mode == "install" || mode == "mtree" || mode == "populate") {
2619152e1c5SLionel Sambuc		for (i = 3; i <= NF; i++)
2629152e1c5SLionel Sambuc			symlink($2, $i);
2639152e1c5SLionel Sambuc	}
2649152e1c5SLionel Sambuc	next;
2659152e1c5SLionel Sambuc}
2669152e1c5SLionel Sambuc
2679152e1c5SLionel Sambuc$1 == "CMD" \
2689152e1c5SLionel Sambuc{
2699152e1c5SLionel Sambuc	if (NF < 2)
2709152e1c5SLionel Sambuc		err("Usage: CMD ...");
2719152e1c5SLionel Sambuc	if (mode == "populate") {
2729152e1c5SLionel Sambuc		printf("(cd %s;", ENVIRON["TARGETDIR"]);
2739152e1c5SLionel Sambuc		for (i = 2; i <= NF; i++)
2749152e1c5SLionel Sambuc			printf(" %s", $i);
2759152e1c5SLionel Sambuc		print ") || exit 1";
2769152e1c5SLionel Sambuc	}
2779152e1c5SLionel Sambuc	next;
2789152e1c5SLionel Sambuc}
2799152e1c5SLionel Sambuc
2809152e1c5SLionel Sambuc$1 == "MTREE" \
2819152e1c5SLionel Sambuc{
2829152e1c5SLionel Sambuc	if (NF < 2)
2839152e1c5SLionel Sambuc		err("Usage: MTREE ...");
2849152e1c5SLionel Sambuc	if (mode == "mtree") {
2859152e1c5SLionel Sambuc		sub(/^[^ \t]+[ \t]+/, "");	# strip first word ("MTREE")
2869152e1c5SLionel Sambuc		print;
2879152e1c5SLionel Sambuc	}
2889152e1c5SLionel Sambuc	next;
2899152e1c5SLionel Sambuc}
2909152e1c5SLionel Sambuc
2919152e1c5SLionel Sambuc
2929152e1c5SLionel Sambuc{
2939152e1c5SLionel Sambuc	err("Unknown keyword '" $1 "'");
2949152e1c5SLionel Sambuc}
2959152e1c5SLionel Sambuc
2969152e1c5SLionel Sambuc
2979152e1c5SLionel Sambucfunction basename (file) \
2989152e1c5SLionel Sambuc{
2999152e1c5SLionel Sambuc	gsub(/[^\/]+\//, "", file);
3009152e1c5SLionel Sambuc	return file;
3019152e1c5SLionel Sambuc}
3029152e1c5SLionel Sambuc
3039152e1c5SLionel Sambucfunction copy (src, dest, perm) \
3049152e1c5SLionel Sambuc{
3059152e1c5SLionel Sambuc	if (perm == "")
3069152e1c5SLionel Sambuc		perm = 444;
3079152e1c5SLionel Sambuc	if (mode == "install") {
3089152e1c5SLionel Sambuc		printf("\t${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP}" \
3099152e1c5SLionel Sambuc		    " -m %s %s %s/%s\n",
3109152e1c5SLionel Sambuc		    perm, src, ENVIRON["TARGETDIR"], dest)
3119152e1c5SLionel Sambuc	} else if (mode == "mtree") {
3129152e1c5SLionel Sambuc		printf("./%s mode=%s\n", dest, perm);
3139152e1c5SLionel Sambuc	} else {
3149152e1c5SLionel Sambuc		printf("rm -rf %s/%s\n", ENVIRON["TARGETDIR"], dest);
3159152e1c5SLionel Sambuc		printf("cp %s %s/%s\n", src, ENVIRON["TARGETDIR"], dest);
3169152e1c5SLionel Sambuc		printf("chmod %s %s/%s\n", perm, ENVIRON["TARGETDIR"], dest);
3179152e1c5SLionel Sambuc	}
3189152e1c5SLionel Sambuc}
3199152e1c5SLionel Sambuc
3209152e1c5SLionel Sambucfunction link (src, dest, perm) \
3219152e1c5SLionel Sambuc{
3229152e1c5SLionel Sambuc	if (mode == "install") {
3239152e1c5SLionel Sambuc		printf("\t${INSTALL_LINK} -o ${BINOWN} -g ${BINGRP}" \
3249152e1c5SLionel Sambuc		    " -m %s %s/%s %s/%s\n",
3259152e1c5SLionel Sambuc		    perm, ENVIRON["TARGETDIR"], src, ENVIRON["TARGETDIR"], dest)
3269152e1c5SLionel Sambuc	} else if (mode == "mtree") {
3279152e1c5SLionel Sambuc		printf("./%s mode=%s\n", dest, perm);
3289152e1c5SLionel Sambuc	} else {
3299152e1c5SLionel Sambuc		printf("rm -rf %s/%s\n", ENVIRON["TARGETDIR"], dest);
3309152e1c5SLionel Sambuc		printf("(cd %s; ln %s %s) || exit 1\n",
3319152e1c5SLionel Sambuc		    ENVIRON["TARGETDIR"], src, dest);
3329152e1c5SLionel Sambuc	}
3339152e1c5SLionel Sambuc}
3349152e1c5SLionel Sambuc
3359152e1c5SLionel Sambucfunction symlink (src, dest) \
3369152e1c5SLionel Sambuc{
3379152e1c5SLionel Sambuc	if (mode == "install") {
3389152e1c5SLionel Sambuc		printf("\t${INSTALL_SYMLINK} %s/%s %s/%s\n",
3399152e1c5SLionel Sambuc		    ENVIRON["TARGETDIR"], src, ENVIRON["TARGETDIR"], dest)
3409152e1c5SLionel Sambuc	} else if (mode == "mtree") {
3419152e1c5SLionel Sambuc		printf("./%s type=link link=%s\n", dest, src);
3429152e1c5SLionel Sambuc	} else {
3439152e1c5SLionel Sambuc		printf("rm -rf %s/%s\n", ENVIRON["TARGETDIR"], dest);
3449152e1c5SLionel Sambuc		printf("(cd %s; ln -s %s %s) || exit 1\n",
3459152e1c5SLionel Sambuc		    ENVIRON["TARGETDIR"], src, dest);
3469152e1c5SLionel Sambuc	}
3479152e1c5SLionel Sambuc}
3489152e1c5SLionel Sambuc
3499152e1c5SLionel Sambucfunction err(msg) \
3509152e1c5SLionel Sambuc{
3519152e1c5SLionel Sambuc	printf("parselist: %s at line %d of input.\n", msg, NR) >"/dev/stderr";
3529152e1c5SLionel Sambuc	exit 1;
3539152e1c5SLionel Sambuc}
3549152e1c5SLionel Sambuc
3559152e1c5SLionel Sambucfunction errx(msg) \
3569152e1c5SLionel Sambuc{
3579152e1c5SLionel Sambuc	printf("parselist: %s.\n", msg) >"/dev/stderr";
3589152e1c5SLionel Sambuc	exit 1;
3599152e1c5SLionel Sambuc}
360