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