Changeset 1809 for trunk/src/kmk/expand.c
- Timestamp:
- Oct 10, 2008, 4:27:38 AM (17 years ago)
- File:
-
- 1 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. */
Note:
See TracChangeset
for help on using the changeset viewer.