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

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

  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') if (lastch != '\r') substdio_BPUTC(subfdout,"\r"[0]);
      substdio_BPUTC(subfdout,ch);
      lastch = ch;
    }
  }
}