Berry failed port attempt leftovers :(
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m9s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m9s
This commit is contained in:
@@ -132,33 +132,59 @@ char* strcat (char* dest, const char* src) {
|
||||
return rdest;
|
||||
}
|
||||
|
||||
int isalnum (int c) { return isalpha (c) || isdigit (c); }
|
||||
|
||||
int isalpha (int c) { return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'); }
|
||||
|
||||
int iscntrl (int c) { return (c >= 0 && c <= 32) || (c == 127); }
|
||||
|
||||
int isdigit (int c) { return (c >= '0' && c <= '9'); }
|
||||
|
||||
int isgraph (int c) { return (c > 32 && c <= 126); }
|
||||
|
||||
int islower (int c) { return (c >= 'A' && c <= 'z'); }
|
||||
|
||||
int isprint (int c) { return (c >= 32 && c <= 126); }
|
||||
|
||||
int ispunct (int c) { return isgraph (c) && !isalnum (c); }
|
||||
|
||||
int isspace (int c) {
|
||||
return (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v');
|
||||
int strncmp (const char* s1, const char* s2, size_t n) {
|
||||
while (n && *s1 && (*s1 == *s2)) {
|
||||
++s1;
|
||||
++s2;
|
||||
--n;
|
||||
}
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return (*(unsigned char*)s1 - *(unsigned char*)s2);
|
||||
}
|
||||
}
|
||||
|
||||
int isupper (int c) { return (c >= 'A' && c <= 'Z'); }
|
||||
/* https://stackoverflow.com/questions/49131175/recreate-the-strstr-function */
|
||||
char* strstr (const char* str, const char* substring) {
|
||||
const char* a;
|
||||
const char* b;
|
||||
|
||||
int isxdigit (int c) { return isdigit (c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); }
|
||||
b = substring;
|
||||
|
||||
int isascii (int c) { return (c >= 0 && c <= 127); }
|
||||
if (*b == 0) {
|
||||
return (char*)str;
|
||||
}
|
||||
|
||||
int isblank (int c) { return (c == ' ' || c == '\t'); }
|
||||
for (; *str != 0; str += 1) {
|
||||
if (*str != *b) {
|
||||
continue;
|
||||
}
|
||||
|
||||
a = str;
|
||||
while (1) {
|
||||
if (*b == 0) {
|
||||
return (char*)str;
|
||||
}
|
||||
if (*a++ != *b++) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
b = substring;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* https://github.com/gcc-mirror/gcc/blob/master/libiberty/strchr.c */
|
||||
char* strchr (register const char* s, int c) {
|
||||
do {
|
||||
if (*s == c) {
|
||||
return (char*)s;
|
||||
}
|
||||
} while (*s++);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* SOURCE: https://aticleworld.com/memmove-function-implementation-in-c/ */
|
||||
void* memmove (void* dest, const void* src, unsigned int n) {
|
||||
@@ -194,3 +220,43 @@ char* strncat (char* dest, const char* src, size_t n) {
|
||||
*ptr = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* https://stackoverflow.com/questions/14476627/strcpy-implementation-in-c */
|
||||
char* strcpy (char* strDest, const char* strSrc) {
|
||||
char* temp = strDest;
|
||||
while ((*strDest++ = *strSrc++))
|
||||
;
|
||||
return temp;
|
||||
}
|
||||
|
||||
int isalnum (int c) { return isalpha (c) || isdigit (c); }
|
||||
|
||||
int isalpha (int c) { return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'); }
|
||||
|
||||
int iscntrl (int c) { return (c >= 0 && c <= 32) || (c == 127); }
|
||||
|
||||
int isdigit (int c) { return (c >= '0' && c <= '9'); }
|
||||
|
||||
int isgraph (int c) { return (c > 32 && c <= 126); }
|
||||
|
||||
int islower (int c) { return (c >= 'A' && c <= 'z'); }
|
||||
|
||||
int isprint (int c) { return (c >= 32 && c <= 126); }
|
||||
|
||||
int ispunct (int c) { return isgraph (c) && !isalnum (c); }
|
||||
|
||||
int isspace (int c) {
|
||||
return (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v');
|
||||
}
|
||||
|
||||
int isupper (int c) { return (c >= 'A' && c <= 'Z'); }
|
||||
|
||||
int isxdigit (int c) { return isdigit (c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); }
|
||||
|
||||
int isascii (int c) { return (c >= 0 && c <= 127); }
|
||||
|
||||
int isblank (int c) { return (c == ' ' || c == '\t'); }
|
||||
|
||||
int tolower (int chr) { return (chr >= 'A' && chr <= 'Z') ? (chr + 32) : (chr); }
|
||||
|
||||
int toupper (int chr) { return (chr >= 'a' && chr <= 'z') ? (chr - 32) : (chr); }
|
||||
|
||||
@@ -39,6 +39,14 @@ void* memchr (const void* s, unsigned char c, size_t n);
|
||||
|
||||
void str_split_lines (const char* str, size_t total_len, void* ctx, strtokenize_cb_func_t cb);
|
||||
|
||||
char* strcpy (char* strDest, const char* strSrc);
|
||||
|
||||
int strncmp (const char* s1, const char* s2, size_t n);
|
||||
|
||||
char* strstr (const char* str, const char* substring);
|
||||
|
||||
char* strchr (register const char* s, int c);
|
||||
|
||||
int isalnum (int c);
|
||||
|
||||
int isalpha (int c);
|
||||
@@ -65,4 +73,8 @@ int isascii (int c);
|
||||
|
||||
int isblank (int c);
|
||||
|
||||
int tolower (int chr);
|
||||
|
||||
int toupper (int chr);
|
||||
|
||||
#endif // _LIBSTRING_STRING_H
|
||||
|
||||
Reference in New Issue
Block a user