From d7b97a830be0a9a3c7a596edcbe3854598172b49 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Sat, 28 Aug 2021 14:28:16 +0200 Subject: [PATCH] Borked strcat --- kernel/kernel.c | 9 +++++---- lib/str.c | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/kernel.c b/kernel/kernel.c index f7ea26c..0333a43 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -1,14 +1,15 @@ #include "../drivers/vga.h" +#include "../lib/str.h" #include "../lib/strf.h" void main() { vga_init(); // Initialize the screen first // i.e. clear the screen et cetera. - int test = 1234; - char* teststr; - teststr = int_to_str(test, teststr); - println(teststr, 0xf0); + char* strbuf = "HEJ"; + char* str2 = "xD"; + strbuf = strcat(strbuf, str2); + println(strbuf, 0xf0); set_cursor_pos(28, 2); print("eOS Version 0.1 2021", 0xf0); diff --git a/lib/str.c b/lib/str.c index a0a7ef7..0153b87 100644 --- a/lib/str.c +++ b/lib/str.c @@ -5,7 +5,6 @@ unsigned int strlen(char* str) { for( c = str; *c != '\0'; c++ ) // search for end-of-string return (unsigned int)(c - str); // get size by delta-address - } char* strcat(char* buf, char* str) { @@ -15,7 +14,11 @@ char* strcat(char* buf, char* str) { *(buf + bufferlen) = 0x3f; // placeholder // concat the str to buf + int cc = 0; for( char* c = str; *c != '\0'; c++ ) { - + *(buf + bufferlen + cc) = *c; + cc++; } + + return buf; }