| 517 | } |
| 518 | |
| 519 | inline std::vector<std::string> split_string(std::string str, |
| 520 | long maxsplit = -1, |
| 521 | std::string delims = " \t") { |
| 522 | std::vector<std::string> results; |
| 523 | if (maxsplit == 0) { |
| 524 | results.push_back(str); |
| 525 | return results; |
| 526 | } |
| 527 | // Note: +1 to include NULL-terminator |
| 528 | std::vector<char> v_str(str.c_str(), str.c_str() + (str.size() + 1)); |
| 529 | char* c_str = v_str.data(); |
| 530 | char* saveptr = c_str; |
| 531 | char* token = nullptr; |
| 532 | for (long i = 0; i != maxsplit; ++i) { |
| 533 | token = ::strtok_r(c_str, delims.c_str(), &saveptr); |
| 534 | c_str = 0; |
| 535 | if (!token) { |
| 536 | return results; |
| 537 | } |
| 538 | results.push_back(token); |
| 539 | } |
| 540 | // Check if there's a final piece |
| 541 | token += ::strlen(token) + 1; |
| 542 | if (token - v_str.data() < (ptrdiff_t)str.size()) { |
| 543 | // Find the start of the final piece |
| 544 | token += ::strspn(token, delims.c_str()); |
| 545 | if (*token) { |
| 546 | results.push_back(token); |
| 547 | } |
| 548 | } |
| 549 | return results; |
| 550 | } |
| 551 | |
| 552 | static const std::map<std::string, std::string>& get_jitsafe_headers_map(); |
| 553 |
no outgoing calls
no test coverage detected