* lisp/emacs-lisp/timer.el (with-timeout): Make sure we cancel the timer
[bpt/emacs.git] / lib-src / ebrowse.c
index bc537ec..7395f2c 100644 (file)
@@ -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>
@@ -49,16 +45,16 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* The character used as a separator in path lists (like $PATH).  */
 
-#if defined(__MSDOS__)
+#if defined (__MSDOS__)
 #define PATH_LIST_SEPARATOR ';'
-#define FILENAME_EQ(X,Y)    (strcasecmp(X,Y) == 0)
+#define FILENAME_EQ(X,Y)    (strcasecmp (X,Y) == 0)
 #else
-#if defined(WINDOWSNT)
+#if defined (WINDOWSNT)
 #define PATH_LIST_SEPARATOR ';'
-#define FILENAME_EQ(X,Y)    (stricmp(X,Y) == 0)
+#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 +73,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 +374,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.  */
 
@@ -493,7 +488,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 +503,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)
@@ -2063,11 +2058,11 @@ re_init_scanner (void)
 }
 
 
-/* Insert a keyword NAME with token value TK into the keyword hash
+/* Insert a keyword NAME with token value TKV into the keyword hash
    table.  */
 
 static void
-insert_keyword (const char *name, int tk)
+insert_keyword (const char *name, int tkv)
 {
   const char *s;
   unsigned h = 0;
@@ -2078,7 +2073,7 @@ insert_keyword (const char *name, int tk)
 
   h %= KEYWORD_TABLE_SIZE;
   k->name = name;
-  k->tk = tk;
+  k->tk = tkv;
   k->next = keyword_table[h];
   keyword_table[h] = k;
 }
@@ -2516,7 +2511,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 +2788,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 +2807,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 +2828,7 @@ operator_name (int *sc)
     }
   else
     {
-      int tokens_matched = 0;
+      size_t tokens_matched = 0;
 
       len = 20;
       if (len > id_size)
@@ -2854,7 +2849,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 +2930,7 @@ parse_qualified_ident_or_type (char **last_id)
     }
 
   while (enter--)
-    leave_namespace();
+    leave_namespace ();
 
   return cls;
 }
@@ -2952,7 +2947,9 @@ parse_qualified_param_ident_or_type (char **last_id)
   static char *id = NULL;
   static int id_size = 0;
 
-  while (LOOKING_AT (IDENT))
+  assert (LOOKING_AT (IDENT));
+
+  do
     {
       int len = strlen (yytext) + 1;
       if (len > id_size)
@@ -2975,6 +2972,7 @@ parse_qualified_param_ident_or_type (char **last_id)
       else
        break;
     }
+  while (LOOKING_AT (IDENT));
 }
 
 
@@ -3548,7 +3546,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)
@@ -3572,12 +3570,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.  */