ZstrFindSubstring
Description
Find first occurrence of needle in haystack.
Success
Returns pointer to first occurrence or NULL if not found.
Failure
Aborts via LOG_FATAL when either pointer is NULL.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Zstr.c:331:
}
Zstr ZstrFindSubstring(Zstr haystack, Zstr needle) {
if (!needle) {
LOG_FATAL("Invalid arguments");- In
BitVec.c:1862:
bool result = false;
if (ZstrFindSubstring(StrBegin(&bv_str), pattern) != NULL) {
result = true;
}- In
Str.c:246:
Zstr str_find_zstr(const Str *s, Zstr key) {
ValidateStr(s);
return ZstrFindSubstring(StrBegin(s), key);
}- In
Http.c:52:
// - includes a Content-Length: 11 (length of "<h1>hi</h1>")
// - ends with the body
bool ok = StrLen(&wire) > 0 && ZstrFindSubstring(StrBegin(&wire), "HTTP/1.1 200 OK\r\n") == StrBegin(&wire) &&
ZstrFindSubstring(StrBegin(&wire), "Content-Type: text/html\r\n") != NULL &&
ZstrFindSubstring(StrBegin(&wire), "Content-Length: 11\r\n") != NULL &&- In
Http.c:53:
// - ends with the body
bool ok = StrLen(&wire) > 0 && ZstrFindSubstring(StrBegin(&wire), "HTTP/1.1 200 OK\r\n") == StrBegin(&wire) &&
ZstrFindSubstring(StrBegin(&wire), "Content-Type: text/html\r\n") != NULL &&
ZstrFindSubstring(StrBegin(&wire), "Content-Length: 11\r\n") != NULL &&
ZstrFindSubstring(StrBegin(&wire), "\r\n\r\n<h1>hi</h1>") != NULL;- In
Http.c:54:
bool ok = StrLen(&wire) > 0 && ZstrFindSubstring(StrBegin(&wire), "HTTP/1.1 200 OK\r\n") == StrBegin(&wire) &&
ZstrFindSubstring(StrBegin(&wire), "Content-Type: text/html\r\n") != NULL &&
ZstrFindSubstring(StrBegin(&wire), "Content-Length: 11\r\n") != NULL &&
ZstrFindSubstring(StrBegin(&wire), "\r\n\r\n<h1>hi</h1>") != NULL;- In
Http.c:55:
ZstrFindSubstring(StrBegin(&wire), "Content-Type: text/html\r\n") != NULL &&
ZstrFindSubstring(StrBegin(&wire), "Content-Length: 11\r\n") != NULL &&
ZstrFindSubstring(StrBegin(&wire), "\r\n\r\n<h1>hi</h1>") != NULL;
StrDeinit(&wire);- In
Backtrace.c:41:
// (Apple's C mangling prepends `_`; substring search matches both
// "bt_capture_with_helper" and "_bt_capture_with_helper".)
bool ok = StrLen(&rendered) > 0 && ZstrFindSubstring(StrBegin(&rendered), "bt_capture_with_helper") != NULL &&
ZstrFindSubstring(StrBegin(&rendered), "bt_capture_outer") != NULL;- In
Backtrace.c:42:
// "bt_capture_with_helper" and "_bt_capture_with_helper".)
bool ok = StrLen(&rendered) > 0 && ZstrFindSubstring(StrBegin(&rendered), "bt_capture_with_helper") != NULL &&
ZstrFindSubstring(StrBegin(&rendered), "bt_capture_outer") != NULL;
#if FEATURE_SYS_SYMRESOLVE- In
Backtrace.c:48:
// the Linux backend emits source filenames today (via DwarfLines);
// macOS / Windows only emit names + offsets.
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "Backtrace.c") != NULL;
#endif- In
Backtrace.c:81:
ok = ok && StrLen(&rendered) > 0;
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "bt_vec_capture_with_helper") != NULL;
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "bt_vec_capture_outer") != NULL;- In
Backtrace.c:82:
ok = ok && StrLen(&rendered) > 0;
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "bt_vec_capture_with_helper") != NULL;
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "bt_vec_capture_outer") != NULL;
StrDeinit(&rendered);- In
Backtrace.c:111:
// Should also contain the helper name through the shared resolver.
bool ok = StrLen(&out) > 0 && ZstrFindSubstring(StrBegin(&out), "bt_capture_with_helper") != NULL;
StrDeinit(&out);- In
Backtrace.c:154:
bool ok = n >= 2;
ok = ok && StrLen(&rendered) > 0;
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "cfi_capture_inner") != NULL;
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "cfi_capture_outer") != NULL;- In
Backtrace.c:155:
ok = ok && StrLen(&rendered) > 0;
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "cfi_capture_inner") != NULL;
ok = ok && ZstrFindSubstring(StrBegin(&rendered), "cfi_capture_outer") != NULL;
StrDeinit(&rendered); ResolvedSymbol r;
bool ok = SymbolResolverResolve(&res, (void *)&symres_marker_helper, &r);
ok = ok && r.symbol_name != NULL && ZstrFindSubstring(r.symbol_name, "symres_marker_helper") != NULL;
SymbolResolverDeinit(&res);- In
MachO.c:264:
const MachoSymbol *sym = MachoResolveAddress(&m, vaddr);
bool ok = sym != NULL && sym->name != NULL &&
ZstrFindSubstring(sym->name, "test_macho_resolves_running_binary_symbol") != NULL;
MachoDeinit(&m);- In
AllocDebug.c:128:
bool ok = StrLen(&out) > 0;
ok = ok && (ZstrFindSubstring(StrBegin(&out), "leak:") != NULL);
ok = ok && (ZstrFindSubstring(StrBegin(&out), "24 bytes") != NULL);
ok = ok && (ZstrFindSubstring(StrBegin(&out), "40 bytes") != NULL);- In
AllocDebug.c:129:
bool ok = StrLen(&out) > 0;
ok = ok && (ZstrFindSubstring(StrBegin(&out), "leak:") != NULL);
ok = ok && (ZstrFindSubstring(StrBegin(&out), "24 bytes") != NULL);
ok = ok && (ZstrFindSubstring(StrBegin(&out), "40 bytes") != NULL);- In
AllocDebug.c:130:
ok = ok && (ZstrFindSubstring(StrBegin(&out), "leak:") != NULL);
ok = ok && (ZstrFindSubstring(StrBegin(&out), "24 bytes") != NULL);
ok = ok && (ZstrFindSubstring(StrBegin(&out), "40 bytes") != NULL);
StrDeinit(&out);- In
Dwarf.c:71:
if (built) {
const DwarfLineEntry *e = DwarfLinesResolve(&lines, file_relative);
if (e && e->file && ZstrFindSubstring(e->file, "Dwarf.c") != NULL && e->line > 0) {
ok = true;
}- In
Dwarf.c:173:
if (built && VecLen(&fns.entries) > 0) {
const DwarfFunction *f = DwarfFunctionsResolve(&fns, file_relative);
ok = f != NULL && f->name != NULL && ZstrFindSubstring(f->name, "dwarf_marker_helper") != NULL;
DwarfFunctionsDeinit(&fns);
} if (built && VecLen(&fns.entries) > 0) {
const DwarfFunction *f = DwarfFunctionsResolve(&fns, file_relative);
ok = f && f->name && ZstrFindSubstring(f->name, expect_name) != NULL;
DwarfFunctionsDeinit(&fns);
}
Last updated on