Changeset 1831 in kBuild for trunk/src/kmk
- Timestamp:
- Oct 11, 2008 1:11:16 PM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/expand.c
r1830 r1831 505 505 o = variable_buffer_output (o, "\0", 2); 506 506 *eolp = o - 2; 507 assert (strchr (variable_buffer + line_offset, '\0') == *eolp); 507 508 return (variable_buffer + line_offset); 508 509 } … … 706 707 o = variable_buffer_output (o, "\0", 2); /* KMK: compensate for the strlen + 1 that was removed above. */ 707 708 *eolp = o - 2; 709 assert (strchr (variable_buffer + line_offset, '\0') == *eolp); 708 710 return (variable_buffer + line_offset); 709 711 } -
trunk/src/kmk/kbuild.c
r1827 r1831 1903 1903 kbuild_put_sdks(&Sdks); 1904 1904 (void)pszFuncName; 1905 return variable_buffer_output(o, "", 1) ; /** @todo not right.*/1905 return variable_buffer_output(o, "", 1) - 1; /** @todo why? */ 1906 1906 } 1907 1907 -
trunk/src/kmk/read.c
r1827 r1831 158 158 #ifndef CONFIG_WITH_VALUE_LENGTH 159 159 static void remove_comments (char *line); 160 #else161 static char *remove_comments (char *line, char *eol);162 #endif163 160 static char *find_char_unquote (char *string, int stop1, int stop2, 164 161 int blank, int ignorevars); 162 #else 163 __inline static char *remove_comments (char *line, char *eol); 164 __inline static char *find_char_unquote_0 (char *string, int stop1, char **eosp); 165 static char * find_char_unquote_2 (char *string, int stop1, int stop2, 166 int blank, int ignorevars, 167 unsigned int string_len); 168 __inline static char * 169 find_char_unquote (char *string, int stop1, int stop2, int blank, int ignorevars) 170 { 171 if (!stop2 && !blank && !ignorevars) 172 { 173 char *p = strchr (string, stop1); 174 if (!p) 175 return NULL; 176 if (p <= string || p[-1] != '\\') 177 return p; 178 /* fall back on find_char_unquote_2 */ 179 } 180 return find_char_unquote_2 (string, stop1, stop2, blank, ignorevars, 0); 181 } 182 #endif 165 183 166 184 … … 536 554 struct floc *fstart; 537 555 struct floc fi; 556 #ifdef CONFIG_WITH_VALUE_LENGTH 557 unsigned int tmp_len; 558 #endif 538 559 539 560 #define record_waiting_files() \ … … 1068 1089 /* Search the line for an unquoted ; that is not after an 1069 1090 unquoted #. */ 1091 #ifndef CONFIG_WITH_VALUE_LENGTH 1070 1092 cmdleft = find_char_unquote (line, ';', '#', 0, 1); 1093 #else 1094 cmdleft = find_char_unquote_2 (line, ';', '#', 0, 1, ebuf->eol - line); 1095 #endif 1071 1096 if (cmdleft != 0 && *cmdleft == '#') 1072 1097 { … … 1111 1136 } 1112 1137 1138 1139 #ifndef CONFIG_WITH_VALUE_LENGTH 1113 1140 p2 = variable_expand_string(NULL, lb_next, wlen); 1141 #else 1142 p2 = variable_expand_string_2 (NULL, lb_next, wlen, &eol); 1143 assert (strchr (p2, '\0') == eol); 1144 #endif 1114 1145 1115 1146 while (1) … … 1119 1150 { 1120 1151 /* Look for a semicolon in the expanded line. */ 1152 #ifndef CONFIG_WITH_VALUE_LENGTH 1121 1153 cmdleft = find_char_unquote (p2, ';', 0, 0, 0); 1154 #else 1155 cmdleft = find_char_unquote_0 (p2, ';', &eol); 1156 #endif 1122 1157 1123 1158 if (cmdleft != 0) … … 1125 1160 unsigned long p2_off = p2 - variable_buffer; 1126 1161 unsigned long cmd_off = cmdleft - variable_buffer; 1162 #ifndef CONFIG_WITH_VALUE_LENGTH 1127 1163 char *pend = p2 + strlen(p2); 1164 #endif 1128 1165 1129 1166 /* Append any remnants of lb, then cut the line short … … 1139 1176 expand below once we know we don't have a 1140 1177 target-specific variable. */ 1178 #ifndef CONFIG_WITH_VALUE_LENGTH 1141 1179 (void)variable_expand_string(pend, lb_next, (long)-1); 1142 1180 lb_next += strlen(lb_next); 1181 #else 1182 tmp_len = strlen (lb_next); 1183 variable_expand_string_2 (eol, lb_next, tmp_len, &eol); 1184 lb_next += tmp_len; 1185 #endif 1143 1186 p2 = variable_buffer + p2_off; 1144 1187 cmdleft = variable_buffer + cmd_off + 1; … … 1146 1189 } 1147 1190 1191 #ifndef CONFIG_WITH_VALUE_LENGTH 1148 1192 colonp = find_char_unquote(p2, ':', 0, 0, 0); 1193 #else 1194 colonp = find_char_unquote_0 (p2, ':', &eol); 1195 #endif 1149 1196 #ifdef HAVE_DOS_PATHS 1150 1197 /* The drive spec brain-damage strikes again... */ … … 1155 1202 colonp > p2 && isalpha ((unsigned char)colonp[-1]) && 1156 1203 (colonp == p2 + 1 || strchr (" \t(", colonp[-2]) != 0)) 1204 # ifndef CONFIG_WITH_VALUE_LENGTH 1157 1205 colonp = find_char_unquote(colonp + 1, ':', 0, 0, 0); 1206 # else 1207 colonp = find_char_unquote_0 (colonp + 1, ':', &eol); 1208 # endif 1158 1209 #endif 1159 1210 if (colonp != 0) … … 1164 1215 break; 1165 1216 1217 #ifndef CONFIG_WITH_VALUE_LENGTH 1166 1218 p2 += strlen(p2); 1167 1219 *(p2++) = ' '; 1168 1220 p2 = variable_expand_string(p2, lb_next, wlen); 1221 #else 1222 *(eol++) = ' '; 1223 p2 = variable_expand_string_2 (eol, lb_next, wlen, &eol); 1224 #endif 1169 1225 /* We don't need to worry about cmdleft here, because if it was 1170 1226 found in the variable_buffer the entire buffer has already … … 1277 1333 { 1278 1334 unsigned int l = p2 - variable_buffer; 1335 #ifndef CONFIG_WITH_VALUE_LENGTH 1279 1336 (void) variable_expand_string (p2 + plen, lb_next, (long)-1); 1337 #else 1338 char *eos; 1339 (void) variable_expand_string_2 (p2 + plen, lb_next, (long)-1, &eos); 1340 #endif 1280 1341 p2 = variable_buffer + l; 1281 1342 … … 1283 1344 if (cmdleft == 0) 1284 1345 { 1346 #ifndef CONFIG_WITH_VALUE_LENGTH 1285 1347 cmdleft = find_char_unquote (p2, ';', 0, 0, 0); 1348 #else 1349 cmdleft = find_char_unquote_0 (p2, ';', &eos); 1350 #endif 1286 1351 if (cmdleft != 0) 1287 1352 *(cmdleft++) = '\0'; … … 1494 1559 static void 1495 1560 remove_comments (char *line) 1496 #else1497 static char *1498 remove_comments (char *line, char *eol)1499 #endif1500 1561 { 1501 1562 char *comment; … … 1506 1567 /* Cut off the line at the #. */ 1507 1568 *comment = '\0'; 1508 1509 #ifdef CONFIG_WITH_VALUE_LENGTH1510 if (comment)1511 eol = comment;1512 assert (strchr (line, '\0') == eol);1513 return eol;1514 #endif1515 1569 } 1570 #else /* CONFIG_WITH_VALUE_LENGTH */ 1571 __inline static char * 1572 remove_comments (char *line, char *eol) 1573 { 1574 unsigned int string_len = eol - line; 1575 register int ch; 1576 char *p; 1577 1578 /* Hope for simple (no comments). */ 1579 p = memchr (line, '#', string_len); 1580 if (!p) 1581 return eol; 1582 1583 /* Found potential comment, enter the slow route. */ 1584 for (;;) 1585 { 1586 if (p > line && p[-1] == '\\') 1587 { 1588 /* Search for more backslashes. */ 1589 int i = -2; 1590 while (&p[i] >= line && p[i] == '\\') 1591 --i; 1592 ++i; 1593 1594 /* The number of backslashes is now -I. 1595 Copy P over itself to swallow half of them. */ 1596 memmove (&p[i], &p[i/2], (string_len - (p - line)) - (i/2) + 1); 1597 p += i/2; 1598 if (i % 2 == 0) 1599 { 1600 /* All the backslashes quoted each other; the STOPCHAR was 1601 unquoted. */ 1602 *p = '\0'; 1603 return p; 1604 } 1605 1606 /* The '#' was quoted by a backslash. Look for another. */ 1607 } 1608 else 1609 { 1610 /* No backslash in sight. */ 1611 *p = '\0'; 1612 return p; 1613 } 1614 1615 /* lazy, string_len isn't correct so do it the slow way. */ 1616 while ((ch = *p) != '#') 1617 { 1618 if (ch == '\0') 1619 return p; 1620 ++p; 1621 } 1622 } 1623 /* won't ever get here. */ 1624 } 1625 #endif /* CONFIG_WITH_VALUE_LENGTH */ 1516 1626 1517 1627 /* Execute a `define' directive. … … 2540 2650 STOPCHAR _cannot_ be '$' if IGNOREVARS is true. */ 2541 2651 2652 #ifndef CONFIG_WITH_VALUE_LENGTH 2542 2653 static char * 2543 2654 find_char_unquote (char *string, int stop1, int stop2, int blank, 2544 2655 int ignorevars) 2656 #else 2657 static char * 2658 find_char_unquote_2 (char *string, int stop1, int stop2, int blank, 2659 int ignorevars, unsigned int string_len) 2660 #endif 2545 2661 { 2662 #ifndef CONFIG_WITH_VALUE_LENGTH 2546 2663 unsigned int string_len = 0; 2664 #endif 2547 2665 char *p = string; 2548 2666 register int ch; /* bird: 'optimiziations' */ 2667 #ifdef CONFIG_WITH_VALUE_LENGTH 2668 assert (string_len == 0 || string_len == strlen (string)); 2669 #endif 2549 2670 2550 2671 if (ignorevars) … … 2631 2752 return 0; 2632 2753 } 2754 2755 #ifdef CONFIG_WITH_VALUE_LENGTH 2756 /* Special case version of find_char_unquote that only takes stop1. 2757 This is so common that it makes a lot of sense to specialize this. 2758 */ 2759 __inline static char * 2760 find_char_unquote_0 (char *string, int stop1, char **eosp) 2761 { 2762 unsigned int string_len = *eosp - string; 2763 char *p = (char *)memchr (string, stop1, string_len); 2764 assert (strlen (string) == string_len); 2765 if (!p) 2766 return NULL; 2767 if (p <= string || p[-1] != '\\') 2768 return p; 2769 2770 p = find_char_unquote_2 (string, stop1, 0, 0, 0, string_len); 2771 *eosp = memchr (string, '\0', string_len); 2772 return p; 2773 } 2774 #endif 2633 2775 2634 2776 /* Search PATTERN for an unquoted % and handle quoting. */
Note:
See TracChangeset
for help on using the changeset viewer.