summaryrefslogtreecommitdiff
path: root/addcr.c
blob: a452450dfdd5b022b758f5f94aacb6fda99ebe62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "substdio.h"
#include "subfd.h"
#include "exit.h"

void main()
{
  register int n;
  register char *x;
  char ch;

  for (;;) {
    n = substdio_feed(subfdin);
    if (n < 0) _exit(111);
    if (!n) _exit(0);
    x = substdio_PEEK(subfdin);
    substdio_SEEK(subfdin,n);
    while (n > 0) {
      ch = *x++; --n;
      if (ch == '\n') substdio_BPUTC(subfdout,"\r"[0]);
      substdio_BPUTC(subfdout,ch);
    }
  }
}