aboutsummaryrefslogtreecommitdiff
path: root/test/bin/bs.m4
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-02-03 18:46:44 +0100
committerlonkaars <loek@pipeframe.xyz>2023-02-03 18:46:44 +0100
commitdb30b8eacce34d6fc901f50982acade589eecd04 (patch)
treec4d98aa0d801cc0dc50c5b2d05febcad626cf17a /test/bin/bs.m4
parent8fb34ff745bac3be2cc6a4d62069e7117eb78ee6 (diff)
add makefile for bin tests
Diffstat (limited to 'test/bin/bs.m4')
-rw-r--r--test/bin/bs.m419
1 files changed, 19 insertions, 0 deletions
diff --git a/test/bin/bs.m4 b/test/bin/bs.m4
new file mode 100644
index 0000000..4312cc0
--- /dev/null
+++ b/test/bin/bs.m4
@@ -0,0 +1,19 @@
+dnl library functions
+define(`forloop',`pushdef(`$1',$2)_forloop(`$1',$2,$3,`$4')popdef(`$1')')dnl
+define(`_forloop',`$4`'ifelse($1,$3,`',`define(`$1',incr($1))_forloop(`$1',$2,$3,`$4')')')dnl
+define(`repeat',`forloop(`i',1,verbose_hex($1),`$2 ')')dnl
+define(`hexc2dec',`eval(10 + translit(`$1',`a-f',`0-5'))')dnl
+define(`hex2dec',`patsubst(translit(`$1',`A-F',`a-f'),`\([a-z]\)',`hexc2dec(\1)')')dnl
+define(`_hex',`ifelse(len($2),0,$3,`_hex(incr($1),substr($2,0,decr(len($2))),eval($3 + (hex2dec(substr($2,decr(len($2)))) * (16 ** $1))))')')dnl
+define(`verbose_hex',`patsubst(`$1',`\(0x\)\([0-9a-fA-F]*\)',`hex(\2)')')dnl
+define(`hex',`_hex(0,patsubst(`$1',`0x',`'),`0')')dnl
+dnl
+dnl main
+define(`INPUT',`include(`/dev/stdin')')dnl
+define(`NOCOMMENTS',`patsubst(`$1', `;.*', `')')dnl
+define(`ONELINE',`patsubst(`$1', `[ \t
+]', `')')dnl
+define(`BYTES',`patsubst(`$1',`\(..\)',`\1
+')')dnl
+define(`OUTPUT',`BYTES(ONELINE(NOCOMMENTS($1)))')dnl
+OUTPUT(INPUT())dnl