Changeset 3140 for trunk/src/kmk/variable.h
- Timestamp:
- Mar 14, 2018, 10:28:10 PM (7 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk
-
Property svn:mergeinfo
set to
/vendor/gnumake/current merged eligible
-
Property svn:mergeinfo
set to
-
trunk/src/kmk/variable.h
r3068 r3140 1 1 /* Definitions for using variables in GNU Make. 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software 4 Foundation, Inc. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 26 24 enum variable_origin 27 25 { 28 o_default, 29 o_env, 30 o_file, 31 o_env_override, 32 o_command, 33 o_override, /* Variable from an `override' directive. */26 o_default, /* Variable from the default set. */ 27 o_env, /* Variable from environment. */ 28 o_file, /* Variable given in a makefile. */ 29 o_env_override, /* Variable from environment, if -e. */ 30 o_command, /* Variable given by user. */ 31 o_override, /* Variable from an 'override' directive. */ 34 32 #ifdef CONFIG_WITH_LOCAL_VARIABLES 35 33 o_local, /* Variable from an 'local' directive. */ 36 34 #endif 37 o_automatic, 38 o_invalid 35 o_automatic, /* Automatic variable -- cannot be set. */ 36 o_invalid /* Core dump time. */ 39 37 }; 40 38 … … 42 40 { 43 41 f_bogus, /* Bogus (error) */ 44 f_simple, /* Simple definition (:= ) */42 f_simple, /* Simple definition (:= or ::=) */ 45 43 f_recursive, /* Recursive definition (=) */ 46 44 f_append, /* Appending definition (+=) */ … … 48 46 f_prepend, /* Prepending definition (>=) */ 49 47 #endif 50 f_conditional /* Conditional definition (?=) */ 48 f_conditional, /* Conditional definition (?=) */ 49 f_shell /* Shell assignment (!=) */ 51 50 }; 52 51 53 52 /* Structure that represents one variable definition. 54 53 Each bucket of the hash table is a chain of these, 55 chained through `next'. */54 chained through 'next'. */ 56 55 57 56 #define EXP_COUNT_BITS 15 /* This gets all the bitfields into 32 bits */ 58 57 #define EXP_COUNT_MAX ((1<<EXP_COUNT_BITS)-1) 59 58 #ifdef CONFIG_WITH_VALUE_LENGTH 60 # define VAR_ALIGN_VALUE_ALLOC(len) ( ((len) + (unsigned int)15) & ~(unsigned int)15 )59 # define VAR_ALIGN_VALUE_ALLOC(len) ( ((len) + (unsigned int)15) & ~(unsigned int)15 ) 61 60 #endif 62 61 … … 64 63 { 65 64 #ifndef CONFIG_WITH_STRCACHE2 66 char *name; 65 char *name; /* Variable name. */ 67 66 #else 68 67 const char *name; /* Variable name (in varaible_strcache). */ 69 68 #endif 70 int length; /* strlen (name) */ 69 char *value; /* Variable value. */ 70 floc fileinfo; /* Where the variable was defined. */ 71 int length; /* strlen (name) */ 71 72 #ifdef CONFIG_WITH_VALUE_LENGTH 72 73 unsigned int value_length; /* The length of the value. */ … … 74 75 /* FIXME: make lengths unsigned! */ 75 76 #endif 76 char *value; /* Variable value. */ 77 struct floc fileinfo; /* Where the variable was defined. */ 78 unsigned int recursive:1; /* Gets recursively re-evaluated. */ 79 unsigned int append:1; /* Nonzero if an appending target-specific 77 unsigned int recursive:1; /* Gets recursively re-evaluated. */ 78 unsigned int append:1; /* Nonzero if an appending target-specific 80 79 variable. */ 81 80 unsigned int conditional:1; /* Nonzero if set with a ?=. */ 82 unsigned int per_target:1; 81 unsigned int per_target:1; /* Nonzero if a target-specific variable. */ 83 82 unsigned int special:1; /* Nonzero if this is a special variable. */ 84 83 unsigned int exportable:1; /* Nonzero if the variable _could_ be 85 84 exported. */ 86 unsigned int expanding:1; 85 unsigned int expanding:1; /* Nonzero if currently being expanded. */ 87 86 unsigned int private_var:1; /* Nonzero avoids inheritance of this 88 87 target-specific variable. */ … … 98 97 #endif 99 98 enum variable_flavor 100 flavor ENUM_BITFIELD (3); 99 flavor ENUM_BITFIELD (3); /* Variable flavor. */ 101 100 enum variable_origin 102 101 #ifdef CONFIG_WITH_LOCAL_VARIABLES 103 102 origin ENUM_BITFIELD (4); /* Variable origin. */ 104 103 #else 105 origin ENUM_BITFIELD (3); 104 origin ENUM_BITFIELD (3); /* Variable origin. */ 106 105 #endif 107 106 enum variable_export 108 107 { 109 v_export,/* Export this variable. */110 v_noexport,/* Don't export this variable. */111 v_ifset,/* Export it if it has a non-default value. */112 v_default/* Decide in target_environment. */108 v_export, /* Export this variable. */ 109 v_noexport, /* Don't export this variable. */ 110 v_ifset, /* Export it if it has a non-default value. */ 111 v_default /* Decide in target_environment. */ 113 112 } export ENUM_BITFIELD (2); 114 113 #ifdef CONFIG_WITH_COMPILER … … 159 158 struct variable_set 160 159 { 161 struct hash_table table; 160 struct hash_table table; /* Hash table of variables. */ 162 161 }; 163 162 … … 166 165 struct variable_set_list 167 166 { 168 struct variable_set_list *next; 169 struct variable_set *set; 167 struct variable_set_list *next; /* Link in the chain. */ 168 struct variable_set *set; /* Variable set. */ 170 169 int next_is_parent; /* True if next is a parent target. */ 171 170 }; … … 185 184 extern struct variable_set_list *current_variable_set_list; 186 185 extern struct variable *default_goal_var; 186 extern struct variable shell_var; 187 187 188 188 #ifdef KMK … … 198 198 variable_buffer_output (char *ptr, const char *string, unsigned int length); 199 199 #else /* KMK */ 200 # include <k/kDefs.h> 200 201 /* Subroutine of variable_expand and friends: 201 202 The text to add is LENGTH chars starting at STRING to the variable_buffer. … … 205 206 the following call. */ 206 207 207 __inline static char * 208 variable_buffer_output (char *ptr, const char *string, unsigned int length) 208 K_INLINE char *variable_buffer_output (char *ptr, const char *string, unsigned int length) 209 209 { 210 210 register unsigned int newlen = length + (ptr - variable_buffer); … … 239 239 return ptr + length; 240 240 } 241 242 241 #endif /* KMK */ 242 243 243 char *variable_expand (const char *line); 244 244 char *variable_expand_for_file (const char *line, struct file *file); … … 249 249 char *allocated_variable_expand_for_file (const char *line, struct file *file); 250 250 #ifndef CONFIG_WITH_VALUE_LENGTH 251 #define 251 #define allocated_variable_expand(line) \ 252 252 allocated_variable_expand_for_file (line, (struct file *) 0) 253 253 #else /* CONFIG_WITH_VALUE_LENGTH */ … … 264 264 variable_expand_string (char *line, const char *string, long length); 265 265 #else /* CONFIG_WITH_VALUE_LENGTH */ 266 # include <k/kDefs.h> 266 267 char * 267 268 variable_expand_string_2 (char *line, const char *string, long length, char **eol); 268 __inline static char * 269 variable_expand_string (char *line, const char *string, long length) 269 K_INLINE char *variable_expand_string (char *line, const char *string, long length) 270 270 { 271 271 char *ignored; … … 274 274 #endif /* CONFIG_WITH_VALUE_LENGTH */ 275 275 void install_variable_buffer (char **bufp, unsigned int *lenp); 276 char *install_variable_buffer_with_hint (char **bufp, unsigned int *lenp, unsigned int size_hint);277 276 void restore_variable_buffer (char *buf, unsigned int len); 278 char *ensure_variable_buffer_space(char *ptr, unsigned int size); 277 char *install_variable_buffer_with_hint (char **bufp, unsigned int *lenp, unsigned int size_hint); /* bird */ 278 char *ensure_variable_buffer_space (char *ptr, unsigned int size); /* bird */ 279 279 #ifdef CONFIG_WITH_VALUE_LENGTH 280 280 void append_expanded_string_to_variable (struct variable *v, const char *value, … … 302 302 const char *replace_percent); 303 303 char *patsubst_expand (char *o, const char *text, char *pattern, char *replace); 304 #ifdef CONFIG_WITH_COMMANDS_FUNC 304 char *func_shell_base (char *o, char **argv, int trim_newlines); 305 void shell_completed (int exit_code, int exit_sig); 306 307 #ifdef CONFIG_WITH_COMMANDS_FUNC /* for append.c */ 305 308 char *func_commands (char *o, char **argv, const char *funcname); 306 309 #endif 310 307 311 #if defined (CONFIG_WITH_VALUE_LENGTH) 308 312 /* Avoid calling handle_function for every variable, do the … … 311 315 # define MAX_FUNCTION_LENGTH 12 312 316 # define MIN_FUNCTION_LENGTH 2 313 MY_INLINE const char * 314 may_be_function_name (const char *name, const char *eos) 317 K_INLINE const char *may_be_function_name (const char *name, const char *eos) 315 318 { 316 319 unsigned char ch; … … 325 328 return 0; 326 329 if (MY_PREDICT_TRUE(!func_char_map[ch = name[2]])) 327 return isspace(ch) ? name + 2 : 0;330 return ISSPACE (ch) ? name + 2 : 0; 328 331 329 332 name += 3; … … 343 346 name++; 344 347 } 345 if (ch == '\0' || isblank(ch))348 if (ch == '\0' || ISBLANK (ch)) 346 349 return name; 347 350 return 0; … … 356 359 char *recursively_expand_for_file (struct variable *v, struct file *file, 357 360 unsigned int *value_lenp); 358 # define recursively_expand(v)recursively_expand_for_file (v, NULL, NULL)359 #endif 361 # define recursively_expand(v) recursively_expand_for_file (v, NULL, NULL) 362 #endif /* CONFIG_WITH_VALUE_LENGTH */ 360 363 #ifdef CONFIG_WITH_COMPILER 361 364 char *reference_recursive_variable (char *o, struct variable *v); … … 370 373 void initialize_file_variables (struct file *file, int reading); 371 374 void print_file_variables (const struct file *file); 372 void print_ variable_set (struct variable_set *set, char *prefix);375 void print_target_variables (const struct file *file); 373 376 void merge_variable_set_lists (struct variable_set_list **to_list, 374 377 struct variable_set_list *from_list); 378 #ifdef KMK 379 void print_variable_set (struct variable_set *set, const char *prefix, int pauto); 380 #endif 381 375 382 #ifndef CONFIG_WITH_VALUE_LENGTH 376 struct variable *do_variable_definition (const structfloc *flocp,383 struct variable *do_variable_definition (const floc *flocp, 377 384 const char *name, const char *value, 378 385 enum variable_origin origin, … … 383 390 do_variable_definition_2 ((flocp), (varname), (value), ~0U, 0, NULL, \ 384 391 (origin), (flavor), (target_var)) 385 struct variable *do_variable_definition_2 (const structfloc *flocp,392 struct variable *do_variable_definition_2 (const floc *flocp, 386 393 const char *varname, 387 394 const char *value, … … 393 400 #endif /* CONFIG_WITH_VALUE_LENGTH */ 394 401 char *parse_variable_definition (const char *line, 395 enum variable_flavor *flavor);396 struct variable *assign_variable_definition (struct variable *v, c har *line IF_WITH_VALUE_LENGTH_PARAM(char *eos));397 struct variable *try_variable_definition (const struct floc *flocp,char *line402 struct variable *v); 403 struct variable *assign_variable_definition (struct variable *v, const char *line IF_WITH_VALUE_LENGTH_PARAM(char *eos)); 404 struct variable *try_variable_definition (const floc *flocp, const char *line 398 405 IF_WITH_VALUE_LENGTH_PARAM(char *eos), 399 406 enum variable_origin origin, … … 401 408 void init_hash_global_variable_set (void); 402 409 void hash_init_function_table (void); 410 void define_new_function(const floc *flocp, const char *name, 411 unsigned int min, unsigned int max, unsigned int flags, 412 gmk_func_ptr func); 403 413 struct variable *lookup_variable (const char *name, unsigned int length); 404 414 struct variable *lookup_variable_in_set (const char *name, unsigned int length, … … 411 421 void append_string_to_variable (struct variable *v, const char *value, 412 422 unsigned int value_len, int append); 413 struct variable * do_variable_definition_append (const structfloc *flocp, struct variable *v,423 struct variable * do_variable_definition_append (const floc *flocp, struct variable *v, 414 424 const char *value, unsigned int value_len, 415 425 int simple_value, enum variable_origin origin, … … 423 433 int recursive, 424 434 struct variable_set *set, 425 const structfloc *flocp);435 const floc *flocp); 426 436 427 437 /* Define a variable in the current variable set. */ … … 467 477 int recursive, 468 478 struct variable_set *set, 469 const structfloc *flocp);479 const floc *flocp); 470 480 471 481 /* Define a variable in the current variable set. */ … … 500 510 501 511 void undefine_variable_in_set (const char *name, unsigned int length, 502 503 512 enum variable_origin origin, 513 struct variable_set *set); 504 514 505 515 /* Remove variable from the current variable set. */ … … 512 522 define_variable_alias_in_set (const char *name, unsigned int length, 513 523 struct variable *target, enum variable_origin origin, 514 struct variable_set *set, const structfloc *flocp);524 struct variable_set *set, const floc *flocp); 515 525 #endif 516 526 … … 518 528 519 529 #define warn_undefined(n,l) do{\ 520 if (warn_undefined_variables_flag) \521 error (reading_file, \522 _("warning: undefined variable `%.*s'"), \523 (int)(l), (n));\530 if (warn_undefined_variables_flag) \ 531 error (reading_file, (l), \ 532 _("warning: undefined variable '%.*s'"), \ 533 (int)(l), (n)); \ 524 534 }while(0) 525 535 … … 539 549 #define MAKELEVEL_NAME "MAKELEVEL" 540 550 #endif 541 #define MAKELEVEL_LENGTH (sizeof (MAKELEVEL_NAME) - 1) 542 551 #define MAKELEVEL_LENGTH (CSTRLEN (MAKELEVEL_NAME))
Note:
See TracChangeset
for help on using the changeset viewer.