summaryrefslogtreecommitdiffstats
path: root/hp48g20230307/prog.c
blob: b29f73680ce9bdecb0651384c0052e843fec87e3 (plain) (blame)
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 <stdio.h>
int main (void) {
	puts("%%HP: T(1)A(D)F(.);");
	putchar(0xab);
	char c = '\0';
	unsigned paren = 0;
	while (!feof(stdin) && !ferror(stdin)) {
		char prevchar = c;
		c = getchar();
		if (prevchar == '-' && c == '>') {
			putchar(0x8d);
			c = '\0';
			continue;
		}
		if (prevchar == '"')
			paren++;
		if (prevchar == '\0')
			continue;
		if (!(paren % 2) && (prevchar == ' ' || prevchar == '\t'))
			putchar('\n');
		else
			putchar(prevchar);
	}
	puts("\n\xbb");
}