Annotation of gcc/fixincludes, revision 1.1.1.11

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.
        !            12: mkdir $LIB > /dev/null 2>&1
1.1.1.3   root       13: 
1.1.1.10  root       14: # Determine whether this system has symbolic links.
                     15: if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
                     16:   rm -f $LIB/ShouldNotExist
                     17:   LINKS=true
                     18: else
                     19:   LINKS=false
                     20: fi
                     21: 
1.1.1.9   root       22: echo 'Making directories:'
                     23: cd /usr/include
1.1.1.10  root       24: if $LINKS; then
                     25:   files=`ls -LR | sed -n s/:$//p`
                     26: else
                     27:   files=`find . -type d -print`
                     28: fi
1.1.1.9   root       29: for file in $files; do
                     30:   mkdir $LIB/$file > /dev/null 2>&1
                     31: done
1.1.1.6   root       32: 
1.1.1.10  root       33: # treetops gets an alternating list
                     34: # of old directories to copy
                     35: # and the new directories to copy to.
                     36: treetops="/usr/include ${LIB}"
                     37: 
                     38: if $LINKS; then
                     39:   echo 'Making internal symbolic directory links'
                     40:   for file in $files; do
                     41:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
                     42:     if [ "$dest" ]; then    
1.1.1.11! root       43:       if expr $dest : '[^/.].*' > /dev/null; then
1.1.1.10  root       44:        rmdir ${LIB}/$file > /dev/null 2>&1
                     45:        rm -f ${LIB}/$file > /dev/null 2>&1
                     46:        ln -s $dest ${LIB}/$file > /dev/null 2>&1
                     47:       else                             # dont make links outside /usr/include
                     48:        treetops="$treetops $dest ${LIB}/$file"
                     49:       fi
                     50:     fi
                     51:   done
                     52: fi
                     53: 
                     54: set - $treetops
                     55: while [ $# != 0 ]; do
                     56:   # $1 is an old directory to copy, and $2 is the new directory to copy to.
1.1.1.11! root       57:   echo "Finding header files in $1:"
        !            58:   cd /usr/include
1.1.1.10  root       59:   cd $1
                     60:   files=`find . -type f -print`
                     61:   echo 'Checking header files:'
                     62:   for file in $files; do
1.1.1.11! root       63:     if egrep '[        ]_IO[A-Z]*\(|#define._IO|CTRL' $file > /dev/null; then
1.1.1.10  root       64:       echo Fixing $file
                     65:       if [ -r $file ]; then
                     66:        cp $file $2/$file >/dev/null 2>&1       \
                     67:        || echo "Can't copy $file"
                     68:        chmod +w $2/$file
1.1.1.11! root       69:        sed -e '
        !            70:                                   :loop
        !            71:          /\\$/                 N
        !            72:          /\\$/                 b loop
        !            73:          /[    ]_IO[A-Z]*(/    s/(\(.\),/('\''\1'\'',/
        !            74:          /#define._IO/         s/'\''x'\''/x/g
        !            75:          /[^A-Z]CTRL[  ]*(/    s/\(.\))/'\''\1'\'')/
        !            76:          /#define.CTRL/                s/'\''c'\''/c/g
        !            77:        ' $2/$file > $2/$file.sed
        !            78:        mv $2/$file.sed $2/$file
1.1.1.10  root       79:        if cmp $file $2/$file >/dev/null 2>&1; then
                     80:           echo Deleting $2/$file\; no fixes were needed.
                     81:           rm $2/$file
                     82:        fi
1.1.1.8   root       83:       fi
1.1.1.5   root       84:     fi
1.1.1.10  root       85:   done
                     86:   shift; shift
1.1.1.2   root       87: done
                     88: 
1.1.1.11! root       89: cd /usr/include
        !            90: 
1.1.1.5   root       91: # Fix one other error in this file: a mismatched quote not inside a C comment.
                     92: file=sundev/vuid_event.h
                     93: if [ -r $file ]; then
                     94:   if [ ! -r ${LIB}/$file ]; then
                     95:     cp $file ${LIB}/$file >/dev/null 2>&1      \
                     96:     || echo "Can't copy $file"
1.1.1.3   root       97:     chmod +w ${LIB}/$file
1.1.1.2   root       98:   fi
1.1.1.5   root       99: fi
1.1.1.4   root      100: 
1.1.1.5   root      101: if [ -r ${LIB}/sundev/vuid_event.h ]; then
                    102:   echo Fixing sundev/vuid_event.h comment
                    103:   ex ${LIB}/sundev/vuid_event.h <<EOF
1.1.1.11! root      104:   g/doesn't/s/doesn't/does not/
        !           105:   wq
        !           106: EOF
        !           107: fi
        !           108: 
        !           109: # Deal with yet another challenge, this in X11/Xmu.h
        !           110: file=X11/Xmu.h
        !           111: if [ -r $file ]; then
        !           112:   if [ ! -r ${LIB}/$file ]; then
        !           113:     mkdir ${LIB}/X11 2>&-
        !           114:     cp $file ${LIB}/$file >/dev/null 2>&1      \
        !           115:     || echo "Can't copy $file"
        !           116:     chmod +w ${LIB}/$file
        !           117:   fi
        !           118: fi
        !           119: 
        !           120: if [ -r ${LIB}/$file ]; then
        !           121:   echo Fixing $file sprintf declaration
        !           122:   ex ${LIB}/$file <<EOF
        !           123:   /^extern char \*     sprintf();$/c
        !           124: #ifndef __STDC__
        !           125: extern char *  sprintf();
        !           126: #endif /* !defined __STDC__ */
        !           127: .
1.1.1.5   root      128:   wq
1.1       root      129: EOF
1.1.1.8   root      130: fi
1.1.1.10  root      131: 
                    132: echo 'Removing unneeded directories:'
                    133: cd $LIB
                    134: files=`find . -type d -print | sort -r`
                    135: for file in $files; do
                    136:   rmdir $LIB/$file > /dev/null 2>&1
                    137: done
                    138: 
1.1.1.11! root      139: if $LINKS; then
        !           140:   echo 'Making internal symbolic non-directory links'
        !           141:   cd /usr/include
        !           142:   files=`find . -type l -print`
        !           143:   for file in $files; do
        !           144:     dest=`ls -ld $file | sed -n 's/.*-> //p'`
        !           145:     if expr "$dest" : '[^/].*' > /dev/null; then    
        !           146:       target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
        !           147:       if [ -f $target ]; then
        !           148:         ln -s $dest ${LIB}/$file >/dev/null 2>&1
        !           149:       fi
        !           150:     fi
        !           151:   done
        !           152: fi
        !           153: 
        !           154: exit 0

unix.superglobalmegacorp.com

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