Replaced "fgets" with a "get_token" function in demo/mtest_opponent.c#500
Conversation
sjaeckel
left a comment
There was a problem hiding this comment.
Tests broken, something like the following "solves the problem"^TM (not sure what other problems it introduces ;) )
diff --git a/demo/mtest_opponent.c b/demo/mtest_opponent.c
index 9f80e65..dbf8745 100644
--- a/demo/mtest_opponent.c
+++ b/demo/mtest_opponent.c
@@ -21,3 +21,3 @@ static char *s_mp_get_token(char *s, int size, FILE *stream)
char *s_bar = s;
- int c;
+ int c, eol_hit = 0;
@@ -35,4 +35,9 @@ static char *s_mp_get_token(char *s, int size, FILE *stream)
if ((c == '\n') || (c == '\r')) {
+ eol_hit = 1;
continue;
}
+ if (eol_hit) {
+ ungetc(c, stream);
+ break;
+ }
*s_bar++ = c;
@@ -110,3 +115,2 @@ static int mtest_opponent(void)
GET_TOKEN(cmd, 4095, stdin);
- cmd[strlen(cmd) - 1u] = '\0';
printf("%-6s ]\r", cmd);
I always try not to leave my PRs broken but Travis took way too long to start that day^Wnight so I went to bed. Sorry!
Good question. I'll take a deeper look this time. Thanks! |
|
Does seem to work, now that Why the local tests did fail before PR is still a mystery to me, because now they do. But I also forgot to remove There is still a non-technical problem left: because of the age of this part ( |
2ae6533 to
24ac0de
Compare
* handle buffer full case * display error reason of `s_mp_get_token()` * display name of variables when `draw()`ing on error
We shouldn't leave the clean-up of the mtest-tokens to
mp_read_radix. This PR would also allow to get rid of the abominable input-sanitizing in #499