diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-01-12 16:54:37 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-01-12 16:54:37 -0500 |
| commit | c60ea2079fb230213308904cd0966e5481d2d994 (patch) | |
| tree | 630bcb480bfcdd2dc4aec5ecb4a2f8d1daa6475a /examples/base64/base64.tm | |
| parent | 645d66e0de0f201404d9ad4b210f90c139a247ff (diff) | |
Fix up examples
Diffstat (limited to 'examples/base64/base64.tm')
| -rw-r--r-- | examples/base64/base64.tm | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/base64/base64.tm b/examples/base64/base64.tm index 52af6e89..6979b157 100644 --- a/examples/base64/base64.tm +++ b/examples/base64/base64.tm @@ -29,7 +29,7 @@ lang Base64: return Base64.from_bytes(text:bytes()) func from_bytes(bytes:[Byte] -> Base64?): - output := [Byte(0) for _ in bytes.length * 4 / 3 + 4] + output := &[Byte(0) for _ in bytes.length * 4 / 3 + 4] src := Int64(1) dest := Int64(1) while src + 2 <= bytes.length: @@ -59,14 +59,14 @@ lang Base64: output[dest+2] = _EQUAL_BYTE output[dest+3] = _EQUAL_BYTE - return Base64.without_escaping(Text.from_bytes(output) or return none) + return Base64.without_escaping(Text.from_bytes(output[]) or return none) func decode_text(b64:Base64 -> Text?): return Text.from_bytes(b64:decode_bytes() or return none) func decode_bytes(b64:Base64 -> [Byte]?): bytes := b64.text_content:bytes() - output := [Byte(0) for _ in bytes.length/4 * 3] + output := &[Byte(0) for _ in bytes.length/4 * 3] src := Int64(1) dest := Int64(1) while src + 3 <= bytes.length: @@ -84,9 +84,9 @@ lang Base64: dest += 3 while output[-1] == 0xFF: - output = output:to(-2) + output[] = output:to(-2) - return output + return output[] func main(input=(/dev/stdin), decode=no): if decode: |
