changeset 42174:e3b97ef49aee

Include stdlib.h and string.h conditionally.
author Pavel Janík <Pavel@Janik.cz>
date Wed, 19 Dec 2001 06:03:40 +0000
parents 9c9bb29ed93f
children 80ed9c7f014f
files lib-src/ebrowse.c
diffstat 1 files changed, 72 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/ebrowse.c	Wed Dec 19 02:23:26 2001 +0000
+++ b/lib-src/ebrowse.c	Wed Dec 19 06:03:40 2001 +0000
@@ -6,7 +6,7 @@
 
    Author: Gerd Moellmann <gerd@gnu.org>
    Maintainer: FSF
-   
+
    This file is part of GNU Emacs.
 
    GNU Emacs is free software; you can redistribute it and/or modify
@@ -28,8 +28,15 @@
 #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"
@@ -400,7 +407,7 @@
 
 #define BUFFER_POS() (in - inbuffer)
 
-/* If current lookahead is CSTRING, the following points to the 
+/* If current lookahead is CSTRING, the following points to the
    first character in the string constant.  Used for recognizing
    extern "C".  */
 
@@ -686,7 +693,7 @@
     {
       lnk = (struct link *) xmalloc (sizeof *lnk);
       lnk2 = (struct link *) xmalloc (sizeof *lnk2);
-  
+
       lnk->sym = sub;
       lnk->next = p;
 
@@ -728,15 +735,15 @@
     case SC_FRIEND:
       list = &cls->friends;
       break;
-      
+
     case SC_TYPE:
       list = &cls->types;
       break;
-      
+
     case SC_STATIC:
       list = var ? &cls->static_vars : &cls->static_fns;
       break;
-      
+
     default:
       list = var ? &cls->vars : &cls->fns;
       break;
@@ -928,7 +935,7 @@
    a bit set giving additional information about the member (see the
    F_* defines).  */
 
-void 
+void
 add_global_decl (name, regexp, pos, hash, var, sc, flags)
      char *name, *regexp;
      int pos;
@@ -1008,15 +1015,15 @@
     case SC_FRIEND:
       list = &cls->friends;
       break;
-      
+
     case SC_TYPE:
       list = &cls->types;
       break;
-      
+
     case SC_STATIC:
       list = var ? &cls->static_vars : &cls->static_fns;
       break;
-      
+
     default:
       list = var ? &cls->vars : &cls->fns;
       break;
@@ -1112,7 +1119,7 @@
      struct sym *context;
 {
   struct sym *p = NULL;
-  
+
   for (p = all_namespaces; p; p = p->next)
     {
       if (streq (p->name, name) && (p->namesp == context))
@@ -1137,7 +1144,7 @@
 
   return p;
 }
-  
+
 
 /* Find namespace alias with name NAME. If not found return NULL. */
 
@@ -1210,7 +1217,7 @@
 				    size * sizeof *namespace_stack);
       namespace_stack_size = size;
     }
-  
+
   namespace_stack[namespace_sp++] = current_namespace;
   current_namespace = p;
 }
@@ -1282,7 +1289,7 @@
      struct sym *p;
 {
   int len;
-  
+
   if (p->namesp)
     sym_scope_1 (p->namesp);
 
@@ -1297,14 +1304,14 @@
   ensure_scope_buffer_room (len + 1);
   strcat (scope_buffer, p->name);
   scope_buffer_len += len;
-  
+
   if (HAS_FLAG (p->flags, F_TEMPLATE))
     {
       ensure_scope_buffer_room (3);
       strcat (scope_buffer, "<>");
       scope_buffer_len += 2;
     }
-  
+
   return scope_buffer;
 }
 
@@ -1321,10 +1328,10 @@
       scope_buffer_size = 1024;
       scope_buffer = (char *) xmalloc (scope_buffer_size);
     }
-  
+
   *scope_buffer = '\0';
   scope_buffer_len = 0;
-  
+
   if (p->namesp)
     sym_scope_1 (p->namesp);
 
@@ -1377,13 +1384,13 @@
 {
   fputs (CLASS_STRUCT, fp);
   PUTSTR (root->name, fp);
-  
+
   /* Print scope, if any.  */
   if (root->namesp)
     PUTSTR (sym_scope (root), fp);
   else
     PUTSTR (NULL, fp);
-  
+
   /* Print flags.  */
   fprintf (fp, "%u", root->flags);
   PUTSTR (root->filename, fp);
@@ -1563,7 +1570,7 @@
 	  add_define (yytext, regexp, pos);
 	}
     }
-  
+
   while (c && (c != '\n' || in_comment || in_string))
     {
       if (c == '\\')
@@ -1580,7 +1587,7 @@
 	}
       else if (c == '"')
 	in_string = !in_string;
-      
+
       if (c == '\n')
 	INCREMENT_LINENO;
 
@@ -2184,7 +2191,7 @@
 {
   in = inbuffer;
   yyline = 1;
-  
+
   if (yytext == NULL)
     {
       int size = 256;
@@ -2386,19 +2393,19 @@
     case '{':
       close = '}';
       break;
-      
+
     case '(':
       close = ')';
       break;
-      
+
     case '<':
       close = '>';
       break;
-      
+
     case '[':
       close = ']';
       break;
-      
+
     default:
       abort ();
     }
@@ -2505,7 +2512,7 @@
             {
 	      char *last_id;
 	      unsigned ident_type_hash = 0;
-	      
+
 	      parse_qualified_param_ident_or_type (&last_id);
 	      if (last_id)
 		{
@@ -2533,7 +2540,7 @@
         case DOUBLE:    case ENUM:      case FLOAT:     case INT:
         case LONG:      case SHORT:     case SIGNED:    case STRUCT:
         case UNION:     case UNSIGNED:  case VOLATILE:  case WCHAR:
-        case ELLIPSIS:  
+        case ELLIPSIS:
           type_seen = 1;
           hash = (hash << 1) ^ LA1;
           MATCH ();
@@ -2553,7 +2560,7 @@
   if (LOOKING_AT (')'))
     {
       MATCH ();
-      
+
       if (LOOKING_AT (CONST))
         {
           /* We can overload the same function on `const' */
@@ -2638,7 +2645,7 @@
         case EXPLICIT:
           SET_FLAG (flags, F_EXPLICIT);
           goto typeseen;
-          
+
         case MUTABLE:
           SET_FLAG (flags, F_MUTABLE);
           goto typeseen;
@@ -2773,7 +2780,7 @@
         {
           regexp = matching_regexp ();
           pos = BUFFER_POS ();
-          
+
           if (cls != NULL)
             {
               if (type_seen || !paren_seen)
@@ -2782,7 +2789,7 @@
 		add_member_decl (cls, id, regexp, pos, hash, 0, sc, vis, 0);
             }
         }
-      
+
       MATCH ();
       print_info ();
     }
@@ -2879,7 +2886,7 @@
 parse_classname ()
 {
   struct sym *last_class = NULL;
-  
+
   while (LOOKING_AT (IDENT))
     {
       last_class = add_sym (yytext, last_class);
@@ -2890,10 +2897,10 @@
           skip_matching ();
           SET_FLAG (last_class->flags, F_TEMPLATE);
         }
-      
+
       if (!LOOKING_AT (DCOLON))
         break;
-      
+
       MATCH ();
     }
 
@@ -2913,7 +2920,7 @@
   static char *id = NULL;
   char *s;
   int len;
-  
+
   MATCH ();
 
   if (LOOKING_AT2 (NEW, DELETE))
@@ -2924,7 +2931,7 @@
 
       s = token_string (LA1);
       MATCH ();
-      
+
       len = strlen (s) + 10;
       if (len > id_size)
 	{
@@ -2934,12 +2941,12 @@
 	}
       strcpy (id, s);
 
-      /* Vector new or delete? */
+      /* Vector new or delete?  */
       if (LOOKING_AT ('['))
 	{
 	  strcat (id, "[");
 	  MATCH ();
-	  
+
 	  if (LOOKING_AT (']'))
 	    {
 	      strcat (id, "]");
@@ -3004,7 +3011,7 @@
   char *id = NULL;
   size_t id_size = 0;
   int enter = 0;
-  
+
   while (LOOKING_AT (IDENT))
     {
       int len = strlen (yytext) + 1;
@@ -3233,7 +3240,7 @@
           sc = SC_TYPE;
           MATCH ();
           break;
-          
+
         case STATIC:
           sc = SC_STATIC;
           MATCH ();
@@ -3361,7 +3368,7 @@
           else
             add_global_defn (id, regexp, pos, 0, 1, sc, flags);
         }
-        
+
       MATCH ();
       print_info ();
     }
@@ -3399,7 +3406,7 @@
   for (;;)
     {
       char *prev_in = in;
-      
+
       switch (LA1)
         {
         case NAMESPACE:
@@ -3410,13 +3417,13 @@
               {
                 char *namespace_name = xstrdup (yytext);
                 MATCH ();
-                
+
                 if (LOOKING_AT ('='))
                   {
 		    struct link *qna = match_qualified_namespace_alias ();
 		    if (qna)
                       register_namespace_alias (namespace_name, qna);
-		      
+
                     if (skip_to (';') == ';')
                       MATCH ();
                   }
@@ -3441,7 +3448,7 @@
             {
               /* This is `extern "C"'.  */
               MATCH ();
-              
+
               if (LOOKING_AT ('{'))
                 {
                   MATCH ();
@@ -3452,7 +3459,7 @@
                 SET_FLAG (flags, F_EXTERNC);
             }
           break;
-          
+
         case TEMPLATE:
           MATCH ();
           SKIP_MATCHING_IF ('<');
@@ -3492,7 +3499,7 @@
 
         case '}':
           return 0;
-          
+
         default:
           declaration (flags);
           flags = start_flags;
@@ -3531,10 +3538,10 @@
     {
       char *start = path_list;
       struct search_path *p;
-      
+
       while (*path_list && *path_list != PATH_LIST_SEPARATOR)
         ++path_list;
-      
+
       p = (struct search_path *) xmalloc (sizeof *p);
       p->path = (char *) xmalloc (path_list - start + 1);
       memcpy (p->path, start, path_list - start);
@@ -3568,7 +3575,7 @@
   static int buffer_size;
   struct search_path *path;
   int flen = strlen (file) + 1;	/* +1 for the slash */
-  
+
   filename = xstrdup (file);
 
   for (path = search_path; path && fp == NULL; path = path->next)
@@ -3580,20 +3587,20 @@
 	  buffer_size = max (len + 1, 2 * buffer_size);
 	  buffer = (char *) xrealloc (buffer, buffer_size);
 	}
-	
+
       strcpy (buffer, path->path);
       strcat (buffer, "/");
       strcat (buffer, file);
       fp = fopen (buffer, "r");
     }
-  
+
   /* Try the original file name.  */
   if (fp == NULL)
      fp = fopen (file, "r");
 
   if (fp == NULL)
     yyerror ("cannot open", NULL);
-  
+
   return fp;
 }
 
@@ -3653,10 +3660,10 @@
      char *file;
 {
   FILE *fp;
-  
+
   fp = open_file (file);
   if (fp)
-    {      
+    {
       int nread, nbytes;
 
       /* Give a progress indication if needed.  */
@@ -3679,7 +3686,7 @@
 	      inbuffer_size = nread + READ_CHUNK_SIZE + 1;
 	      inbuffer = (char *) xrealloc (inbuffer, inbuffer_size);
 	    }
-	  
+
 	  nbytes = fread (inbuffer + nread, 1, READ_CHUNK_SIZE, fp);
 	  if (nbytes <= 0)
 	    break;
@@ -3722,10 +3729,10 @@
 
       buffer[i++] = c;
     }
-  
+
   if (c == EOF && i == 0)
     return NULL;
-  
+
   if (i == buffer_size)
     {
       buffer_size = max (100, buffer_size * 2);
@@ -3765,7 +3772,7 @@
 	case 'p':
 	  info_position = atoi (optarg);
 	  break;
-	  
+
         case 'n':
           f_nested_classes = 0;
           break;
@@ -3773,7 +3780,7 @@
         case 'x':
           f_regexps = 0;
           break;
-        
+
           /* Add the name of a file containing more input files.  */
         case 'f':
 	  if (n_input_files == input_filenames_size)
@@ -3870,10 +3877,10 @@
 	    yyerror ("error getting size of file `%s'", out_filename);
 	  else if (rc == 0)
 	    yyerror ("file `%s' is empty", out_filename);
-	  
+
 	  fclose (fp);
 	}
-      
+
       yyout = fopen (out_filename, f_append ? "a" : "w");
       if (yyout == NULL)
 	{
@@ -3903,7 +3910,7 @@
       for (i = 0; i < n_input_files; ++i)
         {
           FILE *fp = fopen (input_filenames[i], "r");
-          
+
           if (fp == NULL)
             yyerror ("cannot open input file `%s'", input_filenames[i]);
           else