aboutsummaryrefslogtreecommitdiff
path: root/sed/bf2c/bf2c.sed
blob: 0682cd85b9fd01a42314edfb633487c567aaa422 (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
26
27
#!/usr/bin/sed -f

1i\
#include <err.h>\
#include <stdint.h>\
#include <stdio.h>\
#include <stdlib.h>\
int\
main(void)\
{\
	uint8_t *p = calloc(16384, 1);\
	if (!p)\
		err(EXIT_FAILURE, "calloc");

/./!d

s/[^][+<>.,-]//g
s/\[[-+]\]/*p = 0;/g
s/[-+]/(*p)&&;/g
s/</p--;/g
s/>/p++;/g
s/\./putchar(*p);/g
s/,/*p = (uint8_t)getchar();/g
s/\[/while (*p) {/g
s/\]/}/g

$a}