OSDN Git Service

2003-02-04 David Carlton <carlton@math.stanford.edu>
authorcarlton <carlton>
Tue, 4 Feb 2003 21:24:20 +0000 (21:24 +0000)
committercarlton <carlton>
Tue, 4 Feb 2003 21:24:20 +0000 (21:24 +0000)
* linespec.c (decode_compound): Extract code into
lookup_prefix_sym.
(lookup_prefix_sym): New function.

gdb/ChangeLog
gdb/linespec.c

index f504b95..2ff288a 100644 (file)
@@ -1,5 +1,11 @@
 2003-02-04  David Carlton  <carlton@math.stanford.edu>
 
+       * linespec.c (decode_compound): Extract code into
+       lookup_prefix_sym.
+       (lookup_prefix_sym): New function.
+
+2003-02-04  David Carlton  <carlton@math.stanford.edu>
+
        * gdbtypes.h: Delete INTEGER_COERCION_BADNESS,
        FLOAT_COERCION_BADNESS.
        * gdbtypes.c (rank_one_type): Replace all uses of
index 37633cc..4b36d86 100644 (file)
@@ -54,6 +54,8 @@ static struct symtabs_and_lines decode_compound (char **argptr,
                                                 char *saved_arg,
                                                 char *p);
 
+static struct symbol *lookup_prefix_sym (char **argptr, char *p);
+
 static NORETURN void cplusplus_error (const char *name,
                                      const char *fmt, ...)
      ATTR_NORETURN ATTR_FORMAT (printf, 2, 3);
@@ -930,7 +932,7 @@ decode_compound (char **argptr, int funfirstline, char ***canonical,
                 char *saved_arg, char *p)
 {
   struct symtabs_and_lines values;
-  char *p1, *p2;
+  char *p2;
 #if 0
   char *q, *q1;
 #endif
@@ -975,22 +977,7 @@ decode_compound (char **argptr, int funfirstline, char ***canonical,
   p2 = p;              /* Save for restart.  */
   while (1)
     {
-      /* Extract the class name.  */
-      p1 = p;
-      while (p != *argptr && p[-1] == ' ')
-       --p;
-      copy = (char *) alloca (p - *argptr + 1);
-      memcpy (copy, *argptr, p - *argptr);
-      copy[p - *argptr] = 0;
-
-      /* Discard the class name from the arg.  */
-      p = p1 + (p1[0] == ':' ? 2 : 1);
-      while (*p == ' ' || *p == '\t')
-       p++;
-      *argptr = p;
-
-      sym_class = lookup_symbol (copy, 0, STRUCT_NAMESPACE, 0,
-                                (struct symtab **) NULL);
+      sym_class = lookup_prefix_sym (argptr, p);
 
       if (sym_class &&
          (t = check_typedef (SYMBOL_TYPE (sym_class)),
@@ -1168,6 +1155,37 @@ decode_compound (char **argptr, int funfirstline, char ***canonical,
                   copy);
 }
 
+/* Next come some helper functions for decode_compound.  */
+
+/* Return the symbol corresponding to the substring of *ARGPTR ending
+   at P, allowing whitespace.  Also, advance *ARGPTR past the symbol
+   name in question, the compound object separator ("::" or "."), and
+   whitespace.  */
+
+static struct symbol *
+lookup_prefix_sym (char **argptr, char *p)
+{
+  char *p1;
+  char *copy;
+
+  /* Extract the class name.  */
+  p1 = p;
+  while (p != *argptr && p[-1] == ' ')
+    --p;
+  copy = (char *) alloca (p - *argptr + 1);
+  memcpy (copy, *argptr, p - *argptr);
+  copy[p - *argptr] = 0;
+
+  /* Discard the class name from the arg.  */
+  p = p1 + (p1[0] == ':' ? 2 : 1);
+  while (*p == ' ' || *p == '\t')
+    p++;
+  *argptr = p;
+
+  return lookup_symbol (copy, 0, STRUCT_NAMESPACE, 0,
+                       (struct symtab **) NULL);
+}
+
 \f
 
 /* Return the symtab associated to the filename given by the substring