summaryrefslogtreecommitdiff
path: root/lib-src/ebrowse.c
diff options
context:
space:
mode:
authorPavel Janík <Pavel@Janik.cz>2001-12-19 06:03:57 +0000
committerPavel Janík <Pavel@Janik.cz>2001-12-19 06:03:57 +0000
commit69bfc389e93e4167de96c719f7a6c1c7b9ff7b05 (patch)
tree2267cadebaae19c1c126a7e34a8248483e1b847b /lib-src/ebrowse.c
parent797c2e4e0580f259ab982812f94b43e5d60f3098 (diff)
downloademacs-69bfc389e93e4167de96c719f7a6c1c7b9ff7b05.tar.gz
Include stdlib.h and string.h conditionally.
Diffstat (limited to 'lib-src/ebrowse.c')
-rw-r--r--lib-src/ebrowse.c137
1 files changed, 72 insertions, 65 deletions
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index 69bd057a59c..8522a795980 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -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 @@ int inbuffer_size;
#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 @@ add_link (super, sub)
{
lnk = (struct link *) xmalloc (sizeof *lnk);
lnk2 = (struct link *) xmalloc (sizeof *lnk2);
-
+
lnk->sym = sub;
lnk->next = p;
@@ -728,15 +735,15 @@ find_member (cls, name, var, sc, hash)
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 @@ add_global_defn (name, regexp, pos, hash, var, sc, flags)
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 @@ add_member (cls, name, var, sc, hash)
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 @@ check_namespace (name, context)
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 @@ find_namespace (name, context)
return p;
}
-
+
/* Find namespace alias with name NAME. If not found return NULL. */
@@ -1210,7 +1217,7 @@ enter_namespace (name)
size * sizeof *namespace_stack);
namespace_stack_size = size;
}
-
+
namespace_stack[namespace_sp++] = current_namespace;
current_namespace = p;
}
@@ -1282,7 +1289,7 @@ sym_scope_1 (p)
struct sym *p;
{
int len;
-
+
if (p->namesp)
sym_scope_1 (p->namesp);
@@ -1297,14 +1304,14 @@ sym_scope_1 (p)
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 @@ sym_scope (p)
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 @@ dump_sym (fp, root)
{
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 @@ process_pp_line ()
add_define (yytext, regexp, pos);
}
}
-
+
while (c && (c != '\n' || in_comment || in_string))
{
if (c == '\\')
@@ -1580,7 +1587,7 @@ process_pp_line ()
}
else if (c == '"')
in_string = !in_string;
-
+
if (c == '\n')
INCREMENT_LINENO;
@@ -2184,7 +2191,7 @@ re_init_scanner ()
{
in = inbuffer;
yyline = 1;
-
+
if (yytext == NULL)
{
int size = 256;
@@ -2386,19 +2393,19 @@ skip_matching ()
case '{':
close = '}';
break;
-
+
case '(':
close = ')';
break;
-
+
case '<':
close = '>';
break;
-
+
case '[':
close = ']';
break;
-
+
default:
abort ();
}
@@ -2505,7 +2512,7 @@ parm_list (flags)
{
char *last_id;
unsigned ident_type_hash = 0;
-
+
parse_qualified_param_ident_or_type (&last_id);
if (last_id)
{
@@ -2533,7 +2540,7 @@ parm_list (flags)
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 @@ parm_list (flags)
if (LOOKING_AT (')'))
{
MATCH ();
-
+
if (LOOKING_AT (CONST))
{
/* We can overload the same function on `const' */
@@ -2638,7 +2645,7 @@ member (cls, vis)
case EXPLICIT:
SET_FLAG (flags, F_EXPLICIT);
goto typeseen;
-
+
case MUTABLE:
SET_FLAG (flags, F_MUTABLE);
goto typeseen;
@@ -2773,7 +2780,7 @@ member (cls, vis)
{
regexp = matching_regexp ();
pos = BUFFER_POS ();
-
+
if (cls != NULL)
{
if (type_seen || !paren_seen)
@@ -2782,7 +2789,7 @@ member (cls, vis)
add_member_decl (cls, id, regexp, pos, hash, 0, sc, vis, 0);
}
}
-
+
MATCH ();
print_info ();
}
@@ -2879,7 +2886,7 @@ struct sym *
parse_classname ()
{
struct sym *last_class = NULL;
-
+
while (LOOKING_AT (IDENT))
{
last_class = add_sym (yytext, last_class);
@@ -2890,10 +2897,10 @@ parse_classname ()
skip_matching ();
SET_FLAG (last_class->flags, F_TEMPLATE);
}
-
+
if (!LOOKING_AT (DCOLON))
break;
-
+
MATCH ();
}
@@ -2913,7 +2920,7 @@ operator_name (sc)
static char *id = NULL;
char *s;
int len;
-
+
MATCH ();
if (LOOKING_AT2 (NEW, DELETE))
@@ -2924,7 +2931,7 @@ operator_name (sc)
s = token_string (LA1);
MATCH ();
-
+
len = strlen (s) + 10;
if (len > id_size)
{
@@ -2934,12 +2941,12 @@ operator_name (sc)
}
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 @@ parse_qualified_ident_or_type (last_id)
char *id = NULL;
size_t id_size = 0;
int enter = 0;
-
+
while (LOOKING_AT (IDENT))
{
int len = strlen (yytext) + 1;
@@ -3233,7 +3240,7 @@ declaration (flags)
sc = SC_TYPE;
MATCH ();
break;
-
+
case STATIC:
sc = SC_STATIC;
MATCH ();
@@ -3361,7 +3368,7 @@ declaration (flags)
else
add_global_defn (id, regexp, pos, 0, 1, sc, flags);
}
-
+
MATCH ();
print_info ();
}
@@ -3399,7 +3406,7 @@ globals (start_flags)
for (;;)
{
char *prev_in = in;
-
+
switch (LA1)
{
case NAMESPACE:
@@ -3410,13 +3417,13 @@ globals (start_flags)
{
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 @@ globals (start_flags)
{
/* This is `extern "C"'. */
MATCH ();
-
+
if (LOOKING_AT ('{'))
{
MATCH ();
@@ -3452,7 +3459,7 @@ globals (start_flags)
SET_FLAG (flags, F_EXTERNC);
}
break;
-
+
case TEMPLATE:
MATCH ();
SKIP_MATCHING_IF ('<');
@@ -3492,7 +3499,7 @@ globals (start_flags)
case '}':
return 0;
-
+
default:
declaration (flags);
flags = start_flags;
@@ -3531,10 +3538,10 @@ add_search_path (path_list)
{
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 @@ open_file (file)
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 @@ open_file (file)
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 @@ process_file (file)
char *file;
{
FILE *fp;
-
+
fp = open_file (file);
if (fp)
- {
+ {
int nread, nbytes;
/* Give a progress indication if needed. */
@@ -3679,7 +3686,7 @@ process_file (file)
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 @@ read_line (fp)
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 @@ main (argc, argv)
case 'p':
info_position = atoi (optarg);
break;
-
+
case 'n':
f_nested_classes = 0;
break;
@@ -3773,7 +3780,7 @@ main (argc, argv)
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 @@ main (argc, argv)
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 @@ main (argc, argv)
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