=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/suff.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- src/usr.bin/make/suff.c 1995/10/18 08:45:43 1.1 +++ src/usr.bin/make/suff.c 1995/12/14 03:23:38 1.2 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.10 1995/09/25 02:46:30 christos Exp $ */ +/* $NetBSD: suff.c,v 1.11 1995/11/02 23:55:08 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)suff.c 5.6 (Berkeley) 6/1/90"; #else -static char rcsid[] = "$NetBSD: suff.c,v 1.10 1995/09/25 02:46:30 christos Exp $"; +static char rcsid[] = "$NetBSD: suff.c,v 1.11 1995/11/02 23:55:08 christos Exp $"; #endif #endif /* not lint */ @@ -1427,7 +1427,7 @@ /* * Add all elements of the members list to the parent node. */ - while (!Lst_IsEmpty(members)) { + while(!Lst_IsEmpty(members)) { gn = (GNode *)Lst_DeQueue(members); if (DEBUG(SUFF)) { @@ -1995,6 +1995,7 @@ (targ == NULL ? dirSearchPath : targ->suff->searchPath)); if (gn->path != NULL) { + char *ptr; Var_Set(TARGET, gn->path, gn); if (targ != NULL) { @@ -2002,7 +2003,7 @@ * Suffix known for the thing -- trim the suffix off * the path to form the proper .PREFIX variable. */ - int len = strlen(gn->path); + int savep = strlen(gn->path) - targ->suff->nameLen; char savec; if (gn->suffix) @@ -2010,12 +2011,17 @@ gn->suffix = targ->suff; gn->suffix->refCount++; - savec = gn->path[len-targ->suff->nameLen]; - gn->path[len-targ->suff->nameLen] = '\0'; + savec = gn->path[savep]; + gn->path[savep] = '\0'; - Var_Set(PREFIX, gn->path, gn); + if ((ptr = strrchr(gn->path, '/')) != NULL) + ptr++; + else + ptr = gn->path; - gn->path[len-targ->suff->nameLen] = savec; + Var_Set(PREFIX, ptr, gn); + + gn->path[savep] = savec; } else { /* * The .PREFIX gets the full path if the target has @@ -2025,7 +2031,12 @@ gn->suffix->refCount--; gn->suffix = NULL; - Var_Set(PREFIX, gn->path, gn); + if ((ptr = strrchr(gn->path, '/')) != NULL) + ptr++; + else + ptr = gn->path; + + Var_Set(PREFIX, ptr, gn); } } } else {