Ignore:
Timestamp:
Mar 14, 2018, 10:28:10 PM (7 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

Location:
trunk/src/kmk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

  • trunk/src/kmk/variable.h

    r3068 r3140  
    11/* 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.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    2624enum variable_origin
    2725  {
    28     o_default,          /* Variable from the default set.  */
    29     o_env,              /* Variable from environment.  */
    30     o_file,             /* Variable given in a makefile.  */
    31     o_env_override,     /* Variable from environment, if -e.  */
    32     o_command,          /* Variable given by user.  */
    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.  */
    3432#ifdef CONFIG_WITH_LOCAL_VARIABLES
    3533    o_local,            /* Variable from an 'local' directive.  */
    3634#endif
    37     o_automatic,        /* Automatic variable -- cannot be set.  */
    38     o_invalid           /* Core dump time.  */
     35    o_automatic,        /* Automatic variable -- cannot be set.  */
     36    o_invalid           /* Core dump time.  */
    3937  };
    4038
     
    4240  {
    4341    f_bogus,            /* Bogus (error) */
    44     f_simple,           /* Simple definition (:=) */
     42    f_simple,           /* Simple definition (:= or ::=) */
    4543    f_recursive,        /* Recursive definition (=) */
    4644    f_append,           /* Appending definition (+=) */
     
    4846    f_prepend,          /* Prepending definition (>=) */
    4947#endif
    50     f_conditional       /* Conditional definition (?=) */
     48    f_conditional,      /* Conditional definition (?=) */
     49    f_shell             /* Shell assignment (!=) */
    5150  };
    5251
    5352/* Structure that represents one variable definition.
    5453   Each bucket of the hash table is a chain of these,
    55    chained through `next'.  */
     54   chained through 'next'.  */
    5655
    5756#define EXP_COUNT_BITS  15      /* This gets all the bitfields into 32 bits */
    5857#define EXP_COUNT_MAX   ((1<<EXP_COUNT_BITS)-1)
    5958#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 )
    6160#endif
    6261
     
    6463  {
    6564#ifndef CONFIG_WITH_STRCACHE2
    66     char *name;                 /* Variable name.  */
     65    char *name;                 /* Variable name.  */
    6766#else
    6867    const char *name;           /* Variable name (in varaible_strcache).  */
    6968#endif
    70     int length;                 /* strlen (name) */
     69    char *value;                /* Variable value.  */
     70    floc fileinfo;              /* Where the variable was defined.  */
     71    int length;                 /* strlen (name) */
    7172#ifdef CONFIG_WITH_VALUE_LENGTH
    7273    unsigned int value_length;  /* The length of the value.  */
     
    7475    /* FIXME: make lengths unsigned! */
    7576#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
    8079                                   variable.  */
    8180    unsigned int conditional:1; /* Nonzero if set with a ?=. */
    82     unsigned int per_target:1;  /* Nonzero if a target-specific variable.  */
     81    unsigned int per_target:1;  /* Nonzero if a target-specific variable.  */
    8382    unsigned int special:1;     /* Nonzero if this is a special variable. */
    8483    unsigned int exportable:1;  /* Nonzero if the variable _could_ be
    8584                                   exported.  */
    86     unsigned int expanding:1;   /* Nonzero if currently being expanded.  */
     85    unsigned int expanding:1;   /* Nonzero if currently being expanded.  */
    8786    unsigned int private_var:1; /* Nonzero avoids inheritance of this
    8887                                   target-specific variable.  */
     
    9897#endif
    9998    enum variable_flavor
    100       flavor ENUM_BITFIELD (3); /* Variable flavor.  */
     99      flavor ENUM_BITFIELD (3); /* Variable flavor.  */
    101100    enum variable_origin
    102101#ifdef CONFIG_WITH_LOCAL_VARIABLES
    103102      origin ENUM_BITFIELD (4); /* Variable origin.  */
    104103#else
    105       origin ENUM_BITFIELD (3); /* Variable origin.  */
     104      origin ENUM_BITFIELD (3); /* Variable origin.  */
    106105#endif
    107106    enum variable_export
    108107      {
    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.  */
    113112      } export ENUM_BITFIELD (2);
    114113#ifdef CONFIG_WITH_COMPILER
     
    159158struct variable_set
    160159  {
    161     struct hash_table table;    /* Hash table of variables.  */
     160    struct hash_table table;    /* Hash table of variables.  */
    162161  };
    163162
     
    166165struct variable_set_list
    167166  {
    168     struct variable_set_list *next;     /* Link in the chain.  */
    169     struct variable_set *set;           /* Variable set.  */
     167    struct variable_set_list *next;     /* Link in the chain.  */
     168    struct variable_set *set;           /* Variable set.  */
    170169    int next_is_parent;                 /* True if next is a parent target.  */
    171170  };
     
    185184extern struct variable_set_list *current_variable_set_list;
    186185extern struct variable *default_goal_var;
     186extern struct variable shell_var;
    187187
    188188#ifdef KMK
     
    198198variable_buffer_output (char *ptr, const char *string, unsigned int length);
    199199#else /* KMK */
     200# include <k/kDefs.h>
    200201/* Subroutine of variable_expand and friends:
    201202   The text to add is LENGTH chars starting at STRING to the variable_buffer.
     
    205206   the following call.  */
    206207
    207 __inline static char *
    208 variable_buffer_output (char *ptr, const char *string, unsigned int length)
     208K_INLINE char *variable_buffer_output (char *ptr, const char *string, unsigned int length)
    209209{
    210210  register unsigned int newlen = length + (ptr - variable_buffer);
     
    239239  return ptr + length;
    240240}
    241 
    242241#endif /* KMK */
     242
    243243char *variable_expand (const char *line);
    244244char *variable_expand_for_file (const char *line, struct file *file);
     
    249249char *allocated_variable_expand_for_file (const char *line, struct file *file);
    250250#ifndef CONFIG_WITH_VALUE_LENGTH
    251 #define allocated_variable_expand(line) \
     251#define allocated_variable_expand(line) \
    252252  allocated_variable_expand_for_file (line, (struct file *) 0)
    253253#else  /* CONFIG_WITH_VALUE_LENGTH */
     
    264264variable_expand_string (char *line, const char *string, long length);
    265265#else  /* CONFIG_WITH_VALUE_LENGTH */
     266# include <k/kDefs.h>
    266267char *
    267268variable_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)
     269K_INLINE char *variable_expand_string (char *line, const char *string, long length)
    270270{
    271271    char *ignored;
     
    274274#endif /* CONFIG_WITH_VALUE_LENGTH */
    275275void install_variable_buffer (char **bufp, unsigned int *lenp);
    276 char *install_variable_buffer_with_hint (char **bufp, unsigned int *lenp, unsigned int size_hint);
    277276void restore_variable_buffer (char *buf, unsigned int len);
    278 char *ensure_variable_buffer_space(char *ptr, unsigned int size);
     277char *install_variable_buffer_with_hint (char **bufp, unsigned int *lenp, unsigned int size_hint); /* bird */
     278char *ensure_variable_buffer_space (char *ptr, unsigned int size); /* bird */
    279279#ifdef CONFIG_WITH_VALUE_LENGTH
    280280void append_expanded_string_to_variable (struct variable *v, const char *value,
     
    302302                           const char *replace_percent);
    303303char *patsubst_expand (char *o, const char *text, char *pattern, char *replace);
    304 #ifdef CONFIG_WITH_COMMANDS_FUNC
     304char *func_shell_base (char *o, char **argv, int trim_newlines);
     305void shell_completed (int exit_code, int exit_sig);
     306
     307#ifdef CONFIG_WITH_COMMANDS_FUNC /* for append.c */
    305308char *func_commands (char *o, char **argv, const char *funcname);
    306309#endif
     310
    307311#if defined (CONFIG_WITH_VALUE_LENGTH)
    308312/* Avoid calling handle_function for every variable, do the
     
    311315# define MAX_FUNCTION_LENGTH    12
    312316# define MIN_FUNCTION_LENGTH    2
    313 MY_INLINE const char *
    314 may_be_function_name (const char *name, const char *eos)
     317K_INLINE const char *may_be_function_name (const char *name, const char *eos)
    315318{
    316319  unsigned char ch;
     
    325328    return 0;
    326329  if (MY_PREDICT_TRUE(!func_char_map[ch = name[2]]))
    327     return isspace (ch) ? name + 2 : 0;
     330    return ISSPACE (ch) ? name + 2 : 0;
    328331
    329332  name += 3;
     
    343346      name++;
    344347    }
    345   if (ch == '\0' || isblank (ch))
     348  if (ch == '\0' || ISBLANK (ch))
    346349    return name;
    347350  return 0;
     
    356359char *recursively_expand_for_file (struct variable *v, struct file *file,
    357360                                   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 */
    360363#ifdef CONFIG_WITH_COMPILER
    361364char *reference_recursive_variable (char *o, struct variable *v);
     
    370373void initialize_file_variables (struct file *file, int reading);
    371374void print_file_variables (const struct file *file);
    372 void print_variable_set (struct variable_set *set, char *prefix);
     375void print_target_variables (const struct file *file);
    373376void merge_variable_set_lists (struct variable_set_list **to_list,
    374377                               struct variable_set_list *from_list);
     378#ifdef KMK
     379void print_variable_set (struct variable_set *set, const char *prefix, int pauto);
     380#endif
     381
    375382#ifndef CONFIG_WITH_VALUE_LENGTH
    376 struct variable *do_variable_definition (const struct floc *flocp,
     383struct variable *do_variable_definition (const floc *flocp,
    377384                                         const char *name, const char *value,
    378385                                         enum variable_origin origin,
     
    383390    do_variable_definition_2 ((flocp), (varname), (value), ~0U, 0, NULL, \
    384391                              (origin), (flavor), (target_var))
    385 struct variable *do_variable_definition_2 (const struct floc *flocp,
     392struct variable *do_variable_definition_2 (const floc *flocp,
    386393                                           const char *varname,
    387394                                           const char *value,
     
    393400#endif /* CONFIG_WITH_VALUE_LENGTH */
    394401char *parse_variable_definition (const char *line,
    395                                           enum variable_flavor *flavor);
    396 struct variable *assign_variable_definition (struct variable *v, char *line IF_WITH_VALUE_LENGTH_PARAM(char *eos));
    397 struct variable *try_variable_definition (const struct floc *flocp, char *line
     402                                 struct variable *v);
     403struct variable *assign_variable_definition (struct variable *v, const char *line IF_WITH_VALUE_LENGTH_PARAM(char *eos));
     404struct variable *try_variable_definition (const floc *flocp, const char *line
    398405                                          IF_WITH_VALUE_LENGTH_PARAM(char *eos),
    399406                                          enum variable_origin origin,
     
    401408void init_hash_global_variable_set (void);
    402409void hash_init_function_table (void);
     410void define_new_function(const floc *flocp, const char *name,
     411                         unsigned int min, unsigned int max, unsigned int flags,
     412                         gmk_func_ptr func);
    403413struct variable *lookup_variable (const char *name, unsigned int length);
    404414struct variable *lookup_variable_in_set (const char *name, unsigned int length,
     
    411421void append_string_to_variable (struct variable *v, const char *value,
    412422                                unsigned int value_len, int append);
    413 struct variable * do_variable_definition_append (const struct floc *flocp, struct variable *v,
     423struct variable * do_variable_definition_append (const floc *flocp, struct variable *v,
    414424                                                 const char *value, unsigned int value_len,
    415425                                                 int simple_value, enum variable_origin origin,
     
    423433                                         int recursive,
    424434                                         struct variable_set *set,
    425                                          const struct floc *flocp);
     435                                         const floc *flocp);
    426436
    427437/* Define a variable in the current variable set.  */
     
    467477                                         int recursive,
    468478                                         struct variable_set *set,
    469                                          const struct floc *flocp);
     479                                         const floc *flocp);
    470480
    471481/* Define a variable in the current variable set.  */
     
    500510
    501511void undefine_variable_in_set (const char *name, unsigned int length,
    502                                          enum variable_origin origin,
    503                                          struct variable_set *set);
     512                               enum variable_origin origin,
     513                               struct variable_set *set);
    504514
    505515/* Remove variable from the current variable set. */
     
    512522define_variable_alias_in_set (const char *name, unsigned int length,
    513523                              struct variable *target, enum variable_origin origin,
    514                               struct variable_set *set, const struct floc *flocp);
     524                              struct variable_set *set, const floc *flocp);
    515525#endif
    516526
     
    518528
    519529#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));                  \
    524534                              }while(0)
    525535
     
    539549#define MAKELEVEL_NAME "MAKELEVEL"
    540550#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.