Files
2024-02-19 00:24:47 -05:00

53 lines
1.5 KiB
Bash

#!/bin/sh
# Copyright (C) 1992 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public License
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# You should have received a copy of the GNU Library General Public
# License along with the GNU C Library; see the file COPYING.LIB. If
# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
# Cambridge, MA 02139, USA.
if [ $# -ne 2 -a "$1" != -m4 ]; then
echo "Usage: $0 [-ansi | -trad] FILE" >&2
exit 1
fi
case "$1" in
-ansi) macro=ansi ;;
-trad) macro=trad ;;
-m4) ansidecl=$2; macro=$3; shift; shift ;;
*) echo "Usage: $0 [-ansi | -trad] FILE" >&2; exit 1 ;;
esac
file="$2"
if [ "$ansidecl" ]; then
: Nothing.
elif [ -r ansidecl.m4 ]; then
ansidecl=ansidecl.m4
elif [ -r ../ansidecl.m4 ]; then
ansidecl=../ansidecl.m4
else
echo "$0: Can't find ansidecl.m4 in . or .." >&2
exit 1
fi
# Tell GNU m4 to shut up.
M4OPTS=+quiet
export M4OPTS
( echo "define(${macro},1)"; cat $ansidecl; cat "$file" ) |
m4 | awk 'BEGIN { beginning = 1; }
/^$/ { if (!beginning) printf "\n"; }
/./ { beginning = 0; print $0; }'