[SLOF] [PATCH v6 1/2] Fix output word

Thomas Huth thuth at redhat.com
Mon Apr 9 16:15:37 AEST 2018


On 08.04.2018 13:05, Segher Boessenkool wrote:
> Hi!
> 
> On Fri, Apr 06, 2018 at 10:47:03AM +0200, Laurent Vivier wrote:
>>  : output  ( dev-str dev-len -- )
>>     open-dev ?dup IF
> 
> It's a lot simple if you do an early exit if there is no such device.
> You're supposed to output an error message in that case, fwiw.
> 
>> -      \ Close old stdout:
>> -      s" stdout" get-chosen IF
>> -         decode-int nip nip ?dup IF close-dev THEN
>> +      \ find new ihandle and xt handle
>> +      dup s" write" rot ihandle>phandle find-method
>> +      0= IF
>> +         drop
>> +         cr ." Cannot find the write method for the given output console " cr
>> +         EXIT
> 
> This leaks the instance.  The description in the standard say to search
> for the method before doing the open-dev, that solves this problem too.
> 
>> +: term-io-emit ( char -- )
>> +    write-xt IF
>> +       (term-io-char-buf) c!
>> +       (term-io-char-buf) 1 write-xt stdout @ call-package
>> +       drop
>> +    ELSE
>> +       [ ' emit behavior compile, ]
>> +    THEN
>> +;
> 
> What do you expect to be in the emit hook at this point?  Could you
> just use _that_?

The code in slof/fs/term-io.fs is "common" code, i.e. shared between all
"boards", so there is no 100% generic way to say which token should be
expected in the emit hook at this point in time. That's why we have the
detour with [ ' ... behavior compile, ] here. Unless we want to
hard-code a default name for all boards (ok, we currently only have two
boards, but still...), I think that line is a nice and short solution to
the problem.

 Thomas


More information about the SLOF mailing list