home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / pine / c-client / unansi < prev    next >
Text File  |  1994-01-09  |  728b  |  40 lines

  1. #!/bin/sh
  2. #
  3. # convert ansi-C to old-vanilla-C if it conforms to coding conventions:
  4. # all function definitions and declaractions must be of the form
  5. #    stuff (...);
  6. # or    stuff (...)
  7. #
  8. # another quickie by:
  9. # Corey Satten, corey@cac.washington.edu, 12/8/89
  10.  
  11. TMP=/tmp/unansi$$
  12. trap "rm -f $TMP; exit 0" 0 1 2 13 15
  13.  
  14. for f in $*; do
  15. sed '
  16. /^#/b
  17. : joinl
  18. / $/s/ *$//;
  19. /    $/s/    *$//;
  20. /^\([^     ()][^()]*\)(.*,$/ {
  21.     N
  22.     s/\n/ /
  23.     b joinl
  24.     }
  25. /^\([^     ()][^()]*\)(.*);$/s//\1 ();/
  26. /^\([^     ()][^()]*\)([     ]*)$/b
  27. /^\([^     ()][^()]*\)(.*)$/ {
  28.     h
  29.     : loop
  30.     s/\([(,]\)[^,)][^,)]*[ *]\([a-zA-Z_][a-zA-Z_]*\)[][ ]*\([,)]\)/\1\2\3/g
  31.     t loop
  32.     p
  33.     g
  34.     s/^.*(\(.*\))$/    \1;/
  35.     s/,/;\
  36. \    /g
  37.     }
  38. ' $f > $TMP && mv $TMP $f
  39. done
  40.