Changeset 1809 in kBuild for trunk/src/kmk
- Timestamp:
- Oct 10, 2008 2:27:38 AM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/expand.c
r1808 r1809 228 228 char *o; 229 229 unsigned int line_offset; 230 #ifdef KMK230 #ifdef CONFIG_WITH_VALUE_LENGTH 231 231 const char *eos; 232 232 #endif … … 248 248 } 249 249 250 #ifdef KMK250 #ifdef CONFIG_WITH_VALUE_LENGTH 251 251 /* Simple first, 50% of the kBuild calls to this function does 252 252 not need any expansion at all. Should be worth a special case. */ … … 261 261 } 262 262 eos = string + length; 263 #endif /* KMK - optimization*/263 #endif /* CONFIG_WITH_VALUE_LENGTH */ 264 264 265 265 /* If we want a subset of the string, allocate a temporary buffer for it. … … 270 270 memcpy(abuf, string, length); 271 271 abuf[length] = '\0'; 272 #ifdef KMK272 #ifdef CONFIG_WITH_VALUE_LENGTH 273 273 p1 += abuf - string; 274 274 eos += abuf - string; 275 #endif /* KMK - optimization*/275 #endif /* CONFIG_WITH_VALUE_LENGTH */ 276 276 string = abuf; 277 277 } … … 284 284 at the next $ or the end of the input. */ 285 285 286 #ifndef KMK286 #ifndef CONFIG_WITH_VALUE_LENGTH 287 287 p1 = strchr (p, '$'); 288 #endif /* !KMK - optimization */288 #endif 289 289 290 290 o = variable_buffer_output (o, p, p1 != 0 ? (unsigned int)(p1 - p) : strlen (p) + 1); … … 327 327 If so, expand it before expanding the entire reference. */ 328 328 329 #ifndef KMK329 #ifndef CONFIG_WITH_VALUE_LENGTH 330 330 end = strchr (beg, closeparen); 331 #else /* KMK - optimization */331 #else 332 332 end = memchr (beg, closeparen, eos - beg); 333 #endif /* KMK - optimization */333 #endif 334 334 if (end == 0) 335 335 /* Unterminated variable reference. */ … … 470 470 else 471 471 ++p; 472 #ifdef KMK472 #ifdef CONFIG_WITH_VALUE_LENGTH 473 473 p1 = memchr (p, '$', eos - p); 474 #endif /* KMK - optimization */474 #endif 475 475 } 476 476 … … 481 481 return (variable_buffer + line_offset); 482 482 } 483 #ifdef KMK483 #ifdef CONFIG_WITH_VALUE_LENGTH 484 484 485 485 … … 494 494 char *o; 495 495 unsigned int line_offset; 496 #ifdef KMK496 #ifdef CONFIG_WITH_VALUE_LENGTH 497 497 const char *eos; 498 498 #endif … … 514 514 } 515 515 516 #ifdef KMK516 #ifdef CONFIG_WITH_VALUE_LENGTH 517 517 /* Simple first, 50% of the kBuild calls to this function does 518 518 not need any expansion at all. Should be worth a special case. */ … … 528 528 } 529 529 eos = string + length; 530 #endif /* KMK - optimization*/530 #endif /* CONFIG_WITH_VALUE_LENGTH */ 531 531 532 532 /* If we want a subset of the string, allocate a temporary buffer for it. … … 537 537 memcpy(abuf, string, length); 538 538 abuf[length] = '\0'; 539 #ifdef KMK539 #ifdef CONFIG_WITH_VALUE_LENGTH 540 540 p1 += abuf - string; 541 541 eos += abuf - string; … … 551 551 at the next $ or the end of the input. */ 552 552 553 #ifndef KMK553 #ifndef CONFIG_WITH_VALUE_LENGTH 554 554 p1 = strchr (p, '$'); 555 #endif /* !KMK */555 #endif 556 556 557 557 /*o = variable_buffer_output (o, p, p1 != 0 ? (unsigned int)(p1 - p) : strlen (p) + 1); - why +1 ? */ … … 595 595 If so, expand it before expanding the entire reference. */ 596 596 597 #ifndef KMK597 #ifndef CONFIG_WITH_VALUE_LENGTH 598 598 end = strchr (beg, closeparen); 599 #else /* KMK - optimization */599 #else 600 600 end = memchr (beg, closeparen, eos - beg); 601 #endif /* KMK - optimization */601 #endif 602 602 if (end == 0) 603 603 /* Unterminated variable reference. */ … … 738 738 else 739 739 ++p; 740 #ifdef KMK740 #ifdef CONFIG_WITH_VALUE_LENGTH 741 741 p1 = memchr (p, '$', eos - p); 742 #endif /* KMK - optimization */742 #endif 743 743 } 744 744 … … 750 750 return (variable_buffer + line_offset); 751 751 } 752 #endif /* KMK - optimization*/752 #endif /* CONFIG_WITH_VALUE_LENGTH */ 753 753 754 754 … … 904 904 #endif 905 905 906 #if ndef KMK907 # ifdef CONFIG_WITH_VALUE_LENGTH 908 buf = variable_expand_string (buf, v->value, v->value_length);909 # 906 #ifdef CONFIG_WITH_VALUE_LENGTH 907 variable_expand_string_2 (buf, v->value, v->value_length, &buf); 908 return buf; 909 #else 910 910 buf = variable_expand_string (buf, v->value, strlen (v->value)); 911 # endif912 911 return (buf + strlen (buf)); 913 #else /* KMK - optimization */ 914 # ifdef CONFIG_WITH_VALUE_LENGTH 915 variable_expand_string_2 (buf, v->value, v->value_length, &buf); 916 # else 917 variable_expand_string_2 (buf, v->value, strlen (v->value), &buf); 918 # error "huh, this is supposed to be defined" 919 # endif 920 assert (*buf == '\0'); 921 return buf; 922 #endif /* KMK - optimization */ 923 } 924 925 #ifdef CONFIG_WITH_VALUE_LENGTH 926 /* Expands the specified string, appending it to the specified variable value. */ 912 #endif 913 } 914 915 #ifdef CONFIG_WITH_VALUE_LENGTH 916 /* Expands the specified string, appending it to the specified 917 variable value. */ 927 918 void 928 append_expanded_string_to_variable (struct variable *v, const char *value, int append) 929 { 930 char *tmp; 931 unsigned int value_len = strlen (value); 919 append_expanded_string_to_variable (struct variable *v, const char *value, 920 unsigned int value_len, int append) 921 { 932 922 char *p = (char *) memchr (value, '$', value_len); 933 923 if (!p) … … 955 945 /* Append the assignment value. */ 956 946 p = variable_buffer_output (p, value, off_dollar); 957 # ifndef KMK 958 p = variable_expand_string (p, value + off_dollar, value_len - off_dollar); 959 p = strchr (p, '\0'); 960 # else 961 tmp = variable_expand_string_2 (p, value + off_dollar, value_len - off_dollar, &p); 962 assert (*p == '\0'); 963 tmp = strchr (tmp, '\0'); 964 assert (tmp == p); 965 # endif 947 variable_expand_string_2 (p, value + off_dollar, value_len - off_dollar, &p); 966 948 } 967 949 else … … 969 951 /* Expand the assignemnt value. */ 970 952 p = variable_buffer_output (p, value, off_dollar); 971 #ifndef KMK 972 p = variable_expand_string (p, value + off_dollar, value_len - off_dollar); 973 p = strchr (p, '\0'); 974 #else 975 tmp = variable_expand_string_2 (p, value + off_dollar, value_len - off_dollar, &p); 976 assert (*p == '\0'); 977 tmp = strchr (tmp, '\0'); 978 assert (tmp == p); 979 #endif 953 variable_expand_string_2 (p, value + off_dollar, value_len - off_dollar, &p); 980 954 981 955 /* Append a space followed by the old value. */ … … 1046 1020 } 1047 1021 1048 #ifdef KMK /* possible optimization... */1049 /* The special, and most comment case, of1050 allocated_variable_expand_for_file. */1022 #ifdef CONFIG_WITH_VALUE_LENGTH 1023 /* Handle the most common case in allocated_variable_expand_for_file 1024 specially and provide some additional string lenght features. */ 1051 1025 1052 1026 char * 1053 allocated_variable_expand_2 (const char *line, long length, unsigned int *value_len) 1027 allocated_variable_expand_2 (const char *line, unsigned int length, 1028 unsigned int *value_len) 1054 1029 { 1055 1030 char *value; … … 1059 1034 variable_buffer = 0; 1060 1035 1061 #if 0 /* for profiling */1062 if (length < 0)1063 length = strlen (line);1064 #endif1065 1066 1036 if (!value_len) 1067 value = variable_expand_string (NULL, line, length );1037 value = variable_expand_string (NULL, line, length != ~0U ? length : -1); 1068 1038 else 1069 1039 { 1070 1040 char *eol; 1071 value = variable_expand_string_2 (NULL, line, length, &eol); 1041 value = variable_expand_string_2 (NULL, line, 1042 length != ~0U ? length : -1, &eol); 1072 1043 *value_len = eol - value; 1073 1044 } … … 1078 1049 return value; 1079 1050 } 1080 1081 #endif 1051 #endif /* CONFIG_WITH_VALUE_LENGTH */ 1052 1082 1053 /* Install a new variable_buffer context, returning the current one for 1083 1054 safe-keeping. */ -
trunk/src/kmk/function.c
r1805 r1809 931 931 char *list = expand_argument (argv[1], NULL); 932 932 const char *body = argv[2]; 933 #ifdef KMK933 #ifdef CONFIG_WITH_VALUE_LENGTH 934 934 long body_len = strlen (body); 935 #endif /* KMK - optimization */935 #endif 936 936 937 937 int doneany = 0; … … 947 947 while ((p = find_next_token (&list_iterator, &len)) != 0) 948 948 { 949 #ifndef KMK949 #ifndef CONFIG_WITH_VALUE_LENGTH 950 950 char *result = 0; 951 #endif /* KMK - optimization */ 952 #ifdef CONFIG_WITH_VALUE_LENGTH 951 952 free (var->value); 953 var->value = savestring (p, len); 954 result = allocated_variable_expand (body); 955 956 o = variable_buffer_output (o, result, strlen (result)); 957 o = variable_buffer_output (o, " ", 1); 958 doneany = 1; 959 free (result); 960 #else /* CONFIG_WITH_VALUE_LENGTH */ 953 961 if (len >= (unsigned int)var->value_alloc_len) 954 962 { … … 960 968 var->value[len] = '\0'; 961 969 var->value_length = len; 962 #else 963 free (var->value); 964 var->value = savestring (p, len); 965 #endif 966 967 #ifndef KMK 968 result = allocated_variable_expand (body); 969 970 o = variable_buffer_output (o, result, strlen (result)); 971 o = variable_buffer_output (o, " ", 1); 972 doneany = 1; 973 free (result); 974 #else /* KMK - optimization */ 970 975 971 variable_expand_string_2 (o, body, body_len, &o); 976 972 o = variable_buffer_output (o, " ", 1); 977 973 doneany = 1; 978 #endif /* KMK - optimization*/974 #endif /* CONFIG_WITH_VALUE_LENGTH */ 979 975 } 980 976 … … 4314 4310 4315 4311 v->exp_count = EXP_COUNT_MAX; 4316 #ifndef KMK4312 #ifndef CONFIG_WITH_VALUE_LENGTH 4317 4313 o = variable_expand_string (o, body, flen+3); 4318 4314 v->exp_count = 0; 4319 4315 4320 4316 o += strlen (o); 4321 #else /* KMK - optimization*/4317 #else /* CONFIG_WITH_VALUE_LENGTH */ 4322 4318 variable_expand_string_2 (o, body, flen+3, &o); 4323 4319 v->exp_count = 0; 4324 #endif /* KMK - optimization*/4320 #endif /* CONFIG_WITH_VALUE_LENGTH */ 4325 4321 #ifdef CONFIG_WITH_EVALPLUS 4326 4322 } -
trunk/src/kmk/kbuild.c
r1799 r1809 1771 1771 if (!s_fNoCompileCmdsDepsDefined) 1772 1772 { 1773 do_variable_definition(NILF, "_DEPFILES_INCLUDED", pDep->value, o_file, f_append, 0 /* !target_var */); 1773 do_variable_definition_2(NILF, "_DEPFILES_INCLUDED", pDep->value, pDep->value_length, 1774 pDep->flavor == f_simple, 0, o_file, f_append, 0 /* !target_var */); 1774 1775 eval_include_dep(pDep->value, NILF, iVer >= 2 ? incdep_queue : incdep_read_it); 1775 1776 } … … 1801 1802 memcpy(pszDst, "_CMDS_", sizeof("_CMDS_")); 1802 1803 pVar = kbuild_get_recursive_variable(pszSrcVar); 1803 do_variable_definition(NILF, pszDstVar, pVar->value, o_file, f_simple, 0 /* !target_var */); 1804 do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length, 1805 pVar->flavor == f_simple, 0, o_file, f_simple, 0 /* !target_var */); 1804 1806 1805 1807 memcpy(pszSrc, "_OUTPUT", sizeof("_OUTPUT")); 1806 1808 memcpy(pszDst, "_OUTPUT_", sizeof("_OUTPUT_")); 1807 1809 pVar = kbuild_get_recursive_variable(pszSrcVar); 1808 pOutput = do_variable_definition(NILF, pszDstVar, pVar->value, o_file, f_simple, 0 /* !target_var */); 1810 pOutput = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length, 1811 pVar->flavor == f_simple, 0, o_file, f_simple, 0 /* !target_var */); 1809 1812 1810 1813 memcpy(pszSrc, "_OUTPUT_MAYBE", sizeof("_OUTPUT_MAYBE")); 1811 1814 memcpy(pszDst, "_OUTPUT_MAYBE_", sizeof("_OUTPUT_MAYBE_")); 1812 1815 pVar = kbuild_query_recursive_variable(pszSrcVar); 1813 pOutputMaybe = do_variable_definition(NILF, pszDstVar, pVar ? pVar->value : "", o_file, f_simple, 0 /* !target_var */); 1816 if (pVar) 1817 pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length, 1818 pVar->flavor == f_simple, 0, o_file, f_simple, 0 /* !target_var */); 1819 else 1820 pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, "", 0, 1, 0, o_file, f_simple, 0 /* !target_var */); 1814 1821 1815 1822 memcpy(pszSrc, "_DEPEND", sizeof("_DEPEND")); … … 1822 1829 *psz++ = ' '; 1823 1830 memcpy(psz, pSource->value, pSource->value_length + 1); 1824 do_variable_definition(NILF, pszDstVar, pszVal, o_file, f_simple, 0 /* !target_var */); 1825 free(pszVal); 1831 do_variable_definition_2(NILF, pszDstVar, pszVal, pVar->value_length + 1 + pDeps->value_length + 1 + pSource->value_length, 1832 pVar->flavor == f_simple && pDeps->flavor == f_simple && pSource->flavor == f_simple, 1833 pszVal, o_file, f_simple, 0 /* !target_var */); 1826 1834 1827 1835 memcpy(pszSrc, "_DEPORD", sizeof("_DEPORD")); … … 1834 1842 *psz++ = ' '; 1835 1843 memcpy(psz, pOrderDeps->value, pOrderDeps->value_length + 1); 1836 do_variable_definition(NILF, pszDstVar, pszVal, o_file, f_simple, 0 /* !target_var */); 1837 free(pszVal); 1844 do_variable_definition_2(NILF, pszDstVar, pszVal, 1845 pVar->value_length + 1 + pDirDep->value_length + 1 + pOrderDeps->value_length, 1846 pVar->flavor == f_simple && pDirDep->flavor == f_simple && pOrderDeps->flavor == f_simple, 1847 pszVal, o_file, f_simple, 0 /* !target_var */); 1838 1848 1839 1849 /* 1840 1850 _OUT_FILES += $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) 1841 1851 */ 1852 /** @todo use append? */ 1842 1853 pVar = kbuild_get_variable("_OUT_FILES"); 1843 1854 psz = pszVal = xmalloc(pVar->value_length + 1 + pOutput->value_length + 1 + pOutputMaybe->value_length + 1); … … 1847 1858 *psz++ = ' '; 1848 1859 memcpy(psz, pOutputMaybe->value, pOutputMaybe->value_length + 1); 1849 do_variable_definition(NILF, "_OUT_FILES", pszVal, o_file, f_simple, 0 /* !target_var */); 1850 free(pszVal); 1860 do_variable_definition_2(NILF, "_OUT_FILES", pszVal, 1861 pVar->value_length + 1 + pOutput->value_length + 1 + pOutputMaybe->value_length, 1862 pVar->flavor == f_simple && pOutput->flavor == f_simple && pOutputMaybe->flavor == f_simple, 1863 pszVal, o_file, f_simple, 0 /* !target_var */); 1851 1864 1852 1865 /* … … 1854 1867 */ 1855 1868 memcpy(pszDstVar + pTarget->value_length, "_OBJS_", sizeof("_OBJS_")); 1856 do_variable_definition(NILF, pszDstVar, pObj->value, o_file, f_append, 0 /* !target_var */); 1869 do_variable_definition_2(NILF, pszDstVar, pObj->value, pObj->value_length, 1870 pObj->flavor == f_simple, 0, o_file, f_append, 0 /* !target_var */); 1857 1871 1858 1872 /* -
trunk/src/kmk/main.c
r1744 r1809 55 55 # define INCL_BASE 56 56 # include <os2.h> 57 # endif 57 # endif 58 58 #endif /* KMK*/ 59 59 … … 375 375 N_("\ 376 376 -j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.\n"), 377 #endif 377 #endif 378 378 N_("\ 379 379 -k, --keep-going Keep going when some targets can't be made.\n"), … … 1123 1123 /* Determins the number of CPUs that are currently online. 1124 1124 This is used to setup the default number of job slots. */ 1125 static int 1125 static int 1126 1126 get_online_cpu_count(void) 1127 1127 { … … 1151 1151 return cpus ? cpus : 1; 1152 1152 1153 # else 1153 # else 1154 1154 /* UNIX like systems, try sysconf and sysctl. */ 1155 1155 int cpus = -1; … … 1157 1157 int mib[2]; 1158 1158 size_t sz; 1159 # endif 1159 # endif 1160 1160 1161 1161 # ifdef _SC_NPROCESSORS_ONLN -
trunk/src/kmk/read.c
r1807 r1809 418 418 if (!fstat (fileno (ebuf.fp), &st)) 419 419 { 420 unsignedint stream_buf_size = 256*1024;420 int stream_buf_size = 256*1024; 421 421 if (st.st_size < stream_buf_size) 422 stream_buf_size = (st.st_size + 0xfff) & ~0xfff U;422 stream_buf_size = (st.st_size + 0xfff) & ~0xfff; 423 423 stream_buf = xmalloc (stream_buf_size); 424 424 setvbuf (ebuf.fp, stream_buf, _IOFBF, stream_buf_size); … … 2803 2803 { 2804 2804 char *eol; 2805 #ifdef KMK2805 #ifdef CONFIG_WITH_VALUE_LENGTH 2806 2806 char *end; 2807 2807 #endif … … 2815 2815 2816 2816 eol = ebuf->buffer = ebuf->bufnext; 2817 #ifdef KMK2817 #ifdef CONFIG_WITH_VALUE_LENGTH 2818 2818 end = ebuf->bufstart + ebuf->size; 2819 2819 #endif … … 2826 2826 2827 2827 /* Find the next newline. At EOS, stop. */ 2828 #ifndef KMK2828 #ifndef CONFIG_WITH_VALUE_LENGTH 2829 2829 eol = p = strchr (eol , '\n'); 2830 2830 #else -
trunk/src/kmk/variable.c
r1808 r1809 467 467 struct variable * 468 468 define_variable_in_set (const char *name, unsigned int length, 469 const char *value, unsigned int value_length, int duplicate_value, 470 enum variable_origin origin, int recursive, 471 struct variable_set *set, const struct floc *flocp) 469 const char *value, unsigned int value_len, 470 int duplicate_value, enum variable_origin origin, 471 int recursive, struct variable_set *set, 472 const struct floc *flocp) 472 473 #else 473 474 struct variable * … … 510 511 { 511 512 #ifdef CONFIG_WITH_VALUE_LENGTH 512 if (value_len gth== ~0U)513 value_len gth= strlen (value);513 if (value_len == ~0U) 514 value_len = strlen (value); 514 515 else 515 assert (value_len gth== strlen (value));516 assert (value_len == strlen (value)); 516 517 if (!duplicate_value) 517 518 { … … 519 520 free (v->value); 520 521 v->value = (char *)value; 521 v->value_alloc_len = value_len gth+ 1;522 v->value_alloc_len = value_len + 1; 522 523 } 523 524 else 524 525 { 525 if ((unsigned int)v->value_alloc_len <= value_len gth)526 if ((unsigned int)v->value_alloc_len <= value_len) 526 527 { 527 528 free (v->value); 528 v->value_alloc_len = (value_len gth+ 0x40) & ~0x3f;529 v->value_alloc_len = (value_len + 0x40) & ~0x3f; 529 530 v->value = xmalloc (v->value_alloc_len); 530 531 } 531 memcpy (v->value, value, value_len gth+ 1);532 memcpy (v->value, value, value_len + 1); 532 533 } 533 v->value_length = value_len gth;534 v->value_length = value_len; 534 535 #else 535 536 if (v->value != 0) … … 558 559 hash_insert_at (&set->table, v, var_slot); 559 560 #ifdef CONFIG_WITH_VALUE_LENGTH 560 if (value_len gth== ~0U)561 value_len gth= strlen (value);561 if (value_len == ~0U) 562 value_len = strlen (value); 562 563 else 563 assert (value_len gth== strlen (value));564 v->value_length = value_len gth;564 assert (value_len == strlen (value)); 565 v->value_length = value_len; 565 566 if (!duplicate_value) 566 567 { 567 v->value_alloc_len = value_len gth+ 1;568 v->value_alloc_len = value_len + 1; 568 569 v->value = (char *)value; 569 570 } 570 571 else 571 572 { 572 v->value_alloc_len = (value_len gth+ 32) & ~31;573 v->value_alloc_len = (value_len + 32) & ~31; 573 574 v->value = xmalloc (v->value_alloc_len); 574 memcpy (v->value, value, value_len gth+ 1);575 memcpy (v->value, value, value_len + 1); 575 576 } 576 577 #else … … 1618 1619 { 1619 1620 v->value_alloc_len *= 2; 1620 if ( v->value_alloc_len < new_value_len + 1)1621 if ((unsigned)v->value_alloc_len < new_value_len + 1) 1621 1622 v->value_alloc_len = (new_value_len + 1 + value_len + 0x7f) + ~0x7fU; 1622 1623 if (append || !v->value_length) … … 1655 1656 1656 1657 static struct variable * 1657 do_variable_definition_append (const struct floc *flocp, struct variable *v, const char *value, 1658 enum variable_origin origin, int append) 1658 do_variable_definition_append (const struct floc *flocp, struct variable *v, 1659 const char *value, unsigned int value_len, 1660 int simple_value, enum variable_origin origin, 1661 int append) 1659 1662 { 1660 1663 if (env_overrides && origin == o_env) … … 1679 1682 /* The juicy bits, append the specified value to the variable 1680 1683 This is a heavily exercised code path in kBuild. */ 1681 if (v->recursive) 1682 append_string_to_variable (v, value, strlen (value), append); 1684 if (value_len == ~0U) 1685 value_len = strlen (value); 1686 if (v->recursive || simple_value) 1687 append_string_to_variable (v, value, value_len, append); 1683 1688 else 1684 1689 /* The previous definition of the variable was simple. 1685 1690 The new value comes from the old value, which was expanded 1686 1691 when it was set; and from the expanded new value. */ 1687 append_expanded_string_to_variable (v, value, append);1692 append_expanded_string_to_variable (v, value, value_len, append); 1688 1693 1689 1694 /* update the variable */ … … 1697 1702 1698 1703 struct variable * 1704 #ifndef CONFIG_WITH_VALUE_LENGTH 1699 1705 do_variable_definition (const struct floc *flocp, const char *varname, 1700 1706 const char *value, enum variable_origin origin, 1701 1707 enum variable_flavor flavor, int target_var) 1708 #else /* CONFIG_WITH_VALUE_LENGTH */ 1709 do_variable_definition_2 (const struct floc *flocp, 1710 const char *varname, const char *value, 1711 unsigned int value_len, int simple_value, 1712 char *free_value, 1713 enum variable_origin origin, 1714 enum variable_flavor flavor, 1715 int target_var) 1716 #endif /* CONFIG_WITH_VALUE_LENGTH */ 1702 1717 { 1703 1718 const char *p; … … 1708 1723 const size_t varname_len = strlen (varname); /* bird */ 1709 1724 #ifdef CONFIG_WITH_VALUE_LENGTH 1710 unsigned int value_len = ~0U;1725 assert (value_len == ~0U || value_len == strlen (value)); 1711 1726 #endif 1712 1727 … … 1724 1739 variable buffer, and we may still need that if we're looking at a 1725 1740 target-specific variable. */ 1726 #if !defined(KMK) || !defined(CONFIG_WITH_VALUE_LENGTH)1741 #ifndef CONFIG_WITH_VALUE_LENGTH 1727 1742 p = alloc_value = allocated_variable_expand (value); 1728 #else /* KMK - optimization */ 1729 p = alloc_value = allocated_variable_expand_2 (value, -1, &value_len); 1730 #endif /* KMK - optimization */ 1743 #else /* CONFIG_WITH_VALUE_LENGTH */ 1744 if (!simple_value) 1745 p = alloc_value = allocated_variable_expand_2 (value, value_len, &value_len); 1746 else 1747 { 1748 if (value_len == ~0U) 1749 value_len = strlen (value); 1750 if (!free_value) 1751 p = alloc_value = savestring (value, value_len); 1752 else 1753 { 1754 assert (value == free_value); 1755 p = alloc_value = free_value; 1756 free_value = 0; 1757 } 1758 } 1759 #endif /* CONFIG_WITH_VALUE_LENGTH */ 1731 1760 break; 1732 1761 case f_conditional: … … 1789 1818 #ifdef CONFIG_WITH_VALUE_LENGTH 1790 1819 v->append = append; 1820 v = do_variable_definition_append (flocp, v, value, value_len, 1821 simple_value, origin, 1791 1822 # ifdef CONFIG_WITH_PREPEND_ASSIGNMENT 1792 return do_variable_definition_append (flocp, v, value, origin,org_flavor == f_append);1823 org_flavor == f_append); 1793 1824 # else 1794 return do_variable_definition_append (flocp, v, value, origin,1);1825 1); 1795 1826 # endif 1827 if (free_value) 1828 free (free_value); 1829 return v; 1796 1830 #else /* !CONFIG_WITH_VALUE_LENGTH */ 1797 1831 … … 1973 2007 if (alloc_value) 1974 2008 free (alloc_value); 2009 #else 2010 if (free_value) 2011 free (free_value); 1975 2012 #endif 1976 2013 … … 2000 2037 register char *end; 2001 2038 enum variable_flavor flavor = f_bogus; 2002 #ifndef KMK2039 #ifndef CONFIG_WITH_VALUE_LENGTH 2003 2040 char *name; 2004 #endif /* KMK - optimization */2041 #endif 2005 2042 2006 2043 while (1) … … 2086 2123 2087 2124 /* Expand the name, so "$(foo)bar = baz" works. */ 2088 #ifndef KMK2125 #ifndef CONFIG_WITH_VALUE_LENGTH 2089 2126 name = alloca (end - beg + 1); 2090 2127 memcpy (name, beg, end - beg); 2091 2128 name[end - beg] = '\0'; 2092 2129 v->name = allocated_variable_expand (name); 2093 #else /* KMK - optimizations */ 2094 //if (memchr (beg, '$', end - beg)) /* (Mostly for cleaning up the profiler result.) */ 2095 v->name = allocated_variable_expand_2 (beg, end - beg, NULL); 2096 //else 2097 // { 2098 // v->name = memcpy (xmalloc (end - beg + 1), beg, end - beg); 2099 // v->name[end - beg] = '\0'; 2100 // } 2101 #endif /* KMK - optimizations */ 2130 #else /* CONFIG_WITH_VALUE_LENGTH */ 2131 v->name = allocated_variable_expand_2 (beg, end - beg, NULL); 2132 #endif /* CONFIG_WITH_VALUE_LENGTH */ 2102 2133 2103 2134 if (v->name[0] == '\0') -
trunk/src/kmk/variable.h
r1808 r1809 136 136 #endif 137 137 char *allocated_variable_expand_for_file (const char *line, struct file *file); 138 #ifndef KMK138 #ifndef CONFIG_WITH_VALUE_LENGTH 139 139 #define allocated_variable_expand(line) \ 140 140 allocated_variable_expand_for_file (line, (struct file *) 0) 141 #else /* KMK*/141 #else /* CONFIG_WITH_VALUE_LENGTH */ 142 142 # define allocated_variable_expand(line) \ 143 143 allocated_variable_expand_2 (line, -1, NULL) 144 char *allocated_variable_expand_2(const char *line, longlength, unsigned int *value_len);145 #endif 144 char *allocated_variable_expand_2(const char *line, unsigned int length, unsigned int *value_len); 145 #endif /* CONFIG_WITH_VALUE_LENGTH */ 146 146 char *expand_argument (const char *str, const char *end); 147 147 char *variable_expand_string (char *line, const char *string, long length); 148 #ifdef KMK148 #ifdef CONFIG_WITH_VALUE_LENGTH 149 149 char *variable_expand_string_2 (char *line, const char *string, long length, char **eol); 150 150 #endif … … 152 152 void restore_variable_buffer (char *buf, unsigned int len); 153 153 #ifdef CONFIG_WITH_VALUE_LENGTH 154 extern void append_expanded_string_to_variable (struct variable *v, const char *value, int append); 154 void append_expanded_string_to_variable (struct variable *v, const char *value, 155 unsigned int value_len, int append); 155 156 #endif 156 157 … … 184 185 void merge_variable_set_lists (struct variable_set_list **to_list, 185 186 struct variable_set_list *from_list); 187 #ifndef CONFIG_WITH_VALUE_LENGTH 186 188 struct variable *do_variable_definition (const struct floc *flocp, 187 189 const char *name, const char *value, … … 189 191 enum variable_flavor flavor, 190 192 int target_var); 193 #else /* CONFIG_WITH_VALUE_LENGTH */ 194 # define do_variable_definition(flocp, varname, value, origin, flavor, target_var) \ 195 do_variable_definition_2 ((flocp), (varname), (value), ~0U, 0, NULL, \ 196 (origin), (flavor), (target_var)) 197 198 struct variable *do_variable_definition_2 (const struct floc *flocp, 199 const char *varname, 200 const char *value, 201 unsigned int value_len, 202 int simple_value, char *free_value, 203 enum variable_origin origin, 204 enum variable_flavor flavor, 205 int target_var); 206 #endif /* CONFIG_WITH_VALUE_LENGTH */ 191 207 struct variable *parse_variable_definition (struct variable *v, char *line); 192 208 struct variable *try_variable_definition (const struct floc *flocp, char *line,
Note:
See TracChangeset
for help on using the changeset viewer.