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
# compiler: clang
addons:
apt:
packages:
- ed
git:
depth: 10
script:

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -23,3 +23,9 @@ definerule("tabgen",
}
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",
ins = {
"./cvtkeywords",
"util/cmisc+ed",
"./keywords",
matching(filenamesof(cggparser), "%.h$")
},
outleaves = { "enterkeyw.c" },
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
: '$Id$'
grep '^#' $2 >tokendefs
ed -s $1 > $3 <<'!Funky!Stuff!'
grep '^#' $3 >tokendefs
$1 -s $2 > $4 <<'!Funky!Stuff!'
g/^#/d
1,$s/\([^ ]*\)[ ][ ]*\(.*\)/ sy_p=lookup("\1",symkeyw,newsymbol);sy_p->sy_value.syv_keywno=\2;/
1i
@ -18,8 +18,7 @@ enterkeyw() {
$a
}
.
,p
q
1,$p
!Funky!Stuff!
rm tokendefs