summaryrefslogtreecommitdiff
path: root/fixcr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fixcr.c')
-rw-r--r--fixcr.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/fixcr.c b/fixcr.c
new file mode 100644
index 0000000..02b4d7f
--- /dev/null
+++ b/fixcr.c
@@ -0,0 +1,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;
+ }
+ }
+}