tools/nxstyle.c: Was confusing hex constants with strings staring with 'x'. Added logic to complain about hex constants containing upper case characters.

This commit is contained in:
Gregory Nutt 2019-03-09 09:21:12 -06:00
parent 76528df35f
commit cf0f0e69f8

View File

@ -546,10 +546,29 @@ int main(int argc, char **argv, char **envp)
}
while (line[n] == '_' || isalnum(line[n]));
/* Check for mixed upper and lower case */
if (have_upper && have_lower)
{
fprintf(stderr, "Mixed case identifier found at line %d:%d\n",
lineno, ident_index);
/* Special case hex constants. These will look like
* identifiers starting with 'x' or 'X' but preceded
* with '0'
*/
if (ident_index < 1 ||
(line[ident_index] != 'x' && line[ident_index] != 'X') ||
line[ident_index - 1] != '0')
{
fprintf(stderr,
"Mixed case identifier found at line %d:%d\n",
lineno, ident_index);
}
else if (have_upper)
{
fprintf(stderr,
"Upper case hex constant found at line %d:%d\n",
lineno, ident_index);
}
}
/* Check if the identifier is the last thing on the line */