pull/29/head
E. Almqvist 3 years ago
parent e429ac6102
commit 4d6c6fd8dd
  1. 3
      kernel/kernel.c
  2. 21
      lib/str.c
  3. 2
      lib/str.h
  4. 16
      lib/strf.c
  5. 2
      lib/strf.h

@ -6,7 +6,8 @@ void main() {
// i.e. clear the screen et cetera.
int test = 1234;
char* teststr = int_to_str(test);
char* teststr;
teststr = int_to_str(test, teststr);
println(teststr, 0xf0);
set_cursor_pos(28, 2);

@ -0,0 +1,21 @@
#include "str.h"
unsigned int strlen(char* str) {
char* c;
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) {
unsigned int bufferlen = strlen(buf);
// remove the 0x0 char from the buffer
*(buf + bufferlen) = 0x3f; // placeholder
// concat the str to buf
for( char* c = str; *c != '\0'; c++ ) {
}
}

@ -0,0 +1,2 @@
unsigned int strlen(char* str);
char* strcat(char* buf, char* str);

@ -3,13 +3,13 @@
#define int_offset 48
// 0:48 - 9:57
char* int_to_str(int i) {
char* strbuf = "XXXXXX";
while( i > 0 ) {
*(strbuf + 1) = (i % 10) + int_offset;
i /= 10;
char* int_to_str(int i, char* strbuf) {
if( i == 0 ) {
return (char*)(int_offset);
} else {
char cbuf;
cbuf = (char)((i % 10) + int_offset);
return int_to_str(i / 10, strbuf + cbuf);
}
return strbuf;
}

@ -1 +1 @@
char* int_to_str(int i);
char* int_to_str(int i, char* strbuf);

Loading…
Cancel
Save