Encode numeric string for natural sorting. @param[in] in - start of the numeric string skipping leading zeros @param[in] n_digits - length of the string, in characters, not counting leading zeros. @param[out] out - String to write to. The string should have enough preallocated space to fit the encoded key. @return NATSORT_ERR::SUCCESS - success NATSORT_ERR::KEY_
| 5714 | CONCAT(natsort_encode_length(n_digits), in) |
| 5715 | */ |
| 5716 | static NATSORT_ERR natsort_encode_numeric_string(const char *in, |
| 5717 | size_t n_digits, |
| 5718 | String *out) |
| 5719 | { |
| 5720 | DBUG_ASSERT(in); |
| 5721 | DBUG_ASSERT(n_digits); |
| 5722 | |
| 5723 | if (out->length() + natsort_encode_length_max(n_digits - 1) + n_digits > |
| 5724 | out->alloced_length()) |
| 5725 | return NATSORT_ERR::KEY_TOO_LARGE; |
| 5726 | |
| 5727 | natsort_encode_length(n_digits - 1, out); |
| 5728 | out->append(in, n_digits); |
| 5729 | return NATSORT_ERR::SUCCESS; |
| 5730 | } |
| 5731 | |
| 5732 | /* |
| 5733 | Calculate max size of the natsort key. |
no test coverage detected