]> code.delx.au - gnu-emacs/blobdiff - lib-src/ebrowse.c
Merge from trunk after addition of w32common.h.
[gnu-emacs] / lib-src / ebrowse.c
index c2b1fb9f4573765289cad6ed81a454093f0e974a..056ed471fdeaf31b0f9dba47ba4083819afc10bf 100644 (file)
@@ -1,6 +1,6 @@
 /* ebrowse.c --- parsing files for the ebrowse C++ browser
 
-Copyright (C) 1992-2011  Free Software Foundation, Inc.
+Copyright (C) 1992-2012  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -20,11 +20,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
-
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
-
 #include <string.h>
 #include <ctype.h>
 #include <assert.h>
@@ -47,18 +43,13 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #define READ_CHUNK_SIZE (100 * 1024)
 
-/* The character used as a separator in path lists (like $PATH).  */
-
-#if defined(__MSDOS__)
-#define PATH_LIST_SEPARATOR ';'
-#define FILENAME_EQ(X,Y)    (strcasecmp(X,Y) == 0)
+#if defined (__MSDOS__)
+#define FILENAME_EQ(X,Y)    (strcasecmp (X,Y) == 0)
 #else
-#if defined(WINDOWSNT)
-#define PATH_LIST_SEPARATOR ';'
-#define FILENAME_EQ(X,Y)    (stricmp(X,Y) == 0)
+#if defined (WINDOWSNT)
+#define FILENAME_EQ(X,Y)    (stricmp (X,Y) == 0)
 #else
-#define PATH_LIST_SEPARATOR ':'
-#define FILENAME_EQ(X,Y)    (streq(X,Y))
+#define FILENAME_EQ(X,Y)    (streq (X,Y))
 #endif
 #endif
 /* The default output file name.  */
@@ -77,7 +68,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #define TREE_HEADER_STRUCT     "[ebrowse-hs "
 #define TREE_STRUCT            "[ebrowse-ts "
 #define MEMBER_STRUCT          "[ebrowse-ms "
-#define BROWSE_STRUCT          "[ebrowse-bs "
 #define CLASS_STRUCT           "[ebrowse-cs "
 
 /* The name of the symbol table entry for global functions, variables,
@@ -379,7 +369,7 @@ int max_regexp = 50;
 
 char *inbuffer;
 char *in;
-int inbuffer_size;
+size_t inbuffer_size;
 
 /* Return the current buffer position in the input file.  */
 
@@ -468,10 +458,6 @@ static struct member *add_member (struct sym *, char *, int, int, unsigned);
 static void class_definition (struct sym *, int, int, int);
 static char *operator_name (int *);
 static void parse_qualified_param_ident_or_type (char **);
-static void usage (int) NO_RETURN;
-static void version (void) NO_RETURN;
-
-
 \f
 /***********************************************************************
                              Utilities
@@ -493,7 +479,7 @@ yyerror (const char *format, const char *s)
    available.  */
 
 static void *
-xmalloc (int nbytes)
+xmalloc (size_t nbytes)
 {
   void *p = malloc (nbytes);
   if (p == NULL)
@@ -508,7 +494,7 @@ xmalloc (int nbytes)
 /* Like realloc but print an error and exit if out of memory.  */
 
 static void *
-xrealloc (void *p, int sz)
+xrealloc (void *p, size_t sz)
 {
   p = realloc (p, sz);
   if (p == NULL)
@@ -986,7 +972,7 @@ make_namespace (char *name, struct sym *context)
 }
 
 
-/* Find the symbol for namespace NAME.  If not found, retrun NULL */
+/* Find the symbol for namespace NAME.  If not found, return NULL */
 
 static struct sym *
 check_namespace (char *name, struct sym *context)
@@ -2516,7 +2502,7 @@ member (struct sym *cls, int vis)
 
           /* A function or class may follow.  */
         case TEMPLATE:
-          MATCH();
+          MATCH ();
           SET_FLAG (flags, F_TEMPLATE);
           /* Skip over template argument list */
           SKIP_MATCHING_IF ('<');
@@ -2793,10 +2779,10 @@ parse_classname (void)
 static char *
 operator_name (int *sc)
 {
-  static int id_size = 0;
+  static size_t id_size = 0;
   static char *id = NULL;
   const char *s;
-  int len;
+  size_t len;
 
   MATCH ();
 
@@ -2812,7 +2798,7 @@ operator_name (int *sc)
       len = strlen (s) + 10;
       if (len > id_size)
        {
-         int new_size = max (len, 2 * id_size);
+         size_t new_size = max (len, 2 * id_size);
          id = (char *) xrealloc (id, new_size);
          id_size = new_size;
        }
@@ -2833,7 +2819,7 @@ operator_name (int *sc)
     }
   else
     {
-      int tokens_matched = 0;
+      size_t tokens_matched = 0;
 
       len = 20;
       if (len > id_size)
@@ -2854,7 +2840,7 @@ operator_name (int *sc)
          len += strlen (s) + 2;
          if (len > id_size)
            {
-             int new_size = max (len, 2 * id_size);
+             size_t new_size = max (len, 2 * id_size);
              id = (char *) xrealloc (id, new_size);
              id_size = new_size;
            }
@@ -2935,7 +2921,7 @@ parse_qualified_ident_or_type (char **last_id)
     }
 
   while (enter--)
-    leave_namespace();
+    leave_namespace ();
 
   return cls;
 }
@@ -3426,7 +3412,7 @@ add_search_path (char *path_list)
       char *start = path_list;
       struct search_path *p;
 
-      while (*path_list && *path_list != PATH_LIST_SEPARATOR)
+      while (*path_list && *path_list != SEPCHAR)
         ++path_list;
 
       p = (struct search_path *) xmalloc (sizeof *p);
@@ -3443,7 +3429,7 @@ add_search_path (char *path_list)
       else
         search_path = search_path_tail = p;
 
-      while (*path_list == PATH_LIST_SEPARATOR)
+      while (*path_list == SEPCHAR)
         ++path_list;
     }
 }
@@ -3512,7 +3498,7 @@ Usage: ebrowse [options] {files}\n\
       --version                        display version info\n\
 "
 
-static void
+static _Noreturn void
 usage (int error)
 {
   puts (USAGE);
@@ -3527,11 +3513,10 @@ usage (int error)
 # define VERSION "21"
 #endif
 
-static void
+static _Noreturn void
 version (void)
 {
-  /* Makes it easier to update automatically. */
-  char emacs_copyright[] = "Copyright (C) 2011 Free Software Foundation, Inc.";
+  char emacs_copyright[] = COPYRIGHT;
 
   printf ("ebrowse %s\n", VERSION);
   puts (emacs_copyright);
@@ -3551,7 +3536,7 @@ process_file (char *file)
   fp = open_file (file);
   if (fp)
     {
-      int nread, nbytes;
+      size_t nread, nbytes;
 
       /* Give a progress indication if needed.  */
       if (f_very_verbose)
@@ -3575,12 +3560,10 @@ process_file (char *file)
            }
 
          nbytes = fread (inbuffer + nread, 1, READ_CHUNK_SIZE, fp);
-         if (nbytes <= 0)
+         if (nbytes == 0)
            break;
          nread += nbytes;
        }
-      if (nread < 0)
-       nread = 0;
       inbuffer[nread] = '\0';
 
       /* Reinitialize scanner and parser for the new input file.  */