Hi Thorsten,

> > Perhaps it'd be easier to supply a hacked version of `out' on Windows,
> > made to recognized "/dev/null" as special case. Just like you can, for
> > example, use "/" as path separator in a lot of Windows apps.
> 
> I don't know C, but (without really understanding the code) I guess that
> somewhere in 'pushOutFiles' there must be inserted a 
> 
> ,---------------------------------------------------
> | if (OS equals Windows && any equals "/dev/null") {
> | ... send to "NULL" ...                            
> | } else { ... as is ...}                           
> `---------------------------------------------------

Yes, you are on the right track :)

The problem is not really 'out' by itself, but all output functions
('print' etc.) probably called while the 'prg' body of 'out' is running.
The actual direction of the output stream is controlled on the lowest,
the character-output level. This is handled by the put() function, which
is actually a function pointer in the 'Env' environment.

> // from io.c
> ,------------------------------------------------
> | void pushOutFiles(outFrame *f) {               
> |    OutFile = OutFiles[f->fd];                  
> |    f->put = Env.put,  Env.put = putStdout;     
> |    f->link = Env.outFrames,  Env.outFrames = f;
> | }                                              
> `------------------------------------------------

The line

   f->put = Env.put,  Env.put = putStdout;

could set 'Evn.put' - instead of to 'putStdout' - to a do-nothing
function.

It might be tempting simply to set 'OutFile' to NULL in pushOutFiles().
You see that putStdout() does nothing if 'OutFile' is NULL. But this is
dangerous, as you may end up with a segmentation violation. 'OutFile' is
set to NULL in only a few special situations, e.g. when closing a file
descriptor asynchronously.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to