]> code.delx.au - gnu-emacs/blobdiff - lib-src/ebrowse.c
*** empty log message ***
[gnu-emacs] / lib-src / ebrowse.c
index 8522a795980291c681adcf82b2d60877a08658da..94fa9114d2317a99124e97fbc329253c9c37905a 100644 (file)
@@ -1,11 +1,7 @@
 /* ebrowse.c --- parsing files for the ebrowse C++ browser
 
-   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-                2000, 2001
-      Free Software Foundation Inc.
-
-   Author: Gerd Moellmann <gerd@gnu.org>
-   Maintainer: FSF
+   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+                 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
    This file is part of GNU Emacs.
 
@@ -20,8 +16,9 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with GNU Emacs; see the file COPYING.  If not, write to
-   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+   along with GNU Emacs; see the file COPYING.  If not, write to the
+   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -567,7 +564,7 @@ xmalloc (nbytes)
   if (p == NULL)
     {
       yyerror ("out of memory", NULL);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
   return p;
 }
@@ -584,7 +581,7 @@ xrealloc (p, sz)
   if (p == NULL)
     {
       yyerror ("out of memory", NULL);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
   return p;
 }
@@ -651,7 +648,10 @@ add_sym (name, nested_in_class)
   h %= TABLE_SIZE;
 
   for (sym = class_table[h]; sym; sym = sym->next)
-    if (streq (name, sym->name) && sym->namesp == scope)
+    if (streq (name, sym->name)
+       && ((!sym->namesp && !scope)
+           || (sym->namesp && scope
+               && streq (sym->namesp->name, scope->name))))
       break;
 
   if (sym == NULL)
@@ -2426,6 +2426,30 @@ skip_matching ()
     }
 }
 
+void
+skip_initializer ()
+{
+  for (;;)
+    {
+      switch (LA1)
+       {
+       case ';':
+       case ',':
+       case YYEOF:
+         return;
+
+       case '{':
+       case '[':
+       case '(':
+         skip_matching ();
+         break;
+
+       default:
+         MATCH ();
+         break;
+       }
+    }
+}
 
 /* Build qualified namespace alias (A::B::c) and return it. */
 
@@ -2490,7 +2514,7 @@ parm_list (flags)
     {
       switch (LA1)
         {
-         /* Skip over grouping parens or parameter lists in parameter 
+         /* Skip over grouping parens or parameter lists in parameter
             declarations.  */
         case '(':
           skip_matching ();
@@ -3127,7 +3151,7 @@ class_definition (containing, tag, flags, nested)
      settings.  */
   if ((tag != CLASS && !f_structs) || (nested && !f_nested_classes))
     current = NULL;
-  else 
+  else
     {
       current = add_sym (yytext, containing);
       current->pos = BUFFER_POS ();
@@ -3146,7 +3170,7 @@ class_definition (containing, tag, flags, nested)
         {
           switch (LA1)
             {
-            case VIRTUAL: case PUBLIC: case PROTECTED: case PRIVATE: 
+            case VIRTUAL: case PUBLIC: case PROTECTED: case PRIVATE:
               MATCH ();
               break;
 
@@ -3208,6 +3232,54 @@ class_definition (containing, tag, flags, nested)
     }
 }
 
+/* Add to class *CLS information for the declaration of variable or
+   type *ID.  If *CLS is null, this means a global declaration.  SC is
+   the storage class of *ID.  FLAGS is a bit set giving additional
+   information about the member (see the F_* defines).  */
+
+void
+add_declarator (cls, id, flags, sc)
+     struct sym **cls;
+     char **id;
+     int flags, sc;
+{
+  if (LOOKING_AT2 (';', ','))
+    {
+      /* The end of a member variable or of an access declaration
+         `X::f'.  To distinguish between them we have to know whether
+         type information has been seen.  */
+      if (*id)
+        {
+          char *regexp = matching_regexp ();
+          int pos = BUFFER_POS ();
+
+          if (*cls)
+           add_member_defn (*cls, *id, regexp, pos, 0, 1, SC_UNKNOWN, flags);
+          else
+            add_global_defn (*id, regexp, pos, 0, 1, sc, flags);
+        }
+
+      MATCH ();
+      print_info ();
+    }
+  else if (LOOKING_AT ('{'))
+    {
+      if (sc == SC_TYPE && *id)
+        {
+          /* A named enumeration.  */
+          char *regexp = matching_regexp ();
+          int pos = BUFFER_POS ();
+          add_global_defn (*id, regexp, pos, 0, 1, sc, flags);
+        }
+
+      skip_matching ();
+      print_info ();
+    }
+
+  xfree (*id);
+  *id = NULL;
+  *cls = NULL;
+}
 
 /* Parse a declaration.  */
 
@@ -3262,11 +3334,15 @@ declaration (flags)
            }
 
         case '=':
-          /* Assumed to be the start of an initialization in this context.
-             Skip over everything up to ';'.  */
-          skip_to (';');
+          /* Assumed to be the start of an initialization in this
+            context.  */
+         skip_initializer ();
           break;
 
+       case ',':
+         add_declarator (&cls, &id, flags, sc);
+         break;
+
         case OPERATOR:
          {
            char *s = operator_name (&sc);
@@ -3353,40 +3429,7 @@ declaration (flags)
         }
     }
 
-  if (LOOKING_AT (';'))
-    {
-      /* The end of a member variable or of an access declaration
-         `X::f'.  To distinguish between them we have to know whether
-         type information has been seen.  */
-      if (id)
-        {
-          char *regexp = matching_regexp ();
-          int pos = BUFFER_POS ();
-
-          if (cls)
-           add_member_defn (cls, id, regexp, pos, 0, 1, SC_UNKNOWN, flags);
-          else
-            add_global_defn (id, regexp, pos, 0, 1, sc, flags);
-        }
-
-      MATCH ();
-      print_info ();
-    }
-  else if (LOOKING_AT ('{'))
-    {
-      if (sc == SC_TYPE && id)
-        {
-          /* A named enumeration.  */
-          regexp = matching_regexp ();
-          pos = BUFFER_POS ();
-          add_global_defn (id, regexp, pos, 0, 1, sc, flags);
-        }
-
-      skip_matching ();
-      print_info ();
-    }
-
-  xfree (id);
+  add_declarator (&cls, &id, flags, sc);
 }
 
 
@@ -3631,7 +3674,7 @@ usage (error)
      int error;
 {
   puts (USAGE);
-  exit (error ? 1 : 0);
+  exit (error ? EXIT_FAILURE : EXIT_SUCCESS);
 }
 
 
@@ -3646,9 +3689,9 @@ void
 version ()
 {
   printf ("ebrowse %s\n", VERSION);
-  puts ("Copyright (C) 1992-1999, 2000, 2001 Free Software Foundation, Inc.");
+  puts ("Copyright (C) 1992-2006 Free Software Foundation, Inc.");
   puts ("This program is distributed under the same terms as Emacs.");
-  exit (0);
+  exit (EXIT_SUCCESS);
 }
 
 
@@ -3885,7 +3928,7 @@ main (argc, argv)
       if (yyout == NULL)
        {
          yyerror ("cannot open output file `%s'", out_filename);
-         exit (1);
+         exit (EXIT_FAILURE);
        }
     }
 
@@ -3930,8 +3973,10 @@ main (argc, argv)
   if (yyout != stdout)
     fclose (yyout);
 
-  return 0;
+  return EXIT_SUCCESS;
 }
 
+/* arch-tag: fc03b4bc-91a9-4c3d-b3b9-12a77fa86dd8
+   (do not change this comment) */
 
-/* ebrowse.c ends here */
+/* ebrowse.c ends here */