Add a naive /bin/fgrep for testing pipes.

This commit is contained in:
Andreas Kling 2018-11-11 20:42:41 +01:00
commit 18e3ddf605
Notes: sideshowbarker 2024-07-19 16:11:03 +09:00
8 changed files with 56 additions and 8 deletions

View file

@ -191,4 +191,23 @@ char* strsignal(int signum)
return const_cast<char*>(sys_siglist[signum]);
}
char* strstr(const char* haystack, const char* needle)
{
char nch;
char hch;
if ((nch = *needle++) != 0) {
size_t len = strlen(needle);
do {
do {
if ((hch = *haystack++) == 0)
return nullptr;
} while (hch != nch);
} while (strncmp(haystack, needle, len) != 0);
--haystack;
}
return const_cast<char*>(haystack);
}
}