Module Name:    src
Committed By:   sjg
Date:           Thu Apr 15 03:48:39 UTC 2010

Modified Files:
        src/usr.bin/make: make.1 var.c

Log Message:
Add :tA to attempt to resolve to absoute path using realpath().


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/usr.bin/make/make.1
cvs rdiff -u -r1.155 -r1.156 src/usr.bin/make/var.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/make.1
diff -u src/usr.bin/make/make.1:1.169 src/usr.bin/make/make.1:1.170
--- src/usr.bin/make/make.1:1.169	Wed Apr  7 06:45:21 2010
+++ src/usr.bin/make/make.1	Thu Apr 15 03:48:39 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.169 2010/04/07 06:45:21 wiz Exp $
+.\"	$NetBSD: make.1,v 1.170 2010/04/15 03:48:39 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd April 6, 2010
+.Dd April 14, 2010
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -945,6 +945,10 @@
 .Nm .
 .It Cm \&:R
 Replaces each word in the variable with everything but its suffix.
+.It Cm \&:tA
+Attempt to convert variable to an absolute path using
+.Xr realpath 3 ,
+if that fails, the value is unchanged.
 .It Cm \&:tl
 Converts variable to lower-case letters.
 .It Cm \&:ts Ns Ar c
@@ -954,6 +958,7 @@
 If
 .Ar c
 is omitted, then no separator is used.
+The common escapes (including octal numeric codes), work as expected.
 .It Cm \&:tu
 Converts variable to upper-case letters.
 .It Cm \&:tW

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.155 src/usr.bin/make/var.c:1.156
--- src/usr.bin/make/var.c:1.155	Thu Nov 19 00:30:25 2009
+++ src/usr.bin/make/var.c	Thu Apr 15 03:48:39 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.155 2009/11/19 00:30:25 sjg Exp $	*/
+/*	$NetBSD: var.c,v 1.156 2010/04/15 03:48:39 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.155 2009/11/19 00:30:25 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.156 2010/04/15 03:48:39 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.155 2009/11/19 00:30:25 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.156 2010/04/15 03:48:39 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1859,6 +1859,32 @@
     return Buf_Destroy(&buf, FALSE);
 }
 
+
+/*-
+ * VarRealpath --
+ *	Replace each word with the result of realpath()
+ *	if successful.
+ */
+static Boolean
+VarRealpath(GNode *ctx __unused, Var_Parse_State *vpstate,
+	    char *word, Boolean addSpace, Buffer *buf,
+	    void *patternp __unused)
+{
+	char rbuf[MAXPATHLEN];
+	char *rp;
+			    
+	if (addSpace && vpstate->varSpace) {
+	    Buf_AddByte(buf, vpstate->varSpace);
+	}
+	addSpace = TRUE;
+	rp = realpath(word, rbuf);
+	if (rp && *rp == '/')
+		word = rp;
+	
+	Buf_AddBytes(buf, strlen(word), word);
+	return(addSpace);
+}
+
 /*-
  *-----------------------------------------------------------------------
  * VarModify --
@@ -2849,7 +2875,12 @@
 			 * Check for two-character options:
 			 * ":tu", ":tl"
 			 */
-			if (tstr[1] == 'u' || tstr[1] == 'l') {
+			if (tstr[1] == 'A') { /* absolute path */
+			    newStr = VarModify(ctxt, &parsestate, nstr,
+					       VarRealpath, NULL);
+			    cp = tstr + 2;
+			    termc = *cp;
+			} else if (tstr[1] == 'u' || tstr[1] == 'l') {
 			    newStr = VarChangeCase(nstr, (tstr[1] == 'u'));
 			    cp = tstr + 2;
 			    termc = *cp;

Reply via email to