fix issue w/s:get-word, n:put no longer uses temporary string space

FossilOrigin-Name: 0cec7950f8b912d820369e3d3891dbe9136ce7d808addb02ad9866b7ac5f1302
This commit is contained in:
crc 2024-01-23 15:48:11 +00:00
parent 4ace2882d3
commit 1f6fbafe63
5 changed files with 867 additions and 871 deletions

View file

@ -22,6 +22,9 @@
- `HOME` (in the library code) is now a floating buffer
above `here`
- `s:get-word` was not properly breaking on space; this is
now corrected
- `n:put` no longer uses temporary string buffers
- library

View file

@ -1288,9 +1288,11 @@ returns an array containing pointers to each of them.
:n->digit (n-c) s:DIGITS + fetch ;
:convert (n-) [ @Base /mod swap n->digit buffer:add dup n:zero? ] until drop ;
---reveal---
:n:to-string (n-s)
:n:to-string/reversed (n-s)
[ &String buffer:set dup n:abs convert check-sign ] buffer:preserve
&String s:reverse ;
&String ;
:n:to-string (n-s)
n:to-string/reversed s:reverse ;
}}
~~~
@ -1852,7 +1854,8 @@ the log.
:sp (-) ASCII:SPACE c:put ;
:tab (-) ASCII:HT c:put ;
:s:put (s-) &c:put s:for-each ;
:n:put (n-) n:to-string s:put ;
:n:put (n-) n:to-string/reversed dup s:length &+ sip n:inc
[ dup fetch c:put n:dec ] times drop ;
~~~
An interface layer may provide additional I/O words, but these
@ -1913,7 +1916,7 @@ FALSE 'Ignoring var-n
&interpret &drop choose ;
---reveal---
:s:get-word (-s) [ #7 fetch buffer:set
[ c:get dup buffer:add check-bs eol? ] until
[ c:get dup buffer:add check-bs done? ] until
buffer:start s:chop ] buffer:preserve ;
:banner version 'RETRO_12_(%n.%n)\n s:format s:put
FREE EOM FREE - EOM '%n_Max,_%n_Used,_%n_Free\n s:format s:put ;

BIN
ngaImage

Binary file not shown.

View file

@ -171,33 +171,22 @@ is done.
LT:H #1 vt:row,col '>>_ s:put ;
~~~
Start of work on a new input model. The current one uses
`s:evaluate`, which works, but burns through the temporary
strings pool. For this to be practical, I need to avoid doing
that, so it's time to write a replacement.
~~~
'InputStream d:create #1025 allot
'Len var
'At var
:end? (-f) @At @Len gt? ;
:c:get-from-input (-c)
&InputStream @At fetch &At v:inc end? [ &c:get unhook ] if ;
:s:get/input s:get &InputStream s:copy &c:get-from-input &c:get set-hook ;
:quit ioctl:set-lbreak vt:reset bye ;
:bye quit ;
~~~
~~~
:ui
&err:notfound unhook
ioctl:set-cbreak
&banner tob:with
[ vt:reset vt:clear vt:home
display:tob
sections
stats dss (ss watchlist
prompt s:get vt:reset
[ dup s:put nl s:evaluate ] tob:with
prompt s:get-word vt:reset
[ dup s:put sp interpret ] tob:with
] forever ;
ui
@ -209,8 +198,6 @@ Things needed:
- termios device & words (or add termios to unix device?)
- colors for interface elements
- write a better alternative to `s:evaluate` to avoid consuming
the temporary string space
- refactor & document everything
================================================================

File diff suppressed because it is too large Load diff