<commit_before>#include <stddef.h>
#include <stdint.h>
#include "vga.h"
 
static const size_t VGA_WIDTH  = 80;
static const size_t VGA_HEIGHT = 25;
 
static size_t          curr_y      = 0;
static size_t          curr_x      = 0;
static uint16_t *const term_buffer = (uint16_t*)0xB8000;
static uint8_t         term_color;
 
uint8_t make_color(enum VGAColor fg, enum VGAColor bg)
{
	return fg | bg << 4;
}
 
uint16_t make_vga_entry(char c, uint8_t color)
{
	uint16_t c16     = c;
	uint16_t color16 = color;

	return c16 | color16 << 8;
}
 
size_t strlen(const char *str)
{
	size_t len = 0;
	while (str[len++] != '\0')
		;

	return len;
}
 
static void term_put_entry(char c, uint8_t color, size_t x, size_t y)
{
	term_buffer[y * VGA_WIDTH + x] = make_vga_entry(c, color);
}
 
void init_term()
{
	term_color  = make_color(LIGHT_GREY, BLACK);

	for (size_t y = 0; y < VGA_HEIGHT; y++)
		for (size_t x = 0; x < VGA_WIDTH; x++)
			term_put_entry(' ', term_color, x, y);
}
 
void term_set_color(uint8_t color)
{
	term_color = color;
}
 
void term_putchar(char c)
{
	switch (c) {
	case '\n':
		curr_x = 0;
		curr_y++;
		return;
	case '\r':
		curr_x = 0;
		return;
	case '\b':
		if (curr_x == 0) {
			curr_x = VGA_WIDTH - 1;
			curr_y--;
		} else {
			curr_x--;
		}

		return;
	default:
		break;
	}

	term_put_entry(c, term_color, curr_x, curr_y);

	if (++curr_x == VGA_WIDTH) {
		curr_x = 0;

		if (++curr_y == VGA_HEIGHT)
			curr_y = 0;
	}
}
 
void term_puts(const char *str)
{
	for (size_t i = 0; i < strlen(str); i++)
		term_putchar(str[i]);
}
<commit_msg>term_puts outputs a trailing newline Less confusing, considering puts outputs a trailing newline<commit_after>#include <stddef.h>
#include <stdint.h>
#include "vga.h"
 
static const size_t VGA_WIDTH  = 80;
static const size_t VGA_HEIGHT = 25;
 
static size_t          curr_y      = 0;
static size_t          curr_x      = 0;
static uint16_t *const term_buffer = (uint16_t*)0xB8000;
static uint8_t         term_color;
 
uint8_t make_color(enum VGAColor fg, enum VGAColor bg)
{
	return fg | bg << 4;
}
 
uint16_t make_vga_entry(char c, uint8_t color)
{
	uint16_t c16     = c;
	uint16_t color16 = color;

	return c16 | color16 << 8;
}
 
size_t strlen(const char *str)
{
	size_t len = 0;
	while (str[len++] != '\0')
		;

	return len;
}
 
static void term_put_entry(char c, uint8_t color, size_t x, size_t y)
{
	term_buffer[y * VGA_WIDTH + x] = make_vga_entry(c, color);
}
 
void init_term()
{
	term_color  = make_color(LIGHT_GREY, BLACK);

	for (size_t y = 0; y < VGA_HEIGHT; y++)
		for (size_t x = 0; x < VGA_WIDTH; x++)
			term_put_entry(' ', term_color, x, y);
}
 
void term_set_color(uint8_t color)
{
	term_color = color;
}
 
void term_putchar(char c)
{
	switch (c) {
	case '\n':
		curr_x = 0;
		curr_y++;
		return;
	case '\r':
		curr_x = 0;
		return;
	case '\b':
		if (curr_x == 0) {
			curr_x = VGA_WIDTH - 1;
			curr_y--;
		} else {
			curr_x--;
		}

		return;
	default:
		break;
	}

	term_put_entry(c, term_color, curr_x, curr_y);

	if (++curr_x == VGA_WIDTH) {
		curr_x = 0;

		if (++curr_y == VGA_HEIGHT)
			curr_y = 0;
	}
}
 
void term_puts(const char *str)
{
	for (size_t i = 0; i < strlen(str); i++)
		term_putchar(str[i]);

	term_putchar('\n');
}

{'fraction_non_alphanumeric': 0.13929573075724525, 'fraction_numerical': 0.029292614521657837, 'mean_word_length': 3.185136897001304, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2293119', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1410, 'n_words': 351}