diff --git a/src/kernel.cpp b/src/kernel.cpp index e5e30f0..6a698b4 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -76,8 +76,8 @@ int Main(void) { InternalBuffer = (char*) kmalloc(4096); SerialPrintf("[ Mem] Allocated a text buffer at 0x%p\r\n", (size_t) InternalBuffer); - WriteString("\\${FF0000}C\\${}h\\${}r\\${FFFF00}o\\${FF00FF}m\\${FFFF}a "); - WriteString("\\${FFFFFF}T\\${AAAA}i\\${BBBBBB}m\\${}e\\${}!\n"); + Printf("\\${FF0000}C\\${}h\\${}r\\${FFFF00}o\\${FF00FF}m\\${FFFF}a "); + Printf("\\${FFFFFF}T\\${AAAA}i\\${BBBBBB}m\\${}e\\${}!\n"); SetForegroundColor(0x00FFFFFF); diff --git a/src/lainlib/string/str.c b/src/lainlib/string/str.c index 4e3262d..f360b53 100644 --- a/src/lainlib/string/str.c +++ b/src/lainlib/string/str.c @@ -22,8 +22,8 @@ size_t strlen(const char* String) { bool strcmp(char* a, const char* b) { size_t aI = 0, bI = 0; while(true) { + if(b[bI] == '\0') return true; if(a[aI] != b[bI]) return false; - if(a[aI] == '\0') return true; aI++; bI++; } diff --git a/src/video/print.cpp b/src/video/print.cpp index 50f051b..1cb22d8 100644 --- a/src/video/print.cpp +++ b/src/video/print.cpp @@ -202,23 +202,24 @@ int Printf(const char* Format, ...) { switch(*Format) { case '$': { // COLOR - Format ++; // Skip $ and { + Format ++; // Skip $ size_t Color = 0; bool bgFlag = false; switch(*Format) { case '[': + // bg bgFlag = true; [[fallthrough]]; - // bg case '{': // fg - Format++; + Format++; // [ or { + if(*Format == '<') { - Color = ParseEnglishColor((char*) ++Format); Format++; + Color = ParseEnglishColor((char*) Format); } else { - Color = ParseHexColor(++Format, bgFlag); + Color = ParseHexColor(Format, bgFlag); } if(bgFlag) @@ -226,20 +227,18 @@ int Printf(const char* Format, ...) { else SetForegroundColor(Color); - Format++; + while(*Format != '}') + Format++; + Format++; // } break; } - - Format++; break; } case 'f': // FORMAT break; } - - Format++; } else { WriteChar(*Format); Format++; @@ -277,11 +276,10 @@ size_t ParseHexColor(const char* Stream, bool bgFlag) { size_t val = 0; char c; - while ((*Stream != (bgFlag ? ']' : '}')) && (c = *Stream++)) { + while ((*Stream != (bgFlag ? ']' : '}')) && (c = *(++Stream))) { char v = ((c & 0xF) + (c >> 6)) | ((c >> 3) & 0x8); val = (val << 4) | (size_t) v; } - return val; }