mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
Add a naive /bin/fgrep for testing pipes.
This commit is contained in:
parent
d5d45d1088
commit
18e3ddf605
8 changed files with 56 additions and 8 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue