Changeset 937 in kBuild
- Timestamp:
- May 26, 2007 6:43:44 PM (18 years ago)
- Location:
- trunk/src/gmakenew
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmakenew/Makefile.am
r931 r937 90 90 -DCONFIG_WITH_TOUPPER_TOLOWER \ 91 91 -DCONFIG_WITH_EXPLICIT_MULTITARGET \ 92 -DCONFIG_WITH_PREPEND_ASSIGNMENT \ 92 93 \ 93 94 -DKMK \ -
trunk/src/gmakenew/Makefile.kmk
r921 r937 95 95 CONFIG_WITH_TOUPPER_TOLOWER \ 96 96 CONFIG_WITH_EXPLICIT_MULTITARGET \ 97 CONFIG_WITH_PREPEND_ASSIGNMENT \ 97 98 \ 98 99 KMK \ -
trunk/src/gmakenew/read.c
r922 r937 2896 2896 w_dcolon A double-colon 2897 2897 w_semicolon A semicolon 2898 w_varassign A variable assignment operator (=, :=, +=, or ?=)2898 w_varassign A variable assignment operator (=, :=, +=, >=, or ?=) 2899 2899 2900 2900 Note that this function is only used when reading certain parts of the … … 2947 2947 case '+': 2948 2948 case '?': 2949 #ifdef CONFIG_WITH_PREPEND_ASSIGNMENT 2950 case '>': 2951 #endif 2949 2952 if (*p == '=') 2950 2953 { … … 3028 3031 case '?': 3029 3032 case '+': 3033 #ifdef CONFIG_WITH_PREPEND_ASSIGNMENT 3034 case '>': 3035 #endif 3030 3036 if (*p == '=') 3031 3037 goto done_word; -
trunk/src/gmakenew/variable.c
r929 r937 1361 1361 static struct variable * 1362 1362 do_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) 1364 1364 { 1365 1365 if (env_overrides && origin == o_env) … … 1390 1390 unsigned int value_len = strlen (value); 1391 1391 unsigned int new_value_len = value_len + (v->value_length != 0 ? 1 + v->value_length : 0); 1392 int done_1st_prepend_copy = 0; 1392 1393 1393 1394 /* adjust the size. */ 1394 1395 if ((unsigned)v->value_alloc_len <= new_value_len) 1395 1396 { 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 } 1398 1413 } 1399 1414 … … 1401 1416 if (v->value_length != 0) 1402 1417 { 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 } 1405 1430 } 1406 1431 else 1407 1432 memcpy (v->value, value, value_len + 1); 1408 1433 v->value_length = new_value_len; 1409 1434 } … … 1436 1461 int conditional = 0; 1437 1462 const size_t varname_len = strlen (varname); /* bird */ 1438 # 1463 #ifdef CONFIG_WITH_VALUE_LENGTH 1439 1464 unsigned int value_len = ~0U; 1440 # 1465 #endif 1441 1466 1442 1467 /* Calculate the variable's new value in VALUE. */ … … 1470 1495 p = value; 1471 1496 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 1472 1503 case f_append: 1473 1504 { 1505 #endif 1506 1474 1507 /* If we have += but we're in a target variable context, we want to 1475 1508 append only with other variables in the context of this target. */ … … 1499 1532 #ifdef CONFIG_WITH_VALUE_LENGTH 1500 1533 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 1502 1539 #else /* !CONFIG_WITH_VALUE_LENGTH */ 1503 1540 … … 1524 1561 vallen = strlen (val); 1525 1562 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 } 1529 1577 p = tp; 1530 1578 #endif /* !CONFIG_WITH_VALUE_LENGTH */ … … 1724 1772 break; 1725 1773 } 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 1726 1782 else if (c == '?' && *p == '=') 1727 1783 { -
trunk/src/gmakenew/variable.h
r916 r937 39 39 f_recursive, /* Recursive definition (=) */ 40 40 f_append, /* Appending definition (+=) */ 41 #ifdef CONFIG_WITH_PREPEND_ASSIGNMENT 42 f_prepend, /* Prepending definition (>=) */ 43 #endif 41 44 f_conditional /* Conditional definition (?=) */ 42 45 };
Note:
See TracChangeset
for help on using the changeset viewer.