Changeset 1827 in kBuild for trunk/src/kmk
- Timestamp:
- Oct 11, 2008 7:12:10 AM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/dep.h
r1797 r1827 76 76 void free_ns_chain (struct nameseq *n); 77 77 struct dep *read_all_makefiles (const char **makefiles); 78 #ifndef CONFIG_WITH_VALUE_LENGTH 78 79 int eval_buffer (char *buffer); 80 #else 81 int eval_buffer (char *buffer, char *eos); 82 #endif 79 83 int update_goal_chain (struct dep *goals); 80 84 void uniquize_deps (struct dep *); -
trunk/src/kmk/expand.c
r1819 r1827 108 108 109 109 char * 110 #ifndef CONFIG_WITH_VALUE_LENGTH 110 111 recursively_expand_for_file (struct variable *v, struct file *file) 112 #else 113 recursively_expand_for_file (struct variable *v, struct file *file, 114 unsigned int *value_lenp) 115 #endif 111 116 { 112 117 char *value; … … 149 154 150 155 v->expanding = 1; 156 #ifndef CONFIG_WITH_VALUE_LENGTH 151 157 if (v->append) 152 158 value = allocated_variable_append (v); 153 159 else 154 160 value = allocated_variable_expand (v->value); 161 #else /* CONFIG_WITH_VALUE_LENGTH */ 162 if (!v->append) 163 value = allocated_variable_expand_2 (v->value, v->value_length, value_lenp); 164 else 165 { 166 value = allocated_variable_append (v); 167 if (value_lenp) 168 *value_lenp = strlen (value); 169 } 170 #endif /* CONFIG_WITH_VALUE_LENGTH */ 155 171 v->expanding = 0; 156 172 … … 187 203 188 204 #ifdef CONFIG_WITH_VALUE_LENGTH 205 assert ((unsigned int)v->value_length == strlen (v->value)); 189 206 if (!v->recursive) 190 { 191 assert (v->value_length == strlen (v->value)); 192 o = variable_buffer_output (o, v->value, v->value_length); 193 } 207 o = variable_buffer_output (o, v->value, v->value_length); 194 208 else 195 209 { 196 value = recursively_expand (v); 197 o = variable_buffer_output (o, value, strlen (value)); 210 unsigned int value_len; 211 212 value = recursively_expand_for_file (v, NULL, &value_len); 213 o = variable_buffer_output (o, value, value_len); 198 214 free (value); 199 215 } … … 211 227 212 228 229 #ifndef CONFIG_WITH_VALUE_LENGTH /* Only using variable_expand_string_2! */ 213 230 /* Scan STRING for variable references and expansion-function calls. Only 214 231 LENGTH bytes of STRING are actually scanned. If LENGTH is -1, scan until … … 228 245 char *o; 229 246 unsigned int line_offset; 230 #ifdef CONFIG_WITH_VALUE_LENGTH231 const char *eos;232 #endif233 247 234 248 if (!line) … … 239 253 if (length == 0) 240 254 { 241 #ifdef KMK /* this is a bug fix. The 2 vs 1 thing is the strlen + 1 in the loop below. */242 variable_buffer_output (o, "\0", 2);243 return (variable_buffer + line_offset);244 #else245 255 variable_buffer_output (o, "", 1); 246 256 return (variable_buffer); 247 #endif 248 } 249 250 #ifdef CONFIG_WITH_VALUE_LENGTH 251 /* Simple first, 50% of the kBuild calls to this function does 252 not need any expansion at all. Should be worth a special case. */ 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; 263 #endif /* CONFIG_WITH_VALUE_LENGTH */ 257 } 264 258 265 259 /* If we want a subset of the string, allocate a temporary buffer for it. … … 270 264 memcpy(abuf, string, length); 271 265 abuf[length] = '\0'; 272 #ifdef CONFIG_WITH_VALUE_LENGTH273 p1 += abuf - string;274 eos += abuf - string;275 #endif /* CONFIG_WITH_VALUE_LENGTH */276 266 string = abuf; 277 267 } … … 284 274 at the next $ or the end of the input. */ 285 275 286 #ifndef CONFIG_WITH_VALUE_LENGTH287 276 p1 = strchr (p, '$'); 288 #endif289 277 290 278 o = variable_buffer_output (o, p, p1 != 0 ? (unsigned int)(p1 - p) : strlen (p) + 1); … … 327 315 If so, expand it before expanding the entire reference. */ 328 316 329 #ifndef CONFIG_WITH_VALUE_LENGTH330 317 end = strchr (beg, closeparen); 331 #else332 end = memchr (beg, closeparen, eos - beg);333 #endif334 318 if (end == 0) 335 319 /* Unterminated variable reference. */ … … 470 454 else 471 455 ++p; 472 #ifdef CONFIG_WITH_VALUE_LENGTH473 p1 = memchr (p, '$', eos - p);474 #endif475 456 } 476 457 … … 481 462 return (variable_buffer + line_offset); 482 463 } 483 #ifdef CONFIG_WITH_VALUE_LENGTH 484 485 486 /* Same as variable_expand_string except that the pointer at EOL will 487 point to the end of the returned string. */ 464 465 #else /* CONFIG_WITH_VALUE_LENGTH */ 466 /* Scan STRING for variable references and expansion-function calls. Only 467 LENGTH bytes of STRING are actually scanned. If LENGTH is -1, scan until 468 a null byte is found. 469 470 Write the results to LINE, which must point into `variable_buffer'. If 471 LINE is NULL, start at the beginning of the buffer. 472 Return a pointer to LINE, or to the beginning of the buffer if LINE is 473 NULL. Set EOLP to point to the string terminator. 474 */ 488 475 char * 489 variable_expand_string_2 (char *line, const char *string, long length, char **eol )476 variable_expand_string_2 (char *line, const char *string, long length, char **eolp) 490 477 { 491 478 struct variable *v; 492 const char *p, *p1; 493 char *abuf = NULL; 479 const char *p, *p1, *eos; 494 480 char *o; 495 481 unsigned int line_offset; 496 #ifdef CONFIG_WITH_VALUE_LENGTH497 const char *eos;498 #endif499 482 500 483 if (!line) … … 503 486 line_offset = line - variable_buffer; 504 487 505 if (length == 0)506 {507 o = variable_buffer_output (o, "\0", 2);508 *eol = o - 2;509 #ifdef KMK /* this is a bug fix. */510 return (variable_buffer + line_offset);511 #else512 return (variable_buffer);513 #endif514 }515 516 #ifdef CONFIG_WITH_VALUE_LENGTH517 /* Simple first, 50% of the kBuild calls to this function does518 not need any expansion at all. Should be worth a special case. */519 488 if (length < 0) 520 489 length = strlen (string); 490 491 /* Simple 1: Emptry string. */ 492 493 if (length == 0) 494 { 495 o = variable_buffer_output (o, "\0", 2); 496 *eolp = o - 2; 497 return (variable_buffer + line_offset); 498 } 499 500 /* Simple 2: Nothing to expand. ~50% if the kBuild calls. */ 501 521 502 p1 = (const char *)memchr (string, '$', length); 522 503 if (p1 == 0) … … 524 505 o = variable_buffer_output (o, string, length); 525 506 o = variable_buffer_output (o, "\0", 2); 526 *eol = o - 2;507 *eolp = o - 2; 527 508 return (variable_buffer + line_offset); 528 509 } 529 eos = string + length; 530 #endif /* CONFIG_WITH_VALUE_LENGTH */ 531 532 /* If we want a subset of the string, allocate a temporary buffer for it. 533 Most of the functions we use here don't work with length limits. */ 534 if (length > 0 && string[length] != '\0') 535 { 536 abuf = xmalloc(length+1); 537 memcpy(abuf, string, length); 538 abuf[length] = '\0'; 539 #ifdef CONFIG_WITH_VALUE_LENGTH 540 p1 += abuf - string; 541 eos += abuf - string; 542 #endif 543 string = abuf; 544 } 510 545 511 p = string; 512 eos = p + length; 546 513 547 514 while (1) … … 551 518 at the next $ or the end of the input. */ 552 519 553 #ifndef CONFIG_WITH_VALUE_LENGTH 554 p1 = strchr (p, '$'); 555 #endif 556 557 /*o = variable_buffer_output (o, p, p1 != 0 ? (unsigned int)(p1 - p) : strlen (p) + 1); - why +1 ? */ 558 o = variable_buffer_output (o, p, p1 != 0 ? (unsigned int)(p1 - p) : strlen (p)); 520 o = variable_buffer_output (o, p, p1 != 0 ? (p1 - p) : (eos - p)); 559 521 560 522 if (p1 == 0) … … 585 547 op = o; 586 548 begp = p; 587 if (handle_function (&op, &begp ))549 if (handle_function (&op, &begp, eos)) 588 550 { 589 551 o = op; … … 595 557 If so, expand it before expanding the entire reference. */ 596 558 597 #ifndef CONFIG_WITH_VALUE_LENGTH598 end = strchr (beg, closeparen);599 #else600 559 end = memchr (beg, closeparen, eos - beg); 601 #endif602 560 if (end == 0) 603 561 /* Unterminated variable reference. */ … … 609 567 Count parens or braces until it is matched. */ 610 568 int count = 0; 611 for (p = beg; *p != '\0'; ++p)569 for (p = beg; p < eos; ++p) 612 570 { 613 571 if (*p == openparen) … … 621 579 if (count < 0) 622 580 { 623 abeg = expand_argument (beg, p); /* Expand the name. */ 624 beg = abeg; 625 end = strchr (beg, '\0'); 581 unsigned int len; 582 char saved; 583 584 /* Expand the name. */ 585 saved = *p; 586 *(char *)p = '\0'; /* XXX: proove that this is safe! */ 587 abeg = allocated_variable_expand_2 (beg, p - beg, &len); 588 beg = abeg; 589 end = beg + len; 590 *(char *)p = saved; 626 591 } 627 592 } … … 721 686 722 687 case '\0': 723 break; 688 assert (p == eos); 689 break; 724 690 725 691 default: 726 if (isblank ((unsigned char)p[-1])) 692 if (isblank ((unsigned char)p[-1])) /* XXX: This looks incorrect, previous is '$' */ 727 693 break; 728 694 … … 734 700 } 735 701 736 if ( *p == '\0')702 if (++p >= eos) 737 703 break; 738 else739 ++p;740 #ifdef CONFIG_WITH_VALUE_LENGTH741 704 p1 = memchr (p, '$', eos - p); 742 #endif 743 } 744 745 if (abuf) 746 free (abuf); 705 } 747 706 748 707 o = variable_buffer_output (o, "\0", 2); /* KMK: compensate for the strlen + 1 that was removed above. */ 749 *eol = o - 2;708 *eolp = o - 2; 750 709 return (variable_buffer + line_offset); 751 710 } … … 761 720 variable_expand (const char *line) 762 721 { 722 #ifndef CONFIG_WITH_VALUE_LENGTH 763 723 return variable_expand_string(NULL, line, (long)-1); 724 #else 725 char *s; 726 727 /* this function is abused a lot like this: variable_expand(""). */ 728 if (!*line) 729 { 730 s = variable_buffer_output (initialize_variable_output (), "\0", 2); 731 return s - 2; 732 } 733 return variable_expand_string_2 (NULL, line, (long)-1, &s); 734 #endif 764 735 } 765 736 … … 779 750 return xstrdup(""); 780 751 752 #ifndef CONFIG_WITH_VALUE_LENGTH 781 753 if (!end || *end == '\0') 782 754 return allocated_variable_expand (str); 755 #else 756 if (!end) 757 return allocated_variable_expand_2 (str, ~0U, NULL); 758 if (*end == '\0') 759 return allocated_variable_expand_2 (str, end - str, NULL); 760 #endif 783 761 784 762 #ifdef CONFIG_WITH_OPTIMIZATION_HACKS … … 786 764 const char saved_char = *end; 787 765 *(char *)end = '\0'; 766 # ifndef CONFIG_WITH_VALUE_LENGTH 788 767 tmp = allocated_variable_expand ((char *)str); 768 # else 769 tmp = allocated_variable_expand_2 ((char *)str, end - str, NULL); 770 # endif 789 771 *(char *)end = saved_char; 790 772 return tmp; … … 795 777 tmp[end - str] = '\0'; 796 778 779 # ifndef CONFIG_WITH_VALUE_LENGTH 797 780 return allocated_variable_expand (tmp); 781 # else 782 return allocated_variable_expand_2 (tmp, end - str, NULL); 783 # endif 798 784 #endif 799 785 } … … 839 825 struct variable_set_list *save; 840 826 const struct floc *reading_file_saved; 827 char *eol; 841 828 842 829 if (file == 0) 843 return variable_expand_string (o, line, (long)-1);830 return variable_expand_string_2 (o, line, (long)-1, &eol); 844 831 845 832 save = current_variable_set_list; … … 850 837 else 851 838 reading_file = 0; 852 result = variable_expand_string (o, line, (long)-1);839 result = variable_expand_string_2 (o, line, (long)-1, &eol); 853 840 current_variable_set_list = save; 854 841 reading_file = reading_file_saved; … … 893 880 buf = variable_buffer_output (buf, " ", 1); 894 881 #ifdef CONFIG_WITH_VALUE_LENGTH 895 assert ( v->value_length == strlen (v->value));882 assert ((unsigned int)v->value_length == strlen (v->value)); /* FIXME */ 896 883 #endif 897 884 … … 1026 1013 char * 1027 1014 allocated_variable_expand_2 (const char *line, unsigned int length, 1028 unsigned int *value_len )1015 unsigned int *value_lenp) 1029 1016 { 1030 1017 char *value; … … 1032 1019 unsigned int olen = variable_buffer_length; 1033 1020 long len = length == ~0U ? -1L : (long)length; 1021 char *eol; 1034 1022 1035 1023 variable_buffer = 0; 1036 1024 1037 if (!value_len) 1038 value = variable_expand_string (NULL, line, len); 1039 else 1040 { 1041 char *eol; 1042 value = variable_expand_string_2 (NULL, line, len, &eol); 1043 *value_len = eol - value; 1044 } 1025 value = variable_expand_string_2 (NULL, line, len, &eol); 1026 if (value_lenp) 1027 *value_lenp = eol - value; 1045 1028 1046 1029 variable_buffer = obuf; -
trunk/src/kmk/function.c
r1809 r1827 323 323 324 324 325 #if def CONFIG_WITH_OPTIMIZATION_HACKS325 #if defined (CONFIG_WITH_OPTIMIZATION_HACKS) || defined (CONFIG_WITH_VALUE_LENGTH) 326 326 /* The maximum length of a function, once reached there is 327 327 it can't be function and we can skip the hash lookup drop out. */ 328 328 329 # ifdef KMK 330 # define MAX_FUNCTION_LENGTH 12 331 # else 332 # define MAX_FUNCTION_LENGTH 10 333 # endif 334 #endif /* CONFIG_WITH_OPTIMIZATION_HACKS */ 329 # define MAX_FUNCTION_LENGTH 12 330 # define MIN_FUNCTION_LENGTH 2 331 332 /* char map containing the valid function name characters. */ 333 static char func_char_map[256]; 334 335 /* Do the hash table lookup. */ 336 337 __inline static const struct function_table_entry * 338 lookup_function_in_hash_tab (const char *s, unsigned char len) 339 { 340 struct function_table_entry function_table_entry_key; 341 function_table_entry_key.name = s; 342 function_table_entry_key.len = len; 343 344 return hash_find_item (&function_table, &function_table_entry_key); 345 } 335 346 336 347 /* Look up a function by name. */ 337 348 338 #ifdef CONFIG_WITH_OPTIMIZATION_HACKS 339 __inline 340 #endif /* CONFIG_WITH_OPTIMIZATION_HACKS */ 349 __inline static const struct function_table_entry * 350 lookup_function (const char *s, unsigned int len) 351 { 352 unsigned char ch; 353 # if 0 /* insane loop unroll */ 354 355 if (len > MAX_FUNCTION_LENGTH) 356 len = MAX_FUNCTION_LENGTH + 1; 357 358 # define X(idx) \ 359 if (!func_char_map[ch = s[idx]]) \ 360 { \ 361 if (isblank (ch)) \ 362 return lookup_function_in_hash_tab (s, idx); \ 363 return 0; \ 364 } 365 # define Z(idx) \ 366 return lookup_function_in_hash_tab (s, idx); 367 368 switch (len) 369 { 370 default: 371 assert (0); 372 case 0: return 0; 373 case 1: return 0; 374 case 2: X(0); X(1); Z(2); 375 case 3: X(0); X(1); X(2); Z(3); 376 case 4: X(0); X(1); X(2); X(3); Z(4); 377 case 5: X(0); X(1); X(2); X(3); X(4); Z(5); 378 case 6: X(0); X(1); X(2); X(3); X(4); X(5); Z(6); 379 case 7: X(0); X(1); X(2); X(3); X(4); X(5); X(6); Z(7); 380 case 8: X(0); X(1); X(2); X(3); X(4); X(5); X(6); X(7); Z(8); 381 case 9: X(0); X(1); X(2); X(3); X(4); X(5); X(6); X(7); X(8); Z(9); 382 case 10: X(0); X(1); X(2); X(3); X(4); X(5); X(6); X(7); X(8); X(9); Z(10); 383 case 11: X(0); X(1); X(2); X(3); X(4); X(5); X(6); X(7); X(8); X(9); X(10); Z(11); 384 case 12: X(0); X(1); X(2); X(3); X(4); X(5); X(6); X(7); X(8); X(9); X(10); X(11); Z(12); 385 case 13: X(0); X(1); X(2); X(3); X(4); X(5); X(6); X(7); X(8); X(9); X(10); X(11); X(12); 386 if ((ch = s[12]) == '\0' || isblank (ch)) 387 return lookup_function_in_hash_tab (s, 12); 388 return 0; 389 } 390 # undef Z 391 # undef X 392 393 # else /* normal loop */ 394 const char *e = s; 395 if (len > MAX_FUNCTION_LENGTH) 396 len = MAX_FUNCTION_LENGTH; 397 while (func_char_map[ch = *e]) 398 { 399 if (!len--) 400 return 0; 401 e++; 402 } 403 if (ch == '\0' || isblank ((unsigned char) ch)) 404 return lookup_function_in_hash_tab (s, e - s); 405 return 0; 406 # endif /* normal loop */ 407 } 408 409 #else /* original code */ 410 /* Look up a function by name. */ 411 341 412 static const struct function_table_entry * 342 413 lookup_function (const char *s) 343 414 { 344 415 const char *e = s; 345 #ifdef CONFIG_WITH_OPTIMIZATION_HACKS346 int left = MAX_FUNCTION_LENGTH;347 int ch;348 while (((ch = *e) >= 'a' && ch <='z') || ch == '-')349 {350 if (!left--)351 return 0;352 e++;353 }354 #else355 416 while (*e && ( (*e >= 'a' && *e <= 'z') || *e == '-')) 356 417 e++; 357 #endif358 418 if (*e == '\0' || isblank ((unsigned char) *e)) 359 419 { … … 366 426 return 0; 367 427 } 428 #endif /* original code */ 368 429 369 430 … … 1512 1573 install_variable_buffer (&buf, &len); 1513 1574 1575 #ifndef CONFIG_WITH_VALUE_LENGTH 1514 1576 eval_buffer (argv[0]); 1577 #else 1578 eval_buffer (argv[0], strchr (argv[0], '\0')); 1579 #endif 1515 1580 1516 1581 restore_variable_buffer (buf, len); … … 1536 1601 push_new_variable_scope (); 1537 1602 1538 eval_buffer (argv[0] );1603 eval_buffer (argv[0], strchr (argv[0], '\0')); 1539 1604 1540 1605 pop_variable_scope (); … … 1565 1630 1566 1631 off = o - variable_buffer; 1567 o =variable_buffer_output (o, v->value, v->value_length + 1);1632 variable_buffer_output (o, v->value, v->value_length + 1); 1568 1633 o = variable_buffer + off; 1569 assert (!o[v->value_length]);1570 1634 1571 1635 /* Eval the value. Pop the current variable buffer setting so that the … … 1579 1643 reading_file = &v->fileinfo; 1580 1644 1581 eval_buffer (o); 1645 assert (!o[v->value_length]); 1646 eval_buffer (o, o + v->value_length); 1582 1647 1583 1648 reading_file = reading_file_saved; … … 1601 1666 #ifdef CONFIG_WITH_VALUE_LENGTH 1602 1667 o = variable_buffer_output (o, v->value, 1603 v->value_length >= 0 ? v->value_length : strlen(v->value)); 1668 v->value_length >= 0 1669 ? (unsigned int)v->value_length /* FIXME */ 1670 : strlen(v->value)); 1604 1671 #else 1605 1672 o = variable_buffer_output (o, v->value, strlen(v->value)); … … 3061 3128 const char *src = comp; 3062 3129 const char *end = strchr (comp, PATH_SEPARATOR_CHAR); 3063 size_t comp_len = end ? end - comp: strlen (comp);3130 size_t comp_len = end ? (size_t)(end - comp) : strlen (comp); 3064 3131 if (!comp_len) 3065 3132 { … … 4197 4264 } 4198 4265 4199 int 4200 handle_function (char **op, const char **stringp) /* bird split it up */ 4266 4267 int /* bird split it up */ 4268 #ifndef CONFIG_WITH_VALUE_LENGTH 4269 handle_function (char **op, const char **stringp) 4201 4270 { 4202 4271 const struct function_table_entry *entry_p = lookup_function (*stringp + 1); … … 4205 4274 return handle_function2 (entry_p, op, stringp); 4206 4275 } 4276 #else /* CONFIG_WITH_VALUE_LENGTH */ 4277 handle_function (char **op, const char **stringp, const char *eol) 4278 { 4279 const char *fname = *stringp + 1; 4280 const struct function_table_entry *entry_p = lookup_function (fname, eol - fname); 4281 if (!entry_p) 4282 return 0; 4283 return handle_function2 (entry_p, op, stringp); 4284 } 4285 #endif /* CONFIG_WITH_VALUE_LENGTH */ 4207 4286 4208 4287 … … 4246 4325 /* Are we invoking a builtin function? */ 4247 4326 4327 #ifndef CONFIG_WITH_VALUE_LENGTH 4248 4328 entry_p = lookup_function (fname); 4329 #else 4330 entry_p = lookup_function (fname, cp - fname + 1); 4331 #endif 4249 4332 if (entry_p) 4250 4333 { … … 4295 4378 char num[11]; 4296 4379 4380 #ifndef CONFIG_WITH_VALUE_LENGTH 4297 4381 sprintf (num, "%d", i); 4298 4382 define_variable (num, strlen (num), "", o_automatic, 0); 4383 #else 4384 define_variable (num, sprintf (num, "%d", i), "", o_automatic, 0); 4385 #endif 4299 4386 } 4300 4387 … … 4324 4411 { 4325 4412 const struct floc *reading_file_saved = reading_file; 4413 char *eos; 4326 4414 4327 4415 if (!strcmp (funcname, "evalcall")) … … 4331 4419 4332 4420 size_t off = o - variable_buffer; 4333 o = variable_buffer_output (o, v->value, v->value_length + 1);4421 eos = variable_buffer_output (o, v->value, v->value_length + 1) - 1; 4334 4422 o = variable_buffer + off; 4335 4423 if (v->fileinfo.filenm) … … 4341 4429 4342 4430 v->exp_count = EXP_COUNT_MAX; 4343 o = variable_expand_string (o, body, flen+3);4431 o = variable_expand_string_2 (o, body, flen+3, &eos); 4344 4432 v->exp_count = 0; 4345 4433 } 4346 4434 4347 4435 install_variable_buffer (&buf, &len); 4348 eval_buffer (o );4436 eval_buffer (o, eos); 4349 4437 restore_variable_buffer (buf, len); 4350 4438 reading_file = reading_file_saved; … … 4367 4455 hash_load (&function_table, function_table_init, 4368 4456 FUNCTION_TABLE_ENTRIES, sizeof (struct function_table_entry)); 4369 #if def CONFIG_WITH_OPTIMIZATION_HACKS4457 #if defined (CONFIG_WITH_OPTIMIZATION_HACKS) || defined (CONFIG_WITH_VALUE_LENGTH) 4370 4458 { 4371 unsigned i; 4459 unsigned int i; 4460 for (i = 'a'; i <= 'z'; i++) 4461 func_char_map[i] = 1; 4462 func_char_map[(unsigned int)'-'] = 1; 4463 4372 4464 for (i = 0; i < FUNCTION_TABLE_ENTRIES; i++) 4465 { 4373 4466 assert (function_table_init[i].len <= MAX_FUNCTION_LENGTH); 4467 assert (function_table_init[i].len >= MIN_FUNCTION_LENGTH); 4468 } 4374 4469 } 4375 4470 #endif -
trunk/src/kmk/kbuild.c
r1818 r1827 1714 1714 char *pszDstVar, *pszDst, *pszSrcVar, *pszSrc, *pszVal, *psz; 1715 1715 char *pszSavedVarBuf; 1716 unsigned cchSavedVarBuf ;1716 unsigned cchSavedVarBuf, cchVal; 1717 1717 size_t cch; 1718 1718 struct kbuild_sdks Sdks; … … 1893 1893 */ 1894 1894 pVar = kbuild_get_recursive_variable("def_target_source_rule"); 1895 pszVal = allocated_variable_expand_2(pVar->value, pVar->value_length, NULL);1895 pszVal = allocated_variable_expand_2(pVar->value, pVar->value_length, &cchVal); /** @todo we can use the variable buffer here. */ 1896 1896 1897 1897 install_variable_buffer(&pszSavedVarBuf, &cchSavedVarBuf); 1898 eval_buffer(pszVal );1898 eval_buffer(pszVal, pszVal + cchVal); 1899 1899 restore_variable_buffer(pszSavedVarBuf, cchSavedVarBuf); 1900 1900 … … 1903 1903 kbuild_put_sdks(&Sdks); 1904 1904 (void)pszFuncName; 1905 return variable_buffer_output(o, "", 1); 1905 return variable_buffer_output(o, "", 1); /** @todo not right. */ 1906 1906 } 1907 1907 -
trunk/src/kmk/make.h
r1811 r1827 287 287 #define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0) 288 288 289 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)289 #if (defined(__GNUC__) || defined(ENUM_BITFIELDS)) && !defined(NO_ENUM_BITFIELDS) 290 290 # define ENUM_BITFIELD(bits) :bits 291 291 #else -
trunk/src/kmk/read.c
r1821 r1827 469 469 470 470 int 471 #ifndef CONFIG_WITH_VALUE_LENGTH 471 472 eval_buffer (char *buffer) 473 #else 474 eval_buffer (char *buffer, char *eos) 475 #endif 472 476 { 473 477 struct ebuffer ebuf; … … 479 483 /* Evaluate the buffer */ 480 484 485 #ifndef CONFIG_WITH_VALUE_LENGTH 481 486 ebuf.size = strlen (buffer); 487 #else 488 ebuf.size = eos - buffer; 489 ebuf.eol = eos; 490 assert(strchr(buffer, '\0') == eos); 491 #endif 482 492 ebuf.buffer = ebuf.bufnext = ebuf.bufstart = buffer; 483 493 ebuf.fp = NULL; 484 #ifdef CONFIG_WITH_VALUE_LENGTH485 ebuf.eol = ebuf.buffer + ebuf.size;486 #endif487 494 488 495 ebuf.floc = *reading_file; … … 1954 1961 if ((size_t)buf_pos & 7) 1955 1962 buf_pos = variable_buffer_output (buf_pos, "\0\0\0\0\0\0\0\0", 1956 8 - ( size_t)buf_pos & 7);1957 s2 = variable_expand_string (buf_pos, s2, l);1963 8 - ((size_t)buf_pos & 7)); 1964 s2 = variable_expand_string_2 (buf_pos, s2, l, &buf_pos); 1958 1965 #endif 1959 1966 #ifdef CONFIG_WITH_SET_CONDITIONALS -
trunk/src/kmk/variable.c
r1811 r1827 132 132 { 133 133 default: 134 case 32: / /UPDATE_HASH(uvar_end[-16]);134 case 32: /*UPDATE_HASH(uvar_end[-16]);*/ 135 135 case 31: UPDATE_HASH(uvar_end[-15]); 136 case 30: / /UPDATE_HASH(uvar_end[-14]);136 case 30: /*UPDATE_HASH(uvar_end[-14]);*/ 137 137 case 29: UPDATE_HASH(uvar_end[-13]); 138 case 28: / /UPDATE_HASH(uvar_end[-12]);138 case 28: /*UPDATE_HASH(uvar_end[-12]);*/ 139 139 case 27: UPDATE_HASH(uvar_end[-11]); 140 case 26: / /UPDATE_HASH(uvar_end[-10]);140 case 26: /*UPDATE_HASH(uvar_end[-10]);*/ 141 141 case 25: UPDATE_HASH(uvar_end[-9]); 142 case 24: / /UPDATE_HASH(uvar[15]);142 case 24: /*UPDATE_HASH(uvar[15]);*/ 143 143 case 23: UPDATE_HASH(uvar[14]); 144 case 22: / /UPDATE_HASH(uvar[13]);144 case 22: /*UPDATE_HASH(uvar[13]);*/ 145 145 case 21: UPDATE_HASH(uvar[12]); 146 case 20: / /UPDATE_HASH(uvar[11]);146 case 20: /*UPDATE_HASH(uvar[11]);*/ 147 147 case 19: UPDATE_HASH(uvar[10]); 148 case 18: / /UPDATE_HASH(uvar[9]);148 case 18: /*UPDATE_HASH(uvar[9]);*/ 149 149 case 17: UPDATE_HASH(uvar[8]); 150 case 16: / /UPDATE_HASH(uvar_end[-8]);150 case 16: /*UPDATE_HASH(uvar_end[-8]);*/ 151 151 case 15: UPDATE_HASH(uvar_end[-7]); 152 case 14: / /UPDATE_HASH(uvar_end[-6]);152 case 14: /*UPDATE_HASH(uvar_end[-6]);*/ 153 153 case 13: UPDATE_HASH(uvar_end[-5]); 154 case 12: / /UPDATE_HASH(uvar_end[-4]);154 case 12: /*UPDATE_HASH(uvar_end[-4]);*/ 155 155 case 11: UPDATE_HASH(uvar_end[-3]); 156 case 10: / /UPDATE_HASH(uvar_end[-2]);156 case 10: /*UPDATE_HASH(uvar_end[-2]);*/ 157 157 case 9: UPDATE_HASH(uvar_end[-1]); 158 case 8: / /UPDATE_HASH(uvar[7]);158 case 8: /*UPDATE_HASH(uvar[7]);*/ 159 159 case 7: UPDATE_HASH(uvar[6]); 160 case 6: / /UPDATE_HASH(uvar[5]);160 case 6: /*UPDATE_HASH(uvar[5]);*/ 161 161 case 5: UPDATE_HASH(uvar[4]); 162 case 4: / /UPDATE_HASH(uvar[3]);162 case 4: /*UPDATE_HASH(uvar[3]);*/ 163 163 case 3: UPDATE_HASH(uvar[2]); 164 case 2: / /UPDATE_HASH(uvar[1]);164 case 2: /*UPDATE_HASH(uvar[1]);*/ 165 165 case 1: UPDATE_HASH(uvar[0]); 166 166 case 0: … … 193 193 #if 0 /* seems to be a waste of time. */ 194 194 case 97: UPDATE_HASH(uvar_end[-77]); 195 case 96: / /UPDATE_HASH(uvar_end[-76]);196 case 95: / /UPDATE_HASH(uvar_end[-75]);197 case 94: / /UPDATE_HASH(uvar_end[-74]);195 case 96: /*UPDATE_HASH(uvar_end[-76]);*/ 196 case 95: /*UPDATE_HASH(uvar_end[-75]);*/ 197 case 94: /*UPDATE_HASH(uvar_end[-74]);*/ 198 198 case 93: UPDATE_HASH(uvar_end[-73]); 199 case 92: / /UPDATE_HASH(uvar_end[-72]);200 case 91: / /UPDATE_HASH(uvar_end[-71]);201 case 90: / /UPDATE_HASH(uvar_end[-70]);199 case 92: /*UPDATE_HASH(uvar_end[-72]);*/ 200 case 91: /*UPDATE_HASH(uvar_end[-71]);*/ 201 case 90: /*UPDATE_HASH(uvar_end[-70]);*/ 202 202 case 89: UPDATE_HASH(uvar_end[-69]); 203 case 88: / /UPDATE_HASH(uvar_end[-68]);204 case 87: / /UPDATE_HASH(uvar_end[-67]);205 case 86: / /UPDATE_HASH(uvar_end[-66]);203 case 88: /*UPDATE_HASH(uvar_end[-68]);*/ 204 case 87: /*UPDATE_HASH(uvar_end[-67]);*/ 205 case 86: /*UPDATE_HASH(uvar_end[-66]);*/ 206 206 case 85: UPDATE_HASH(uvar_end[-65]); 207 case 84: / /UPDATE_HASH(uvar_end[-64]);208 case 83: / /UPDATE_HASH(uvar_end[-63]);209 case 82: / /UPDATE_HASH(uvar_end[-62]);207 case 84: /*UPDATE_HASH(uvar_end[-64]);*/ 208 case 83: /*UPDATE_HASH(uvar_end[-63]);*/ 209 case 82: /*UPDATE_HASH(uvar_end[-62]);*/ 210 210 case 81: UPDATE_HASH(uvar_end[-61]); 211 case 80: / /UPDATE_HASH(uvar_end[-60]);212 case 79: / /UPDATE_HASH(uvar_end[-59]);213 case 78: / /UPDATE_HASH(uvar_end[-58]);211 case 80: /*UPDATE_HASH(uvar_end[-60]);*/ 212 case 79: /*UPDATE_HASH(uvar_end[-59]);*/ 213 case 78: /*UPDATE_HASH(uvar_end[-58]);*/ 214 214 case 77: UPDATE_HASH(uvar_end[-57]); 215 case 76: / /UPDATE_HASH(uvar_end[-56]);216 case 75: / /UPDATE_HASH(uvar_end[-55]);217 case 74: / /UPDATE_HASH(uvar_end[-54]);215 case 76: /*UPDATE_HASH(uvar_end[-56]);*/ 216 case 75: /*UPDATE_HASH(uvar_end[-55]);*/ 217 case 74: /*UPDATE_HASH(uvar_end[-54]);*/ 218 218 case 73: UPDATE_HASH(uvar_end[-53]); 219 case 72: / /UPDATE_HASH(uvar_end[-52]);220 case 71: / /UPDATE_HASH(uvar_end[-51]);221 case 70: / /UPDATE_HASH(uvar_end[-50]);219 case 72: /*UPDATE_HASH(uvar_end[-52]);*/ 220 case 71: /*UPDATE_HASH(uvar_end[-51]);*/ 221 case 70: /*UPDATE_HASH(uvar_end[-50]);*/ 222 222 case 69: UPDATE_HASH(uvar_end[-49]); 223 case 68: / /UPDATE_HASH(uvar_end[-48]);224 case 67: / /UPDATE_HASH(uvar_end[-47]);225 case 66: / /UPDATE_HASH(uvar_end[-46]);223 case 68: /*UPDATE_HASH(uvar_end[-48]);*/ 224 case 67: /*UPDATE_HASH(uvar_end[-47]);*/ 225 case 66: /*UPDATE_HASH(uvar_end[-46]);*/ 226 226 case 65: UPDATE_HASH(uvar_end[-49]); 227 case 64: / /UPDATE_HASH(uvar_end[-48]);228 case 63: / /UPDATE_HASH(uvar_end[-47]);229 case 62: / /UPDATE_HASH(uvar_end[-46]);227 case 64: /*UPDATE_HASH(uvar_end[-48]);*/ 228 case 63: /*UPDATE_HASH(uvar_end[-47]);*/ 229 case 62: /*UPDATE_HASH(uvar_end[-46]);*/ 230 230 case 61: UPDATE_HASH(uvar_end[-45]); 231 case 60: / /UPDATE_HASH(uvar_end[-44]);232 case 59: / /UPDATE_HASH(uvar_end[-43]);233 case 58: / /UPDATE_HASH(uvar_end[-42]);231 case 60: /*UPDATE_HASH(uvar_end[-44]);*/ 232 case 59: /*UPDATE_HASH(uvar_end[-43]);*/ 233 case 58: /*UPDATE_HASH(uvar_end[-42]);*/ 234 234 case 57: UPDATE_HASH(uvar_end[-41]); 235 case 56: / /UPDATE_HASH(uvar_end[-40]);236 case 55: / /UPDATE_HASH(uvar_end[-39]);237 case 54: / /UPDATE_HASH(uvar_end[-38]);235 case 56: /*UPDATE_HASH(uvar_end[-40]);*/ 236 case 55: /*UPDATE_HASH(uvar_end[-39]);*/ 237 case 54: /*UPDATE_HASH(uvar_end[-38]);*/ 238 238 case 53: UPDATE_HASH(uvar_end[-37]); 239 case 52: / /UPDATE_HASH(uvar_end[-36]);239 case 52: /*UPDATE_HASH(uvar_end[-36]);*/ 240 240 case 51: UPDATE_HASH(uvar_end[-35]); 241 case 50: / /UPDATE_HASH(uvar_end[-34]);241 case 50: /*UPDATE_HASH(uvar_end[-34]);*/ 242 242 case 49: UPDATE_HASH(uvar_end[-33]); 243 243 #endif 244 case 48: / /UPDATE_HASH(uvar_end[-32]);244 case 48: /*UPDATE_HASH(uvar_end[-32]);*/ 245 245 case 47: UPDATE_HASH(uvar_end[-31]); 246 case 46: / /UPDATE_HASH(uvar_end[-30]);246 case 46: /*UPDATE_HASH(uvar_end[-30]);*/ 247 247 case 45: UPDATE_HASH(uvar_end[-29]); 248 case 44: / /UPDATE_HASH(uvar_end[-28]);248 case 44: /*UPDATE_HASH(uvar_end[-28]);*/ 249 249 case 43: UPDATE_HASH(uvar_end[-27]); 250 case 42: / /UPDATE_HASH(uvar_end[-26]);250 case 42: /*UPDATE_HASH(uvar_end[-26]);*/ 251 251 case 41: UPDATE_HASH(uvar_end[-25]); 252 case 40: / /UPDATE_HASH(uvar_end[-24]);252 case 40: /*UPDATE_HASH(uvar_end[-24]);*/ 253 253 case 39: UPDATE_HASH(uvar_end[-23]); 254 case 38: / /UPDATE_HASH(uvar_end[-22]);254 case 38: /*UPDATE_HASH(uvar_end[-22]);*/ 255 255 case 37: UPDATE_HASH(uvar_end[-21]); 256 case 36: / /UPDATE_HASH(uvar_end[-20]);256 case 36: /*UPDATE_HASH(uvar_end[-20]);*/ 257 257 case 35: UPDATE_HASH(uvar_end[-19]); 258 case 34: / /UPDATE_HASH(uvar_end[-18]);258 case 34: /*UPDATE_HASH(uvar_end[-18]);*/ 259 259 case 33: UPDATE_HASH(uvar_end[-17]); 260 260 … … 1577 1577 && v->origin != o_env && v->origin != o_env_override) 1578 1578 { 1579 #ifndef CONFIG_WITH_VALUE_LENGTH 1579 1580 char *value = recursively_expand_for_file (v, file); 1581 #else 1582 char *value = recursively_expand_for_file (v, file, NULL); 1583 #endif 1580 1584 #ifdef WINDOWS32 1581 1585 if (strcmp(v->name, "Path") == 0 || … … 2193 2197 2194 2198 vp = do_variable_definition_2 (flocp, v.name, v.value, 2195 v.value_length != -1 ? v.value_length : ~0U,2199 v.value_length != -1 ? (unsigned int)v.value_length : ~0U, /* FIXME */ 2196 2200 0, NULL, origin, v.flavor, target_var); 2197 2201 #endif -
trunk/src/kmk/variable.h
r1811 r1827 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, unsigned int length, unsigned int *value_len );144 char *allocated_variable_expand_2(const char *line, unsigned int length, unsigned int *value_lenp); 145 145 #endif /* CONFIG_WITH_VALUE_LENGTH */ 146 146 char *expand_argument (const char *str, const char *end); 147 #ifndef CONFIG_WITH_VALUE_LENGTH 147 148 char *variable_expand_string (char *line, const char *string, long length); 148 # ifdef CONFIG_WITH_VALUE_LENGTH149 #else /* CONFIG_WITH_VALUE_LENGTH */ 149 150 char *variable_expand_string_2 (char *line, const char *string, long length, char **eol); 150 #endif 151 __inline static char * 152 variable_expand_string (char *line, const char *string, long length) 153 { 154 char *ignored; 155 return variable_expand_string_2 (line, string, length, &ignored); 156 } 157 #endif /* CONFIG_WITH_VALUE_LENGTH */ 151 158 void install_variable_buffer (char **bufp, unsigned int *lenp); 152 159 void restore_variable_buffer (char *buf, unsigned int len); … … 157 164 158 165 /* function.c */ 166 #ifndef CONFIG_WITH_VALUE_LENGTH 159 167 int handle_function (char **op, const char **stringp); 168 #else 169 int handle_function (char **op, const char **stringp, const char *eol); 170 #endif 160 171 int pattern_matches (const char *pattern, const char *percent, const char *str); 161 172 char *subst_expand (char *o, const char *text, const char *subst, … … 171 182 172 183 /* expand.c */ 184 #ifndef CONFIG_WITH_VALUE_LENGTH 173 185 char *recursively_expand_for_file (struct variable *v, struct file *file); 174 186 #define recursively_expand(v) recursively_expand_for_file (v, NULL) 187 #else 188 char *recursively_expand_for_file (struct variable *v, struct file *file, 189 unsigned int *value_lenp); 190 #define recursively_expand(v) recursively_expand_for_file (v, NULL, NULL) 191 #endif 175 192 176 193 /* variable.c */
Note:
See TracChangeset
for help on using the changeset viewer.