aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-02-22 12:53:14 -0700
committerTom Tromey <tromey@adacore.com>2022-04-04 12:46:09 -0600
commit67700be2867e6f03d7e0891a47429aab2b879551 (patch)
treec4d1c2060c89017dcc208ed9f7a09fe9bb7ab075 /gdb
parentc66ed94ae961c19b0d3028489d00a2df5a949aac (diff)
downloadgdb-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')
-rw-r--r--gdb/ada-lex.l31
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';