tools/nxstyle: Fix false alarm 'Garbage follows right bracket' on named structures that are fields of other structures or unions.
This commit is contained in:
parent
b58ccc96e4
commit
f3c2022b4e
@ -1074,18 +1074,61 @@ int main(int argc, char **argv, char **envp)
|
|||||||
line[n + 1] != ',' &&
|
line[n + 1] != ',' &&
|
||||||
line[n + 1] != ';')
|
line[n + 1] != ';')
|
||||||
{
|
{
|
||||||
/* One case where there may be garbage after the right
|
int sndx = n + 1;
|
||||||
* bracket is, for example, when declaring a until or
|
|
||||||
* structure variable using an un-named union or
|
/* Skip over spaces */
|
||||||
* structure.
|
|
||||||
|
while (line[sndx] == ' ')
|
||||||
|
{
|
||||||
|
sndx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* One possibility is that the right bracket is
|
||||||
|
* followed by an identifier then a semi-colon.
|
||||||
|
* Comma is possible to but would be a case of
|
||||||
|
* multiple declaration of multiple instances.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (prevdnest <= 0 || dnest > 0)
|
if (line[sndx] == '_' || isalpha(line[sndx]))
|
||||||
{
|
{
|
||||||
/* REVISIT: Generates false alarms on named structures
|
int endx = sndx;
|
||||||
* that are fields of other structures or unions.
|
|
||||||
|
/* Skip to the end of the identifier. Checking
|
||||||
|
* for mixed case identifiers will be done
|
||||||
|
* elsewhere.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
while (line[endx] == '_' ||
|
||||||
|
isalnum(line[endx]))
|
||||||
|
{
|
||||||
|
endx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle according to what comes after the
|
||||||
|
* identifier.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (strncmp(&line[sndx], "while", 5) == 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"'while' must be on a separate line %d:%d\n",
|
||||||
|
lineno, sndx);
|
||||||
|
}
|
||||||
|
else if (line[endx] == ',')
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"Multiple data definitions on line %d:%d\n",
|
||||||
|
lineno, endx);
|
||||||
|
}
|
||||||
|
else if (line[endx] != ';')
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"Garbage follows right bracket at line %d:%d\n",
|
||||||
|
lineno, n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Garbage follows right bracket at line %d:%d\n",
|
"Garbage follows right bracket at line %d:%d\n",
|
||||||
lineno, n);
|
lineno, n);
|
||||||
|
Loading…
Reference in New Issue
Block a user