Changeset 1811 in kBuild
- Timestamp:
- Oct 10, 2008 5:19:58 AM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/main.c
r1809 r1811 2805 2805 /* Ignore plain `-' for compatibility. */ 2806 2806 return; 2807 #ifndef CONFIG_WITH_VALUE_LENGTH 2807 2808 v = try_variable_definition (0, arg, o_command, 0); 2809 #else 2810 v = try_variable_definition (0, arg, NULL, o_command, 0); 2811 #endif 2808 2812 if (v != 0) 2809 2813 { -
trunk/src/kmk/make.h
r1793 r1811 386 386 char *next_token (const char *); 387 387 char *end_of_token (const char *); 388 #ifndef CONFIG_WITH_VALUE_LENGTH 388 389 void collapse_continuations (char *); 390 #else 391 char *collapse_continuations (char *, unsigned int); 392 #endif 389 393 #ifdef CONFIG_WITH_OPTIMIZATION_HACKS /* memchr is usually compiler intrinsic, thus faster. */ 390 394 # define lindex(s, limit, c) ((char *)memchr((s), (c), (limit) - (s))) -
trunk/src/kmk/misc.c
r1535 r1811 20 20 #include "dep.h" 21 21 #include "debug.h" 22 #ifdef CONFIG_WITH_VALUE_LENGTH 23 # include <assert.h> 24 #endif 22 25 23 26 /* All bcopy calls in this file can be replaced by memcpy and save a tick or two. */ … … 83 86 This is done by copying the text at LINE into itself. */ 84 87 88 #ifndef CONFIG_WITH_VALUE_LENGTH 85 89 void 86 90 collapse_continuations (char *line) 91 #else 92 char * 93 collapse_continuations (char *line, unsigned int linelen) 94 #endif 87 95 { 88 96 register char *in, *out, *p; … … 90 98 register unsigned int bs_write; 91 99 100 #ifndef CONFIG_WITH_VALUE_LENGTH 92 101 in = strchr (line, '\n'); 93 102 if (in == 0) 94 103 return; 104 #else 105 assert (strlen (line) == linelen); 106 in = memchr (line, '\n', linelen); 107 if (in == 0) 108 return line + linelen; 109 #endif 95 110 96 111 out = in; … … 158 173 159 174 *out = '\0'; 175 #ifdef CONFIG_WITH_VALUE_LENGTH 176 assert (strchr (line, '\0') == out); 177 return out; 178 #endif 160 179 } 161 180 -
trunk/src/kmk/read.c
r1809 r1811 54 54 char *bufnext; /* Start of the next line in the buffer. */ 55 55 char *bufstart; /* Start of the entire buffer. */ 56 #ifdef CONFIG_WITH_VALUE_LENGTH 57 char *eol; /* End of the current line in the buffer. */ 58 #endif 56 59 unsigned int size; /* Malloc'd size of buffer. */ 57 60 FILE *fp; /* File, or NULL if this is an internal buffer. */ … … 149 152 static enum make_word_type get_next_mword (char *buffer, char *delim, 150 153 char **startp, unsigned int *length); 154 #ifndef CONFIG_WITH_VALUE_LENGTH 151 155 static void remove_comments (char *line); 156 #else 157 static char *remove_comments (char *line, char *eol); 158 #endif 152 159 static char *find_char_unquote (char *string, int stop1, int stop2, 153 160 int blank, int ignorevars); … … 430 437 ebuf.size = 200; 431 438 ebuf.buffer = ebuf.bufnext = ebuf.bufstart = xmalloc (ebuf.size); 439 #ifdef CONFIG_WITH_VALUE_LENGTH 440 ebuf.eol = NULL; 441 #endif 432 442 433 443 curfile = reading_file; … … 464 474 ebuf.buffer = ebuf.bufnext = ebuf.bufstart = buffer; 465 475 ebuf.fp = NULL; 476 #ifdef CONFIG_WITH_VALUE_LENGTH 477 ebuf.eol = ebuf.buffer + ebuf.size; 478 #endif 466 479 467 480 ebuf.floc = *reading_file; … … 546 559 { 547 560 unsigned int linelen; 561 #ifdef CONFIG_WITH_VALUE_LENGTH 562 char *eol; 563 #endif 548 564 char *line; 549 565 unsigned int wlen; … … 564 580 continue; 565 581 582 #ifndef CONFIG_WITH_VALUE_LENGTH 566 583 linelen = strlen (line); 584 #else 585 linelen = ebuf->eol - line; 586 assert (strlen (line) == linelen); 587 #endif 567 588 568 589 /* Check for a shell command line first. … … 612 633 collapsed = xmalloc (collapsed_length); 613 634 } 635 #ifndef CONFIG_WITH_VALUE_LENGTH 614 636 strcpy (collapsed, line); 615 637 /* Collapse continuation lines. */ 616 638 collapse_continuations (collapsed); 617 639 remove_comments (collapsed); 640 #else 641 memcpy (collapsed, line, linelen + 1); 642 /* Collapse continuation lines. */ 643 eol = collapse_continuations (collapsed, linelen); 644 assert (strchr (collapsed, '\0') == eol); 645 eol = remove_comments (collapsed, eol); 646 assert (strchr (collapsed, '\0') == eol); 647 #endif 618 648 619 649 /* Compare a word, both length and contents. */ … … 723 753 } 724 754 else if (!ignoring 755 #ifndef CONFIG_WITH_VALUE_LENGTH 725 756 && !try_variable_definition (fstart, p2, o_override, 0)) 757 #else 758 && !try_variable_definition (fstart, p2, eol, o_override, 0)) 759 #endif 726 760 error (fstart, _("invalid `override' directive")); 727 761 … … 757 791 } 758 792 else if (!ignoring 793 # ifndef CONFIG_WITH_VALUE_LENGTH 759 794 && !try_variable_definition (fstart, p2, o_local, 0)) 795 # else 796 && !try_variable_definition (fstart, p2, eol, o_local, 0)) 797 # endif 760 798 error (fstart, _("invalid `local' directive")); 761 799 … … 778 816 struct variable *v; 779 817 818 #ifndef CONFIG_WITH_VALUE_LENGTH 780 819 v = try_variable_definition (fstart, p2, o_file, 0); 820 #else 821 v = try_variable_definition (fstart, p2, eol, o_file, 0); 822 #endif 781 823 if (v != 0) 782 824 v->export = v_export; … … 789 831 /* Expand the line so we can use indirect and constructed 790 832 variable names in an export command. */ 791 cp = ap = allocated_variable_expand (p2); 833 cp = ap = allocated_variable_expand (p2); ///// FIXME 792 834 793 835 for (p = find_next_token (&cp, &l); p != 0; … … 819 861 /* Expand the line so we can use indirect and constructed 820 862 variable names in an unexport command. */ 821 cp = ap = allocated_variable_expand (p2); 863 cp = ap = allocated_variable_expand (p2); ///// FIXME 822 864 823 865 for (p = find_next_token (&cp, &l); p != 0; … … 862 904 863 905 #ifdef CONFIG_WITH_INCLUDEDEP 906 assert (strchr (p2, '\0') == eol); 864 907 if (word1eq ("includedep") || word1eq ("includedep-queue") || word1eq ("includedep-flush")) 865 908 { … … 874 917 char *free_me = NULL; 875 918 char *name = p2; 876 char *end = strchr (name, '\0'); 877 char saved; 878 if (memchr (name, '$', end - name)) 919 920 if (memchr (name, '$', eol - name)) 879 921 { 880 922 free_me = name = allocated_variable_expand (name); 881 923 while (isspace ((unsigned char)*name)) 882 924 ++name; 883 e nd= strchr (name, '\0');925 eol = strchr (name, '\0'); 884 926 } 885 927 886 while (end > name && isspace ((unsigned char)end[-1])) 887 --end; 888 889 saved = *end; /* not sure if this is required... */ 890 *end = '\0'; 928 while (eol > name && isspace ((unsigned char)eol[-1])) 929 --eol; 930 931 *eol = '\0'; 891 932 eval_include_dep (name, fstart, op); 892 *end = saved;893 933 894 934 if (free_me) … … 909 949 int noerror = (p[0] != 'i'); 910 950 911 p = allocated_variable_expand (p2); 951 p = allocated_variable_expand (p2); //// FIXME 912 952 913 953 /* If no filenames, it's a no-op. */ … … 956 996 } 957 997 998 #ifndef CONFIG_WITH_VALUE_LENGTH 958 999 if (try_variable_definition (fstart, p, o_file, 0)) 1000 #else 1001 if (try_variable_definition (fstart, p, eol, o_file, 0)) 1002 #endif 959 1003 /* This line has been dealt with. */ 960 1004 goto rule_complete; … … 1004 1048 semip = cmdleft; 1005 1049 1050 #ifndef CONFIG_WITH_VALUE_LENGTH 1006 1051 collapse_continuations (line); 1052 #else 1053 collapse_continuations (line, strlen (line)); /**@todo fix this */ 1054 #endif 1007 1055 1008 1056 /* We can't expand the entire line, since if it's a per-target … … 1411 1459 This is done by copying the text at LINE onto itself. */ 1412 1460 1461 #ifndef CONFIG_WITH_VALUE_LENGTH 1413 1462 static void 1414 1463 remove_comments (char *line) 1464 #else 1465 static char * 1466 remove_comments (char *line, char *eol) 1467 #endif 1415 1468 { 1416 1469 char *comment; … … 1421 1474 /* Cut off the line at the #. */ 1422 1475 *comment = '\0'; 1476 1477 #ifdef CONFIG_WITH_VALUE_LENGTH 1478 if (comment) 1479 eol = comment; 1480 assert (strchr (line, '\0') == eol); 1481 return eol; 1482 #endif 1423 1483 } 1424 1484 … … 1461 1521 line = ebuf->buffer; 1462 1522 1523 #ifndef CONFIG_WITH_VALUE_LENGTH 1463 1524 collapse_continuations (line); 1525 #else 1526 ebuf->eol = collapse_continuations (line, ebuf->eol - line); 1527 #endif 1464 1528 1465 1529 /* If the line doesn't begin with a tab, test to see if it introduces … … 1470 1534 { 1471 1535 p = next_token (line); 1536 #ifndef CONFIG_WITH_VALUE_LENGTH 1472 1537 len = strlen (p); 1538 #else 1539 len = ebuf->eol - p; 1540 assert (len == strlen (p)); 1541 #endif 1473 1542 1474 1543 /* If this is another 'define', increment the level count. */ … … 1483 1552 { 1484 1553 p += 5; 1554 #ifndef CONFIG_WITH_VALUE_LENGTH 1485 1555 remove_comments (p); 1556 #else 1557 ebuf->eol = remove_comments (p, ebuf->eol); 1558 #endif 1486 1559 if (*next_token (p) != '\0') 1487 1560 error (&ebuf->floc, … … 1506 1579 1507 1580 /* Otherwise add this line to the variable definition. */ 1581 #ifndef CONFIG_WITH_VALUE_LENGTH 1508 1582 len = strlen (line); 1583 #else 1584 len = ebuf->eol - line; 1585 assert (len == strlen (line)); 1586 #endif 1509 1587 if (idx + len + 1 > length) 1510 1588 { … … 1960 2038 /* I don't think this can fail since we already determined it was a 1961 2039 variable definition. */ 2040 #ifndef CONFIG_WITH_VALUE_LENGTH 1962 2041 v = parse_variable_definition (&p->variable, defn); 2042 #else 2043 v = parse_variable_definition (&p->variable, defn, NULL); 2044 #endif 1963 2045 assert (v != 0); 1964 2046 … … 1988 2070 1989 2071 current_variable_set_list = f->variables; 2072 #ifndef CONFIG_WITH_VALUE_LENGTH 1990 2073 v = try_variable_definition (flocp, defn, origin, 1); 2074 #else 2075 v = try_variable_definition (flocp, defn, NULL, origin, 1); 2076 #endif 1991 2077 if (!v) 1992 2078 error (flocp, _("Malformed target-specific variable definition")); … … 2836 2922 { 2837 2923 ebuf->bufnext = ebuf->bufstart + ebuf->size + 1; 2924 #ifdef CONFIG_WITH_VALUE_LENGTH 2925 ebuf->eol = end; 2926 #endif 2838 2927 return 0; 2839 2928 } … … 2850 2939 *eol = '\0'; 2851 2940 ebuf->bufnext = eol+1; 2941 #ifdef CONFIG_WITH_VALUE_LENGTH 2942 ebuf->eol = eol; 2943 #endif 2852 2944 2853 2945 return 0; … … 2874 2966 end = p + ebuf->size; 2875 2967 *p = '\0'; 2968 #ifdef CONFIG_WITH_VALUE_LENGTH 2969 ebuf->eol = p; 2970 #endif 2876 2971 2877 2972 while (fgets (p, end - p, ebuf->fp) != 0) … … 2927 3022 { 2928 3023 p[-1] = '\0'; 3024 #ifdef CONFIG_WITH_VALUE_LENGTH 3025 ebuf->eol = p - 1; 3026 #endif 2929 3027 break; 2930 3028 } … … 2933 3031 another line. */ 2934 3032 if (end - p >= 80) 2935 continue; 3033 { 3034 #ifdef CONFIG_WITH_VALUE_LENGTH 3035 ebuf->eol = p; 3036 #endif 3037 continue; 3038 } 2936 3039 2937 3040 /* We need more space at the end of our buffer, so realloc it. … … 2945 3048 end = start + ebuf->size; 2946 3049 *p = '\0'; 3050 #ifdef CONFIG_WITH_VALUE_LENGTH 3051 ebuf->eol = p; 3052 #endif 2947 3053 } 2948 3054 } … … 3493 3599 return new; 3494 3600 } 3601 -
trunk/src/kmk/variable.c
r1809 r1811 921 921 else 922 922 { 923 #ifndef CONFIG_WITH_VALUE_LENGTH 923 924 v = do_variable_definition ( 924 925 &p->variable.fileinfo, p->variable.name, 925 926 p->variable.value, p->variable.origin, 926 927 p->variable.flavor, 1); 928 #else 929 v = do_variable_definition_2 ( 930 &p->variable.fileinfo, p->variable.name, 931 p->variable.value, p->variable.value_length, 0, 0, 932 p->variable.origin, p->variable.flavor, 1); 933 #endif 927 934 } 928 935 … … 2030 2037 2031 2038 struct variable * 2039 #ifndef CONFIG_WITH_VALUE_LENGTH 2032 2040 parse_variable_definition (struct variable *v, char *line) 2041 #else 2042 parse_variable_definition (struct variable *v, char *line, char *eos) 2043 #endif 2033 2044 { 2034 2045 register int c; … … 2119 2130 v->value = p; 2120 2131 #ifdef CONFIG_WITH_VALUE_LENGTH 2121 v->value_length = v->value_alloc_len = -1; 2132 v->value_alloc_len = -1; 2133 v->value_length = eos != NULL ? eos - p : -1; 2134 assert (eos == NULL || strchr (p, '\0') == eos); 2122 2135 #endif 2123 2136 … … 2153 2166 2154 2167 struct variable * 2168 #ifndef CONFIG_WITH_VALUE_LENGTH 2155 2169 try_variable_definition (const struct floc *flocp, char *line, 2156 2170 enum variable_origin origin, int target_var) 2171 #else 2172 try_variable_definition (const struct floc *flocp, char *line, char *eos, 2173 enum variable_origin origin, int target_var) 2174 #endif 2157 2175 { 2158 2176 struct variable v; … … 2164 2182 v.fileinfo.filenm = 0; 2165 2183 2184 #ifndef CONFIG_WITH_VALUE_LENGTH 2166 2185 if (!parse_variable_definition (&v, line)) 2167 2186 return 0; … … 2169 2188 vp = do_variable_definition (flocp, v.name, v.value, 2170 2189 origin, v.flavor, target_var); 2190 #else 2191 if (!parse_variable_definition (&v, line, eos)) 2192 return 0; 2193 2194 vp = do_variable_definition_2 (flocp, v.name, v.value, 2195 v.value_length != -1 ? v.value_length : ~0U, 2196 0, NULL, origin, v.flavor, target_var); 2197 #endif 2171 2198 2172 2199 free (v.name); -
trunk/src/kmk/variable.h
r1809 r1811 191 191 enum variable_flavor flavor, 192 192 int target_var); 193 struct variable *parse_variable_definition (struct variable *v, char *line); 194 struct variable *try_variable_definition (const struct floc *flocp, char *line, 195 enum variable_origin origin, 196 int target_var); 193 197 #else /* CONFIG_WITH_VALUE_LENGTH */ 194 198 # define do_variable_definition(flocp, varname, value, origin, flavor, target_var) \ … … 204 208 enum variable_flavor flavor, 205 209 int target_var); 206 #endif /* CONFIG_WITH_VALUE_LENGTH */ 207 struct variable *parse_variable_definition (struct variable *v, char *line);210 struct variable *parse_variable_definition (struct variable *v, char *line, 211 char *eos); 208 212 struct variable *try_variable_definition (const struct floc *flocp, char *line, 213 char *eos, 209 214 enum variable_origin origin, 210 215 int target_var); 216 #endif /* CONFIG_WITH_VALUE_LENGTH */ 211 217 void init_hash_global_variable_set (void); 212 218 void hash_init_function_table (void);
Note:
See TracChangeset
for help on using the changeset viewer.