fix
This commit is contained in:
parent
a495e0dc2c
commit
6fe18b3572
4
Makefile
4
Makefile
@ -5,8 +5,8 @@ BUILDDIR = build
|
||||
SRC := $(wildcard $(SRCDIR)/**/*.c)
|
||||
OBJ := $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SRC))
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -iquoteheaders -c
|
||||
CC = i386-elf-gcc
|
||||
CFLAGS = -std=gnu99 -ffreestanding -O2 -Wall -Wextra -iquoteheaders -c
|
||||
|
||||
AR = ar
|
||||
ARFLAGS =
|
||||
|
@ -18,6 +18,7 @@ static int print_flag(char flag, va_list ap)
|
||||
case 's':
|
||||
return terminal_writestring(va_arg(ap, char *));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kvprintf(int level, const char *restrict format, va_list ap)
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "../../headers/terminal.h"
|
||||
#include "terminal.h"
|
||||
#include "string.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
@ -14,14 +15,6 @@ static inline uint16_t vga_entry(unsigned char uc, uint8_t color)
|
||||
return (uint16_t) uc | (uint16_t) color << 8;
|
||||
}
|
||||
|
||||
size_t strlen(const char* str)
|
||||
{
|
||||
size_t len = 0;
|
||||
while (str[len])
|
||||
len++;
|
||||
return len;
|
||||
}
|
||||
|
||||
static const size_t VGA_WIDTH = 80;
|
||||
static const size_t VGA_HEIGHT = 25;
|
||||
|
||||
@ -81,17 +74,20 @@ int terminal_writestring(const char* data)
|
||||
return len;
|
||||
}
|
||||
|
||||
int terminal_writelong(long number)
|
||||
int terminal_writelong(long n)
|
||||
{
|
||||
unsigned long number2 = number;
|
||||
|
||||
if (number < 0) {
|
||||
terminal_putchar('-');
|
||||
number2 = -number;
|
||||
}
|
||||
else {
|
||||
if (number2 > 9)
|
||||
terminal_writelong(number2 / 10);
|
||||
terminal_putchar(number2 % 10);
|
||||
}
|
||||
long div = 10;
|
||||
int rv = 0;
|
||||
if (n < 0) {
|
||||
rv += terminal_putchar('-');
|
||||
n *= -1;
|
||||
}
|
||||
div = 1;
|
||||
while (div <= n / 10)
|
||||
div *= 10;
|
||||
while (div > 0) {
|
||||
rv += terminal_putchar('0' + n / div % 10);
|
||||
div /= 10;
|
||||
}
|
||||
return rv;
|
||||
}
|
Loading…
Reference in New Issue
Block a user