Small fixes

This commit is contained in:
Kyler Olsen 2025-11-28 21:41:36 -07:00
parent d333cdfad5
commit 521bd9907a
2 changed files with 4 additions and 5 deletions

View File

@ -14,7 +14,6 @@
#include "sls/string.h"
#include "sls/interpreter.h"
static const size_t BUFFER_SIZE = 256;
static const SlsStr REPL_FILE_NAME = SLS_STR_CONST("<STDIN>");
int repl(int argc, char *argv[]) {
@ -28,8 +27,8 @@ int repl(int argc, char *argv[]) {
LexerInfo lexer_info;
InterpreterState *interpreter_state = interpreter_create();
char buf[BUFFER_SIZE];
while (fgets(buf, BUFFER_SIZE, stdin)) {
char buf[256];
while (fgets(buf, sizeof buf, stdin)) {
size_t len = strlen(buf);
if (len && buf[len - 1] == '\n') buf[len - 1] = '\0';
if (strncmp(buf, "#exit", 5) == 0) {
@ -37,7 +36,7 @@ int repl(int argc, char *argv[]) {
return 0;
}
SlsStr code = sls_str_malloc(buf, BUFFER_SIZE);
SlsStr code = sls_str_malloc(buf, sizeof buf);
init_lexer(&lexer_info, REPL_FILE_NAME, code);
LexerResult result = lexical_analysis(&lexer_info);
if (result.type == SLS_ERROR) {