fix geadline #6

Merged
starnakin merged 1 commits from kdx/IronGOLEM:master into master 2023-07-26 06:55:08 -04:00
3 changed files with 4 additions and 11 deletions
Showing only changes of commit 4bd9f50bd4 - Show all commits

View File

@ -89,6 +89,8 @@ geadline2(prompt, text)
esccode('D'); esccode('D');
} }
} }
} else if (c == '\n') {
return buf;
} else { } else {
size = size + 1; size = size + 1;
if (size >= capacity) { if (size >= capacity) {
@ -115,16 +117,11 @@ geadline2(prompt, text)
esccode('D'); esccode('D');
} }
i = i + 1; i = i + 1;
if (c == '\n')
return buf;
} }
} }
} }
geadline(prompt) geadline(prompt) => geadline2(prompt, NULL);
{
geadline2(prompt, NULL);
}
esccode(c) esccode(c)
{ {

View File

@ -1,3 +1,3 @@
yo yo
bozo bozo
z^[[Dbo^[[C^[[C^[[Co zboo

View File

@ -6,17 +6,13 @@ main()
ptr = geadline(""); ptr = geadline("");
test_str(ptr, "yo", ""); test_str(ptr, "yo", "");
free(ptr);
ptr = geadline(""); ptr = geadline("");
test_str(ptr, "bozo", ""); test_str(ptr, "bozo", "");
free(ptr);
ptr = geadline(""); ptr = geadline("");
test_str(ptr, "bozo", "arrow"); test_str(ptr, "bozo", "arrow");
free(ptr);
ptr = geadline(""); ptr = geadline("");
test_num(ptr, 0, ""); test_num(ptr, 0, "");
free(ptr);
} }