| 804 | } |
| 805 | |
| 806 | static void sqlite_camel_split(sqlite3_context *ctx, int argc, sqlite3_value **argv) { |
| 807 | (void)argc; |
| 808 | const char *input = (const char *)sqlite3_value_text(argv[0]); |
| 809 | if (!input || !input[0]) { |
| 810 | sqlite3_result_text(ctx, input ? input : "", SQLITE_AUTO_LEN, CBM_SQLITE_TRANSIENT); |
| 811 | return; |
| 812 | } |
| 813 | char buf[CAMEL_SPLIT_BUF]; |
| 814 | int len = snprintf(buf, sizeof(buf), "%s ", input); |
| 815 | if (len < 0 || len >= (int)sizeof(buf)) { |
| 816 | /* Input too long — fall back to the original string unmodified. */ |
| 817 | sqlite3_result_text(ctx, input, SQLITE_AUTO_LEN, CBM_SQLITE_TRANSIENT); |
| 818 | return; |
| 819 | } |
| 820 | for (int i = 0; input[i] && len < (int)sizeof(buf) - CAMEL_BUF_GUARD; i++) { |
| 821 | if (camel_should_split(input, i)) { |
| 822 | buf[len++] = ' '; |
| 823 | } |
| 824 | buf[len++] = input[i]; |
| 825 | } |
| 826 | buf[len] = '\0'; |
| 827 | sqlite3_result_text(ctx, buf, len, CBM_SQLITE_TRANSIENT); |
| 828 | } |
| 829 | |
| 830 | /* ── REGEXP function for SQLite ──────────────────────────────────── */ |
| 831 |
nothing calls this directly
no test coverage detected