- Timestamp:
- Oct 10, 2008, 9:10:26 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/read.c
r1811 r1817 139 139 static void do_define (char *name, unsigned int namelen, 140 140 enum variable_origin origin, struct ebuffer *ebuf); 141 #ifndef CONFIG_WITH_VALUE_LENGTH 141 142 static int conditional_line (char *line, int len, const struct floc *flocp); 143 #else 144 static int conditional_line (char *line, char *eol, int len, const struct floc *flocp); 145 #endif 142 146 #ifndef CONFIG_WITH_INCLUDEDEP 143 147 static void record_files (struct nameseq *filenames, const char *pattern, … … 189 193 warn_undefined_variables_flag = 0; 190 194 195 #ifndef CONFIG_WITH_VALUE_LENGTH 191 196 value = allocated_variable_expand ("$(MAKEFILES)"); 197 #else 198 value = allocated_variable_expand_2 (STRING_SIZE_TUPLE("$(MAKEFILES)"), NULL); 199 #endif 192 200 193 201 warn_undefined_variables_flag = save; … … 686 694 if (!in_ignored_define) 687 695 { 696 #ifndef CONFIG_WITH_VALUE_LENGTH 688 697 int i = conditional_line (p, wlen, fstart); 698 #else 699 int i = conditional_line (p, eol, wlen, fstart); 700 #endif 689 701 if (i != -2) 690 702 { … … 831 843 /* Expand the line so we can use indirect and constructed 832 844 variable names in an export command. */ 833 cp = ap = allocated_variable_expand (p2); ///// FIXME 845 #ifndef CONFIG_WITH_VALUE_LENGTH 846 cp = ap = allocated_variable_expand (p2); 847 #else 848 cp = ap = allocated_variable_expand_2 (p2, eol - p2, NULL); 849 #endif 834 850 835 851 for (p = find_next_token (&cp, &l); p != 0; … … 861 877 /* Expand the line so we can use indirect and constructed 862 878 variable names in an unexport command. */ 863 cp = ap = allocated_variable_expand (p2); ///// FIXME 879 #ifndef CONFIG_WITH_VALUE_LENGTH 880 cp = ap = allocated_variable_expand (p2); 881 #else 882 cp = ap = allocated_variable_expand_2 (p2, eol - p2, NULL); 883 #endif 864 884 865 885 for (p = find_next_token (&cp, &l); p != 0; … … 920 940 if (memchr (name, '$', eol - name)) 921 941 { 922 free_me = name = allocated_variable_expand (name); 942 unsigned int name_len; 943 free_me = name = allocated_variable_expand_2 (name, eol - name, &name_len); 944 eol = name + name_len; 923 945 while (isspace ((unsigned char)*name)) 924 946 ++name; 925 eol = strchr (name, '\0');926 947 } 927 948 … … 949 970 int noerror = (p[0] != 'i'); 950 971 951 p = allocated_variable_expand (p2); //// FIXME 972 #ifndef CONFIG_WITH_VALUE_LENGTH 973 p = allocated_variable_expand (p2); 974 #else 975 p = allocated_variable_expand_2 (p2, eol - p2, NULL); 976 #endif 952 977 953 978 /* If no filenames, it's a no-op. */ … … 1618 1643 1619 1644 static int 1645 #ifndef CONFIG_WITH_VALUE_LENGTH 1620 1646 conditional_line (char *line, int len, const struct floc *flocp) 1647 #else 1648 conditional_line (char *line, char *eol, int len, const struct floc *flocp) 1649 #endif 1621 1650 { 1622 1651 char *cmdname; … … 1632 1661 unsigned int i; 1633 1662 unsigned int o; 1663 #ifdef CONFIG_WITH_VALUE_LENGTH 1664 assert (strchr (line, '\0') == eol); 1665 #endif 1634 1666 1635 1667 /* Compare a word, both length and contents. */ … … 1717 1749 /* If it's 'else' or 'endif' or an illegal conditional, fail. */ 1718 1750 if (word1eq("else") || word1eq("endif") 1751 #ifndef CONFIG_WITH_VALUE_LENGTH 1719 1752 || conditional_line (line, len, flocp) < 0) 1753 #else 1754 || conditional_line (line, eol, len, flocp) < 0) 1755 #endif 1720 1756 EXTRANEOUS (); 1721 1757 else … … 1770 1806 /* Expand the thing we're looking up, so we can use indirect and 1771 1807 constructed variable names. */ 1808 #ifndef CONFIG_WITH_VALUE_LENGTH 1772 1809 var = allocated_variable_expand (line); 1810 #else 1811 var = allocated_variable_expand_2 (line, eol - line, NULL); 1812 #endif 1773 1813 1774 1814 /* Make sure there's only one variable name to test. */ … … 1806 1846 unsigned int l; 1807 1847 char termin = *line == '(' ? ',' : *line; 1848 #ifdef CONFIG_WITH_VALUE_LENGTH 1849 char *buf_pos; 1850 #endif 1808 1851 1809 1852 if (termin != ',' && termin != '"' && termin != '\'') … … 1837 1880 --p; 1838 1881 *p = '\0'; 1882 #ifdef CONFIG_WITH_VALUE_LENGTH 1883 l = p - s1; 1884 #endif 1839 1885 } 1840 1886 else 1841 *line++ = '\0'; 1842 1887 { 1888 #ifdef CONFIG_WITH_VALUE_LENGTH 1889 l = line - s1; 1890 #endif 1891 *line++ = '\0'; 1892 } 1893 1894 #ifndef CONFIG_WITH_VALUE_LENGTH 1843 1895 s2 = variable_expand (s1); 1844 1896 /* We must allocate a new copy of the expanded string because … … 1847 1899 s1 = alloca (l + 1); 1848 1900 memcpy (s1, s2, l + 1); 1901 #else 1902 s1 = variable_expand_string_2 (NULL, s1, l, &buf_pos); 1903 ++buf_pos; 1904 #endif 1849 1905 1850 1906 if (termin != ',') … … 1886 1942 1887 1943 *line = '\0'; 1944 #ifdef CONFIG_WITH_VALUE_LENGTH 1945 l = line - s2; 1946 #endif 1888 1947 line = next_token (++line); 1889 1948 if (*line != '\0') 1890 1949 EXTRANEOUS (); 1891 1950 1951 #ifndef CONFIG_WITH_VALUE_LENGTH 1892 1952 s2 = variable_expand (s2); 1953 #else 1954 if ((size_t)buf_pos & 7) 1955 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); 1958 #endif 1893 1959 #ifdef CONFIG_WITH_SET_CONDITIONALS 1894 1960 if (cmdtype == c_if1of || cmdtype == c_ifn1of) … … 3398 3464 warn_undefined_variables_flag = 0; 3399 3465 3466 #ifndef CONFIG_WITH_VALUE_LENGTH 3400 3467 home_dir = allocated_variable_expand ("$(HOME)"); 3468 #else 3469 home_dir = allocated_variable_expand_2 (STRING_SIZE_TUPLE("$(HOME)"), NULL); 3470 #endif 3401 3471 3402 3472 warn_undefined_variables_flag = save;
Note:
See TracChangeset
for help on using the changeset viewer.