# Fixup procedure definitions. # Copyright (c) 1992-2012 by Hamilton Laboratories. All rights reserved. # 1. foo() { --> proc foo(A) # } end # 2. argv holds arguments passed to a .csh script; formal arguments # to a C shell procedure are declared, requiring this change # (but not inside a comment or quoted string): # $1 thru $9 --> $A[0] thru $A[8] # (Note that Hamilton C shell interprets all subscripts as starting # at zero. Also, argv[0] to a shell script is the first argument, # not the scriptname unless bsdargv == 1; the name of the script # is found in the $scriptname variable.) # 3. shift --> shift A /^[^#].*()/,/^[ ]*}/{ /()/s/\([^a-zA-Z]*\)\([a-zA-Z][a-zA-Z0-9_]*\).*/\1proc \2(A)/ s/^\([^'#]*\)\$1/\1\$A[0]/g s/^\([^'#]*\)\$2/\1\$A[1]/g s/^\([^'#]*\)\$3/\1\$A[2]/g s/^\([^'#]*\)\$4/\1\$A[3]/g s/^\([^'#]*\)\$5/\1\$A[4]/g s/^\([^'#]*\)\$6/\1\$A[5]/g s/^\([^'#]*\)\$7/\1\$A[6]/g s/^\([^'#]*\)\$8/\1\$A[7]/g s/^\([^'#]*\)\$9/\1\$A[8]/g s/^\([^'#]*\)\${1}/\1\${A[0]}/g s/^\([^'#]*\)\${2}/\1\${A[1]}/g s/^\([^'#]*\)\${3}/\1\${A[2]}/g s/^\([^'#]*\)\${4}/\1\${A[3]}/g s/^\([^'#]*\)\${5}/\1\${A[4]}/g s/^\([^'#]*\)\${6}/\1\${A[5]}/g s/^\([^'#]*\)\${7}/\1\${A[6]}/g s/^\([^'#]*\)\${8}/\1\${A[7]}/g s/^\([^'#]*\)\${9}/\1\${A[8]}/g s/shift/shift A/g /^[ ]*}/s/}/end/ } |