summaryrefslogtreecommitdiff
path: root/05/util.b
diff options
context:
space:
mode:
Diffstat (limited to '05/util.b')
-rw-r--r--05/util.b22
1 files changed, 22 insertions, 0 deletions
diff --git a/05/util.b b/05/util.b
index 51a98da..fc1aa1e 100644
--- a/05/util.b
+++ b/05/util.b
@@ -308,6 +308,28 @@ function fputn_signed
fputn(fd, n)
return
+function fputx
+ argument fd
+ argument n
+ local m
+ local x
+ m = 60
+ :fputx_loop
+ x = n > m
+ x &= 0xf
+ x += .hex_digits
+ fputc(fd, *1x)
+ m -= 4
+ if m >= 0 goto fputx_loop
+ return
+:hex_digits
+ string 0123456789abcdef
+
+function putx
+ argument n
+ fputx(1, n)
+ return
+
function putn
argument n
fputn(1, n)