* comparison runs for at most "n" characters.
*/
+// ARM implementation in ../arm/strncmp.s
+// ARM64 implementation in ../arm64/strncmp.s
int
strncmp(
const char *s1,
* Deprecation Warning:
* strcpy() is being deprecated. Please use strlcpy() instead.
*/
-#if !CONFIG_EMBEDDED
char *
strcpy(
char *to,
return ret;
}
-#endif
/*
* Abstract:
* to the "to" string.
*/
+// ARM and ARM64 implementation in ../arm/strncpy.c
char *
strncpy(
char *s1,
* outputs:
* length of s or max; whichever is smaller
*/
-size_t
+
+// ARM implementation in ../arm/strnlen.s
+// ARM64 implementation in ../arm64/strnlen.s
+size_t
strnlen(const char *s, size_t max) {
const char *es = s + max, *p = s;
while(*p && p != es)
* Deprecation Warning:
* strcat() is being deprecated. Please use strlcat() instead.
*/
-#if !CONFIG_EMBEDDED
char *
strcat(
char *dest,
;
return (old);
}
-#endif
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
+
+// ARM and ARM64 implementation in ../arm/strlcpy.c
size_t
strlcpy(char *dst, const char *src, size_t siz)
{
/*
* Return TRUE(1) if string 2 is a prefix of string 1.
- */
-int
-strprefix(register const char *s1, register const char *s2)
-{
- register int c;
-
- while ((c = *s2++) != '\0') {
- if (c != *s1++)
- return (0);
- }
- return (1);
+ */
+int
+strprefix(const char *s1, const char *s2)
+{
+ int c;
+
+ while ((c = *s2++) != '\0') {
+ if (c != *s1++)
+ return (0);
+ }
+ return (1);
+}
+
+char *
+strnstr(char *s, const char *find, size_t slen)
+{
+ char c, sc;
+ size_t len;
+
+ if ((c = *find++) != '\0') {
+ len = strlen(find);
+ do {
+ do {
+ if ((sc = *s++) == '\0' || slen-- < 1)
+ return (NULL);
+ } while (sc != c);
+ if (len > slen)
+ return (NULL);
+ } while (strncmp(s, find, len) != 0);
+ s--;
+ }
+ return (s);
}