public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Refactor ada-lex.l:processId
@ 2022-04-04 18:50 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2022-04-04 18:50 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=67700be2867e6f03d7e0891a47429aab2b879551

commit 67700be2867e6f03d7e0891a47429aab2b879551
Author: Tom Tromey <tromey@adacore.com>
Date:   Tue Feb 22 12:53:14 2022 -0700

    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".

Diff:
---
 gdb/ada-lex.l | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 6c32a9bd002..40e450bf679 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';


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-04 18:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04 18:50 [binutils-gdb] Refactor ada-lex.l:processId Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).