diff options
author | Marvin Borner | 2019-12-21 22:22:03 +0100 |
---|---|---|
committer | Marvin Borner | 2019-12-21 22:22:03 +0100 |
commit | 499784a824c541001c2fd52ae95eba88dcfc952b (patch) | |
tree | c3c26d7c8a3b9291d909f4655b7d27a5ae2369bc /src/userspace/mlibc | |
parent | 38610cd06dc0b5a3a4ee46f5fe7c341191aa2bc1 (diff) |
Many debugging/serial improvements
Sorry for the little information, but I did many things :)
Diffstat (limited to 'src/userspace/mlibc')
-rw-r--r-- | src/userspace/mlibc/stdio/readline.c | 6 | ||||
-rw-r--r-- | src/userspace/mlibc/stdio/vprintf.c | 8 | ||||
-rw-r--r-- | src/userspace/mlibc/stdlib/atoi.c | 2 | ||||
-rw-r--r-- | src/userspace/mlibc/stdlib/htoa.c | 6 | ||||
-rw-r--r-- | src/userspace/mlibc/stdlib/htoi.c | 2 | ||||
-rw-r--r-- | src/userspace/mlibc/stdlib/itoa.c | 5 | ||||
-rw-r--r-- | src/userspace/mlibc/string/strcat.c | 2 | ||||
-rw-r--r-- | src/userspace/mlibc/string/strcati.c | 2 | ||||
-rw-r--r-- | src/userspace/mlibc/string/strcmp.c | 2 | ||||
-rw-r--r-- | src/userspace/mlibc/string/strcpy.c | 2 | ||||
-rw-r--r-- | src/userspace/mlibc/string/strdisp.c | 2 | ||||
-rw-r--r-- | src/userspace/mlibc/string/strdup.c | 2 | ||||
-rw-r--r-- | src/userspace/mlibc/string/strinv.c | 2 | ||||
-rw-r--r-- | src/userspace/mlibc/string/strlen.c | 2 |
14 files changed, 21 insertions, 24 deletions
diff --git a/src/userspace/mlibc/stdio/readline.c b/src/userspace/mlibc/stdio/readline.c index 91b5da0..8937702 100644 --- a/src/userspace/mlibc/stdio/readline.c +++ b/src/userspace/mlibc/stdio/readline.c @@ -1,16 +1,14 @@ -#include <syscall.h> -#include <mlibc/string.h> +#include <mlibc/stdlib.h> #include <mlibc/stdio.h> char *readline() { - char *ret = ""; + char ret[256] = {'\0'}; char buf = 0; while (buf != '\n') { buf = getch(); writec(buf); strcpy(ret, &buf); } - strcpy(ret, &buf); return ret; }
\ No newline at end of file diff --git a/src/userspace/mlibc/stdio/vprintf.c b/src/userspace/mlibc/stdio/vprintf.c index 1d43c77..2536b79 100644 --- a/src/userspace/mlibc/stdio/vprintf.c +++ b/src/userspace/mlibc/stdio/vprintf.c @@ -3,7 +3,7 @@ #include <mlibc/stdio.h> #include <mlibc/stdlib.h> -void __writes(const char *data) +void _writes(const char *data) { for (size_t i = 0; i < strlen(data); i++) writec(data[i]); } @@ -25,16 +25,16 @@ void vprintf(const char *fmt, va_list args) buff = *fmt; if (buff == 's') { const char *str = va_arg(args, const char*); - __writes(str); + _writes(str); readyToFormat = 0; } else if (buff == 'x') { char *p = htoa((uint32_t) va_arg(args, int)); - __writes(p); + _writes(p); free(p); readyToFormat = 0; } else if (buff == 'd') { char *p = itoa(va_arg(args, int)); - __writes(p); + _writes(p); free(p); readyToFormat = 0; } else if (buff == 'c') { diff --git a/src/userspace/mlibc/stdlib/atoi.c b/src/userspace/mlibc/stdlib/atoi.c index 0643372..67a603e 100644 --- a/src/userspace/mlibc/stdlib/atoi.c +++ b/src/userspace/mlibc/stdlib/atoi.c @@ -1,7 +1,7 @@ #include <mlibc/math.h> #include <stddef.h> #include <stdint.h> -#include <mlibc/string.h> +#include <mlibc/stdlib.h> int atoi(char *str) { diff --git a/src/userspace/mlibc/stdlib/htoa.c b/src/userspace/mlibc/stdlib/htoa.c index 098e1c8..579db5d 100644 --- a/src/userspace/mlibc/stdlib/htoa.c +++ b/src/userspace/mlibc/stdlib/htoa.c @@ -1,8 +1,8 @@ #include <stdint.h> -#include <mlibc/string.h> +#include <mlibc/stdlib.h> #include <mlibc/stdlib.h> -static const char __HTOA_TABLE[] = "0123456789ABCDEF"; +static const char HTOA_TABLE[] = "0123456789ABCDEF"; char *htoa(uint32_t n) { @@ -11,7 +11,7 @@ char *htoa(uint32_t n) int i = 0; while (n) { - ret[i++] = __HTOA_TABLE[n & 0xF]; + ret[i++] = HTOA_TABLE[n & 0xF]; n >>= 4; } diff --git a/src/userspace/mlibc/stdlib/htoi.c b/src/userspace/mlibc/stdlib/htoi.c index 489e5c0..93b387a 100644 --- a/src/userspace/mlibc/stdlib/htoi.c +++ b/src/userspace/mlibc/stdlib/htoi.c @@ -1,6 +1,6 @@ #include <stddef.h> #include <mlibc/math.h> -#include <mlibc/string.h> +#include <mlibc/stdlib.h> int htoi(char *str) { diff --git a/src/userspace/mlibc/stdlib/itoa.c b/src/userspace/mlibc/stdlib/itoa.c index 55c1383..567824f 100644 --- a/src/userspace/mlibc/stdlib/itoa.c +++ b/src/userspace/mlibc/stdlib/itoa.c @@ -1,9 +1,8 @@ #include <stdint.h> #include <mlibc/math.h> -#include <mlibc/string.h> #include <mlibc/stdlib.h> -static const char __ITOA_TABLE[] = "0123456789"; +static const char ITOA_TABLE[] = "0123456789"; char *itoa(int n) { @@ -28,7 +27,7 @@ char *itoa(int n) for (int i = 0; i < sz; i++) { int digit = (n % pow(10, i + 1)) / pow(10, i); - ret[i] = __ITOA_TABLE[digit]; + ret[i] = ITOA_TABLE[digit]; } ret[sz] = 0; diff --git a/src/userspace/mlibc/string/strcat.c b/src/userspace/mlibc/string/strcat.c index 0448430..2876604 100644 --- a/src/userspace/mlibc/string/strcat.c +++ b/src/userspace/mlibc/string/strcat.c @@ -1,4 +1,4 @@ -#include <mlibc/string.h> +#include <mlibc/stdlib.h> void strcat(char *dest, const char *orig) { diff --git a/src/userspace/mlibc/string/strcati.c b/src/userspace/mlibc/string/strcati.c index 8fdcc1a..312792f 100644 --- a/src/userspace/mlibc/string/strcati.c +++ b/src/userspace/mlibc/string/strcati.c @@ -1,4 +1,4 @@ -#include <mlibc/string.h> +#include <mlibc/stdlib.h> void strcati(char *dest, const char *orig) { diff --git a/src/userspace/mlibc/string/strcmp.c b/src/userspace/mlibc/string/strcmp.c index be6c17a..903234f 100644 --- a/src/userspace/mlibc/string/strcmp.c +++ b/src/userspace/mlibc/string/strcmp.c @@ -1,4 +1,4 @@ -#include <mlibc/string.h> +#include <mlibc/stdlib.h> char strcmp(const char *a, const char *b) { diff --git a/src/userspace/mlibc/string/strcpy.c b/src/userspace/mlibc/string/strcpy.c index 8dfa65f..18f3f25 100644 --- a/src/userspace/mlibc/string/strcpy.c +++ b/src/userspace/mlibc/string/strcpy.c @@ -1,4 +1,4 @@ -#include <mlibc/string.h> +#include <mlibc/stdlib.h> void strcpy(char *dest, const char *orig) { diff --git a/src/userspace/mlibc/string/strdisp.c b/src/userspace/mlibc/string/strdisp.c index d793718..5d8ee7d 100644 --- a/src/userspace/mlibc/string/strdisp.c +++ b/src/userspace/mlibc/string/strdisp.c @@ -1,4 +1,4 @@ -#include <mlibc/string.h> +#include <mlibc/stdlib.h> void strdisponce(char *str) { diff --git a/src/userspace/mlibc/string/strdup.c b/src/userspace/mlibc/string/strdup.c index bb3597d..e77536c 100644 --- a/src/userspace/mlibc/string/strdup.c +++ b/src/userspace/mlibc/string/strdup.c @@ -1,4 +1,4 @@ -#include <mlibc/string.h> +#include <mlibc/stdlib.h> #include <mlibc/stdlib.h> char *strdup(const char *orig) diff --git a/src/userspace/mlibc/string/strinv.c b/src/userspace/mlibc/string/strinv.c index 71f3355..4f54775 100644 --- a/src/userspace/mlibc/string/strinv.c +++ b/src/userspace/mlibc/string/strinv.c @@ -1,4 +1,4 @@ -#include <mlibc/string.h> +#include <mlibc/stdlib.h> void strinv(char *str) { diff --git a/src/userspace/mlibc/string/strlen.c b/src/userspace/mlibc/string/strlen.c index f6a06a4..c8d9c4f 100644 --- a/src/userspace/mlibc/string/strlen.c +++ b/src/userspace/mlibc/string/strlen.c @@ -1,4 +1,4 @@ -#include <mlibc/string.h> +#include <mlibc/stdlib.h> size_t strlen(const char *str) { |