| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
#include "hash.h" |
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
enum variable_origin |
|---|
| 24 |
{ |
|---|
| 25 |
o_default, |
|---|
| 26 |
o_env, |
|---|
| 27 |
o_file, |
|---|
| 28 |
o_env_override, |
|---|
| 29 |
o_command, |
|---|
| 30 |
o_override, |
|---|
| 31 |
o_automatic, |
|---|
| 32 |
o_invalid |
|---|
| 33 |
}; |
|---|
| 34 |
|
|---|
| 35 |
enum variable_flavor |
|---|
| 36 |
{ |
|---|
| 37 |
f_bogus, |
|---|
| 38 |
f_simple, |
|---|
| 39 |
f_recursive, |
|---|
| 40 |
f_append, |
|---|
| 41 |
f_conditional |
|---|
| 42 |
}; |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
#define EXP_COUNT_BITS 15 |
|---|
| 49 |
#define EXP_COUNT_MAX ((1<<EXP_COUNT_BITS)-1) |
|---|
| 50 |
|
|---|
| 51 |
struct variable |
|---|
| 52 |
{ |
|---|
| 53 |
char *name; |
|---|
| 54 |
int length; |
|---|
| 55 |
char *value; |
|---|
| 56 |
struct floc fileinfo; |
|---|
| 57 |
unsigned int recursive:1; |
|---|
| 58 |
unsigned int append:1; |
|---|
| 59 |
variable. */ |
|---|
| 60 |
unsigned int conditional:1; |
|---|
| 61 |
unsigned int per_target:1; |
|---|
| 62 |
unsigned int special:1; |
|---|
| 63 |
unsigned int exportable:1; |
|---|
| 64 |
exported. */ |
|---|
| 65 |
unsigned int expanding:1; |
|---|
| 66 |
unsigned int exp_count:EXP_COUNT_BITS; |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
enum variable_flavor |
|---|
| 70 |
flavor ENUM_BITFIELD (3); |
|---|
| 71 |
enum variable_origin |
|---|
| 72 |
origin ENUM_BITFIELD (3); |
|---|
| 73 |
enum variable_export |
|---|
| 74 |
{ |
|---|
| 75 |
v_export, |
|---|
| 76 |
v_noexport, |
|---|
| 77 |
v_ifset, |
|---|
| 78 |
v_default |
|---|
| 79 |
} export ENUM_BITFIELD (2); |
|---|
| 80 |
}; |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
struct variable_set |
|---|
| 85 |
{ |
|---|
| 86 |
struct hash_table table; |
|---|
| 87 |
}; |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
struct variable_set_list |
|---|
| 92 |
{ |
|---|
| 93 |
struct variable_set_list *next; |
|---|
| 94 |
struct variable_set *set; |
|---|
| 95 |
}; |
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
struct pattern_var |
|---|
| 100 |
{ |
|---|
| 101 |
struct pattern_var *next; |
|---|
| 102 |
char *target; |
|---|
| 103 |
unsigned int len; |
|---|
| 104 |
char *suffix; |
|---|
| 105 |
struct variable variable; |
|---|
| 106 |
}; |
|---|
| 107 |
|
|---|
| 108 |
extern char *variable_buffer; |
|---|
| 109 |
extern struct variable_set_list *current_variable_set_list; |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
extern char *variable_buffer_output PARAMS ((char *ptr, char *string, unsigned int length)); |
|---|
| 113 |
extern char *variable_expand PARAMS ((char *line)); |
|---|
| 114 |
extern char *variable_expand_for_file PARAMS ((char *line, struct file *file)); |
|---|
| 115 |
extern char *allocated_variable_expand_for_file PARAMS ((char *line, struct file *file)); |
|---|
| 116 |
#define allocated_variable_expand(line) \ |
|---|
| 117 |
allocated_variable_expand_for_file (line, (struct file *) 0) |
|---|
| 118 |
extern char *expand_argument PARAMS ((const char *str, const char *end)); |
|---|
| 119 |
extern char *variable_expand_string PARAMS ((char *line, char *string, |
|---|
| 120 |
long length)); |
|---|
| 121 |
extern void install_variable_buffer PARAMS ((char **bufp, unsigned int *lenp)); |
|---|
| 122 |
extern void restore_variable_buffer PARAMS ((char *buf, unsigned int len)); |
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
extern int handle_function PARAMS ((char **op, char **stringp)); |
|---|
| 126 |
extern int pattern_matches PARAMS ((char *pattern, char *percent, char *str)); |
|---|
| 127 |
extern char *subst_expand PARAMS ((char *o, char *text, char *subst, char *replace, |
|---|
| 128 |
unsigned int slen, unsigned int rlen, int by_word)); |
|---|
| 129 |
extern char *patsubst_expand PARAMS ((char *o, char *text, char *pattern, char *replace, |
|---|
| 130 |
char *pattern_percent, char *replace_percent)); |
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
extern char *recursively_expand_for_file PARAMS ((struct variable *v, |
|---|
| 134 |
struct file *file)); |
|---|
| 135 |
#define recursively_expand(v) recursively_expand_for_file (v, NULL) |
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
extern struct variable_set_list *create_new_variable_set PARAMS ((void)); |
|---|
| 139 |
extern void free_variable_set PARAMS ((struct variable_set_list *)); |
|---|
| 140 |
extern struct variable_set_list *push_new_variable_scope PARAMS ((void)); |
|---|
| 141 |
extern void pop_variable_scope PARAMS ((void)); |
|---|
| 142 |
extern void define_automatic_variables PARAMS ((void)); |
|---|
| 143 |
extern void initialize_file_variables PARAMS ((struct file *file, int read)); |
|---|
| 144 |
extern void print_file_variables PARAMS ((struct file *file)); |
|---|
| 145 |
extern void print_variable_set PARAMS ((struct variable_set *set, char *prefix)); |
|---|
| 146 |
extern void merge_variable_set_lists PARAMS ((struct variable_set_list **to_list, struct variable_set_list *from_list)); |
|---|
| 147 |
extern struct variable *do_variable_definition PARAMS ((const struct floc *flocp, const char *name, char *value, enum variable_origin origin, enum variable_flavor flavor, int target_var)); |
|---|
| 148 |
extern struct variable *parse_variable_definition PARAMS ((struct variable *v, char *line)); |
|---|
| 149 |
extern struct variable *try_variable_definition PARAMS ((const struct floc *flocp, char *line, enum variable_origin origin, int target_var)); |
|---|
| 150 |
extern void init_hash_global_variable_set PARAMS ((void)); |
|---|
| 151 |
extern void hash_init_function_table PARAMS ((void)); |
|---|
| 152 |
extern struct variable *lookup_variable PARAMS ((const char *name, unsigned int length)); |
|---|
| 153 |
extern struct variable *lookup_variable_in_set PARAMS ((const char *name, |
|---|
| 154 |
unsigned int length, |
|---|
| 155 |
const struct variable_set *set)); |
|---|
| 156 |
|
|---|
| 157 |
extern struct variable *define_variable_in_set |
|---|
| 158 |
PARAMS ((const char *name, unsigned int length, char *value, |
|---|
| 159 |
enum variable_origin origin, int recursive, |
|---|
| 160 |
struct variable_set *set, const struct floc *flocp)); |
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
#define define_variable(n,l,v,o,r) \ |
|---|
| 165 |
define_variable_in_set((n),(l),(v),(o),(r),\ |
|---|
| 166 |
current_variable_set_list->set,NILF) |
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
#define define_variable_loc(n,l,v,o,r,f) \ |
|---|
| 171 |
define_variable_in_set((n),(l),(v),(o),(r),\ |
|---|
| 172 |
current_variable_set_list->set,(f)) |
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
#define define_variable_global(n,l,v,o,r,f) \ |
|---|
| 177 |
define_variable_in_set((n),(l),(v),(o),(r),NULL,(f)) |
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
#define define_variable_for_file(n,l,v,o,r,f) \ |
|---|
| 182 |
define_variable_in_set((n),(l),(v),(o),(r),(f)->variables->set,NILF) |
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
#define warn_undefined(n,l) do{\ |
|---|
| 187 |
if (warn_undefined_variables_flag) \ |
|---|
| 188 |
error (reading_file, \ |
|---|
| 189 |
_("warning: undefined variable `%.*s'"), \ |
|---|
| 190 |
(int)(l), (n)); \ |
|---|
| 191 |
}while(0) |
|---|
| 192 |
|
|---|
| 193 |
extern char **target_environment PARAMS ((struct file *file)); |
|---|
| 194 |
|
|---|
| 195 |
extern struct pattern_var *create_pattern_var PARAMS ((char *target, char *suffix)); |
|---|
| 196 |
|
|---|
| 197 |
extern int export_all_variables; |
|---|
| 198 |
|
|---|
| 199 |
#define MAKELEVEL_NAME "MAKELEVEL" |
|---|
| 200 |
#define MAKELEVEL_LENGTH (sizeof (MAKELEVEL_NAME) - 1) |
|---|