core: write_byte: Prepare for M2-Planet.

* src/posix.c (write_byte): Prepare for M2-Planet.
This commit is contained in:
Jan Nieuwenhuizen 2019-10-24 21:29:45 +02:00
parent c382d0d964
commit 831544d353
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 12 additions and 4 deletions

View File

@ -140,10 +140,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__