Only needing stdio

This commit is contained in:
Devine Lu Linvega 2020-09-09 19:05:15 -07:00
parent 40b93afad5
commit dc4ddecf4f
2 changed files with 8 additions and 8 deletions

View File

@ -10,4 +10,4 @@ cc -std=c89 -DDEBUG -Wall -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werr
./main
rm ./main
# rm ./main

14
main.c
View File

@ -1,4 +1,3 @@
#include <stdlib.h>
#include <stdio.h>
#define NAMELEN 32
@ -397,13 +396,13 @@ act(Parade* p, char* cmd, char* val)
}
}
void
int
answer(Parade* p, char* input)
{
int split = cpof(input, ' ');
char action[NAMELEN], value[TEXTLEN];
if(scmp(input, "quit"))
exit(0);
return 0;
if(split >= 0) {
sstr(input, action, 0, split);
sstr(input, value, split + 1, imin(slen(input) - split, TEXTLEN - 1));
@ -415,6 +414,7 @@ answer(Parade* p, char* input)
value[0] = '\0';
}
act(p, action, value);
return 1;
}
int
@ -436,8 +436,8 @@ listen(Parade* p)
char input[TEXTLEN];
printf("~ ");
if(fgets(input, TEXTLEN, stdin))
answer(p, strm(input));
return 1;
return answer(p, strm(input));
return 0;
}
int
@ -449,7 +449,7 @@ main(void)
addvessel(&parade, &parade.vessels[0], "ghost");
guest = &parade.vessels[1];
printf("A %s appeared in the %s.\n", guest->name, guest->parent->name);
while(1)
listen(&parade);
while(listen(&parade))
;
return 0;
}