fix text rendering crash with strings containing nulls
parent
3bf3e13f2e
commit
e91e0edc3b
|
@ -12,8 +12,6 @@
|
|||
- optimize away dispatch
|
||||
|
||||
- code gc
|
||||
- ppc register decls
|
||||
|
||||
- #jump-f #jump-f-label
|
||||
- extract word inside M:, C:, and structure browsing for these
|
||||
- each-slot combinator
|
||||
|
@ -22,7 +20,6 @@
|
|||
- don't hardcode so many colors
|
||||
- ffi unicode strings: null char security hole
|
||||
- utf16 string boxing
|
||||
- sdl console crash
|
||||
- more accurate types for various words
|
||||
- optimize out >array, >tuple, >hashtable etc
|
||||
- write read: write should flush
|
||||
|
|
|
@ -133,8 +133,13 @@ global [
|
|||
SDL_LockSurface
|
||||
] when drop ;
|
||||
|
||||
: filter-nulls ( str -- str )
|
||||
"\0" over str-contains? [
|
||||
[ dup CHAR: \0 = [ drop CHAR: \s ] when ] str-map
|
||||
] when ;
|
||||
|
||||
: draw-string ( x y font text fg -- width )
|
||||
over str-length 0 = [
|
||||
>r filter-nulls r> over str-length 0 = [
|
||||
2drop 3drop 0
|
||||
] [
|
||||
>r >r lookup-font r> r>
|
||||
|
@ -145,7 +150,7 @@ global [
|
|||
] ifte ;
|
||||
|
||||
: size-string ( font text -- w h )
|
||||
>r lookup-font r> dup str-length 0 = [
|
||||
>r lookup-font r> filter-nulls dup str-length 0 = [
|
||||
drop TTF_FontHeight 0 swap
|
||||
] [
|
||||
<int-box> <int-box> [ TTF_SizeUNICODE drop ] 2keep
|
||||
|
|
|
@ -7,7 +7,7 @@ USE: lists
|
|||
|
||||
num-types [
|
||||
[
|
||||
(instances) [
|
||||
builtin-type instances [
|
||||
class drop
|
||||
] each
|
||||
] keep
|
||||
|
|
|
@ -51,8 +51,3 @@ C: quuux-tuple-2
|
|||
|
||||
point-x
|
||||
] unit-test
|
||||
|
||||
! Ensure we have a fresh word.
|
||||
DEFER: losing-eq FORGET: losing-eq
|
||||
[ t ] [ DEFER: losing-eq \ losing-eq TUPLE: losing-eq x y ; \ losing-eq eq? ]
|
||||
unit-test
|
||||
|
|
Loading…
Reference in New Issue