Merge pull request #243 from avdgrinten/fix-ansi-build
Fix ANSI-only build after strcasestr() implementation
This commit is contained in:
commit
91a0ad612a
|
@ -1,5 +1,4 @@
|
|||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <errno.h>
|
||||
#include <wchar.h>
|
||||
#include <ctype.h>
|
||||
|
@ -224,18 +223,6 @@ char *strchrnul(const char *s, int c) {
|
|||
return const_cast<char *>(s + i);
|
||||
}
|
||||
|
||||
char *strcasestr(const char *s, const char *pattern) {
|
||||
size_t plen = strlen(pattern);
|
||||
const char *p = s;
|
||||
while(*p) {
|
||||
// Need strncasecmp() to avoid checking past the end of a successful match.
|
||||
if(!strncasecmp(p, pattern, plen))
|
||||
return const_cast<char *>(p);
|
||||
++p;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
double wcstod(const wchar_t *__restrict, wchar_t **__restrict) MLIBC_STUB_BODY
|
||||
float wcstof(const wchar_t *__restrict, wchar_t **__restrict) MLIBC_STUB_BODY
|
||||
long double wcstold(const wchar_t *__restrict, wchar_t **__restrict) MLIBC_STUB_BODY
|
||||
|
|
|
@ -42,7 +42,6 @@ char *strtok(char *__restrict s, const char *__restrict delimiter);
|
|||
|
||||
// This is a GNU extension.
|
||||
char *strchrnul(const char *, int);
|
||||
char *strcasestr(const char *, const char *);
|
||||
|
||||
// [7.24.6] Miscellaneous functions
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include <bits/ensure.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <mlibc/debug.hpp>
|
||||
|
@ -101,3 +101,14 @@ char *strsignal(int sig) {
|
|||
return const_cast<char *>(s);
|
||||
}
|
||||
|
||||
char *strcasestr(const char *s, const char *pattern) {
|
||||
size_t plen = strlen(pattern);
|
||||
const char *p = s;
|
||||
while(*p) {
|
||||
// Need strncasecmp() to avoid checking past the end of a successful match.
|
||||
if(!strncasecmp(p, pattern, plen))
|
||||
return const_cast<char *>(p);
|
||||
++p;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@ char *strsignal(int sig);
|
|||
|
||||
int strcoll_l(const char *s1, const char *s2, locale_t locale);
|
||||
|
||||
// GNU extensions.
|
||||
char *strcasestr(const char *, const char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue