Include <getopt.h> not "getopt.h".
[bpt/emacs.git] / lib-src / ebrowse.c
index 37b48a3..5cb9de5 100644 (file)
@@ -1,8 +1,8 @@
 /* ebrowse.c --- parsing files for the ebrowse C++ browser
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-              2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-              Free Software Foundation, Inc.
+  2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -20,23 +20,17 @@ You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
-
 #include <stdio.h>
 
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
 
-#ifdef HAVE_STRING_H
 #include <string.h>
-#endif
-
 #include <ctype.h>
 #include <assert.h>
-#include "getopt.h"
+#include <getopt.h>
 
 /* The SunOS compiler doesn't have SEEK_END.  */
 #ifndef SEEK_END
@@ -45,12 +39,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* Conditionalize function prototypes.  */
 
-#ifdef PROTOTYPES              /* From config.h.  */
-#define P_(x) x
-#else
-#define P_(x) ()
-#endif
-
 /* Value is non-zero if strings X and Y compare equal.  */
 
 #define streq(X, Y) (*(X) == *(Y) && strcmp ((X) + 1, (Y) + 1) == 0)
@@ -261,10 +249,10 @@ struct member
   int vis;                     /* Visibility (public, ...).  */
   int flags;                   /* See F_* above.  */
   char *regexp;                        /* Matching regular expression.  */
-  char *filename;              /* Don't free this shared string.  */
+  const char *filename;                /* Don't free this shared string.  */
   int pos;                     /* Buffer position of occurrence.  */
   char *def_regexp;            /* Regular expression matching definition.  */
-  char *def_filename;          /* File name of definition.  */
+  const char *def_filename;    /* File name of definition.  */
   int def_pos;                 /* Buffer position of definition.  */
   char name[1];                        /* Member name.  */
 };
@@ -306,8 +294,8 @@ struct sym
   struct member *types;                /* List of local types.  */
   char *regexp;                        /* Matching regular expression.  */
   int pos;                     /* Buffer position.  */
-  char *filename;              /* File in which it can be found.  */
-  char *sfilename;             /* File in which members can be found.  */
+  const char *filename;                /* File in which it can be found.  */
+  const char *sfilename;       /* File in which members can be found.  */
   struct sym *namesp;          /* Namespace in which defined. .  */
   char name[1];                 /* Name of the class.  */
 };
@@ -365,7 +353,7 @@ int yyline;
 
 /* The name of the current input file.  */
 
-char *filename;
+const char *filename;
 
 /* Three character class vectors, and macros to test membership
    of characters.  */
@@ -456,7 +444,7 @@ int tk = -1;
 
 struct kw
 {
-  char *name;                  /* Spelling.  */
+  const char *name;            /* Spelling.  */
   int tk;                      /* Token value.  */
   struct kw *next;             /* Next in collision chain.  */
 };
@@ -482,10 +470,10 @@ struct search_path *search_path_tail;
 int yylex (void);
 void yyparse (void);
 void re_init_parser (void);
-char *token_string (int);
+const char *token_string (int);
 char *matching_regexp (void);
 void init_sym (void);
-struct sym *add_sym (char *, struct sym *);
+struct sym *add_sym (const char *, struct sym *);
 void add_link (struct sym *, struct sym *);
 void add_member_defn (struct sym *, char *, char *,
                       int, unsigned, int, int, int);
@@ -501,11 +489,9 @@ void mark_inherited_virtual (void);
 void leave_namespace (void);
 void enter_namespace (char *);
 void register_namespace_alias (char *, struct link *);
-void insert_keyword (char *, int);
+void insert_keyword (const char *, int);
 void re_init_scanner (void);
 void init_scanner (void);
-void usage (int);
-void version (void);
 void process_file (char *);
 void add_search_path (char *);
 FILE *open_file (char *);
@@ -516,7 +502,6 @@ int dump_tree (FILE *, struct sym *);
 struct member *find_member (struct sym *, char *, int, int, unsigned);
 struct member *add_member (struct sym *, char *, int, int, unsigned);
 void mark_virtual (struct sym *);
-void mark_virtual (struct sym *);
 struct sym *make_namespace (char *, struct sym *);
 char *sym_scope (struct sym *);
 char *sym_scope_1 (struct sym *);
@@ -532,7 +517,7 @@ struct sym *parse_classname (void);
 struct sym *parse_qualified_ident_or_type (char **);
 void parse_qualified_param_ident_or_type (char **);
 int globals (int);
-void yyerror (char *, char *);
+void yyerror (const char *, const char *);
 void usage (int) NO_RETURN;
 void version (void) NO_RETURN;
 
@@ -546,7 +531,7 @@ void version (void) NO_RETURN;
    name and line number.  */
 
 void
-yyerror (char *format, char *s)
+yyerror (const char *format, const char *s)
 {
   fprintf (stderr, "%s:%d: ", filename, yyline);
   fprintf (stderr, format, s);
@@ -620,11 +605,11 @@ init_sym (void)
    create a new symbol and set it to default values.  */
 
 struct sym *
-add_sym (char *name, struct sym *nested_in_class)
+add_sym (const char *name, struct sym *nested_in_class)
 {
   struct sym *sym;
   unsigned h;
-  char *s;
+  const char *s;
   struct sym *scope = nested_in_class ? nested_in_class : current_namespace;
 
   for (s = name, h = 0; *s; ++s)
@@ -647,7 +632,7 @@ add_sym (char *name, struct sym *nested_in_class)
        }
 
       sym = (struct sym *) xmalloc (sizeof *sym + strlen (name));
-      bzero (sym, sizeof *sym);
+      memset (sym, 0, sizeof *sym);
       strcpy (sym->name, name);
       sym->namesp = scope;
       sym->next = class_table[h];
@@ -1042,7 +1027,7 @@ struct sym *
 make_namespace (char *name, struct sym *context)
 {
   struct sym *s = (struct sym *) xmalloc (sizeof *s + strlen (name));
-  bzero (s, sizeof *s);
+  memset (s, 0, sizeof *s);
   strcpy (s->name, name);
   s->next = all_namespaces;
   s->namesp = context;
@@ -1062,10 +1047,10 @@ check_namespace (char *name, struct sym *context)
     {
       if (streq (p->name, name) && (p->namesp == context))
            break;
-       }
+    }
 
   return p;
-    }
+}
 
 /* Find the symbol for namespace NAME.  If not found, add a new symbol
    for NAME to all_namespaces.  */
@@ -1715,6 +1700,11 @@ yylex (void)
             case '/':
              while (GET (c) && c != '\n')
                ;
+             /* Don't try to read past the end of the input buffer if
+                the file ends in a C++ comment without a newline.  */
+             if (c == 0)
+               return YYEOF;
+
              INCREMENT_LINENO;
              break;
 
@@ -1990,7 +1980,7 @@ matching_regexp (void)
 
 /* Return a printable representation of token T.  */
 
-char *
+const char *
 token_string (int t)
 {
   static char b[3];
@@ -2126,9 +2116,9 @@ re_init_scanner (void)
    table.  */
 
 void
-insert_keyword (char *name, int tk)
+insert_keyword (const char *name, int tk)
 {
-  char *s;
+  const char *s;
   unsigned h = 0;
   struct kw *k = (struct kw *) xmalloc (sizeof *k);
 
@@ -2854,7 +2844,7 @@ operator_name (int *sc)
 {
   static int id_size = 0;
   static char *id = NULL;
-  char *s;
+  const char *s;
   int len;
 
   MATCH ();
@@ -3587,7 +3577,7 @@ void
 version (void)
 {
   /* Makes it easier to update automatically. */
-  char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc.";
+  char emacs_copyright[] = "Copyright (C) 2011 Free Software Foundation, Inc.";
 
   printf ("ebrowse %s\n", VERSION);
   puts (emacs_copyright);
@@ -3695,7 +3685,7 @@ main (int argc, char **argv)
 {
   int i;
   int any_inputfiles = 0;
-  static char *out_filename = DEFAULT_OUTFILE;
+  static const char *out_filename = DEFAULT_OUTFILE;
   static char **input_filenames = NULL;
   static int input_filenames_size = 0;
   static int n_input_files;
@@ -3887,7 +3877,4 @@ main (int argc, char **argv)
   return EXIT_SUCCESS;
 }
 
-/* arch-tag: fc03b4bc-91a9-4c3d-b3b9-12a77fa86dd8
-   (do not change this comment) */
-
 /* ebrowse.c ends here */