home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / hcshdemo.zip / csh-os2.zip / SAMPLES / SH_2_CSH / PROC.SED < prev    next >
Text File  |  1993-11-24  |  1KB  |  42 lines

  1. #    Fixup procedure definitions:
  2.  
  3. #        1.    foo() {        -->    proc foo(A)
  4. #            }                        end
  5.  
  6. #        2. argv holds arguments passed to a .csh script; formal arguments
  7. #            to a C shell procedure are declared, requiring this change
  8. #            (but not inside a comment or quoted string):
  9.  
  10. #                $1 thru $9    -->    $A[0] thru $A[8]
  11.  
  12. #            (Note that Hamilton C shell interprets all subscripts as starting
  13. #            at zero.  Also, argv[0] to a shell script is the first argument,
  14. #            not the scriptname unless bsdargv == 1; the name of the script
  15. #            is found in the $scriptname variable.)
  16.  
  17. #        3. shift            -->    shift A
  18.  
  19. /^[^#].*()/,/^[     ]*}/{
  20.     /()/s/\([^a-zA-Z]*\)\([a-zA-Z][a-zA-Z0-9_]*\).*/\1proc \2(A)/
  21.     s/^\([^'#]*\)\$1/\1\$A[0]/g
  22.     s/^\([^'#]*\)\$2/\1\$A[1]/g
  23.     s/^\([^'#]*\)\$3/\1\$A[2]/g
  24.     s/^\([^'#]*\)\$4/\1\$A[3]/g
  25.     s/^\([^'#]*\)\$5/\1\$A[4]/g
  26.     s/^\([^'#]*\)\$6/\1\$A[5]/g
  27.     s/^\([^'#]*\)\$7/\1\$A[6]/g
  28.     s/^\([^'#]*\)\$8/\1\$A[7]/g
  29.     s/^\([^'#]*\)\$9/\1\$A[8]/g
  30.     s/^\([^'#]*\)\${1}/\1\${A[0]}/g
  31.     s/^\([^'#]*\)\${2}/\1\${A[1]}/g
  32.     s/^\([^'#]*\)\${3}/\1\${A[2]}/g
  33.     s/^\([^'#]*\)\${4}/\1\${A[3]}/g
  34.     s/^\([^'#]*\)\${5}/\1\${A[4]}/g
  35.     s/^\([^'#]*\)\${6}/\1\${A[5]}/g
  36.     s/^\([^'#]*\)\${7}/\1\${A[6]}/g
  37.     s/^\([^'#]*\)\${8}/\1\${A[7]}/g
  38.     s/^\([^'#]*\)\${9}/\1\${A[8]}/g
  39.     s/shift/shift A/g
  40.     /^[     ]*}/s/}/end/
  41.     }
  42.