"properly handle running out of space in the buffer (which is now lowered too)"

This commit is contained in:
IoIxD 2026-01-21 14:14:38 -07:00
commit 20c9b01967

View file

@ -11,15 +11,16 @@ MSH_ENTRY_POINT {
while (1) { while (1) {
int out; int out;
char *buf = msh_callocate(2048, sizeof(char)); char *buf = msh_callocate(512, sizeof(char));
int i = 0, n = 0, last = 0; int i = 0, n = 0, last = 0;
SIZE_TYPE sz = 0, leftoff = 0; SIZE_TYPE sz = 0, leftoff = 0;
msh_print_strings(msh_working_directory(), " %> ", 0); msh_print_strings(msh_working_directory(), " %> ", 0);
while ((out = msh_read_input(buf, &sz, 2048)), out != -1) { while ((out = msh_read_input(buf, &sz, 512)), out != -1) {
switch (out) { switch (out) {
/* backspace */ /* backspace (also do this when we run out of space) */
case -2:
case 0x7F: case 0x7F:
if (sz > 0) { if (sz > 0) {
msh_move_cursor(-1); msh_move_cursor(-1);