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

Segher Boessenkool segher at kernel.crashing.org
Tue Mar 20 23:12:49 AEDT 2018


Hi!

On Tue, Mar 20, 2018 at 12:07:34PM +0100, Laurent Vivier wrote:
>  : output  ( dev-str dev-len -- )
>     open-dev ?dup IF
> +      \ find new ihandle and xt handle
> +      dup s" write" rot ihandle>phandle find-method
> +      0= IF drop cr ." Cannot change output console " cr EXIT THEN
>        \ Close old stdout:
> -      s" stdout" get-chosen IF
> -         decode-int nip nip ?dup IF close-dev THEN
> -      THEN
> +      stdout-ihandle ?dup IF close-dev THEN
>        \ Now set the new stdout:
> +      to write-xt
> +      dup to stdout-ihandle
>        encode-int s" stdout" set-chosen
>     THEN
>  ;

The ihandle variables should be called stdin and stdout, and be variables
(not values).  These are standard words.

Things can be factored better with e.g. a
  : set-stdout ( ihandle -- )
method (that also handles setting the /chosen thing).  Or you could
make the /chosen property use the actual same stdout variable.

In general, if a word is too long, factor it, don't make it spaghetti :-)

The error messages could be more specific (say *what* is wrong).


Segher


More information about the SLOF mailing list