core: write_byte: Prepare for M2-Planet.

* src/posix.c (write_byte): Prepare for M2-Planet.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2020-07-16 21:29:45 +02:00
parent 2f0796cfb5
commit 752c5f7d1b
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -144,10 +144,18 @@ write_byte (SCM x) /*:((arity . n)) */
SCM c = car (x);
SCM p = cdr (x);
int fd = __stdout;
if (TYPE (p) == TPAIR && TYPE (car (p)) == TNUMBER && VALUE (CAR (p)) != 1)
fd = VALUE (CAR (p));
if (TYPE (p) == TPAIR && TYPE (car (p)) == TNUMBER && VALUE (CAR (p)) == 2)
fd = __stderr;
if (TYPE (p) == TPAIR)
{
SCM f = CAR (p);
if (TYPE (f) == TNUMBER)
{
long v = VALUE (f);
if (v != 1)
fd = v;
if (v == 2)
fd = __stderr;
}
}
char cc = VALUE (c);
write (fd, &cc, 1);
#if !__MESC__