Compare commits

..

No commits in common. "bdfac39bc94376d1fa47cc5d1f687938062f9693" and "08f7352a314d69eb11ea8138ec46e0368196a8a0" have entirely different histories.

4 changed files with 4 additions and 23 deletions

View File

@ -8,5 +8,4 @@ int strncmp(const char *s1, const char *s2, size_t n);
size_t strlen(const char *str);
char *strstr(const char *haystack, const char *needle);
void *memcpy(void *dest, const void *src, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);
void *memset(void *str, int c, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);

View File

@ -1,11 +0,0 @@
#include <stddef.h>
#include <stdint.h>
void *memset(void *str, int c, size_t n)
{
uint8_t *c1 = (uint8_t *)str;
for (size_t i = 0; i < n; i++)
c1[i] = c;
return c1;
}

View File

@ -40,7 +40,7 @@ static CMD_TOK find_command(char *line)
return command;
}
static void read_line(void)
static void read_line(char *buf, size_t size)
{
size_t i = 0;
struct key_event ev;
@ -50,9 +50,6 @@ static void read_line(void)
ev = terminal_getkey();
if (ev.c == '\n')
break;
char *buf = screen->line;
i = strlen(screen->line);
const size_t size = sizeof(screen->line);
if (prev_scan_code != ev.scan_code && ev.scan_code) {
if (ev.scan_code == KEY_BACKSPACE && i) {
buf[--i] = '\0';
@ -70,14 +67,14 @@ static void read_line(void)
prev_scan_code = ev.scan_code;
}
kprintf(0, "\n");
screen->line[i] = '\0';
buf[i] = '\0';
}
void shell_init(void)
{
while (1) {
kprintf(0, PROMPT);
read_line();
read_line(screen->line, sizeof(screen->line));
switch (find_command(screen->line)) {
case HELP:
kprintf(0, "Welcome to bozOShell, the shell of "
@ -110,6 +107,5 @@ void shell_init(void)
default:
break;
}
memset(screen->line, '\0', sizeof(screen->line));
}
}

View File

@ -1,6 +1,5 @@
#include "ctype.h"
#include "kprintf.h"
#include "shell.h"
#include "string.h"
#include "sys/io.h"
#include "terminal.h"
@ -45,8 +44,6 @@ void terminal_set_screen(int pos)
screen = &screens[pos];
memcpy(TERM_BUF, screen->buffer, sizeof(screen->buffer));
update_cursor();
if (TERM_BUF[0] == vga_entry(' ', VGA_COLOR_WHITE))
kprintf(0, PROMPT);
}
void terminal_setcolor(uint8_t color)