Fix to Gitlab issue #32. Now SEED and WASTE are in adventure.yaml
NOTE: the tests are all updated because now, like every other action, SEED and WASTE have a \n before their output, as they correctly use SPEAK
This commit is contained in:
parent
ef236aea3b
commit
5337e00725
84 changed files with 174 additions and 32 deletions
31
misc.c
31
misc.c
|
@ -399,6 +399,30 @@ static int get_special_vocab_id(const char* word)
|
|||
return (WORD_NOT_FOUND);
|
||||
}
|
||||
|
||||
static bool is_valid_int(const char *str)
|
||||
/* Returns true if the string passed in is represents a valid integer,
|
||||
* that could then be parsed by atoi() */
|
||||
{
|
||||
// Handle negative number
|
||||
if (*str == '-')
|
||||
++str;
|
||||
|
||||
// Handle empty string or just "-"
|
||||
if (!*str)
|
||||
return false;
|
||||
|
||||
// Check for non-digit chars in the rest of the stirng.
|
||||
while (*str)
|
||||
{
|
||||
if (!isdigit(*str))
|
||||
return false;
|
||||
else
|
||||
++str;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void get_vocab_metadata(const char* word, vocab_t* id, enum wordtype* type)
|
||||
{
|
||||
/* Check for an empty string */
|
||||
|
@ -445,6 +469,13 @@ static void get_vocab_metadata(const char* word, vocab_t* id, enum wordtype* typ
|
|||
return;
|
||||
}
|
||||
|
||||
// Check words that are actually numbers.
|
||||
if (is_valid_int(word)) {
|
||||
*id = WORD_EMPTY;
|
||||
*type = NUMERIC;
|
||||
return;
|
||||
}
|
||||
|
||||
*id = WORD_NOT_FOUND;
|
||||
*type = NO_WORD_TYPE;
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue