Annotation of gcc/fixincludes, revision 1.1.1.12

1.1.1.2   root        1: #! /bin/sh
1.1       root        2: # Install modified versions of certain ANSI-incompatible system header files
                      3: # which are fixed to work correctly with ANSI C
                      4: # and placed in a directory that GNU C will search.
                      5: # This works properly on a Sun in system version 3.4;
                      6: # for other versions, you had better check.
                      7: 
1.1.1.3   root        8: # Directory in which to store the results.
1.1.1.11  root        9: LIB=${LIB-/usr/local/lib/gcc-include}
                     10: 
                     11: # Make sure it exists.
1.1.1.12! root       12: if [ ! -d $LIB ]; then
        !            13:   mkdir $LIB || exit 1
        !            14: fi
1.1.1.3   root       15: 
1.1.1.10  root       16: # Determine whether this system has symbolic links.
                     17: if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
                     18:   rm -f $LIB/ShouldNotExist
                     19:   LINKS=true
                     20: else
                     21:   LINKS=false
                     22: fi
                     23: 
1.1.1.9   root       24: echo 'Making directories:'
                     25: cd /usr/include
1.1.1.10  root       26: if $LINKS; then
                     27:   files=`ls -LR | sed -n s/:$//p`
                     28: else
1.1.1.12! root       29:   files=`find . -type d -print | sed '/^.$/d'`
1.1.1.10  root       30: fi
1.1.1.9   root       31: for file in $files; do
1.1.1.12! root       32:   rm -rf $LIB/$file
        !            33:   if [ ! -d $LIB/$file ]
        !            34:   then mkdir $LIB/$file
        !            35:   fi
1.1.1.9   root       36: done
1.1.1.6   root       37: 
1.1.1.10  root       38: # treetops gets an alternating list
                     39: # of old directories to copy
                     40: # and the new directories to copy to.
                     41: treetops="/usr/include ${LIB}"
                     42: 
                     43: if $LINKS; then
                     44:   echo 'Making internal symbolic directory links'
                     45:   for file in $files; do
                     46:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                     47:     if [ "$dest" ]; then    
1.1.1.12! root       48:       cwd=`pwd`
        !            49:       # In case $dest is relative, get to $file's dir first.
        !            50:       cd /usr/include
        !            51:       cd `echo ./$file | sed -n 's&[^/]*$&&p'`
        !            52:       # Check that the target directory exists.
        !            53:       # Redirections changed to avoid bug in sh on Ultrix.
        !            54:       (cd $dest) > /dev/null 2>&1
        !            55:       if [ $? = 0 ]; then
        !            56:        cd $dest
        !            57:        # X gets the dir that the link actually leads to.
        !            58:        x=`pwd`
        !            59:        # If link leads back into /usr/include,
        !            60:        # make a similar link here.
        !            61:        if expr $x : '/usr/include/.*' > /dev/null; then
        !            62:          # Y gets the actual target dir name, relative to /usr/include.
        !            63:          y=`echo $x | sed -n 's&/usr/include/&&p'`
        !            64:          echo $file '->' $y ': Making link'
        !            65:          rm -fr ${LIB}/$file > /dev/null 2>&1
        !            66:          ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
        !            67:        else
        !            68:          # If the link is to outside /usr/include,
        !            69:          # treat this directory as if it actually contained the files.
        !            70: # This line used to have $dest instead of $x.
        !            71: # $dest seemed to be wrong for links found in subdirectories
        !            72: # of /usr/include.  Does this change break anything?
        !            73:          treetops="$treetops $x ${LIB}/$file"
        !            74:        fi
1.1.1.10  root       75:       fi
1.1.1.12! root       76:       cd $cwd
1.1.1.10  root       77:     fi
                     78:   done
                     79: fi
                     80: 
                     81: set - $treetops
                     82: while [ $# != 0 ]; do
                     83:   # $1 is an old directory to copy, and $2 is the new directory to copy to.
1.1.1.11  root       84:   echo "Finding header files in $1:"
                     85:   cd /usr/include
1.1.1.10  root       86:   cd $1
1.1.1.12! root       87:   files=`find . -name '*.h' -type f -print`
1.1.1.10  root       88:   echo 'Checking header files:'
                     89:   for file in $files; do
1.1.1.11  root       90:     if egrep '[        ]_IO[A-Z]*\(|#define._IO|CTRL' $file > /dev/null; then
1.1.1.10  root       91:       echo Fixing $file
                     92:       if [ -r $file ]; then
                     93:        cp $file $2/$file >/dev/null 2>&1       \
                     94:        || echo "Can't copy $file"
                     95:        chmod +w $2/$file
1.1.1.11  root       96:        sed -e '
                     97:                                   :loop
                     98:          /\\$/                 N
                     99:          /\\$/                 b loop
1.1.1.12! root      100:          /[    ]_IO[A-Z]*[     ]*(/    s/(\(.\),/('\''\1'\'',/
1.1.1.11  root      101:          /#define._IO/         s/'\''x'\''/x/g
1.1.1.12! root      102:          /[^A-Z]CTRL[  ]*(/    s/\([^'\'']\))/'\''\1'\'')/
1.1.1.11  root      103:          /#define.CTRL/                s/'\''c'\''/c/g
1.1.1.12! root      104:          /#define._CTRL/               s/'\''c'\''/c/g
1.1.1.11  root      105:        ' $2/$file > $2/$file.sed
                    106:        mv $2/$file.sed $2/$file
1.1.1.10  root      107:        if cmp $file $2/$file >/dev/null 2>&1; then
                    108:           echo Deleting $2/$file\; no fixes were needed.
                    109:           rm $2/$file
                    110:        fi
1.1.1.8   root      111:       fi
1.1.1.5   root      112:     fi
1.1.1.10  root      113:   done
                    114:   shift; shift
1.1.1.2   root      115: done
                    116: 
1.1.1.11  root      117: cd /usr/include
                    118: 
1.1.1.5   root      119: # Fix one other error in this file: a mismatched quote not inside a C comment.
                    120: file=sundev/vuid_event.h
                    121: if [ -r $file ]; then
                    122:   if [ ! -r ${LIB}/$file ]; then
                    123:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    124:     || echo "Can't copy $file"
1.1.1.3   root      125:     chmod +w ${LIB}/$file
1.1.1.2   root      126:   fi
1.1.1.5   root      127: fi
1.1.1.4   root      128: 
1.1.1.12! root      129: if [ -r ${LIB}/$file ]; then
        !           130:   echo Fixing $file comment
        !           131:   ex ${LIB}/$file <<EOF
1.1.1.11  root      132:   g/doesn't/s/doesn't/does not/
                    133:   wq
                    134: EOF
1.1.1.12! root      135:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
        !           136:     echo Deleting ${LIB}/$file\; no fixes were needed.
        !           137:     rm ${LIB}/$file
        !           138:   fi
        !           139: fi
        !           140: 
        !           141: # Fix an error in this file: a missing semi-colon at the end of the statsswtch
        !           142: # structure definition.
        !           143: file=rpcsvc/rstat.h
        !           144: if [ -r $file ]; then
        !           145:   if [ ! -r ${LIB}/$file ]; then
        !           146:     cp $file ${LIB}/$file >/dev/null 2>&1      \
        !           147:     || echo "Can't copy $file"
        !           148:     chmod +w ${LIB}/$file
        !           149:   fi
        !           150: fi
        !           151: 
        !           152: if [ -r ${LIB}/$file ]; then
        !           153:   echo Fixing $file, definition of statsswtch
        !           154:   ex ${LIB}/$file <<EOF
        !           155:   g/boottime$/s//&;/
        !           156:   wq
        !           157: EOF
        !           158:   if cmp $file $2/$file >/dev/null 2>&1; then
        !           159:     echo Deleting $2/$file\; no fixes were needed.
        !           160:     rm $2/$file
        !           161:   fi
1.1.1.11  root      162: fi
                    163: 
                    164: # Deal with yet another challenge, this in X11/Xmu.h
                    165: file=X11/Xmu.h
                    166: if [ -r $file ]; then
                    167:   if [ ! -r ${LIB}/$file ]; then
                    168:     mkdir ${LIB}/X11 2>&-
                    169:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                    170:     || echo "Can't copy $file"
                    171:     chmod +w ${LIB}/$file
                    172:   fi
                    173: fi
                    174: 
                    175: if [ -r ${LIB}/$file ]; then
                    176:   echo Fixing $file sprintf declaration
                    177:   ex ${LIB}/$file <<EOF
                    178:   /^extern char \*     sprintf();$/c
                    179: #ifndef __STDC__
                    180: extern char *  sprintf();
                    181: #endif /* !defined __STDC__ */
                    182: .
1.1.1.5   root      183:   wq
1.1       root      184: EOF
1.1.1.12! root      185:   if cmp $file ${LIB}/$file >/dev/null 2>&1; then
        !           186:     echo Deleting ${LIB}/$file\; no fixes were needed.
        !           187:     rm ${LIB}/$file
        !           188:   fi
        !           189: fi
        !           190: 
        !           191: # Check for missing ';' in struct
        !           192: 
        !           193: file=netinet/ip.h
        !           194: if [ -r $file ]; then
        !           195:   if [ ! -r ${LIB}/$file ]; then
        !           196:     mkdir ${LIB}/netinet 2>&-
        !           197:     sed -e '/^struct/,/^};/s/}$/};/' $file > ${LIB}/$file
        !           198:     cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
        !           199:   fi
        !           200: fi
        !           201: 
        !           202: # Fix the CAT macro in memvar.h.
        !           203: 
        !           204: file=pixrect/memvar.h
        !           205: if [ -r $file ]; then
        !           206:   if [ ! -r ${LIB}/$file ]; then
        !           207:     mkdir ${LIB}/pixrect 2>&-
        !           208:     sed -e '/^#define.CAT(a,b)/ s/IDENT(a)b/a##b/g' $file > ${LIB}/$file
        !           209:     cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
        !           210:   fi
        !           211: fi
        !           212: 
        !           213: # Check for yet more missing ';' in struct (in SunOS 4.0.x)
        !           214: 
        !           215: file=rpcsvc/rusers.h
        !           216: if [ -r $file ]; then
        !           217:   if [ ! -r ${LIB}/$file ]; then
        !           218:     mkdir ${LIB}/rpcsvc 2>&-
        !           219:     sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' $file > ${LIB}/$file
        !           220:     cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
        !           221:   fi
        !           222: fi
        !           223: 
        !           224: # Check for yet more missing ';' in struct (in SunOS 4.0.x)
        !           225: 
        !           226: file=rpcsvc/rusers.h
        !           227: if [ -r $file ]; then
        !           228:   if [ ! -r ${LIB}/$file ]; then
        !           229:     mkdir ${LIB}/rpcsvc 2>&-
        !           230:     sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' $file > ${LIB}/$file
        !           231:     cmp $file ${LIB}/$file >&- && rm -f ${LIB}/$file
        !           232:   fi
1.1.1.8   root      233: fi
1.1.1.10  root      234: 
                    235: echo 'Removing unneeded directories:'
                    236: cd $LIB
                    237: files=`find . -type d -print | sort -r`
                    238: for file in $files; do
                    239:   rmdir $LIB/$file > /dev/null 2>&1
                    240: done
                    241: 
1.1.1.11  root      242: if $LINKS; then
                    243:   echo 'Making internal symbolic non-directory links'
                    244:   cd /usr/include
                    245:   files=`find . -type l -print`
                    246:   for file in $files; do
                    247:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                    248:     if expr "$dest" : '[^/].*' > /dev/null; then    
                    249:       target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
                    250:       if [ -f $target ]; then
                    251:         ln -s $dest ${LIB}/$file >/dev/null 2>&1
                    252:       fi
                    253:     fi
                    254:   done
                    255: fi
                    256: 
                    257: exit 0

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.