diff options
author | Marvin Borner | 2020-06-17 18:31:46 +0200 |
---|---|---|
committer | Marvin Borner | 2020-06-17 18:31:46 +0200 |
commit | eed77bd2970a00d1394ed027ceca5b646e4671ce (patch) | |
tree | c44643d98aed2b6818f2b33417c0dea9c5853094 /src/userspace/libc/string | |
parent | 49dfa1f4021026bf7c4d77817959c8aa24067016 (diff) |
Started rewrite
Diffstat (limited to 'src/userspace/libc/string')
-rw-r--r-- | src/userspace/libc/string/strcat.c | 12 | ||||
-rw-r--r-- | src/userspace/libc/string/strcati.c | 10 | ||||
-rw-r--r-- | src/userspace/libc/string/strcmp.c | 14 | ||||
-rw-r--r-- | src/userspace/libc/string/strcpy.c | 11 | ||||
-rw-r--r-- | src/userspace/libc/string/strdisp.c | 15 | ||||
-rw-r--r-- | src/userspace/libc/string/strdup.c | 12 | ||||
-rw-r--r-- | src/userspace/libc/string/strinv.c | 14 | ||||
-rw-r--r-- | src/userspace/libc/string/strlen.c | 9 | ||||
-rw-r--r-- | src/userspace/libc/string/strncmp.c | 16 | ||||
-rw-r--r-- | src/userspace/libc/string/strsep.c | 25 | ||||
-rw-r--r-- | src/userspace/libc/string/strstr.c | 25 |
11 files changed, 0 insertions, 163 deletions
diff --git a/src/userspace/libc/string/strcat.c b/src/userspace/libc/string/strcat.c deleted file mode 100644 index bb8f09b..0000000 --- a/src/userspace/libc/string/strcat.c +++ /dev/null @@ -1,12 +0,0 @@ -#include <stdint.h> -#include <string.h> - -void strcat(char *dest, char *orig) -{ - u32 s_dest = strlen(dest); - u32 s_orig = strlen(orig); - - for (u32 i = 0; i < s_orig; i++) - dest[s_dest + i] = orig[i]; - dest[s_dest + s_orig] = 0; -}
\ No newline at end of file diff --git a/src/userspace/libc/string/strcati.c b/src/userspace/libc/string/strcati.c deleted file mode 100644 index d82fbfc..0000000 --- a/src/userspace/libc/string/strcati.c +++ /dev/null @@ -1,10 +0,0 @@ -#include <stdint.h> -#include <string.h> - -void strcati(char *dest, char *orig) -{ - u32 s_orig = strlen(orig); - strdisp(dest, (int)s_orig); - for (u32 i = 0; i < s_orig; i++) - dest[i] = orig[i]; -}
\ No newline at end of file diff --git a/src/userspace/libc/string/strcmp.c b/src/userspace/libc/string/strcmp.c deleted file mode 100644 index 932877d..0000000 --- a/src/userspace/libc/string/strcmp.c +++ /dev/null @@ -1,14 +0,0 @@ -#include <stdint.h> -#include <string.h> - -char strcmp(char *a, char *b) -{ - if (strlen(a) != strlen(b)) - return 1; - - for (u32 i = 0; i < strlen(a); i++) - if (a[i] != b[i]) - return 1; - - return 0; -}
\ No newline at end of file diff --git a/src/userspace/libc/string/strcpy.c b/src/userspace/libc/string/strcpy.c deleted file mode 100644 index a12d3e0..0000000 --- a/src/userspace/libc/string/strcpy.c +++ /dev/null @@ -1,11 +0,0 @@ -#include <stdint.h> -#include <string.h> - -void strcpy(char *dest, char *orig) -{ - u32 s_orig = strlen(orig); - - for (u32 i = 0; i < s_orig; i++) - dest[i] = orig[i]; - dest[s_orig] = 0; -}
\ No newline at end of file diff --git a/src/userspace/libc/string/strdisp.c b/src/userspace/libc/string/strdisp.c deleted file mode 100644 index 88815ef..0000000 --- a/src/userspace/libc/string/strdisp.c +++ /dev/null @@ -1,15 +0,0 @@ -#include <stdint.h> -#include <string.h> - -void strdisponce(char *str) -{ - for (u32 i = sizeof(str) + 2; i > 0; i--) - str[i] = str[i - 1]; - str[0] = 0; -} - -void strdisp(char *str, int n) -{ - for (int i = 0; i < n; i++) - strdisponce(str); -}
\ No newline at end of file diff --git a/src/userspace/libc/string/strdup.c b/src/userspace/libc/string/strdup.c deleted file mode 100644 index a42b02d..0000000 --- a/src/userspace/libc/string/strdup.c +++ /dev/null @@ -1,12 +0,0 @@ -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -char *strdup(char *orig) -{ - u32 s_orig = strlen(orig); - char *ret = (char *)malloc(s_orig + 1); - strcpy(ret, orig); - return ret; -}
\ No newline at end of file diff --git a/src/userspace/libc/string/strinv.c b/src/userspace/libc/string/strinv.c deleted file mode 100644 index 261e57e..0000000 --- a/src/userspace/libc/string/strinv.c +++ /dev/null @@ -1,14 +0,0 @@ -#include <stdint.h> -#include <string.h> - -void strinv(char *str) -{ - u32 s_str = strlen(str); - - int iterations = (int)s_str / 2; - for (int i = 0; i < iterations; i++) { - char aux = str[i]; - str[i] = str[(s_str - i) - 1]; - str[(s_str - i) - 1] = aux; - } -}
\ No newline at end of file diff --git a/src/userspace/libc/string/strlen.c b/src/userspace/libc/string/strlen.c deleted file mode 100644 index cb04675..0000000 --- a/src/userspace/libc/string/strlen.c +++ /dev/null @@ -1,9 +0,0 @@ -#include <stdint.h> - -u32 strlen(char *str) -{ - u32 len = 0; - while (str[len]) - len++; - return len; -}
\ No newline at end of file diff --git a/src/userspace/libc/string/strncmp.c b/src/userspace/libc/string/strncmp.c deleted file mode 100644 index 450fbd8..0000000 --- a/src/userspace/libc/string/strncmp.c +++ /dev/null @@ -1,16 +0,0 @@ -int strncmp(char *s1, char *s2, int c) -{ - int result = 0; - - while (c) { - result = *s1 - *s2++; - - if ((result != 0) || (*s1++ == 0)) { - break; - } - - c--; - } - - return result; -}
\ No newline at end of file diff --git a/src/userspace/libc/string/strsep.c b/src/userspace/libc/string/strsep.c deleted file mode 100644 index badbf0f..0000000 --- a/src/userspace/libc/string/strsep.c +++ /dev/null @@ -1,25 +0,0 @@ -#include <stddef.h> - -char *strsep(char **stringp, char *delim) -{ - char *s; - const char *spanp; - int c, sc; - char *tok; - if ((s = *stringp) == NULL) - return (NULL); - for (tok = s;;) { - c = *s++; - spanp = delim; - do { - if ((sc = *spanp++) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - *stringp = s; - return (tok); - } - } while (sc != 0); - } -}
\ No newline at end of file diff --git a/src/userspace/libc/string/strstr.c b/src/userspace/libc/string/strstr.c deleted file mode 100644 index c87f3fc..0000000 --- a/src/userspace/libc/string/strstr.c +++ /dev/null @@ -1,25 +0,0 @@ -#include <stdint.h> -#include <string.h> - -char *strstr(char *in, char *str) -{ - char c; - u32 len; - - c = *str++; - if (!c) - return (char *)in; - - len = strlen(str); - do { - char sc; - - do { - sc = *in++; - if (!sc) - return (char *)0; - } while (sc != c); - } while (strncmp(in, str, len) != 0); - - return (char *)(in - 1); -}
\ No newline at end of file |