diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-31 23:33:22 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-31 23:33:22 -0400 |
| commit | 5fc7577b5a3bc2c445522dfd5b287e1c6eddc3e9 (patch) | |
| tree | 34d44c9330dc3ec71fc850b95b3412a1ce292cb8 /lib/base64 | |
| parent | a571ccffd795a595e990a3405dcf977aafc33c6c (diff) | |
Switch to using optional return values for list indexing.
Diffstat (limited to 'lib/base64')
| -rw-r--r-- | lib/base64/CHANGES.md | 4 | ||||
| -rw-r--r-- | lib/base64/base64.tm | 34 |
2 files changed, 21 insertions, 17 deletions
diff --git a/lib/base64/CHANGES.md b/lib/base64/CHANGES.md index 42ae752c..6c67c96d 100644 --- a/lib/base64/CHANGES.md +++ b/lib/base64/CHANGES.md @@ -1,5 +1,9 @@ # Version History +## v1.1 + +Update syntax for Tomo. + ## v1.0 Initial version diff --git a/lib/base64/base64.tm b/lib/base64/base64.tm index bf512a83..f31cfbc5 100644 --- a/lib/base64/base64.tm +++ b/lib/base64/base64.tm @@ -33,28 +33,28 @@ lang Base64 dest := Int64(1) while src + 2 <= Int64(bytes.length) chunk24 := ( - (Int32(bytes[src]) <<< 16) or (Int32(bytes[src+1]) <<< 8) or Int32(bytes[src+2]) + (Int32(bytes[src]!) <<< 16) or (Int32(bytes[src+1]!) <<< 8) or Int32(bytes[src+2]!) ) src += 3 - output[dest] = _enc[1 + ((chunk24 >>> 18) and 0b111111)] - output[dest+1] = _enc[1 + ((chunk24 >>> 12) and 0b111111)] - output[dest+2] = _enc[1 + ((chunk24 >>> 6) and 0b111111)] - output[dest+3] = _enc[1 + (chunk24 and 0b111111)] + output[dest] = _enc[1 + ((chunk24 >>> 18) and 0b111111)]! + output[dest+1] = _enc[1 + ((chunk24 >>> 12) and 0b111111)]! + output[dest+2] = _enc[1 + ((chunk24 >>> 6) and 0b111111)]! + output[dest+3] = _enc[1 + (chunk24 and 0b111111)]! dest += 4 if src + 1 == bytes.length chunk16 := ( - (Int32(bytes[src]) <<< 8) or Int32(bytes[src+1]) + (Int32(bytes[src]!) <<< 8) or Int32(bytes[src+1]!) ) - output[dest] = _enc[1 + ((chunk16 >>> 10) and 0b11111)] - output[dest+1] = _enc[1 + ((chunk16 >>> 4) and 0b111111)] - output[dest+2] = _enc[1 + ((chunk16 <<< 2)and 0b111111)] + output[dest] = _enc[1 + ((chunk16 >>> 10) and 0b11111)]! + output[dest+1] = _enc[1 + ((chunk16 >>> 4) and 0b111111)]! + output[dest+2] = _enc[1 + ((chunk16 <<< 2)and 0b111111)]! output[dest+3] = _EQUAL_BYTE else if src == bytes.length - chunk8 := Int32(bytes[src]) - output[dest] = _enc[1 + ((chunk8 >>> 2) and 0b111111)] - output[dest+1] = _enc[1 + ((chunk8 <<< 4) and 0b111111)] + chunk8 := Int32(bytes[src]!) + output[dest] = _enc[1 + ((chunk8 >>> 2) and 0b111111)]! + output[dest+1] = _enc[1 + ((chunk8 <<< 4) and 0b111111)]! output[dest+2] = _EQUAL_BYTE output[dest+3] = _EQUAL_BYTE @@ -70,10 +70,10 @@ lang Base64 dest := Int64(1) while src + 3 <= Int64(bytes.length) chunk24 := ( - (Int32(_dec[1+bytes[src]]) <<< 18) or - (Int32(_dec[1+bytes[src+1]]) <<< 12) or - (Int32(_dec[1+bytes[src+2]]) <<< 6) or - Int32(_dec[1+bytes[src+3]]) + (Int32(_dec[1+bytes[src]!]!) <<< 18) or + (Int32(_dec[1+bytes[src+1]!]!) <<< 12) or + (Int32(_dec[1+bytes[src+2]!]!) <<< 6) or + Int32(_dec[1+bytes[src+3]!]!) ) src += 4 @@ -82,7 +82,7 @@ lang Base64 output[dest+2] = Byte(chunk24 and 0xFF) dest += 3 - while output[-1] == 0xFF + while output[-1]! == 0xFF output[] = output.to(-2) return output[] |
