Commit 69bfc389 authored by Pavel Janík's avatar Pavel Janík
Browse files

Include stdlib.h and string.h conditionally.

parent 797c2e4e
2001-12-19 Pavel Jan,Bm(Bk <Pavel@Janik.cz>
* ebrowse.c: Include stdlib.h and string.h conditionally.
2001-12-18 Eli Zaretskii <eliz@is.elta.co.il> 2001-12-18 Eli Zaretskii <eliz@is.elta.co.il>
* yow.c (main): Use time_t, not long, to avoid a compiler warning. * yow.c (main): Use time_t, not long, to avoid a compiler warning.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
Author: Gerd Moellmann <gerd@gnu.org> Author: Gerd Moellmann <gerd@gnu.org>
Maintainer: FSF Maintainer: FSF
This file is part of GNU Emacs. This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify GNU Emacs is free software; you can redistribute it and/or modify
...@@ -28,8 +28,15 @@ ...@@ -28,8 +28,15 @@
#endif #endif
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h> #include <string.h>
#endif
#include <ctype.h> #include <ctype.h>
#include <assert.h> #include <assert.h>
#include "getopt.h" #include "getopt.h"
...@@ -400,7 +407,7 @@ int inbuffer_size; ...@@ -400,7 +407,7 @@ int inbuffer_size;
#define BUFFER_POS() (in - inbuffer) #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 first character in the string constant. Used for recognizing
extern "C". */ extern "C". */
...@@ -686,7 +693,7 @@ add_link (super, sub) ...@@ -686,7 +693,7 @@ add_link (super, sub)
{ {
lnk = (struct link *) xmalloc (sizeof *lnk); lnk = (struct link *) xmalloc (sizeof *lnk);
lnk2 = (struct link *) xmalloc (sizeof *lnk2); lnk2 = (struct link *) xmalloc (sizeof *lnk2);
lnk->sym = sub; lnk->sym = sub;
lnk->next = p; lnk->next = p;
...@@ -728,15 +735,15 @@ find_member (cls, name, var, sc, hash) ...@@ -728,15 +735,15 @@ find_member (cls, name, var, sc, hash)
case SC_FRIEND: case SC_FRIEND:
list = &cls->friends; list = &cls->friends;
break; break;
case SC_TYPE: case SC_TYPE:
list = &cls->types; list = &cls->types;
break; break;
case SC_STATIC: case SC_STATIC:
list = var ? &cls->static_vars : &cls->static_fns; list = var ? &cls->static_vars : &cls->static_fns;
break; break;
default: default:
list = var ? &cls->vars : &cls->fns; list = var ? &cls->vars : &cls->fns;
break; break;
...@@ -928,7 +935,7 @@ add_global_defn (name, regexp, pos, hash, var, sc, flags) ...@@ -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 a bit set giving additional information about the member (see the
F_* defines). */ F_* defines). */
void void
add_global_decl (name, regexp, pos, hash, var, sc, flags) add_global_decl (name, regexp, pos, hash, var, sc, flags)
char *name, *regexp; char *name, *regexp;
int pos; int pos;
...@@ -1008,15 +1015,15 @@ add_member (cls, name, var, sc, hash) ...@@ -1008,15 +1015,15 @@ add_member (cls, name, var, sc, hash)
case SC_FRIEND: case SC_FRIEND:
list = &cls->friends; list = &cls->friends;
break; break;
case SC_TYPE: case SC_TYPE:
list = &cls->types; list = &cls->types;
break; break;
case SC_STATIC: case SC_STATIC:
list = var ? &cls->static_vars : &cls->static_fns; list = var ? &cls->static_vars : &cls->static_fns;
break; break;
default: default:
list = var ? &cls->vars : &cls->fns; list = var ? &cls->vars : &cls->fns;
break; break;
...@@ -1112,7 +1119,7 @@ check_namespace (name, context) ...@@ -1112,7 +1119,7 @@ check_namespace (name, context)
struct sym *context; struct sym *context;
{ {
struct sym *p = NULL; struct sym *p = NULL;
for (p = all_namespaces; p; p = p->next) for (p = all_namespaces; p; p = p->next)
{ {
if (streq (p->name, name) && (p->namesp == context)) if (streq (p->name, name) && (p->namesp == context))
...@@ -1137,7 +1144,7 @@ find_namespace (name, context) ...@@ -1137,7 +1144,7 @@ find_namespace (name, context)
return p; return p;
} }
/* Find namespace alias with name NAME. If not found return NULL. */ /* Find namespace alias with name NAME. If not found return NULL. */
...@@ -1210,7 +1217,7 @@ enter_namespace (name) ...@@ -1210,7 +1217,7 @@ enter_namespace (name)
size * sizeof *namespace_stack); size * sizeof *namespace_stack);
namespace_stack_size = size; namespace_stack_size = size;
} }
namespace_stack[namespace_sp++] = current_namespace; namespace_stack[namespace_sp++] = current_namespace;
current_namespace = p; current_namespace = p;
} }
...@@ -1282,7 +1289,7 @@ sym_scope_1 (p) ...@@ -1282,7 +1289,7 @@ sym_scope_1 (p)
struct sym *p; struct sym *p;
{ {
int len; int len;
if (p->namesp) if (p->namesp)
sym_scope_1 (p->namesp); sym_scope_1 (p->namesp);
...@@ -1297,14 +1304,14 @@ sym_scope_1 (p) ...@@ -1297,14 +1304,14 @@ sym_scope_1 (p)
ensure_scope_buffer_room (len + 1); ensure_scope_buffer_room (len + 1);
strcat (scope_buffer, p->name); strcat (scope_buffer, p->name);
scope_buffer_len += len; scope_buffer_len += len;
if (HAS_FLAG (p->flags, F_TEMPLATE)) if (HAS_FLAG (p->flags, F_TEMPLATE))
{ {
ensure_scope_buffer_room (3); ensure_scope_buffer_room (3);
strcat (scope_buffer, "<>"); strcat (scope_buffer, "<>");
scope_buffer_len += 2; scope_buffer_len += 2;
} }
return scope_buffer; return scope_buffer;
} }
...@@ -1321,10 +1328,10 @@ sym_scope (p) ...@@ -1321,10 +1328,10 @@ sym_scope (p)
scope_buffer_size = 1024; scope_buffer_size = 1024;
scope_buffer = (char *) xmalloc (scope_buffer_size); scope_buffer = (char *) xmalloc (scope_buffer_size);
} }
*scope_buffer = '\0'; *scope_buffer = '\0';
scope_buffer_len = 0; scope_buffer_len = 0;
if (p->namesp) if (p->namesp)
sym_scope_1 (p->namesp); sym_scope_1 (p->namesp);
...@@ -1377,13 +1384,13 @@ dump_sym (fp, root) ...@@ -1377,13 +1384,13 @@ dump_sym (fp, root)
{ {
fputs (CLASS_STRUCT, fp); fputs (CLASS_STRUCT, fp);
PUTSTR (root->name, fp); PUTSTR (root->name, fp);
/* Print scope, if any. */ /* Print scope, if any. */
if (root->namesp) if (root->namesp)
PUTSTR (sym_scope (root), fp); PUTSTR (sym_scope (root), fp);
else else
PUTSTR (NULL, fp); PUTSTR (NULL, fp);
/* Print flags. */ /* Print flags. */
fprintf (fp, "%u", root->flags); fprintf (fp, "%u", root->flags);
PUTSTR (root->filename, fp); PUTSTR (root->filename, fp);
...@@ -1563,7 +1570,7 @@ process_pp_line () ...@@ -1563,7 +1570,7 @@ process_pp_line ()
add_define (yytext, regexp, pos); add_define (yytext, regexp, pos);
} }
} }
while (c && (c != '\n' || in_comment || in_string)) while (c && (c != '\n' || in_comment || in_string))
{ {
if (c == '\\') if (c == '\\')
...@@ -1580,7 +1587,7 @@ process_pp_line () ...@@ -1580,7 +1587,7 @@ process_pp_line ()
} }
else if (c == '"') else if (c == '"')
in_string = !in_string; in_string = !in_string;
if (c == '\n') if (c == '\n')
INCREMENT_LINENO; INCREMENT_LINENO;
...@@ -2184,7 +2191,7 @@ re_init_scanner () ...@@ -2184,7 +2191,7 @@ re_init_scanner ()
{ {
in = inbuffer; in = inbuffer;
yyline = 1; yyline = 1;
if (yytext == NULL) if (yytext == NULL)
{ {
int size = 256; int size = 256;
...@@ -2386,19 +2393,19 @@ skip_matching () ...@@ -2386,19 +2393,19 @@ skip_matching ()
case '{': case '{':
close = '}'; close = '}';
break; break;
case '(': case '(':
close = ')'; close = ')';
break; break;
case '<': case '<':
close = '>'; close = '>';
break; break;
case '[': case '[':
close = ']'; close = ']';
break; break;
default: default:
abort (); abort ();
} }
...@@ -2505,7 +2512,7 @@ parm_list (flags) ...@@ -2505,7 +2512,7 @@ parm_list (flags)
{ {
char *last_id; char *last_id;
unsigned ident_type_hash = 0; unsigned ident_type_hash = 0;
parse_qualified_param_ident_or_type (&last_id); parse_qualified_param_ident_or_type (&last_id);
if (last_id) if (last_id)
{ {
...@@ -2533,7 +2540,7 @@ parm_list (flags) ...@@ -2533,7 +2540,7 @@ parm_list (flags)
case DOUBLE: case ENUM: case FLOAT: case INT: case DOUBLE: case ENUM: case FLOAT: case INT:
case LONG: case SHORT: case SIGNED: case STRUCT: case LONG: case SHORT: case SIGNED: case STRUCT:
case UNION: case UNSIGNED: case VOLATILE: case WCHAR: case UNION: case UNSIGNED: case VOLATILE: case WCHAR:
case ELLIPSIS: case ELLIPSIS:
type_seen = 1; type_seen = 1;
hash = (hash << 1) ^ LA1; hash = (hash << 1) ^ LA1;
MATCH (); MATCH ();
...@@ -2553,7 +2560,7 @@ parm_list (flags) ...@@ -2553,7 +2560,7 @@ parm_list (flags)
if (LOOKING_AT (')')) if (LOOKING_AT (')'))
{ {
MATCH (); MATCH ();
if (LOOKING_AT (CONST)) if (LOOKING_AT (CONST))
{ {
/* We can overload the same function on `const' */ /* We can overload the same function on `const' */
...@@ -2638,7 +2645,7 @@ member (cls, vis) ...@@ -2638,7 +2645,7 @@ member (cls, vis)
case EXPLICIT: case EXPLICIT:
SET_FLAG (flags, F_EXPLICIT); SET_FLAG (flags, F_EXPLICIT);
goto typeseen; goto typeseen;
case MUTABLE: case MUTABLE:
SET_FLAG (flags, F_MUTABLE); SET_FLAG (flags, F_MUTABLE);
goto typeseen; goto typeseen;
...@@ -2773,7 +2780,7 @@ member (cls, vis) ...@@ -2773,7 +2780,7 @@ member (cls, vis)
{ {
regexp = matching_regexp (); regexp = matching_regexp ();
pos = BUFFER_POS (); pos = BUFFER_POS ();
if (cls != NULL) if (cls != NULL)
{ {
if (type_seen || !paren_seen) if (type_seen || !paren_seen)
...@@ -2782,7 +2789,7 @@ member (cls, vis) ...@@ -2782,7 +2789,7 @@ member (cls, vis)
add_member_decl (cls, id, regexp, pos, hash, 0, sc, vis, 0); add_member_decl (cls, id, regexp, pos, hash, 0, sc, vis, 0);
} }
} }
MATCH (); MATCH ();
print_info (); print_info ();
} }
...@@ -2879,7 +2886,7 @@ struct sym * ...@@ -2879,7 +2886,7 @@ struct sym *
parse_classname () parse_classname ()
{ {
struct sym *last_class = NULL; struct sym *last_class = NULL;
while (LOOKING_AT (IDENT)) while (LOOKING_AT (IDENT))
{ {
last_class = add_sym (yytext, last_class); last_class = add_sym (yytext, last_class);
...@@ -2890,10 +2897,10 @@ parse_classname () ...@@ -2890,10 +2897,10 @@ parse_classname ()
skip_matching (); skip_matching ();
SET_FLAG (last_class->flags, F_TEMPLATE); SET_FLAG (last_class->flags, F_TEMPLATE);
} }
if (!LOOKING_AT (DCOLON)) if (!LOOKING_AT (DCOLON))
break; break;
MATCH (); MATCH ();
} }
...@@ -2913,7 +2920,7 @@ operator_name (sc) ...@@ -2913,7 +2920,7 @@ operator_name (sc)
static char *id = NULL; static char *id = NULL;
char *s; char *s;
int len; int len;
MATCH (); MATCH ();
if (LOOKING_AT2 (NEW, DELETE)) if (LOOKING_AT2 (NEW, DELETE))
...@@ -2924,7 +2931,7 @@ operator_name (sc) ...@@ -2924,7 +2931,7 @@ operator_name (sc)
s = token_string (LA1); s = token_string (LA1);
MATCH (); MATCH ();
len = strlen (s) + 10; len = strlen (s) + 10;
if (len > id_size) if (len > id_size)
{ {
...@@ -2934,12 +2941,12 @@ operator_name (sc) ...@@ -2934,12 +2941,12 @@ operator_name (sc)
} }
strcpy (id, s); strcpy (id, s);
/* Vector new or delete? */ /* Vector new or delete? */
if (LOOKING_AT ('[')) if (LOOKING_AT ('['))
{ {
strcat (id, "["); strcat (id, "[");
MATCH (); MATCH ();
if (LOOKING_AT (']')) if (LOOKING_AT (']'))
{ {
strcat (id, "]"); strcat (id, "]");
...@@ -3004,7 +3011,7 @@ parse_qualified_ident_or_type (last_id) ...@@ -3004,7 +3011,7 @@ parse_qualified_ident_or_type (last_id)
char *id = NULL; char *id = NULL;
size_t id_size = 0; size_t id_size = 0;
int enter = 0; int enter = 0;
while (LOOKING_AT (IDENT)) while (LOOKING_AT (IDENT))
{ {
int len = strlen (yytext) + 1; int len = strlen (yytext) + 1;
...@@ -3233,7 +3240,7 @@ declaration (flags) ...@@ -3233,7 +3240,7 @@ declaration (flags)
sc = SC_TYPE; sc = SC_TYPE;
MATCH (); MATCH ();
break; break;
case STATIC: case STATIC:
sc = SC_STATIC; sc = SC_STATIC;
MATCH (); MATCH ();
...@@ -3361,7 +3368,7 @@ declaration (flags) ...@@ -3361,7 +3368,7 @@ declaration (flags)
else else
add_global_defn (id, regexp, pos, 0, 1, sc, flags); add_global_defn (id, regexp, pos, 0, 1, sc, flags);
} }
MATCH (); MATCH ();
print_info (); print_info ();
} }
...@@ -3399,7 +3406,7 @@ globals (start_flags) ...@@ -3399,7 +3406,7 @@ globals (start_flags)
for (;;) for (;;)
{ {
char *prev_in = in; char *prev_in = in;
switch (LA1) switch (LA1)
{ {
case NAMESPACE: case NAMESPACE:
...@@ -3410,13 +3417,13 @@ globals (start_flags) ...@@ -3410,13 +3417,13 @@ globals (start_flags)
{ {
char *namespace_name = xstrdup (yytext); char *namespace_name = xstrdup (yytext);
MATCH (); MATCH ();
if (LOOKING_AT ('=')) if (LOOKING_AT ('='))
{ {
struct link *qna = match_qualified_namespace_alias (); struct link *qna = match_qualified_namespace_alias ();
if (qna) if (qna)
register_namespace_alias (namespace_name, qna); register_namespace_alias (namespace_name, qna);
if (skip_to (';') == ';') if (skip_to (';') == ';')
MATCH (); MATCH ();
} }
...@@ -3441,7 +3448,7 @@ globals (start_flags) ...@@ -3441,7 +3448,7 @@ globals (start_flags)
{ {
/* This is `extern "C"'. */ /* This is `extern "C"'. */
MATCH (); MATCH ();
if (LOOKING_AT ('{')) if (LOOKING_AT ('{'))
{ {
MATCH (); MATCH ();
...@@ -3452,7 +3459,7 @@ globals (start_flags) ...@@ -3452,7 +3459,7 @@ globals (start_flags)
SET_FLAG (flags, F_EXTERNC); SET_FLAG (flags, F_EXTERNC);
} }
break; break;
case TEMPLATE: case TEMPLATE:
MATCH (); MATCH ();
SKIP_MATCHING_IF ('<'); SKIP_MATCHING_IF ('<');
...@@ -3492,7 +3499,7 @@ globals (start_flags) ...@@ -3492,7 +3499,7 @@ globals (start_flags)
case '}': case '}':
return 0; return 0;
default: default:
declaration (flags); declaration (flags);
flags = start_flags; flags = start_flags;
...@@ -3531,10 +3538,10 @@ add_search_path (path_list) ...@@ -3531,10 +3538,10 @@ add_search_path (path_list)
{ {
char *start = path_list; char *start = path_list;
struct search_path *p; struct search_path *p;
while (*path_list && *path_list != PATH_LIST_SEPARATOR) while (*path_list && *path_list != PATH_LIST_SEPARATOR)
++path_list; ++path_list;
p = (struct search_path *) xmalloc (sizeof *p); p = (struct search_path *) xmalloc (sizeof *p);
p->path = (char *) xmalloc (path_list - start + 1); p->path = (char *) xmalloc (path_list - start + 1);
memcpy (p->path, start, path_list - start); memcpy (p->path, start, path_list - start);
...@@ -3568,7 +3575,7 @@ open_file (file) ...@@ -3568,7 +3575,7 @@ open_file (file)
static int buffer_size; static int buffer_size;
struct search_path *path; struct search_path *path;
int flen = strlen (file) + 1; /* +1 for the slash */ int flen = strlen (file) + 1; /* +1 for the slash */
filename = xstrdup (file); filename = xstrdup (file);
for (path = search_path; path && fp == NULL; path = path->next) for (path = search_path; path && fp == NULL; path = path->next)
...@@ -3580,20 +3587,20 @@ open_file (file) ...@@ -3580,20 +3587,20 @@ open_file (file)
buffer_size = max (len + 1, 2 * buffer_size); buffer_size = max (len + 1, 2 * buffer_size);
buffer = (char *) xrealloc (buffer, buffer_size); buffer = (char *) xrealloc (buffer, buffer_size);
} }
strcpy (buffer, path->path); strcpy (buffer, path->path);
strcat (buffer, "/"); strcat (buffer, "/");
strcat (buffer, file); strcat (buffer, file);
fp = fopen (buffer, "r"); fp = fopen (buffer, "r");
} }
/* Try the original file name. */ /* Try the original file name. */
if (fp == NULL) if (fp == NULL)
fp = fopen (file, "r"); fp = fopen (file, "r");
if (fp == NULL) if (fp == NULL)
yyerror ("cannot open", NULL); yyerror ("cannot open", NULL);
return fp; return fp;
} }
...@@ -3653,10 +3660,10 @@ process_file (file) ...@@ -3653,10 +3660,10 @@ process_file (file)
char *file;