=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/targequiv.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** src/usr.bin/make/targequiv.c 2008/11/04 07:22:36 1.1 --- src/usr.bin/make/targequiv.c 2010/04/25 13:59:53 1.2 *************** *** 1,4 **** ! /* $OpenBSD: targequiv.c,v 1.1 2008/11/04 07:22:36 espie Exp $ */ /* * Copyright (c) 2007-2008 Marc Espie. * --- 1,4 ---- ! /* $OpenBSD: targequiv.c,v 1.2 2010/04/25 13:59:53 espie Exp $ */ /* * Copyright (c) 2007-2008 Marc Espie. * *************** *** 53,59 **** }; static struct ohash_info equiv_info = { ! offsetof(struct equiv_list, name), NULL, hash_alloc, hash_free, element_alloc }; --- 53,59 ---- }; static struct ohash_info equiv_info = { ! offsetof(struct equiv_list, name), NULL, hash_alloc, hash_free, element_alloc }; *************** *** 61,69 **** static void build_equivalence(void); static void add_to_equiv_list(struct ohash *, GNode *); static char *names_match(GNode *, GNode *); ! static char *names_match_with_dir(const char *, const char *, char *, char *, const char *); ! static char *names_match_with_dirs(const char *, const char *, char *, char *, const char *, const char *); static char *relative_reduce(const char *, const char *); static char *relative_reduce2(const char *, const char *, const char *); --- 61,69 ---- static void build_equivalence(void); static void add_to_equiv_list(struct ohash *, GNode *); static char *names_match(GNode *, GNode *); ! static char *names_match_with_dir(const char *, const char *, char *, char *, const char *); ! static char *names_match_with_dirs(const char *, const char *, char *, char *, const char *, const char *); static char *relative_reduce(const char *, const char *); static char *relative_reduce2(const char *, const char *, const char *); *************** *** 76,82 **** * to insert same-basename targets in a simply linked list. Then they make * those lists circular, to the exception of lone elements, since they can't * alias to anything. ! * * This structure is used to simplify alias-lookup to a great extent: two * nodes can only alias each other if they're part of the same equivalence * set. Most nodes either don't belong to an alias set, or to a very simple --- 76,82 ---- * to insert same-basename targets in a simply linked list. Then they make * those lists circular, to the exception of lone elements, since they can't * alias to anything. ! * * This structure is used to simplify alias-lookup to a great extent: two * nodes can only alias each other if they're part of the same equivalence * set. Most nodes either don't belong to an alias set, or to a very simple *************** *** 184,190 **** attach_node(GNode *gn, GNode *extra) { /* XXX normally extra->sibling == extra, but this is not ! * always the case yet, so we merge the two lists */ GNode *tmp; --- 184,190 ---- attach_node(GNode *gn, GNode *extra) { /* XXX normally extra->sibling == extra, but this is not ! * always the case yet, so we merge the two lists */ GNode *tmp; *************** *** 240,253 **** buffer[i++] = '/'; i = parse_reduce(i, src); ! return estrdup(buffer); } static char * relative_reduce(const char *dir, const char *src) { size_t i = 0; ! if (buffer == NULL) buffer = emalloc(bufsize); --- 240,253 ---- buffer[i++] = '/'; i = parse_reduce(i, src); ! return estrdup(buffer); } static char * relative_reduce(const char *dir, const char *src) { size_t i = 0; ! if (buffer == NULL) buffer = emalloc(bufsize); *************** *** 258,271 **** if (buffer[i-1] != '/') buffer[i++] = '/'; i = parse_reduce(i, src); ! return estrdup(buffer); } static char * relative_reduce2(const char *dir1, const char *dir2, const char *src) { size_t i = 0; ! if (buffer == NULL) buffer = emalloc(bufsize); --- 258,271 ---- if (buffer[i-1] != '/') buffer[i++] = '/'; i = parse_reduce(i, src); ! return estrdup(buffer); } static char * relative_reduce2(const char *dir1, const char *dir2, const char *src) { size_t i = 0; ! if (buffer == NULL) buffer = emalloc(bufsize); *************** *** 281,296 **** buffer[i++] = '/'; i = parse_reduce(i, src); ! return estrdup(buffer); } static char * ! names_match_with_dir(const char *a, const char *b, char *ra, char *rb, const char *dir) { bool r; bool free_a, free_b; ! if (ra == NULL) { ra = relative_reduce(dir, a); free_a = true; --- 281,296 ---- buffer[i++] = '/'; i = parse_reduce(i, src); ! return estrdup(buffer); } static char * ! names_match_with_dir(const char *a, const char *b, char *ra, char *rb, const char *dir) { bool r; bool free_a, free_b; ! if (ra == NULL) { ra = relative_reduce(dir, a); free_a = true; *************** *** 317,328 **** } static char * ! names_match_with_dirs(const char *a, const char *b, char *ra, char *rb, const char *dir1, const char *dir2) { bool r; bool free_a, free_b; ! if (ra == NULL) { ra = relative_reduce2(dir1, dir2, a); free_a = true; --- 317,328 ---- } static char * ! names_match_with_dirs(const char *a, const char *b, char *ra, char *rb, const char *dir1, const char *dir2) { bool r; bool free_a, free_b; ! if (ra == NULL) { ra = relative_reduce2(dir1, dir2, a); free_a = true; *************** *** 366,372 **** } else { r = names_match_with_dir(a->name, b->name, ra, rb, objdir); if (!r) ! r = names_match_with_dir(a->name, b->name, ra, rb, curdir); if (!r) { /* b has necessarily the same one */ --- 366,372 ---- } else { r = names_match_with_dir(a->name, b->name, ra, rb, objdir); if (!r) ! r = names_match_with_dir(a->name, b->name, ra, rb, curdir); if (!r) { /* b has necessarily the same one */ *************** *** 376,382 **** for (ln = Lst_First(l); ln != NULL; ln = Lst_Adv(ln)) { const char *p = PathEntry_name(Lst_Datum(ln)); if (p[0] == '/') { ! r = names_match_with_dir(a->name, b->name, ra, rb, p); if (r) break; --- 376,382 ---- for (ln = Lst_First(l); ln != NULL; ln = Lst_Adv(ln)) { const char *p = PathEntry_name(Lst_Datum(ln)); if (p[0] == '/') { ! r = names_match_with_dir(a->name, b->name, ra, rb, p); if (r) break; *************** *** 449,455 **** is_sibling(GNode *gn, GNode *gn2) { GNode *sibling; ! sibling = gn; do { if (sibling == gn2) --- 449,455 ---- is_sibling(GNode *gn, GNode *gn2) { GNode *sibling; ! sibling = gn; do { if (sibling == gn2)