add s:truncate, s:oversize?, s:temp now truncates overlength strings. s:append & s:prepend no longer perform append in some cases where one of the strings is too long

FossilOrigin-Name: b65e270ca07300f18ef575d32e7b176d56e56fb244aaac04782780fdcbd61c93
This commit is contained in:
crc 2024-08-06 14:31:21 +00:00
parent 5a2867cbb9
commit 7c4aaf1a1f
4 changed files with 951 additions and 937 deletions

View file

@ -28,6 +28,11 @@
now corrected
- `n:put` no longer uses temporary string buffers
- `s:get` now truncates strings longer than `TempStringMax`
- add `s:oversize?`
- add `s:truncate`
- `s:append`, `s:prepend` now truncate if source string is
at `TempStringMax`
- `s:temp` now truncates strings longer than `TempStringMax`
- library

View file

@ -845,6 +845,12 @@ variables.
:TempStringMax ; data #512 !TempStringMax
:STRINGS EOM @TempStrings @TempStringMax * - ;
:s:oversize? (s-f)
s:length @TempStringMax n:dec gt? ;
:s:truncate (s-s)
dup s:oversize? [ #0 over @TempStringMax + store ] if ;
{{
:Current `0 ; data
@ -852,11 +858,8 @@ variables.
:s:next (-)
&Current v:inc
@Current @TempStrings eq? [ #0 !Current ] if ;
:truncate (s-s)
dup s:length @TempStringMax n:dec gt?
[ #0 over @TempStringMax + store ] if ;
---reveal---
:s:temp (s-s) truncate
:s:temp (s-s) s:truncate
dup s:length n:inc s:pointer swap copy
s:pointer s:next ;
:s:empty (-s) s:pointer s:next #0 over store ;
@ -934,7 +937,11 @@ a string.
~~~
:s:prepend (ss-s)
s:temp [ dup s:length + [ dup s:length n:inc ] dip swap copy ] sip ;
s:temp [ dup s:oversize?
&drop-pair
[ dup s:length + [ dup s:length n:inc ] dip swap copy ]
choose
] sip ;
:s:append (ss-s) swap s:prepend ;
~~~

BIN
ngaImage

Binary file not shown.

File diff suppressed because it is too large Load diff