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 - `HOME` (in the library code) is now a floating buffer
above `here` above `here`
- `s:get-word` was not properly breaking on space; this is
now corrected
- `n:put` no longer uses temporary string buffers
- library - library

View file

@ -1288,9 +1288,11 @@ returns an array containing pointers to each of them.
:n->digit (n-c) s:DIGITS + fetch ; :n->digit (n-c) s:DIGITS + fetch ;
:convert (n-) [ @Base /mod swap n->digit buffer:add dup n:zero? ] until drop ; :convert (n-) [ @Base /mod swap n->digit buffer:add dup n:zero? ] until drop ;
---reveal--- ---reveal---
:n:to-string (n-s) :n:to-string/reversed (n-s)
[ &String buffer:set dup n:abs convert check-sign ] buffer:preserve [ &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 ; :sp (-) ASCII:SPACE c:put ;
:tab (-) ASCII:HT c:put ; :tab (-) ASCII:HT c:put ;
:s:put (s-) &c:put s:for-each ; :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 An interface layer may provide additional I/O words, but these
@ -1913,7 +1916,7 @@ FALSE 'Ignoring var-n
&interpret &drop choose ; &interpret &drop choose ;
---reveal--- ---reveal---
:s:get-word (-s) [ #7 fetch buffer:set :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 ; buffer:start s:chop ] buffer:preserve ;
:banner version 'RETRO_12_(%n.%n)\n s:format s:put :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 ; 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 ; 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 :quit ioctl:set-lbreak vt:reset bye ;
'Len var :bye quit ;
'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 ;
~~~ ~~~
~~~ ~~~
:ui :ui
&err:notfound unhook &err:notfound unhook
ioctl:set-cbreak
&banner tob:with &banner tob:with
[ vt:reset vt:clear vt:home [ vt:reset vt:clear vt:home
display:tob display:tob
sections sections
stats dss (ss watchlist stats dss (ss watchlist
prompt s:get vt:reset prompt s:get-word vt:reset
[ dup s:put nl s:evaluate ] tob:with [ dup s:put sp interpret ] tob:with
] forever ; ] forever ;
ui ui
@ -209,8 +198,6 @@ Things needed:
- termios device & words (or add termios to unix device?) - termios device & words (or add termios to unix device?)
- colors for interface elements - colors for interface elements
- write a better alternative to `s:evaluate` to avoid consuming
the temporary string space
- refactor & document everything - refactor & document everything
================================================================ ================================================================

File diff suppressed because it is too large Load diff