diff options
| author | yazevnul <[email protected]> | 2022-02-10 16:46:46 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:46:46 +0300 |
| commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
| tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 /contrib/libs/base64/plain32/dec_uint32.c | |
| parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/base64/plain32/dec_uint32.c')
| -rw-r--r-- | contrib/libs/base64/plain32/dec_uint32.c | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/contrib/libs/base64/plain32/dec_uint32.c b/contrib/libs/base64/plain32/dec_uint32.c index db701d73d41..58fd78c7422 100644 --- a/contrib/libs/base64/plain32/dec_uint32.c +++ b/contrib/libs/base64/plain32/dec_uint32.c @@ -1,50 +1,50 @@ -// If we have native uint32's, pick off 4 bytes at a time for as long as we -// can, but make sure that we quit before seeing any == markers at the end of -// the string. Also, because we write a zero at the end of the output, ensure -// that there are at least 2 valid bytes of input data remaining to close the -// gap. 4 + 2 + 2 = 8 bytes: -while (srclen >= 8) -{ - uint32_t str, res, dec; - - // Load string: +// If we have native uint32's, pick off 4 bytes at a time for as long as we +// can, but make sure that we quit before seeing any == markers at the end of +// the string. Also, because we write a zero at the end of the output, ensure +// that there are at least 2 valid bytes of input data remaining to close the +// gap. 4 + 2 + 2 = 8 bytes: +while (srclen >= 8) +{ + uint32_t str, res, dec; + + // Load string: //str = *(uint32_t *)c; memcpy(&str, c, sizeof(str)); - - // Shuffle bytes to 32-bit bigendian: - str = cpu_to_be32(str); - - // Lookup each byte in the decoding table; if we encounter any - // "invalid" values, fall back on the bytewise code: - if ((dec = plain32_base64_table_dec[str >> 24]) > 63) { - break; - } - res = dec << 26; - - if ((dec = plain32_base64_table_dec[(str >> 16) & 0xFF]) > 63) { - break; - } - res |= dec << 20; - - if ((dec = plain32_base64_table_dec[(str >> 8) & 0xFF]) > 63) { - break; - } - res |= dec << 14; - - if ((dec = plain32_base64_table_dec[str & 0xFF]) > 63) { - break; - } - res |= dec << 8; - - // Reshuffle and repack into 3-byte output format: - res = be32_to_cpu(res); - - // Store back: + + // Shuffle bytes to 32-bit bigendian: + str = cpu_to_be32(str); + + // Lookup each byte in the decoding table; if we encounter any + // "invalid" values, fall back on the bytewise code: + if ((dec = plain32_base64_table_dec[str >> 24]) > 63) { + break; + } + res = dec << 26; + + if ((dec = plain32_base64_table_dec[(str >> 16) & 0xFF]) > 63) { + break; + } + res |= dec << 20; + + if ((dec = plain32_base64_table_dec[(str >> 8) & 0xFF]) > 63) { + break; + } + res |= dec << 14; + + if ((dec = plain32_base64_table_dec[str & 0xFF]) > 63) { + break; + } + res |= dec << 8; + + // Reshuffle and repack into 3-byte output format: + res = be32_to_cpu(res); + + // Store back: //*(uint32_t *)o = res; memcpy(o, &res, sizeof(res)); - - c += 4; - o += 3; - outl += 3; - srclen -= 4; -} + + c += 4; + o += 3; + outl += 3; + srclen -= 4; +} |
