Commit 2318e520 authored by David Gobbi's avatar David Gobbi
Browse files

Fix evaluation of char literals with escape codes.

The char pointer was not being advanced, leading to incorrect evaluation
and a false syntax error.  Also, octal and hexadecimal escape codes were
not evaluated with the correct signedness.
parent 5158a4ce
......@@ -392,25 +392,25 @@ static int preproc_evaluate_char(
else if (*cp != '\'' && *cp != '\n' && *cp != '\0')
{
cp++;
if (*cp == 'a') { *val = '\a'; }
else if (*cp == 'b') { *val = '\b'; }
else if (*cp == 'f') { *val = '\f'; }
else if (*cp == 'n') { *val = '\n'; }
else if (*cp == 'r') { *val = '\r'; }
else if (*cp == 't') { *val = '\t'; }
else if (*cp == 'v') { *val = '\v'; }
else if (*cp == '\'') { *val = '\''; }
else if (*cp == '\"') { *val = '\"'; }
else if (*cp == '\\') { *val = '\\'; }
else if (*cp == '\?') { *val = '\?'; }
else if (*cp == '0')
{
*val = string_to_preproc_int(cp, 8);
if (*cp == 'a') { *val = '\a'; cp++; }
else if (*cp == 'b') { *val = '\b'; cp++; }
else if (*cp == 'f') { *val = '\f'; cp++; }
else if (*cp == 'n') { *val = '\n'; cp++; }
else if (*cp == 'r') { *val = '\r'; cp++; }
else if (*cp == 't') { *val = '\t'; cp++; }
else if (*cp == 'v') { *val = '\v'; cp++; }
else if (*cp == '\'') { *val = '\''; cp++; }
else if (*cp == '\"') { *val = '\"'; cp++; }
else if (*cp == '\\') { *val = '\\'; cp++; }
else if (*cp == '\?') { *val = '\?'; cp++; }
else if (*cp >= '0' && *cp <= '7')
{
*val = (char)string_to_preproc_int(cp, 8);
do { cp++; } while (*cp >= '0' && *cp <= '7');
}
else if (*cp == 'x')
{
*val = string_to_preproc_int(cp+1, 16);
*val = (char)string_to_preproc_int(cp+1, 16);
do { cp++; } while (vtkParse_CharType(*cp, CPRE_HEX));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment