VirtualBox

Changeset 937 in kBuild


Ignore:
Timestamp:
May 26, 2007 6:43:44 PM (18 years ago)
Author:
bird
Message:

Implemented the prepend assignment operator '<='.

Location:
trunk/src/gmakenew
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmakenew/Makefile.am

    r931 r937  
    9090        -DCONFIG_WITH_TOUPPER_TOLOWER \
    9191        -DCONFIG_WITH_EXPLICIT_MULTITARGET \
     92        -DCONFIG_WITH_PREPEND_ASSIGNMENT \
    9293        \
    9394        -DKMK \
  • trunk/src/gmakenew/Makefile.kmk

    r921 r937  
    9595        CONFIG_WITH_TOUPPER_TOLOWER \
    9696        CONFIG_WITH_EXPLICIT_MULTITARGET \
     97        CONFIG_WITH_PREPEND_ASSIGNMENT \
    9798        \
    9899        KMK \
  • trunk/src/gmakenew/read.c

    r922 r937  
    28962896     w_dcolon       A double-colon
    28972897     w_semicolon    A semicolon
    2898      w_varassign    A variable assignment operator (=, :=, +=, or ?=)
     2898     w_varassign    A variable assignment operator (=, :=, +=, >=, or ?=)
    28992899
    29002900   Note that this function is only used when reading certain parts of the
     
    29472947    case '+':
    29482948    case '?':
     2949#ifdef CONFIG_WITH_PREPEND_ASSIGNMENT
     2950    case '>':
     2951#endif
    29492952      if (*p == '=')
    29502953        {
     
    30283031        case '?':
    30293032        case '+':
     3033#ifdef CONFIG_WITH_PREPEND_ASSIGNMENT
     3034        case '>':
     3035#endif
    30303036          if (*p == '=')
    30313037            goto done_word;
  • trunk/src/gmakenew/variable.c

    r929 r937  
    13611361static struct variable *
    13621362do_variable_definition_append (const struct floc *flocp, struct variable *v, const char *value,
    1363                                enum variable_origin origin)
     1363                               enum variable_origin origin, int append)
    13641364{
    13651365  if (env_overrides && origin == o_env)
     
    13901390      unsigned int value_len = strlen (value);
    13911391      unsigned int new_value_len = value_len + (v->value_length != 0 ? 1 + v->value_length : 0);
     1392      int done_1st_prepend_copy = 0;
    13921393
    13931394      /* adjust the size. */
    13941395      if ((unsigned)v->value_alloc_len <= new_value_len)
    13951396        {
    1396           v->value_alloc_len = (new_value_len + 0x80) + 0x7f;
    1397           v->value = xrealloc (v->value, v->value_alloc_len);
     1397          /* XXX: anticipating further appends/prepends. */
     1398          if (value_len > v->value_alloc_len)
     1399            v->value_alloc_len = (new_value_len + 0x80) + 0x7f;
     1400          else
     1401            v->value_alloc_len = (new_value_len + value_len + 0x80) + 0x7f;
     1402          if (append || !v->value_length)
     1403            v->value = xrealloc (v->value, v->value_alloc_len);
     1404          else
     1405            {
     1406              /* avoid the extra memcpy the xrealloc may have to do */
     1407              char *new_buf = xmalloc (v->value_alloc_len);
     1408              memcpy (&new_buf[value_len + 1], v->value, v->value_length + 1);
     1409              done_1st_prepend_copy = 1;
     1410              free (v->value);
     1411              v->value = new_buf;
     1412            }
    13981413        }
    13991414
     
    14011416      if (v->value_length != 0)
    14021417        {
    1403           v->value[v->value_length] = ' ';
    1404           memcpy (&v->value[v->value_length + 1], value, value_len + 1);
     1418          if (append)
     1419            {
     1420              v->value[v->value_length] = ' ';
     1421              memcpy (&v->value[v->value_length + 1], value, value_len + 1);
     1422            }
     1423          else
     1424            {
     1425              if (!done_1st_prepend_copy)
     1426                memmove (&v->value[value_len + 1], v->value, v->value_length + 1);
     1427              v->value[value_len] = ' ';
     1428              memcpy (v->value, value, value_len);
     1429            }
    14051430        }
    14061431      else
    1407           memcpy (v->value, value, value_len + 1);
     1432        memcpy (v->value, value, value_len + 1);
    14081433      v->value_length = new_value_len;
    14091434    }
     
    14361461  int conditional = 0;
    14371462  const size_t varname_len = strlen (varname); /* bird */
    1438 # ifdef CONFIG_WITH_VALUE_LENGTH
     1463#ifdef CONFIG_WITH_VALUE_LENGTH
    14391464  unsigned int value_len = ~0U;
    1440 # endif
     1465#endif
    14411466
    14421467  /* Calculate the variable's new value in VALUE.  */
     
    14701495      p = value;
    14711496      break;
     1497#ifdef CONFIG_WITH_PREPEND_ASSIGNMENT
     1498    case f_append:
     1499    case f_prepend:
     1500      {
     1501        const enum variable_flavor org_flavor = flavor;
     1502#else
    14721503    case f_append:
    14731504      {
     1505#endif
     1506
    14741507        /* If we have += but we're in a target variable context, we want to
    14751508           append only with other variables in the context of this target.  */
     
    14991532#ifdef CONFIG_WITH_VALUE_LENGTH
    15001533            v->append = append;
    1501             return do_variable_definition_append (flocp, v, value, origin);
     1534# ifdef CONFIG_WITH_PREPEND_ASSIGNMENT
     1535            return do_variable_definition_append (flocp, v, value, origin, org_flavor == f_append);
     1536# else
     1537            return do_variable_definition_append (flocp, v, value, origin, 1);
     1538# endif
    15021539#else /* !CONFIG_WITH_VALUE_LENGTH */
    15031540
     
    15241561            vallen = strlen (val);
    15251562            tp = alloca (oldlen + 1 + vallen + 1);
    1526             memcpy (tp, v->value, oldlen);
    1527             tp[oldlen] = ' ';
    1528             memcpy (&tp[oldlen + 1], val, vallen + 1);
     1563# ifdef CONFIG_WITH_PREPEND_ASSIGNMENT
     1564            if (org_flavor == f_prepend)
     1565              {
     1566                memcpy (tp, val, vallen);
     1567                tp[oldlen] = ' ';
     1568                memcpy (&tp[oldlen + 1], v->value, oldlen + 1);
     1569              }
     1570            else
     1571# endif /* CONFIG_WITH_PREPEND_ASSIGNMENT */
     1572              {
     1573                memcpy (tp, v->value, oldlen);
     1574                tp[oldlen] = ' ';
     1575                memcpy (&tp[oldlen + 1], val, vallen + 1);
     1576              }
    15291577            p = tp;
    15301578#endif /* !CONFIG_WITH_VALUE_LENGTH */
     
    17241772          break;
    17251773        }
     1774#ifdef CONFIG_WITH_PREPEND_ASSIGNMENT
     1775      else if (c == '<' && *p == '=')
     1776        {
     1777          end = p++ - 1;
     1778          flavor = f_prepend;
     1779          break;
     1780        }
     1781#endif
    17261782      else if (c == '?' && *p == '=')
    17271783        {
  • trunk/src/gmakenew/variable.h

    r916 r937  
    3939    f_recursive,        /* Recursive definition (=) */
    4040    f_append,           /* Appending definition (+=) */
     41#ifdef CONFIG_WITH_PREPEND_ASSIGNMENT
     42    f_prepend,          /* Prepending definition (>=) */
     43#endif
    4144    f_conditional       /* Conditional definition (?=) */
    4245  };
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette