-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathtxt2cbn.c
49 lines (45 loc) · 1.41 KB
/
txt2cbn.c
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#define ERROR 00404
#include "pdp11_cr_dat.h"
static int colStart = 1; /* starting column */
static int colEnd = 80; /* ending column */
main ()
{
int col, c;
while (1) {
for (col = colStart; col <= colEnd; ) {
switch (c = fgetc (stdin)) {
case EOF:
/* fall through */
case '\n':
while (col <= colEnd) {
fputc (o29_code[' '] & 077, stdout);
fputc ((o29_code[' '] >> 6) & 077, stdout);
col++;
}
break;
case '\t':
do {
fputc (o29_code[' '] & 077, stdout);
fputc ((o29_code[' '] >> 6) & 077, stdout);
col++;
} while (((col & 07) != 1) && (col <= colEnd));
break;
default:
fputc (o29_code[c] & 077, stdout);
fputc ((o29_code[c] >> 6) & 077, stdout);
col++;
break;
}
}
/* flush long lines, or flag over-length card */
if (c != '\n' && c != EOF) {
printf ("overlength line\n");
do c = fgetc (stdin);
while ((c != EOF) && (c != '\n'));
}
if (c == EOF)
break;
}
exit (1);
}