1999-01-06 15:44:41 -05:00
|
|
|
/* Part of CPP library. (Macro hash table support.)
|
|
|
|
Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
1999-01-07 17:02:07 -05:00
|
|
|
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1999-01-06 15:44:41 -05:00
|
|
|
|
1995-03-16 16:59:07 -05:00
|
|
|
/* different kinds of things that can appear in the value field
|
1999-02-08 15:27:27 -05:00
|
|
|
of a hash node. */
|
|
|
|
union hashval
|
|
|
|
{
|
|
|
|
const char *cpval; /* some predefined macros */
|
|
|
|
DEFINITION *defn; /* #define */
|
|
|
|
struct hashnode *aschain; /* #assert */
|
1995-03-16 16:59:07 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
struct hashnode {
|
|
|
|
struct hashnode *next; /* double links for easy deletion */
|
|
|
|
struct hashnode *prev;
|
|
|
|
struct hashnode **bucket_hdr; /* also, a back pointer to this node's hash
|
|
|
|
chain is kept, in case the node is the head
|
|
|
|
of the chain and gets deleted. */
|
|
|
|
enum node_type type; /* type of special token */
|
|
|
|
int length; /* length of token, for quick comparison */
|
|
|
|
U_CHAR *name; /* the actual name */
|
|
|
|
union hashval value; /* pointer to expansion, or whatever */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct hashnode HASHNODE;
|
|
|
|
|
|
|
|
/* Some definitions for the hash table. The hash function MUST be
|
|
|
|
computed as shown in hashf () below. That is because the rescan
|
|
|
|
loop computes the hash value `on the fly' for most tokens,
|
|
|
|
in order to avoid the overhead of a lot of procedure calls to
|
|
|
|
the hashf () function. Hashf () only exists for the sake of
|
|
|
|
politeness, for use when speed isn't so important. */
|
|
|
|
|
|
|
|
#define HASHSTEP(old, c) ((old << 2) + c)
|
|
|
|
#define MAKE_POS(v) (v & 0x7fffffff) /* make number positive */
|
|
|
|
|
1999-02-25 09:24:40 -05:00
|
|
|
extern HASHNODE *cpp_install PARAMS ((cpp_reader *, U_CHAR *, int,
|
|
|
|
enum node_type, const char *, int));
|
|
|
|
extern int hashf PARAMS ((const U_CHAR *, int, int));
|
|
|
|
extern void delete_macro PARAMS ((HASHNODE *));
|
cpplib.c: Kill define of STDC_VALUE.
1999-02-18 18:32 -0500 Zack Weinberg <zack@rabi.columbia.edu>
* cpplib.c: Kill define of STDC_VALUE. Don't include output.h
or prefix.h. Change CPP_IS_MACRO_BUFFER to not refer to
macro_cleanup.
(GET_ENV_PATH_LIST, PATH_SEPARATOR, STANDARD_INCLUDE_DIR,
predefs, SIZE_TYPE, PTRDIFF_TYPE, WCHAR_TYPE,
CPP_WCHAR_TYPE, USER_LABEL_PREFIX, REGISTER_PREFIX, struct
cpp_pending, version_string, struct default_include,
include_defaults_array, path_include, cpp_options_init,
dump_special_to_buffer, initialize_builtins, cpp_start_read,
cpp_reader_init, nreverse_pending, push_pending, print_help,
cpp_handle_option, cpp_handle_options, cpp_finish,
cpp_cleanup): Move to cppinit.c.
(macro_cleanup, struct arglist, collect_expansion,
create_definition, compare_defs, comp_def_part, ARG_BASE,
struct argdata, macarg, change_newlines, timestamp,
monthnames, special_symbol, unsafe_chars, macroexpand,
push_macro_expansion): Move to cpphash.c.
(quote_string, check_macro_name, cpp_expand_to_buffer,
output_line_command, cpp_undef): Export.
(null_underflow, null_cleanup, handle_directive): Make static.
* cpplib.h: Prototype now-exported functions. Adjust decls of
syntax tables so we can include cpplib.h in cppinit.c.
* cpphash.h: Prototype all functions exported by cpphash.c.
* cppinit.c: Make syntax tables initialized data if possible
(uses GCC designated-initializer extension).
* cppexp.c: Make cpp_lex static.
* Makefile.in: Move -D switches for the various include dirs
from cpplib.o rule to cppinit.o rule. Adjust dependencies.
From-SVN: r25287
1999-02-18 10:35:49 -05:00
|
|
|
|
|
|
|
extern MACRODEF create_definition PARAMS ((U_CHAR *, U_CHAR *,
|
|
|
|
cpp_reader *, int));
|
|
|
|
extern int compare_defs PARAMS ((cpp_reader *, DEFINITION *,
|
|
|
|
DEFINITION *));
|
|
|
|
extern void macroexpand PARAMS ((cpp_reader *, HASHNODE *));
|