|
1 |
| -/* auto-generated on 2024-11-12 20:00:19 -0500. Do not edit! */ |
| 1 | +/* auto-generated on 2024-11-14 14:52:31 -0500. Do not edit! */ |
2 | 2 | /* begin file src/simdutf.cpp */
|
3 | 3 | #include "simdutf.h"
|
4 | 4 | // We include base64_tables once.
|
@@ -7229,6 +7229,11 @@ template <class char_type> bool is_ascii_white_space(char_type c) {
|
7229 | 7229 | return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f';
|
7230 | 7230 | }
|
7231 | 7231 |
|
| 7232 | +template <class char_type> bool is_ascii_white_space_or_padding(char_type c) { |
| 7233 | + return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || |
| 7234 | + c == '='; |
| 7235 | +} |
| 7236 | + |
7232 | 7237 | template <class char_type> bool is_eight_byte(char_type c) {
|
7233 | 7238 | if (sizeof(char_type) == 1) {
|
7234 | 7239 | return true;
|
@@ -9491,6 +9496,21 @@ simdutf_warn_unused result base64_to_binary_safe_impl(
|
9491 | 9496 | if (r.error != error_code::INVALID_BASE64_CHARACTER &&
|
9492 | 9497 | r.error != error_code::BASE64_EXTRA_BITS) {
|
9493 | 9498 | outlen = r.output_count;
|
| 9499 | + if (last_chunk_handling_options == stop_before_partial) { |
| 9500 | + if ((r.output_count % 3) != 0) { |
| 9501 | + bool empty_trail = true; |
| 9502 | + for (size_t i = r.input_count; i < length; i++) { |
| 9503 | + if (!scalar::base64::is_ascii_white_space_or_padding(input[i])) { |
| 9504 | + empty_trail = false; |
| 9505 | + break; |
| 9506 | + } |
| 9507 | + } |
| 9508 | + if (empty_trail) { |
| 9509 | + r.input_count = length; |
| 9510 | + } |
| 9511 | + } |
| 9512 | + return {r.error, r.input_count}; |
| 9513 | + } |
9494 | 9514 | return {r.error, length};
|
9495 | 9515 | }
|
9496 | 9516 | return r;
|
@@ -9557,7 +9577,11 @@ simdutf_warn_unused result base64_to_binary_safe_impl(
|
9557 | 9577 | }
|
9558 | 9578 | if (rr.error == error_code::SUCCESS &&
|
9559 | 9579 | last_chunk_handling_options == stop_before_partial) {
|
9560 |
| - rr.count = tail_input - input; |
| 9580 | + if (tail_input > input + input_index) { |
| 9581 | + rr.count = tail_input - input; |
| 9582 | + } else if (r.input_count > 0) { |
| 9583 | + rr.count = r.input_count + rr.count; |
| 9584 | + } |
9561 | 9585 | return rr;
|
9562 | 9586 | }
|
9563 | 9587 | rr.count += input_index;
|
@@ -15891,9 +15915,9 @@ compress_decode_base64(char *dst, const char_type *src, size_t srclen,
|
15891 | 15915 | if (src < srcend + equalsigns) {
|
15892 | 15916 | full_result r = scalar::base64::base64_tail_decode(
|
15893 | 15917 | dst, src, srcend - src, equalsigns, options, last_chunk_options);
|
| 15918 | + r.input_count += size_t(src - srcinit); |
15894 | 15919 | if (r.error == error_code::INVALID_BASE64_CHARACTER ||
|
15895 | 15920 | r.error == error_code::BASE64_EXTRA_BITS) {
|
15896 |
| - r.input_count += size_t(src - srcinit); |
15897 | 15921 | return r;
|
15898 | 15922 | } else {
|
15899 | 15923 | r.output_count += size_t(dst - dstinit);
|
@@ -23716,9 +23740,9 @@ compress_decode_base64(char *dst, const chartype *src, size_t srclen,
|
23716 | 23740 | if (src < srcend + equalsigns) {
|
23717 | 23741 | full_result r = scalar::base64::base64_tail_decode(
|
23718 | 23742 | dst, src, srcend - src, equalsigns, options, last_chunk_options);
|
| 23743 | + r.input_count += size_t(src - srcinit); |
23719 | 23744 | if (r.error == error_code::INVALID_BASE64_CHARACTER ||
|
23720 | 23745 | r.error == error_code::BASE64_EXTRA_BITS) {
|
23721 |
| - r.input_count += size_t(src - srcinit); |
23722 | 23746 | return r;
|
23723 | 23747 | } else {
|
23724 | 23748 | r.output_count += size_t(dst - dstinit);
|
@@ -28552,9 +28576,9 @@ compress_decode_base64(char *dst, const chartype *src, size_t srclen,
|
28552 | 28576 | if (src < srcend + equalsigns) {
|
28553 | 28577 | full_result r = scalar::base64::base64_tail_decode(
|
28554 | 28578 | dst, src, srcend - src, equalsigns, options, last_chunk_options);
|
| 28579 | + r.input_count += size_t(src - srcinit); |
28555 | 28580 | if (r.error == error_code::INVALID_BASE64_CHARACTER ||
|
28556 | 28581 | r.error == error_code::BASE64_EXTRA_BITS) {
|
28557 |
| - r.input_count += size_t(src - srcinit); |
28558 | 28582 | return r;
|
28559 | 28583 | } else {
|
28560 | 28584 | r.output_count += size_t(dst - dstinit);
|
@@ -38307,9 +38331,9 @@ compress_decode_base64(char *dst, const chartype *src, size_t srclen,
|
38307 | 38331 | if (src < srcend + equalsigns) {
|
38308 | 38332 | full_result r = scalar::base64::base64_tail_decode(
|
38309 | 38333 | dst, src, srcend - src, equalsigns, options, last_chunk_options);
|
| 38334 | + r.input_count += size_t(src - srcinit); |
38310 | 38335 | if (r.error == error_code::INVALID_BASE64_CHARACTER ||
|
38311 | 38336 | r.error == error_code::BASE64_EXTRA_BITS) {
|
38312 |
| - r.input_count += size_t(src - srcinit); |
38313 | 38337 | return r;
|
38314 | 38338 | } else {
|
38315 | 38339 | r.output_count += size_t(dst - dstinit);
|
|
0 commit comments