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 >
Wrap
Text File
|
1993-11-24
|
1KB
|
42 lines
# Fixup procedure definitions:
# 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/
}