Changeset 1808 for trunk/src/kmk
- Timestamp:
- Oct 9, 2008, 7:36:19 AM (17 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/expand.c
r1805 r1808 228 228 char *o; 229 229 unsigned int line_offset; 230 #ifdef KMK 231 const char *eos; 232 #endif 230 233 231 234 if (!line) … … 245 248 } 246 249 250 #ifdef KMK 247 251 /* Simple first, 50% of the kBuild calls to this function does 248 252 not need any expansion at all. Should be worth a special case. */ 249 #ifdef KMK 250 if (length > 0) 251 { 252 p1 = (const char *)memchr (string, '$', length); 253 if (p1 == 0) 254 { 255 if (string[length] == '\0') 256 o = variable_buffer_output (o, string, length); 257 else 258 o = variable_buffer_output (o, string, length); 259 variable_buffer_output (o, "\0", 2); 260 return (variable_buffer + line_offset); 261 } 262 } 263 else 264 { 265 p1 = strchr (string, '$'); 266 if (p1 == 0) 267 { 268 length = strlen (string); 269 o = variable_buffer_output (o, string, length); 270 variable_buffer_output (o, "\0", 2); 271 return (variable_buffer + line_offset); 272 } 273 } 253 if (length < 0) 254 length = strlen (string); 255 p1 = (const char *)memchr (string, '$', length); 256 if (p1 == 0) 257 { 258 o = variable_buffer_output (o, string, length); 259 variable_buffer_output (o, "\0", 2); 260 return (variable_buffer + line_offset); 261 } 262 eos = string + length; 274 263 #endif /* KMK - optimization */ 275 264 … … 283 272 #ifdef KMK 284 273 p1 += abuf - string; 274 eos += abuf - string; 285 275 #endif /* KMK - optimization */ 286 276 string = abuf; … … 337 327 If so, expand it before expanding the entire reference. */ 338 328 329 #ifndef KMK 339 330 end = strchr (beg, closeparen); 331 #else /* KMK - optimization */ 332 end = memchr (beg, closeparen, eos - beg); 333 #endif /* KMK - optimization */ 340 334 if (end == 0) 341 335 /* Unterminated variable reference. */ … … 477 471 ++p; 478 472 #ifdef KMK 479 p1 = strchr (p, '$');473 p1 = memchr (p, '$', eos - p); 480 474 #endif /* KMK - optimization */ 481 475 } … … 500 494 char *o; 501 495 unsigned int line_offset; 496 #ifdef KMK 497 const char *eos; 498 #endif 502 499 503 500 if (!line) … … 517 514 } 518 515 516 #ifdef KMK 519 517 /* Simple first, 50% of the kBuild calls to this function does 520 518 not need any expansion at all. Should be worth a special case. */ 521 #ifdef KMK 522 if (length > 0) 523 { 524 p1 = (const char *)memchr (string, '$', length); 525 if (p1 == 0) 526 { 527 if (string[length] == '\0') 528 o = variable_buffer_output (o, string, length); 529 else 530 o = variable_buffer_output (o, string, length); 531 o = variable_buffer_output (o, "\0", 2); 532 *eol = o - 2; 533 return (variable_buffer + line_offset); 534 } 535 } 536 else 537 { 538 p1 = strchr (string, '$'); 539 if (p1 == 0) 540 { 541 length = strlen (string); 542 o = variable_buffer_output (o, string, length + 1); 543 o = variable_buffer_output (o, "\0", 2); 544 *eol = o - 2; 545 return (variable_buffer + line_offset); 546 } 547 } 548 #endif /* KMK */ 519 if (length < 0) 520 length = strlen (string); 521 p1 = (const char *)memchr (string, '$', length); 522 if (p1 == 0) 523 { 524 o = variable_buffer_output (o, string, length); 525 o = variable_buffer_output (o, "\0", 2); 526 *eol = o - 2; 527 return (variable_buffer + line_offset); 528 } 529 eos = string + length; 530 #endif /* KMK - optimization */ 549 531 550 532 /* If we want a subset of the string, allocate a temporary buffer for it. … … 557 539 #ifdef KMK 558 540 p1 += abuf - string; 541 eos += abuf - string; 559 542 #endif 560 543 string = abuf; … … 612 595 If so, expand it before expanding the entire reference. */ 613 596 597 #ifndef KMK 614 598 end = strchr (beg, closeparen); 599 #else /* KMK - optimization */ 600 end = memchr (beg, closeparen, eos - beg); 601 #endif /* KMK - optimization */ 615 602 if (end == 0) 616 603 /* Unterminated variable reference. */ … … 752 739 ++p; 753 740 #ifdef KMK 754 p1 = strchr (p, '$');755 #endif 741 p1 = memchr (p, '$', eos - p); 742 #endif /* KMK - optimization */ 756 743 } 757 744 … … 1064 1051 1065 1052 char * 1066 allocated_variable_expand_2 (const char *line, long length )1053 allocated_variable_expand_2 (const char *line, long length, unsigned int *value_len) 1067 1054 { 1068 1055 char *value; … … 1077 1064 #endif 1078 1065 1079 value = variable_expand_string (NULL, line, length); 1066 if (!value_len) 1067 value = variable_expand_string (NULL, line, length); 1068 else 1069 { 1070 char *eol; 1071 value = variable_expand_string_2 (NULL, line, length, &eol); 1072 *value_len = eol - value; 1073 } 1080 1074 1081 1075 variable_buffer = obuf; -
trunk/src/kmk/variable.c
r1805 r1808 1724 1724 variable buffer, and we may still need that if we're looking at a 1725 1725 target-specific variable. */ 1726 #if !defined(KMK) || !defined(CONFIG_WITH_VALUE_LENGTH) 1726 1727 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 */ 1727 1731 break; 1728 1732 case f_conditional: … … 2089 2093 #else /* KMK - optimizations */ 2090 2094 //if (memchr (beg, '$', end - beg)) /* (Mostly for cleaning up the profiler result.) */ 2091 v->name = allocated_variable_expand_2 (beg, end - beg );2095 v->name = allocated_variable_expand_2 (beg, end - beg, NULL); 2092 2096 //else 2093 2097 // { -
trunk/src/kmk/variable.h
r1805 r1808 141 141 #else /* KMK */ 142 142 # define allocated_variable_expand(line) \ 143 allocated_variable_expand_2 (line, -1 )144 char *allocated_variable_expand_2(const char *line, long length );143 allocated_variable_expand_2 (line, -1, NULL) 144 char *allocated_variable_expand_2(const char *line, long length, unsigned int *value_len); 145 145 #endif 146 146 char *expand_argument (const char *str, const char *end);
Note:
See TracChangeset
for help on using the changeset viewer.