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

Laurent Vivier lvivier at redhat.com
Tue Mar 27 22:23:53 AEDT 2018


On 26/03/2018 13:11, Thomas Huth wrote:
> On 26.03.2018 13:06, Thomas Huth wrote:
>> On 23.03.2018 12:42, Laurent Vivier wrote:
>>> We can select the console output, but it does not really work
>>>
>>> Implement term-io-emit, as we have term-io-key to really
>>> send characters to the output selected by stdout.
>>>
>>> Signed-off-by: Laurent Vivier <lvivier at redhat.com>
>>> ---
>>>  slof/fs/term-io.fs | 33 ++++++++++++++++++++++++++++-----
>>>  1 file changed, 28 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/slof/fs/term-io.fs b/slof/fs/term-io.fs
>>> index 52ce12a..97d02a4 100644
>>> --- a/slof/fs/term-io.fs
>>> +++ b/slof/fs/term-io.fs
>>> @@ -10,6 +10,17 @@
>>>  \ *     IBM Corporation - initial implementation
>>>  \ ****************************************************************************/
>>>  
>>> +0 VALUE write-xt
>>> +
>>> +VARIABLE stdout
>>> +
>>> +: set-stdout ( ihandle -- )
>>> +   \ Close old stdout:
>>> +   stdout @ ?dup IF close-dev THEN
>>> +   \ Now set the new stdout:
>>> +   dup stdout !
>>> +   encode-int s" stdout" set-chosen
>>> +;
>>>  
>>>  : input  ( dev-str dev-len -- )
>>>     open-dev ?dup IF
>>> @@ -24,12 +35,15 @@
>>>  
>>>  : output  ( dev-str dev-len -- )
>>>     open-dev ?dup IF
>>> -      \ 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
>>>        THEN
>>> -      \ Now set the new stdout:
>>> -      encode-int s" stdout" set-chosen
>>> +      to write-xt
>>> +      set-stdout
>>>     THEN
>>>  ;
>>>  
>>> @@ -40,6 +54,15 @@
>>>  
>>>  1 BUFFER: (term-io-char-buf)
>>>  
>>> +: term-io-emit ( char -- )
>>> +    write-xt 0= IF drop EXIT THEN
>>
>> Patch looks basically fine to me, but this part is a little bit ugly: As
>> long as write-xt is 0, there won't be a way to print out any console
>> output. So between the point in time where term-io.fs is included (i.e.
>> tree.fs in OF.fs) and the point in time where "output" is called, there
>> won't be any console output anymore.
>> To fix this, use the trick that is already used in term-io-key:
>>
>>   write-xt 0= IF [ ' emit behavior compile, ] THEN
> 
> And of course there should also be an "EXIT" before the "THEN" in this
> case :-)

I did this in v2 of the patch, but Segher said:

> That is very problematic.  If the xt of term-io-emit already is the
> behaviour of emit, this will loop.  It sounds like you just want the
> "system emit"; just assign that to the hook, don't do extra redirections?

But I don't know to have only "system emit".

Any advice?

Thanks,
Laurent



More information about the SLOF mailing list