Module Name:    src
Committed By:   mlelstv
Date:           Fri Jun 19 08:03:35 UTC 2015

Modified Files:
        src/usr.bin/make: compat.c metachar.c var.c

Log Message:
Adjust metachar handling to previous behaviour:
- space and tab are no shell metachars, remove them from generic
  metachar function
- add space and tab as to-be-quoted characters for :Q modifier
- add = and : as characters that require command handling by the shell


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/make/compat.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/metachar.c
cvs rdiff -u -r1.193 -r1.194 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/compat.c
diff -u src/usr.bin/make/compat.c:1.97 src/usr.bin/make/compat.c:1.98
--- src/usr.bin/make/compat.c:1.97	Wed Jun 17 17:43:23 2015
+++ src/usr.bin/make/compat.c	Fri Jun 19 08:03:35 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.97 2015/06/17 17:43:23 christos Exp $	*/
+/*	$NetBSD: compat.c,v 1.98 2015/06/19 08:03:35 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.97 2015/06/17 17:43:23 christos Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.98 2015/06/19 08:03:35 mlelstv Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.97 2015/06/17 17:43:23 christos Exp $");
+__RCSID("$NetBSD: compat.c,v 1.98 2015/06/19 08:03:35 mlelstv Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -274,9 +274,13 @@ CompatRunCommand(void *cmdp, void *gnp)
      * Search for meta characters in the command. If there are no meta
      * characters, there's no need to execute a shell to execute the
      * command.
+     *
+     * Additionally variable assignments and empty commands
+     * go to the shell. Therefore treat '=' and ':' like shell
+     * meta characters as documented in make(1).
      */
     
-    useShell = hasmeta(cmd);
+    useShell = hasmeta(cmd) || strchr(cmd,'=') || strchr(cmd,':');
 #endif
 
     /*

Index: src/usr.bin/make/metachar.c
diff -u src/usr.bin/make/metachar.c:1.4 src/usr.bin/make/metachar.c:1.5
--- src/usr.bin/make/metachar.c:1.4	Thu Jun 18 19:49:08 2015
+++ src/usr.bin/make/metachar.c	Fri Jun 19 08:03:35 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: metachar.c,v 1.4 2015/06/18 19:49:08 christos Exp $	*/
+/*	$NetBSD: metachar.c,v 1.5 2015/06/19 08:03:35 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #endif
 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: metachar.c,v 1.4 2015/06/18 19:49:08 christos Exp $");
+__RCSID("$NetBSD: metachar.c,v 1.5 2015/06/19 08:03:35 mlelstv Exp $");
 #endif
 
 #include "metachar.h"
@@ -55,13 +55,13 @@ unsigned char _metachar[128] = {
 //    nul   soh   stx   etx   eot   enq   ack   bel
 	1,    0,    0,    0,    0,    0,    0,    0,
 //     bs    ht    nl    vt    np    cr    so    si
-	0,    1,    1,    0,	0,    0,    0,    0,
+	0,    0,    1,    0,	0,    0,    0,    0,
 //    dle   dc1   dc2   dc3   dc4   nak   syn   etb
 	0,    0,    0,    0,    0,    0,    0,    0,
 //    can    em   sub   esc    fs    gs    rs    us
 	0,    0,    0,    0,    0,    0,    0,    0,
 //     sp     !     "     #     $     %     &     '
-	1,    1,    1,    1,    1,    0,    1,    1,
+	0,    1,    1,    1,    1,    0,    1,    1,
 //      (     )     *     +     ,     -     .     /
 	1,    1,    1,    0,    0,    0,    0,    0,
 //      0     1     2     3     4     5     6     7
@@ -85,3 +85,4 @@ unsigned char _metachar[128] = {
 //      x     y     z     {     |     }     ~   del
 	0,    0,    0,    1,    1,    1,    1,    0,
 };
+

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.193 src/usr.bin/make/var.c:1.194
--- src/usr.bin/make/var.c:1.193	Wed Jun 17 17:43:23 2015
+++ src/usr.bin/make/var.c	Fri Jun 19 08:03:35 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.193 2015/06/17 17:43:23 christos Exp $	*/
+/*	$NetBSD: var.c,v 1.194 2015/06/19 08:03:35 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.193 2015/06/17 17:43:23 christos Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.194 2015/06/19 08:03:35 mlelstv 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.193 2015/06/17 17:43:23 christos Exp $");
+__RCSID("$NetBSD: var.c,v 1.194 2015/06/19 08:03:35 mlelstv Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2246,7 +2246,7 @@ VarGetPattern(GNode *ctxt, Var_Parse_Sta
 /*-
  *-----------------------------------------------------------------------
  * VarQuote --
- *	Quote shell meta-characters in the string
+ *	Quote shell meta-characters and space characters in the string
  *
  * Results:
  *	The quoted string
@@ -2275,7 +2275,7 @@ VarQuote(char *str)
 	    Buf_AddBytes(&buf, nlen, newline);
 	    continue;
 	}
-	if (ismeta((unsigned char)*str))
+	if (*str == ' ' || *str == '\t' || ismeta((unsigned char)*str))
 	    Buf_AddByte(&buf, '\\');
 	Buf_AddByte(&buf, *str);
     }

Reply via email to