🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99521

fixcpp.sh fix CPP garbage (not a bug)

#99521
From: Simon J. Gerraty
Date: Thu, 09 Aug 1990 06:28
139 lines
4481 bytes
As the subject says, its not really a bug, but those warnings
produced by ANSI compilers (such as GCC) about garbage after
pre-processor directives can make it painful trying to find the
real errors.

I actually wrote the following script while trying to build
GATED on a new System V system that only has an ANSI compiler.
It was imposssible to find the errors due to all the warnings.
This script was also useful when porting Emacs to the same
system.

I think it would be very nice if the official Emacs distubution
were run though this thing, so that ANSI'ish compilers just did
their job and otherwise kept quiet.  A total of 23 files in the
dist-18.55/src dir were affected.

So, no guarantees, but fixcpp.sh is offered for use, and for
disstribution with GCC.

#!/bin/sh
# This is a shell archive.  Remove anything before this line.
# Unpack it by saving it in a file and typing "sh file".
#
sed 's/^X//' > fixcpp <<\!!!EOF!!!
X#!/bin/sh
X#
X# NAME:
X#	fixcpp - fix CPP errors
X#
X# SYNOPSIS:
X#	fixcpp [-c][-p patch_file][-b bak_dir][-n new_dir] files(s)
X#
X# DESCRIPTION:
X#	For each named file, use sed(1) to fixup any descriptive
X#	text after #else or #endif or that is not properly
X#	commented as this causes ANSI compilers to generate
X#	unnecessary warnings.
X#
X#	Naturally this script is not guaranteed to be bullit
X#	proof, use of -n or -b is advisable!
X#
X#	-c causes fixcpp to make sure that only files that
X#	needed changing are affected by returning the original
X#	file to its original location if no changes were needed.
X#
X#	-p causes fixcpp to append to a patch file the context
X#	diffs of the changes wraught.
X#
X# SEE ALSO:
X#	sed(1)
X#
X# AMENDED:
X#	90/08/08 22:46:32 (sjg)
X#
X# RELEASED:
X#	90/08/08 22:46:34 v1.4
X#
X# SCCSID:
X#	@(#)fixcpp.sh 1.4 90/08/08 22:46:32 (sjg)
X#
X#	@(#)Copyright (c) 1990 Simon J. Gerraty
X#
X#       This is free software.  It comes with NO WARRANTY.
X#       Everyone is granted permission to copy, modify and
X#       redistribute this source code provided that all
X#       recipients are given similar rights, and that the above
X#       copyright notice and this notice are preserved in all
X#       copies. 
X
XTMPF=/tmp/fixcpp.$$
XNEWDIR=
XBAKDIR=
XPATCHF=
XCHECK=
X
Xset -- `getopt "cp:b:n:" $*`
Xif [ $? != 0 ]; then
X	echo "$0 [-c][-p patch_file][-b bakup_dir][-n new_dir] file [file ...]" >&2
X	exit 1
Xfi
Xfor i in $*
Xdo
X	case $i in
X	-c)	CHECK=yes; shift;;
X	-p)	PATCHF=$2; shift 2;;
X	-b)	BAKDIR=$2; shift 2;;
X	-n)	NEWDIR=$2; shift 2;;
X	--)	shift; break;;
X	esac
Xdone
XNEWDIR=${NEWDIR:-.}
Xif [ $BAKDIR ]; then
X	if [ ! -d $BAKDIR ]; then
X		echo "$0: no such directory -- $BAKDIR" >&2
X		exit 1
X	fi
Xfi
X
X
X
Xfor i in $*
Xdo
X	if [ $BAKDIR ]; then
X		mv $i $BAKDIR
X		infile=$BAKDIR/$i
X	else
X		if [ "$NEWDIR" = "." ]; then
X			mv $i ${TMPF}
X			infile=${TMPF}
X		else
X			infile=$i
X		fi
X	fi	
X	sed -e 's;^#\([ 	]*e[nl][^ 	]*[ 	][ 	]*\)\([^/ 	][^\*].*\);#\1/* \2 */;' -e 's;^#\([ 	]*e[nl][^ 	]*[ 	][ 	]*\)\([^/ 	]\)$;#\1/* \2 */;' $infile >${NEWDIR}/$i
X	if [ "${CHECK}" = "yes" -o ${PATCHF} ]; then
X		if cmp -s $infile ${NEWDIR}/$i ; then
X			if [ "${CHECK}" = "yes" ]; then
X				if [ $BAKDIR ]; then
X					mv $infile ${NEWDIR}/$i
X				else
X					rm ${NEWDIR}/$i
X				fi
X			fi
X		else
X			if [ $PATCHF ]; then
X				diff -c $infile ${NEWDIR}/$i >> ${PATCHF}
X			fi
X		fi
X	fi
X
Xdone
X
Xrm -f ${TMPF}
!!!EOF!!!
# End of archive
--
Simon J. Gerraty			<sjg@sun0.melb.bull.oz.au>

#include <disclaimer>             /* imagine something *very* witty here */
Technical Details
Message-ID: <1990Aug9.062820.13669@melb.bull.oz.au>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!sunic!uupsi!rpi!zaphod.mps.ohio-state.edu!usc!hacgate!ladcgw.ladc.bull.com!melb.bull.oz.au!sun0!sjg

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,5d5df09759a86ff2,start
X-Google-Attributes: gid113d02,public
X-Google-Thread: fb2f1,5d5df09759a86ff2,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-08-09 16:28:46 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!sunic!uupsi!rpi!zaphod.mps.ohio-state.edu!usc!hacgate!ladcgw.ladc.bull.com!melb.bull.oz.au!sun0!sjg
From: sjg@sun0.melb.bull.oz.au (Simon J. Gerraty)
Newsgroups: gnu.emacs.bug,gnu.gcc.bug
Subject: fixcpp.sh fix CPP garbage (not a bug)
Summary: ensure text after #endif #else etc is quoted
Message-ID: <1990Aug9.062820.13669@melb.bull.oz.au>
Date: 9 Aug 90 06:28:20 GMT
Sender: news@melb.bull.oz.au
Organization: Bull HN Information Systems Australia
Lines: 139
Posted: Thu Aug  9 07:28:20 1990