Merge pull request #85 from davidgiven/dtrg-ed

Fix the incompatibility with modern ed
This commit is contained in:
David Given 2018-06-02 19:23:19 +03:00 committed by GitHub
commit c47661f07e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 2244 additions and 36 deletions

View file

@ -17,11 +17,6 @@ matrix:
# env: HOMEBREW_NO_AUTO_UPDATE=1 # env: HOMEBREW_NO_AUTO_UPDATE=1
# compiler: clang # compiler: clang
addons:
apt:
packages:
- ed
git: git:
depth: 10 depth: 10
script: script:

View file

@ -9,6 +9,7 @@ normalrule {
name = "tokentab_h", name = "tokentab_h",
ins = { ins = {
"./maketokentab", "./maketokentab",
"util/cmisc+ed",
matching(filenamesof("+llgen"), "/Lpars.h$"), matching(filenamesof("+llgen"), "/Lpars.h$"),
}, },
outleaves = { "tokentab.h" }, outleaves = { "tokentab.h" },

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
ed -s "${1:-Lpars.h}" > $2 <<'+' $1 -s "${2:-Lpars.h}" > $3 <<'+'
1d 1d
1,$s/# *define // 1,$s/# *define //
1,$s/ ...$// 1,$s/ ...$//
@ -14,5 +14,4 @@ $a
}; };
. .
1,$p 1,$p
q
+ +

View file

@ -38,4 +38,3 @@ g/_b64_sft/s//.b64_sft/g
g/_b64_rsft/s//.b64_rsft/g g/_b64_rsft/s//.b64_rsft/g
g/_b64_lsft/s//.b64_lsft/g g/_b64_lsft/s//.b64_lsft/g
1,$p 1,$p
q

View file

@ -29,11 +29,12 @@ for _, plat in ipairs({"cpm"}) do
name = "ed_"..plat.."/"..n, name = "ed_"..plat.."/"..n,
ins = { ins = {
"./FP.script", "./FP.script",
"util/cmisc+ed",
assembly, assembly,
}, },
outleaves = { n..".s" }, outleaves = { n..".s" },
commands = { commands = {
"ed -s %{ins[2]} <%{ins[1]} >%{outs}" "%{ins[2]} -s %{ins[3]} <%{ins[1]} >%{outs}"
} }
} }
end end

View file

@ -2,13 +2,14 @@ normalrule {
name = "em_code_ek_h", name = "em_code_ek_h",
ins = { ins = {
"./make.em.gen", "./make.em.gen",
"util/cmisc+ed",
"./em.nogen", "./em.nogen",
"h/em_table" "h/em_table"
}, },
outleaves = { "em_codeEK.h" }, outleaves = { "em_codeEK.h" },
commands = { commands = {
"%{ins[1]} %{ins[3]} > %{outs}", "%{ins[1]} %{ins[2]} %{ins[4]} > %{outs}",
"cat %{ins[2]} >> %{outs}" "cat %{ins[3]} >> %{outs}"
} }
} }

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
echo "/* this part is generated from $1 at: " `date` "*/" echo "/* this part is generated from $2 at: " `date` "*/"
ed -s $1 <<'EOI' $1 -s $2 <<'EOI'
1,/^$/d 1,/^$/d
1,/^$/d 1,/^$/d
1,$s/^\(...\) \(.\).*/\1:\2/ 1,$s/^\(...\) \(.\).*/\1:\2/

View file

@ -2,6 +2,7 @@ local generated = normalrule {
name = "generated", name = "generated",
ins = { ins = {
"./new_table", "./new_table",
"util/cmisc+ed",
"h/em_table", -- relative to root, which is a bit evil "h/em_table", -- relative to root, which is a bit evil
}, },
outleaves = { outleaves = {
@ -16,7 +17,7 @@ local generated = normalrule {
"h+emheaders" "h+emheaders"
}, },
commands = { commands = {
"%{ins[1]} %{ins[2]} %{dir} %{dir}" "%{ins[1]} %{ins[2]} %{ins[3]} %{dir} %{dir}"
} }
} }

View file

@ -1,25 +1,26 @@
#!/bin/sh #!/bin/sh
set -e set -e
em_table=$1 ed=$1
h=${2-.} em_table=$2
d=${3-.} h=${3-.}
d=${4-.}
set `grep fpseu $em_table` set `grep fpseu $em_table`
p=$2 p=$2
set `grep fmnem $em_table` set `grep fmnem $em_table`
m=$2 m=$2
ed - $em_table <<'A' > X $ed - $em_table <<'A' > X
1,/^$/g/ /s// /gp 1,/^$/g/ /s// /gp
A A
ed - $em_table <<'A' | awk '{$2=$2+'$p'; print}' > Y $ed - $em_table <<'A' | awk '{$2=$2+'$p'; print}' > Y
1,/^$/d 1,/^$/d
1,/^$/g/ /s// /gp 1,/^$/g/ /s// /gp
A A
ed - $em_table <<'A' | awk '{print $0,'$m'+i++}' > Z $ed - $em_table <<'A' | awk '{print $0,'$m'+i++}' > Z
1,/^$/d 1,/^$/d
1,/^$/d 1,/^$/d
1,/^$/g/ /s// /gp 1,/^$/g/ /s// /gp
@ -30,23 +31,23 @@ echo 'lpseu' `expr $i + $p - 1` >>X
i=`wc -l <Z` i=`wc -l <Z`
echo 'lmnem' `expr $i + $m - 1` >>X echo 'lmnem' `expr $i + $m - 1` >>X
ed - X <<'A' > $h/em_spec.h $ed - X <<'A' > $h/em_spec.h
g/^/s//#define sp_/p g/^/s//#define sp_/p
A A
ed - Y <<'A' > $h/em_pseu.h $ed - Y <<'A' > $h/em_pseu.h
g/ \(.*\) .*/s// \1/ g/ \(.*\) .*/s// \1/
g/\(.*\) \(.*\)/s//#define ps_\1 \2/p g/\(.*\) \(.*\)/s//#define ps_\1 \2/p
A A
ed - Z <<'A' > $h/em_mnem.h $ed - Z <<'A' > $h/em_mnem.h
g/ .* /s// / g/ .* /s// /
g/\(.*\) \(.*\)/s//#define op_\1 \2/p g/\(.*\) \(.*\)/s//#define op_\1 \2/p
A A
( (
echo 'char em_pseu[][4] = {' echo 'char em_pseu[][4] = {'
ed - Y <<'A' $ed - Y <<'A'
g/\(...\).*/s// "\1",/p g/\(...\).*/s// "\1",/p
A A
echo '};' echo '};'
@ -54,7 +55,7 @@ echo '};'
( (
echo 'char em_mnem[][4] = {' echo 'char em_mnem[][4] = {'
ed - Z <<'A' $ed - Z <<'A'
g/\(...\).*/s// "\1",/p g/\(...\).*/s// "\1",/p
A A
echo '};' echo '};'
@ -63,7 +64,7 @@ echo '};'
( (
echo '#include <em_flag.h> echo '#include <em_flag.h>
char em_flag[] = {' char em_flag[] = {'
ed - Z <<'A' | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ $ed - Z <<'A' | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
g/^... /s/// g/^... /s///
g/ .*/s/// g/ .*/s///
g/\(.\)\(.\)/s//PAR_\1 | FLO_\2/ g/\(.\)\(.\)/s//PAR_\1 | FLO_\2/

View file

@ -8,7 +8,7 @@ case x$# in
exit 1 exit 1
;; ;;
esac esac
ed -s $2 << A $ED -s $2 << A
1,/^\$/d 1,/^\$/d
1,/^\$/d 1,/^\$/d
1,/^\$/g/^\(...\) [$1].*/s//\\1/gp 1,/^\$/g/^\(...\) [$1].*/s//\\1/gp

View file

@ -2,6 +2,7 @@ normalrule {
name = "c_mnem_narg_h", name = "c_mnem_narg_h",
ins = { ins = {
"./m_C_mnem_na", "./m_C_mnem_na",
"util/cmisc+ed",
"h/em_table", "h/em_table",
"./argtype" "./argtype"
}, },
@ -15,6 +16,7 @@ normalrule {
name = "c_mnem_h", name = "c_mnem_h",
ins = { ins = {
"./m_C_mnem", "./m_C_mnem",
"util/cmisc+ed",
"h/em_table", "h/em_table",
"./argtype" "./argtype"
}, },

View file

@ -1,7 +1,8 @@
#!/bin/sh #!/bin/sh
EM_TABLE=$1 export ED=$1
ARGTYPE=$2 EM_TABLE=$2
ARGTYPE=$3
echo "switch(p->em_opcode) {" echo "switch(p->em_opcode) {"
for i in - cdflnorswz p b for i in - cdflnorswz p b
do do

View file

@ -1,5 +1,7 @@
EM_TABLE=$1 #!/bin/sh
ARGTYPE=$2 export ED=$1
EM_TABLE=$2
ARGTYPE=$3
list=`$ARGTYPE w $EM_TABLE` list=`$ARGTYPE w $EM_TABLE`
echo "switch(p->em_opcode) {" echo "switch(p->em_opcode) {"
for i in $list for i in $list

View file

@ -23,3 +23,9 @@ definerule("tabgen",
} }
end end
) )
cprogram {
name = "ed",
srcs = { "./ed.c" }
}

2199
util/cmisc/ed.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -14,12 +14,13 @@ normalrule {
name = "keywords", name = "keywords",
ins = { ins = {
"./cvtkeywords", "./cvtkeywords",
"util/cmisc+ed",
"./keywords", "./keywords",
matching(filenamesof(cggparser), "%.h$") matching(filenamesof(cggparser), "%.h$")
}, },
outleaves = { "enterkeyw.c" }, outleaves = { "enterkeyw.c" },
commands = { commands = {
"%{ins[1]} %{ins[2]} %{ins[3]} %{outs[1]}" "%{ins[1]} %{ins[2]} %{ins[3]} %{ins[4]} %{outs[1]}"
} }
} }

View file

@ -1,8 +1,8 @@
#!/bin/sh #!/bin/sh
: '$Id$' : '$Id$'
grep '^#' $2 >tokendefs grep '^#' $3 >tokendefs
ed -s $1 > $3 <<'!Funky!Stuff!' $1 -s $2 > $4 <<'!Funky!Stuff!'
g/^#/d g/^#/d
1,$s/\([^ ]*\)[ ][ ]*\(.*\)/ sy_p=lookup("\1",symkeyw,newsymbol);sy_p->sy_value.syv_keywno=\2;/ 1,$s/\([^ ]*\)[ ][ ]*\(.*\)/ sy_p=lookup("\1",symkeyw,newsymbol);sy_p->sy_value.syv_keywno=\2;/
1i 1i
@ -18,8 +18,7 @@ enterkeyw() {
$a $a
} }
. .
,p 1,$p
q
!Funky!Stuff! !Funky!Stuff!
rm tokendefs rm tokendefs