source: trunk/third/gcc/fixcpp @ 8834

Revision 8834, 2.3 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r8833, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# NAME:
4#       fixcpp - fix CPP errors
5#
6# SYNOPSIS:
7#       fixcpp [-c][-p patch_file][-b bak_dir][-n new_dir] files(s)
8#
9# DESCRIPTION:
10#       For each named file, use sed(1) to fixup any descriptive
11#       text after #else or #endif or that is not properly
12#       commented as this causes ANSI compilers to generate
13#       unnecessary warnings.
14#
15#       Naturally this script is not guaranteed to be bullet
16#       proof, use of -n or -b is advisable!
17#
18#       -c causes fixcpp to make sure that only files that
19#       needed changing are affected by returning the original
20#       file to its original location if no changes were needed.
21#
22#       -p causes fixcpp to append to a patch file the context
23#       diffs of the changes wrought.
24#
25# SEE ALSO:
26#       sed(1)
27#
28# AMENDED:
29#       90/08/08 22:46:32 (sjg)
30#
31# RELEASED:
32#       90/08/08 22:46:34 v1.4
33#
34# SCCSID:
35#       @(#)fixcpp.sh 1.4 90/08/08 22:46:32 (sjg)
36#
37#       @(#)Copyright (c) 1990 Simon J. Gerraty
38#
39#       This is free software.  It comes with NO WARRANTY.
40#       Everyone is granted permission to copy, modify and
41#       redistribute this source code provided that all
42#       recipients are given similar rights, and that the above
43#       copyright notice and this notice are preserved in all
44#       copies.
45
46TMPF=/tmp/fixcpp.$$
47NEWDIR=
48BAKDIR=
49PATCHF=
50CHECK=
51
52set -- `getopt "cp:b:n:" $*`
53if [ $? != 0 ]; then
54        echo "$0 [-c][-p patch_file][-b bakup_dir][-n new_dir] file [file ...]" >&2
55        exit 1
56fi
57for i in $*
58do
59        case $i in
60        -c)     CHECK=yes; shift;;
61        -p)     PATCHF=$2; shift 2;;
62        -b)     BAKDIR=$2; shift 2;;
63        -n)     NEWDIR=$2; shift 2;;
64        --)     shift; break;;
65        esac
66done
67NEWDIR=${NEWDIR:-.}
68if [ $BAKDIR ]; then
69        if [ ! -d $BAKDIR ]; then
70                echo "$0: no such directory -- $BAKDIR" >&2
71                exit 1
72        fi
73fi
74
75
76
77for i in $*
78do
79        if [ $BAKDIR ]; then
80                mv $i $BAKDIR
81                infile=$BAKDIR/$i
82        else
83                if [ "$NEWDIR" = "." ]; then
84                        mv $i ${TMPF}
85                        infile=${TMPF}
86                else
87                        infile=$i
88                fi
89        fi     
90        sed -e 's;^#\([         ]*e[nl][^       ]*[     ][      ]*\)\([^/       ][^\*].*\);#\1/* \2 */;' -e 's;^#\([    ]*e[nl][^       ]*[     ][      ]*\)\([^/       ]\)$;#\1/* \2 */;' $infile >${NEWDIR}/$i
91        if [ "${CHECK}" = "yes" -o ${PATCHF} ]; then
92                if cmp -s $infile ${NEWDIR}/$i ; then
93                        if [ "${CHECK}" = "yes" ]; then
94                                if [ $BAKDIR ]; then
95                                        mv $infile ${NEWDIR}/$i
96                                else
97                                        rm ${NEWDIR}/$i
98                                fi
99                        fi
100                else
101                        if [ $PATCHF ]; then
102                                diff -c $infile ${NEWDIR}/$i >> ${PATCHF}
103                        fi
104                fi
105        fi
106
107done
108
109rm -f ${TMPF}
Note: See TracBrowser for help on using the repository browser.