fix other mandelbrot variants
[mu.git] / tools / expand_string_handle
blob0c739f65676a840a30c0a89be6358cb89e035a72
1 #!/bin/sh
2 # Expand syntax sugar for SubX string literals and show the corresponding handle definition.
4 # The handle has a fake alloc-id; we're never going to try to reclaim global
5 # variables, we just sometimes need handles in them to satisfy type constraints.
7 INPUT=$(cat)
8 echo " 0x11/imm32/alloc-id:fake:payload"
9 echo " # \"$INPUT\""
11 # print length in bytes
12 printf " 0x%x/imm32/size\n" $(echo -n $INPUT |wc -c)
14 # print ascii codes for each character in hex
15 echo -n " "
16 for c in $(echo "$INPUT" |sed -e 's/./& /g')
18 echo -n " 0x$(printf '%x' "'$c")/$c"
19 done
20 echo