home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume27 / unproto / part02 / cpp.sh next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1992-01-17  |  823 b   |  36 lines

  1. #!/bin/sh
  2.  
  3. # @(#) cpp.sh 1.3 92/01/15 21:53:22
  4.  
  5. # Unprototypeing preprocessor for pre-ANSI C compilers.  On some systems,
  6. # this script can be as simple as:
  7. #
  8. #    /lib/cpp "$@" | unproto
  9. #
  10. # However, some cc(1) drivers specify output file names on the
  11. # preprocessor command line, so this shell script must be prepared to
  12. # intercept them.  Depending on the driver program, the cpp options may
  13. # even go before or after the file name argument(s). The script below
  14. # tries to tackle all these cases.
  15. #
  16. # You may want to add -Ipath_to_stdarg.h_file, -Dvoid=, -Dvolatile=, 
  17. # and even -D__STDC__.
  18.  
  19. cpp_args=""
  20.  
  21. while :
  22. do
  23.     case $1 in
  24.     "")    break;;
  25.     -*)    cpp_args="$cpp_args $1";;
  26.      *)    cpp_args="$cpp_args $1"
  27.         case $2 in
  28.         ""|-*)    ;;
  29.             *)    exec 1> $2 || exit 1; shift;;
  30.         esac;;
  31.     esac
  32.     shift
  33. done
  34.  
  35. /lib/cpp $cpp_args | unproto
  36.