1471 if (first_member == dependency) {
1472 break;
1473 }
1474 }
1475 }
1476 }
1477 Wstring wcb;
1478 /* Then scan all the dependencies again. This time we want to expand */
1479 /* shell file wildcards */
1480 for (remove = &line->body.line.dependencies, dependency = *remove;
1481 dependency != NULL;
1482 dependency = *remove) {
1483 if (dependency->name == NULL) {
1484 dependency = *remove = (*remove)->next;
1485 continue;
1486 }
1487 /* If dependency name string contains shell wildcards */
1488 /* replace the name with the expansion */
1489 if (dependency->name->wildcard) {
1490 wcb.init(dependency->name);
1491 if ((start = (wchar_t *) wschr(wcb.get_string(),
1492 (int) parenleft_char)) != NULL) {
1493 /* lib(*) type pattern */
1494 library = buffer;
1495 (void) wsncpy(buffer,
1496 wcb.get_string(),
1497 start - wcb.get_string());
1498 buffer[start-wcb.get_string()] =
1499 (int) nul_char;
1500 (void) wsncpy(pattern,
1501 start + 1,
1502 (int) (dependency->name->hash.length-(start-wcb.get_string())-2));
1503 pattern[dependency->name->hash.length -
1504 (start-wcb.get_string()) - 2] =
1505 (int) nul_char;
1506 } else {
1507 library = NULL;
1508 (void) wsncpy(pattern,
1509 wcb.get_string(),
1510 (int) dependency->name->hash.length);
1511 pattern[dependency->name->hash.length] =
1512 (int) nul_char;
1513 }
1514 start = (wchar_t *) wsrchr(pattern, (int) slash_char);
1515 if (start == NULL) {
1516 directory = dot;
1517 p = pattern;
1518 } else {
1519 directory = GETNAME(pattern, start-pattern);
1520 p = start+1;
1521 }
1522 /* The expansion is handled by the read_dir() routine*/
1523 if (read_dir(directory, p, line, library)) {
1524 *remove = (*remove)->next;
1525 } else {
1526 remove = &dependency->next;
1527 }
1528 } else {
1529 remove = &dependency->next;
1530 }
1531 }
1532
1533 /* Then unbind $@ */
1534 (void) SETVAR(c_at, (Name) NULL, false);
2683 if (sym_link_depth++ > 90) {
2684 fatal(gettext("Can't read symbolic link `%s': Number of symbolic links encountered during path name traversal exceeds 90."),
2685 target->string_mb);
2686 }
2687 /* Read the value of the link. */
2688 result = readlink_vroot(target->string_mb,
2689 link,
2690 sizeof(link),
2691 NULL,
2692 VROOT_DEFAULT);
2693 if (result == -1) {
2694 fatal(gettext("Can't read symbolic link `%s': %s"),
2695 target->string_mb, errmsg(errno));
2696 }
2697 link[result] = 0;
2698 /* Use the value to build the proper filename. */
2699 INIT_STRING_FROM_STACK(string, name);
2700
2701 Wstring wcb(target);
2702 if ((link[0] != slash_char) &&
2703 ((p = (wchar_t *) wsrchr(wcb.get_string(), slash_char)) != NULL)) {
2704 append_string(wcb.get_string(), &string, p - wcb.get_string() + 1);
2705 }
2706 append_string(link, &string, result);
2707 /* Replace the old name with the translated name. */
2708 target = normalize_name(string.buffer.start, string.text.p - string.buffer.start);
2709 (void) exists(target);
2710 if (string.free_after_use) {
2711 retmem(string.buffer.start);
2712 }
2713 }
2714
2715 /*
2716 * read_dir() also reads the ?/SCCS dir and saves information
2717 * about which files have SCSC/s. files.
2718 */
2719 if (target->stat.has_sccs == DONT_KNOW_SCCS) {
2720 read_directory_of_file(target);
2721 }
2722 switch (target->stat.has_sccs) {
2723 case DONT_KNOW_SCCS:
2801 * read_directory_of_file(file)
2802 *
2803 * Reads the directory the specified file lives in.
2804 *
2805 * Parameters:
2806 * file The file we need to read dir for
2807 *
2808 * Global variables used:
2809 * dot The Name ".", used as the default dir
2810 */
2811 void
2812 read_directory_of_file(register Name file)
2813 {
2814
2815 Wstring file_string(file);
2816 wchar_t * wcb = file_string.get_string();
2817 wchar_t usr_include_buf[MAXPATHLEN];
2818 wchar_t usr_include_sys_buf[MAXPATHLEN];
2819
2820 register Name directory = dot;
2821 register wchar_t *p = (wchar_t *) wsrchr(wcb,
2822 (int) slash_char);
2823 register int length = p - wcb;
2824 static Name usr_include;
2825 static Name usr_include_sys;
2826
2827 if (usr_include == NULL) {
2828 MBSTOWCS(usr_include_buf, "/usr/include");
2829 usr_include = GETNAME(usr_include_buf, FIND_LENGTH);
2830 MBSTOWCS(usr_include_sys_buf, "/usr/include/sys");
2831 usr_include_sys = GETNAME(usr_include_sys_buf, FIND_LENGTH);
2832 }
2833
2834 /*
2835 * If the filename contains a "/" we have to extract the path
2836 * Else the path defaults to ".".
2837 */
2838 if (p != NULL) {
2839 /*
2840 * Check some popular directories first to possibly
2841 * save time. Compare string length first to gain speed.
2875 static void
2876 add_pattern_conditionals(register Name target)
2877 {
2878 register Property conditional;
2879 Property new_prop;
2880 Property *previous;
2881 Name_rec dummy;
2882 wchar_t *pattern;
2883 wchar_t *percent;
2884 int length;
2885
2886 Wstring wcb(target);
2887 Wstring wcb1;
2888
2889 for (conditional = get_prop(conditionals->prop, conditional_prop);
2890 conditional != NULL;
2891 conditional = get_prop(conditional->next, conditional_prop)) {
2892 wcb1.init(conditional->body.conditional.target);
2893 pattern = wcb1.get_string();
2894 if (pattern[1] != 0) {
2895 percent = (wchar_t *) wschr(pattern, (int) percent_char);
2896 if (!wcb.equaln(pattern, percent-pattern) ||
2897 !IS_WEQUAL(wcb.get_string(wcb.length()-wslen(percent+1)), percent+1)) {
2898 continue;
2899 }
2900 }
2901 for (previous = &target->prop;
2902 *previous != NULL;
2903 previous = &(*previous)->next) {
2904 if (((*previous)->type == conditional_prop) &&
2905 ((*previous)->body.conditional.sequence >
2906 conditional->body.conditional.sequence)) {
2907 break;
2908 }
2909 }
2910 if (*previous == NULL) {
2911 new_prop = append_prop(target, conditional_prop);
2912 } else {
2913 dummy.prop = NULL;
2914 new_prop = append_prop(&dummy, conditional_prop);
2915 new_prop->next = *previous;
2916 *previous = new_prop;
2917 }
|
1471 if (first_member == dependency) {
1472 break;
1473 }
1474 }
1475 }
1476 }
1477 Wstring wcb;
1478 /* Then scan all the dependencies again. This time we want to expand */
1479 /* shell file wildcards */
1480 for (remove = &line->body.line.dependencies, dependency = *remove;
1481 dependency != NULL;
1482 dependency = *remove) {
1483 if (dependency->name == NULL) {
1484 dependency = *remove = (*remove)->next;
1485 continue;
1486 }
1487 /* If dependency name string contains shell wildcards */
1488 /* replace the name with the expansion */
1489 if (dependency->name->wildcard) {
1490 wcb.init(dependency->name);
1491 if ((start = (wchar_t *) wcschr(wcb.get_string(),
1492 (int) parenleft_char)) != NULL) {
1493 /* lib(*) type pattern */
1494 library = buffer;
1495 (void) wcsncpy(buffer,
1496 wcb.get_string(),
1497 start - wcb.get_string());
1498 buffer[start-wcb.get_string()] =
1499 (int) nul_char;
1500 (void) wcsncpy(pattern,
1501 start + 1,
1502 (int) (dependency->name->hash.length-(start-wcb.get_string())-2));
1503 pattern[dependency->name->hash.length -
1504 (start-wcb.get_string()) - 2] =
1505 (int) nul_char;
1506 } else {
1507 library = NULL;
1508 (void) wcsncpy(pattern,
1509 wcb.get_string(),
1510 (int) dependency->name->hash.length);
1511 pattern[dependency->name->hash.length] =
1512 (int) nul_char;
1513 }
1514 start = (wchar_t *) wcsrchr(pattern, (int) slash_char);
1515 if (start == NULL) {
1516 directory = dot;
1517 p = pattern;
1518 } else {
1519 directory = GETNAME(pattern, start-pattern);
1520 p = start+1;
1521 }
1522 /* The expansion is handled by the read_dir() routine*/
1523 if (read_dir(directory, p, line, library)) {
1524 *remove = (*remove)->next;
1525 } else {
1526 remove = &dependency->next;
1527 }
1528 } else {
1529 remove = &dependency->next;
1530 }
1531 }
1532
1533 /* Then unbind $@ */
1534 (void) SETVAR(c_at, (Name) NULL, false);
2683 if (sym_link_depth++ > 90) {
2684 fatal(gettext("Can't read symbolic link `%s': Number of symbolic links encountered during path name traversal exceeds 90."),
2685 target->string_mb);
2686 }
2687 /* Read the value of the link. */
2688 result = readlink_vroot(target->string_mb,
2689 link,
2690 sizeof(link),
2691 NULL,
2692 VROOT_DEFAULT);
2693 if (result == -1) {
2694 fatal(gettext("Can't read symbolic link `%s': %s"),
2695 target->string_mb, errmsg(errno));
2696 }
2697 link[result] = 0;
2698 /* Use the value to build the proper filename. */
2699 INIT_STRING_FROM_STACK(string, name);
2700
2701 Wstring wcb(target);
2702 if ((link[0] != slash_char) &&
2703 ((p = (wchar_t *) wcsrchr(wcb.get_string(), slash_char)) != NULL)) {
2704 append_string(wcb.get_string(), &string, p - wcb.get_string() + 1);
2705 }
2706 append_string(link, &string, result);
2707 /* Replace the old name with the translated name. */
2708 target = normalize_name(string.buffer.start, string.text.p - string.buffer.start);
2709 (void) exists(target);
2710 if (string.free_after_use) {
2711 retmem(string.buffer.start);
2712 }
2713 }
2714
2715 /*
2716 * read_dir() also reads the ?/SCCS dir and saves information
2717 * about which files have SCSC/s. files.
2718 */
2719 if (target->stat.has_sccs == DONT_KNOW_SCCS) {
2720 read_directory_of_file(target);
2721 }
2722 switch (target->stat.has_sccs) {
2723 case DONT_KNOW_SCCS:
2801 * read_directory_of_file(file)
2802 *
2803 * Reads the directory the specified file lives in.
2804 *
2805 * Parameters:
2806 * file The file we need to read dir for
2807 *
2808 * Global variables used:
2809 * dot The Name ".", used as the default dir
2810 */
2811 void
2812 read_directory_of_file(register Name file)
2813 {
2814
2815 Wstring file_string(file);
2816 wchar_t * wcb = file_string.get_string();
2817 wchar_t usr_include_buf[MAXPATHLEN];
2818 wchar_t usr_include_sys_buf[MAXPATHLEN];
2819
2820 register Name directory = dot;
2821 register wchar_t *p = (wchar_t *) wcsrchr(wcb,
2822 (int) slash_char);
2823 register int length = p - wcb;
2824 static Name usr_include;
2825 static Name usr_include_sys;
2826
2827 if (usr_include == NULL) {
2828 MBSTOWCS(usr_include_buf, "/usr/include");
2829 usr_include = GETNAME(usr_include_buf, FIND_LENGTH);
2830 MBSTOWCS(usr_include_sys_buf, "/usr/include/sys");
2831 usr_include_sys = GETNAME(usr_include_sys_buf, FIND_LENGTH);
2832 }
2833
2834 /*
2835 * If the filename contains a "/" we have to extract the path
2836 * Else the path defaults to ".".
2837 */
2838 if (p != NULL) {
2839 /*
2840 * Check some popular directories first to possibly
2841 * save time. Compare string length first to gain speed.
2875 static void
2876 add_pattern_conditionals(register Name target)
2877 {
2878 register Property conditional;
2879 Property new_prop;
2880 Property *previous;
2881 Name_rec dummy;
2882 wchar_t *pattern;
2883 wchar_t *percent;
2884 int length;
2885
2886 Wstring wcb(target);
2887 Wstring wcb1;
2888
2889 for (conditional = get_prop(conditionals->prop, conditional_prop);
2890 conditional != NULL;
2891 conditional = get_prop(conditional->next, conditional_prop)) {
2892 wcb1.init(conditional->body.conditional.target);
2893 pattern = wcb1.get_string();
2894 if (pattern[1] != 0) {
2895 percent = (wchar_t *) wcschr(pattern, (int) percent_char);
2896 if (!wcb.equaln(pattern, percent-pattern) ||
2897 !IS_WEQUAL(wcb.get_string(wcb.length()-wcslen(percent+1)), percent+1)) {
2898 continue;
2899 }
2900 }
2901 for (previous = &target->prop;
2902 *previous != NULL;
2903 previous = &(*previous)->next) {
2904 if (((*previous)->type == conditional_prop) &&
2905 ((*previous)->body.conditional.sequence >
2906 conditional->body.conditional.sequence)) {
2907 break;
2908 }
2909 }
2910 if (*previous == NULL) {
2911 new_prop = append_prop(target, conditional_prop);
2912 } else {
2913 dummy.prop = NULL;
2914 new_prop = append_prop(&dummy, conditional_prop);
2915 new_prop->next = *previous;
2916 *previous = new_prop;
2917 }
|