diff options
author | Tom Tromey <tom@tromey.com> | 2021-12-03 14:45:37 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-12-08 13:20:30 -0700 |
commit | 696d6f4d5c1bc9b36d0402c2393efe62e49392d9 (patch) | |
tree | e0a5c7edfce36b065afc1f443a15906936c44660 /gdb/p-exp.y | |
parent | 621f8c42d3df079ca5781cdb0925c5ec3498f59c (diff) | |
download | gdb-696d6f4d5c1bc9b36d0402c2393efe62e49392d9.zip gdb-696d6f4d5c1bc9b36d0402c2393efe62e49392d9.tar.gz gdb-696d6f4d5c1bc9b36d0402c2393efe62e49392d9.tar.bz2 |
Use for-each more in gdb
There are some loops in gdb that use ARRAY_SIZE (or a wordier
equivalent) to loop over a static array. This patch changes some of
these to use foreach instead.
Regression tested on x86-64 Fedora 34.
Diffstat (limited to 'gdb/p-exp.y')
-rw-r--r-- | gdb/p-exp.y | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/gdb/p-exp.y b/gdb/p-exp.y index f496ce2..e9ebf1f 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -1107,28 +1107,28 @@ yylex (void) /* See if it is a special token of length 3. */ if (explen > 2) - for (int i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++) - if (strncasecmp (tokstart, tokentab3[i].oper, 3) == 0 - && (!isalpha (tokentab3[i].oper[0]) || explen == 3 + for (const auto &token : tokentab3) + if (strncasecmp (tokstart, token.oper, 3) == 0 + && (!isalpha (token.oper[0]) || explen == 3 || (!isalpha (tokstart[3]) && !isdigit (tokstart[3]) && tokstart[3] != '_'))) { pstate->lexptr += 3; - yylval.opcode = tokentab3[i].opcode; - return tokentab3[i].token; + yylval.opcode = token.opcode; + return token.token; } /* See if it is a special token of length 2. */ if (explen > 1) - for (int i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++) - if (strncasecmp (tokstart, tokentab2[i].oper, 2) == 0 - && (!isalpha (tokentab2[i].oper[0]) || explen == 2 + for (const auto &token : tokentab2) + if (strncasecmp (tokstart, token.oper, 2) == 0 + && (!isalpha (token.oper[0]) || explen == 2 || (!isalpha (tokstart[2]) && !isdigit (tokstart[2]) && tokstart[2] != '_'))) { pstate->lexptr += 2; - yylval.opcode = tokentab2[i].opcode; - return tokentab2[i].token; + yylval.opcode = token.opcode; + return token.token; } switch (c = *tokstart) |