don't continue on empty strings

This commit is contained in:
biglyderv 2025-03-28 01:36:28 -04:00
parent c278da1705
commit a6451e4904
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5

View file

@ -48,14 +48,25 @@ int main(int argc, char *argv[]) {
init_tables(elements, inv, polls, 1);
printf("%s, welcome to Elemental on Command Line!\n", name);
int newline = 1;
while (1) {
// todo: separate into functions
printf("\n");
if (newline) {
printf("\n");
}
fgets(command, MAX_BUF_LENGTH - 1, stdin);
int cl = strlen(command);
if (cl < 2) {
newline = 0;
continue;
} else {
newline = 1;
}
for (int i = 0; i < cl - 1; i++) {
command[i] = tolower(command[i]);
}