diff options
author | Tom Tromey <tromey@adacore.com> | 2022-02-22 12:53:14 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-04-04 12:46:09 -0600 |
commit | 67700be2867e6f03d7e0891a47429aab2b879551 (patch) | |
tree | c4d1c2060c89017dcc208ed9f7a09fe9bb7ab075 /gdb/ada-lex.l | |
parent | c66ed94ae961c19b0d3028489d00a2df5a949aac (diff) | |
download | gdb-67700be2867e6f03d7e0891a47429aab2b879551.zip gdb-67700be2867e6f03d7e0891a47429aab2b879551.tar.gz gdb-67700be2867e6f03d7e0891a47429aab2b879551.tar.bz2 |
Refactor ada-lex.l:processId
processId in ada-lex.l is a bit funny -- it uses an "if" and a
"switch", and a nested loop. This patch cleans it up a bit, changing
it to use a boolean flag and a simpler "if".
Diffstat (limited to 'gdb/ada-lex.l')
-rw-r--r-- | gdb/ada-lex.l | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 6c32a9b..40e450b 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -541,33 +541,28 @@ processId (const char *name0, int len) return result; } + bool in_quotes = false; i = i0 = 0; while (i0 < len) { - if (isalnum (name0[i0])) + if (in_quotes) + name[i++] = name0[i0++]; + else if (isalnum (name0[i0])) { name[i] = tolower (name0[i0]); i += 1; i0 += 1; } - else switch (name0[i0]) + else if (isspace (name0[i0])) + i0 += 1; + else if (name0[i0] == '\'') { - default: - name[i] = name0[i0]; - i += 1; i0 += 1; - break; - case ' ': case '\t': - i0 += 1; - break; - case '\'': - do - { - name[i] = name0[i0]; - i += 1; i0 += 1; - } - while (i0 < len && name0[i0] != '\''); - i0 += 1; - break; + /* Copy the starting quote, but not the ending quote. */ + if (!in_quotes) + name[i++] = name0[i0++]; + in_quotes = !in_quotes; } + else + name[i++] = name0[i0++]; } name[i] = '\000'; |