Fix for off-by-one error in tokenizer error message reporting

This commit is contained in:
ridiculousfish 2013-12-08 18:16:55 -08:00
parent 925fe65dd8
commit 5769fa6aed

View file

@ -64,7 +64,6 @@ static const wchar_t *tok_desc[] =
{
N_(L"Tokenizer not yet initialized"),
N_(L"Tokenizer error"),
N_(L"Invalid token"),
N_(L"String"),
N_(L"Pipe"),
N_(L"End of command"),
@ -77,6 +76,8 @@ static const wchar_t *tok_desc[] =
N_(L"Comment")
};
/**
Set the latest tokens string to be the specified error message
*/
@ -559,7 +560,7 @@ static bool my_iswspace(wchar_t c)
const wchar_t *tok_get_desc(int type)
{
if (type < 0 || (size_t)type >= sizeof(tok_desc))
if (type < 0 || (size_t)type >= (sizeof tok_desc / sizeof *tok_desc))
{
return _(L"Invalid token type");
}