aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-01-08 15:29:24 +0100
committerDimitri Sokolyuk <demon@dim13.org>2018-01-08 15:29:24 +0100
commit9b4b8bd1910787b4380404ac7315ae65763dcac7 (patch)
tree2377561611ec0ee3f6c44f5f20de72e897ed9218
parent3db68304a75583a2e9ff78e221aa319c6efb9d7f (diff)
Swicth to \n as EOL
-rw-r--r--console.go24
-rw-r--r--j1eforth/j1.4th4
-rw-r--r--testdata/j1e.binbin6670 -> 6670 bytes
3 files changed, 5 insertions, 23 deletions
diff --git a/console.go b/console.go
index 69082ae..5c63fbb 100644
--- a/console.go
+++ b/console.go
@@ -6,28 +6,10 @@ import (
)
type Console struct {
- r io.Reader
- w io.Writer
+ io.Reader
+ io.Writer
}
func NewConsole() *Console {
- return &Console{
- r: os.Stdin,
- w: os.Stdout,
- }
-}
-
-func (c *Console) Read(p []byte) (int, error) {
- n, err := c.r.Read(p)
- for i, v := range p {
- // replace nl with cr
- if v == 10 {
- p[i] = 13
- }
- }
- return n, err
-}
-
-func (c *Console) Write(p []byte) (int, error) {
- return c.w.Write(p)
+ return &Console{Reader: os.Stdin, Writer: os.Stdout}
}
diff --git a/j1eforth/j1.4th b/j1eforth/j1.4th
index e9ea766..7ce4e7a 100644
--- a/j1eforth/j1.4th
+++ b/j1eforth/j1.4th
@@ -504,7 +504,7 @@ t: key ( -- c )
begin
?key
until f000 literal @ t;
-t: nuf? ( -- t ) ?key dup if drop key =cr literal = then exit t;
+t: nuf? ( -- t ) ?key dup if drop key =lf literal = then exit t;
t: space ( -- ) bl emit t;
t: spaces ( +n -- ) 0 literal max for aft space then next t;
t: type ( b u -- ) for aft count emit then next drop t;
@@ -580,7 +580,7 @@ t: ^h ( bot eot cur -- bot eot cur )
t: tap ( bot eot cur c -- bot eot cur )
dup emit over c! 1+ t;
t: ktap ( bot eot cur c -- bot eot cur )
- dup =cr literal xor if
+ dup =lf literal xor if
=bksp literal xor if
bl tap exit
then ^h exit
diff --git a/testdata/j1e.bin b/testdata/j1e.bin
index 339c14c..6b92192 100644
--- a/testdata/j1e.bin
+++ b/testdata/j1e.bin
Binary files differ