[comp.lang.lisp.x] Second bug report of the month

toma@sail.LABS.TEK.COM (Tom Almy) (02/19/91)

Problem: Even though XLISP maintains separate streams for *standard-output*
and various errors, all output goes to standard output anyway.

Diagnosis: xlputc() calls ostputc() for both stdout and stderr. Changing it
so that ostputc() is called only for stdout does not work properly because
cursor positioning gets confused.

Solution: Check for redirected standard output, and if none, bind all output
streams to *standard-output*.

Add to xlglob.c:
int redirectout = FALSE;	/* output is redirected */

Add to xlinit.c:
extern int redirectout;

Change:
    setvalue(s_stderr,cvfile(stderr));
to:
    setvalue(s_stderr,redirectout ? cvfile(stderr) : getvalue(s_stdout));

In xlio.c, function xlputc(), change:
	if (fp == stdout | fp == stderr)
to:
	if (fp == stdout)

***Now the hard part. In the *stuff.c file you need to add code to osinit()
that will set redirectoutput to TRUE of stdout is redirected. If you don't
do this, then output cannot be redirected (as before). The following code
words under MS/DOS using the Borland or Zortech compilers:

	if (*(char *)MK_FP(_psp,0x19) != *(char *)MK_FP(_psp,0x1a))
		redirectout = TRUE;

With other compilers or operating systems, you will have to figure out
how to decide if stdout has been redirected.

-- 
Tom Almy
toma@sail.labs.tek.com
Standard Disclaimers Apply