MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / find_first_substr

Function find_first_substr

plugins/plugin_utils/plugin_utils.cpp:430–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

428}
429
430size_t find_first_substr(const std::string& findin, const std::string findwhat, size_t offset) {
431 if (findwhat.size()) {
432 for (size_t f = offset; f < findin.size(); f++) {
433 if (findin[f] == findwhat[0]) {
434 size_t start = f;
435 for (size_t w = 1; w < findwhat.size(); w++) {
436 if (f + w > findin.size()) {
437 return std::string::npos;
438 }
439 if (findin[f + w] != findwhat[w]) {
440 f += w;
441 w = findwhat.size();
442 }
443 }
444 if (start == f) {
445 return f;
446 }
447 }
448 }
449 }
450 return std::string::npos;
451}
452
453std::string getStringRange(const std::string& find, size_t start, size_t end) {
454 std::string ret;

Callers 3

getTemplateMetaDataMethod · 0.85
pendingMethod · 0.85
handleAuthedRequestMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected