Module Name:    src
Committed By:   sjg
Date:           Thu Aug 10 21:07:48 UTC 2017

Modified Files:
        src/usr.bin/make: meta.c

Log Message:
Avoid full path meta file names for subdir of .OBJDIR


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/usr.bin/make/meta.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.68 src/usr.bin/make/meta.c:1.69
--- src/usr.bin/make/meta.c:1.68	Sun Jul  9 04:54:00 2017
+++ src/usr.bin/make/meta.c	Thu Aug 10 21:07:48 2017
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.68 2017/07/09 04:54:00 sjg Exp $ */
+/*      $NetBSD: meta.c,v 1.69 2017/08/10 21:07:48 sjg Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -246,6 +246,8 @@ meta_name(struct GNode *gn, char *mname,
     char *rp;
     char *cp;
     char *tp;
+    char *dtp;
+    size_t ldname;
 
     /*
      * Weed out relative paths from the target file name.
@@ -282,10 +284,15 @@ meta_name(struct GNode *gn, char *mname,
     }
     /* on some systems dirname may modify its arg */
     tp = bmake_strdup(tname);
-    if (strcmp(dname, dirname(tp)) == 0)
+    dtp = dirname(tp);
+    if (strcmp(dname, dtp) == 0)
 	snprintf(mname, mnamelen, "%s.meta", tname);
     else {
-	snprintf(mname, mnamelen, "%s/%s.meta", dname, tname);
+	ldname = strlen(dname);
+	if (strncmp(dname, dtp, ldname) == 0 && dtp[ldname] == '/')
+	    snprintf(mname, mnamelen, "%s/%s.meta", dname, &tname[ldname+1]);
+	else
+	    snprintf(mname, mnamelen, "%s/%s.meta", dname, tname);
 
 	/*
 	 * Replace path separators in the file name after the

Reply via email to