Module Name:    src
Committed By:   christos
Date:           Sun Dec 13 16:50:47 UTC 2020

Modified Files:
        src/external/gpl3/gdb/dist/gdb: c-exp.y

Log Message:
Improve previous: generated names end with .[[:digits:]] so look for that
instead.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/gpl3/gdb/dist/gdb/c-exp.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gdb/dist/gdb/c-exp.y
diff -u src/external/gpl3/gdb/dist/gdb/c-exp.y:1.2 src/external/gpl3/gdb/dist/gdb/c-exp.y:1.3
--- src/external/gpl3/gdb/dist/gdb/c-exp.y:1.2	Fri Dec 11 13:25:45 2020
+++ src/external/gpl3/gdb/dist/gdb/c-exp.y	Sun Dec 13 11:50:47 2020
@@ -2608,7 +2608,63 @@ static bool last_was_structop;
 /* Depth of parentheses.  */
 static int paren_depth;
 
-static const char PART[] = ".part.";
+static int
+get_namelen (const char *tokstart, bool dot)
+{
+  int c;
+  int namelen;
+
+  for (c = tokstart[namelen];
+       (c == '_' || c == '$' || (dot && c == '.') || c_ident_is_alnum (c) || c == '<');)
+    {
+      /* Template parameter lists are part of the name.
+	 FIXME: This mishandles `print $a<4&&$a>3'.  */
+
+      if (c == '<')
+	{
+	  if (! is_cast_operator (tokstart, namelen))
+	    {
+	      /* Scan ahead to get rest of the template specification.  Note
+		 that we look ahead only when the '<' adjoins non-whitespace
+		 characters; for comparison expressions, e.g. "a < b > c",
+		 there must be spaces before the '<', etc. */
+	      const char *p = find_template_name_end (tokstart + namelen);
+
+	      if (p)
+		namelen = p - tokstart;
+	    }
+	  break;
+	}
+      c = tokstart[++namelen];
+    }
+  return namelen;
+}
+
+static bool is_generated_symbol (const char *symbol)
+{
+  /* generated symbol are of the form:
+
+     <symbol>.<number>
+     <symbol>.isra.<number>
+     <symbol>.part.<number>
+
+    So we see if the symbol ends with .<number>
+   */
+
+  int len = get_namelen (symbol, true);
+  int ndigits;
+
+  if (len-- == 0)
+    return false;
+
+  for (ndigits = 0; ndigits <= len && ISDIGIT(symbol[len - ndigits]); ndigits++)
+    continue;
+
+  if (ndigits == 0)
+    return false;
+
+  return symbol[len - ndigits] == '.';
+}
 
 /* Read one token, getting characters through lexptr.  */
 
@@ -2725,13 +2781,6 @@ lex_one_token (struct parser_state *par_
       return c;
 
     case '.':
-      /* Gross! recognize <symbol>.part.N */
-      if (strncmp(pstate->lexptr, PART, sizeof(PART) - 1) == 0 &&
-	ISDIGIT(pstate->lexptr[sizeof(PART) - 1]) &&
-	pstate->lexptr[sizeof(PART)] == '\0')
-	{
-	  break;
-	}
       /* Might be a floating point number.  */
       if (pstate->lexptr[1] < '0' || pstate->lexptr[1] > '9')
 	{
@@ -2895,30 +2944,7 @@ lex_one_token (struct parser_state *par_
     error (_("Invalid character '%c' in expression."), c);
 
   /* It's a name.  See how long it is.  */
-  namelen = 0;
-  for (c = tokstart[namelen];
-       (c == '_' || c == '$' || c == '.' || c_ident_is_alnum (c) || c == '<');)
-    {
-      /* Template parameter lists are part of the name.
-	 FIXME: This mishandles `print $a<4&&$a>3'.  */
-
-      if (c == '<')
-	{
-	  if (! is_cast_operator (tokstart, namelen))
-	    {
-	      /* Scan ahead to get rest of the template specification.  Note
-		 that we look ahead only when the '<' adjoins non-whitespace
-		 characters; for comparison expressions, e.g. "a < b > c",
-		 there must be spaces before the '<', etc. */
-	      const char *p = find_template_name_end (tokstart + namelen);
-
-	      if (p)
-		namelen = p - tokstart;
-	    }
-	  break;
-	}
-      c = tokstart[++namelen];
-    }
+  namelen = get_namelen (tokstart, is_generated_symbol (tokstart));
 
   /* The token "if" terminates the expression and is NOT removed from
      the input stream.  It doesn't count if it appears in the

Reply via email to