Module Name:    src
Committed By:   sjg
Date:           Fri Jan 25 02:01:11 UTC 2013

Modified Files:
        src/usr.bin/make: compat.c job.c main.c

Log Message:
Remove Check_Cwd - it is no longer needed.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/make/compat.c
cvs rdiff -u -r1.163 -r1.164 src/usr.bin/make/job.c
cvs rdiff -u -r1.203 -r1.204 src/usr.bin/make/main.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.90 src/usr.bin/make/compat.c:1.91
--- src/usr.bin/make/compat.c:1.90	Sun Oct  7 19:17:31 2012
+++ src/usr.bin/make/compat.c	Fri Jan 25 02:01:10 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.90 2012/10/07 19:17:31 sjg Exp $	*/
+/*	$NetBSD: compat.c,v 1.91 2013/01/25 02:01:10 sjg 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.90 2012/10/07 19:17:31 sjg Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.91 2013/01/25 02:01:10 sjg 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.90 2012/10/07 19:17:31 sjg Exp $");
+__RCSID("$NetBSD: compat.c,v 1.91 2013/01/25 02:01:10 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -374,7 +374,6 @@ again:
 	Fatal("Could not fork");
     }
     if (cpid == 0) {
-	Check_Cwd(av);
 	Var_ExportVars();
 #ifdef USE_META
 	if (useMeta) {

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.163 src/usr.bin/make/job.c:1.164
--- src/usr.bin/make/job.c:1.163	Tue Jul  3 21:03:40 2012
+++ src/usr.bin/make/job.c	Fri Jan 25 02:01:10 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.163 2012/07/03 21:03:40 sjg Exp $	*/
+/*	$NetBSD: job.c,v 1.164 2013/01/25 02:01:10 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.163 2012/07/03 21:03:40 sjg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.164 2013/01/25 02:01:10 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.163 2012/07/03 21:03:40 sjg Exp $");
+__RCSID("$NetBSD: job.c,v 1.164 2013/01/25 02:01:10 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -675,7 +675,6 @@ JobPrintCommand(void *cmdp, void *jobp)
     char	  *escCmd = NULL;    /* Command with quotes/backticks escaped */
     char     	  *cmd = (char *)cmdp;
     Job           *job = (Job *)jobp;
-    char	  *cp, *tmp;
     int           i, j;
 
     noSpecials = NoExecute(job->node);
@@ -847,11 +846,6 @@ JobPrintCommand(void *cmdp, void *jobp)
 	    job->flags |= JOB_TRACED;
     }
     
-    if ((cp = Check_Cwd_Cmd(cmd)) != NULL) {
-	    DBPRINTF("test -d %s && ", cp);
-	    DBPRINTF("cd %s\n", cp);
-    }
-
     DBPRINTF(cmdTemplate, cmd);
     free(cmdStart);
     if (escCmd)
@@ -871,10 +865,6 @@ JobPrintCommand(void *cmdp, void *jobp)
     if (shutUp && commandShell->hasEchoCtl) {
 	DBPRINTF("%s\n", commandShell->echoOn);
     }
-    if (cp != NULL) {
-	    DBPRINTF("test -d %s && ", cp);
-	    DBPRINTF("cd %s\n", Var_Value(".OBJDIR", VAR_GLOBAL, &tmp));
-    }
     return 0;
 }
 

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.203 src/usr.bin/make/main.c:1.204
--- src/usr.bin/make/main.c:1.203	Fri Aug 31 07:00:36 2012
+++ src/usr.bin/make/main.c	Fri Jan 25 02:01:10 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.203 2012/08/31 07:00:36 sjg Exp $	*/
+/*	$NetBSD: main.c,v 1.204 2013/01/25 02:01:10 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.203 2012/08/31 07:00:36 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.204 2013/01/25 02:01:10 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.203 2012/08/31 07:00:36 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.204 2013/01/25 02:01:10 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -176,7 +176,6 @@ Boolean			varNoExportEnv;	/* -X flag */
 Boolean			doing_depend;	/* Set while reading .depend */
 static Boolean		jobsRunning;	/* TRUE if the jobs might be running */
 static const char *	tracefile;
-static char *		Check_Cwd_av(int, char **, int);
 static void		MainParseArgs(int, char **);
 static int		ReadMakefile(const void *, const void *);
 static void		usage(void) MAKE_ATTR_DEAD;
@@ -1165,8 +1164,6 @@ main(int argc, char **argv)
 		jp_0, jp_1, maxJobs, maxJobTokens, compatMake);
 
 	Main_ExportMAKEFLAGS(TRUE);	/* initial export */
-
-	Check_Cwd_av(0, NULL, 0);	/* initialize it */
 	
 
 	/*
@@ -1384,190 +1381,6 @@ found:
 }
 
 
-/*
- * If MAKEOBJDIRPREFIX is in use, make ends up not in .CURDIR
- * in situations that would not arrise with ./obj (links or not).
- * This tends to break things like:
- *
- * build:
- * 	${MAKE} includes
- *
- * This function spots when ${.MAKE:T} or ${.MAKE} is a command (as
- * opposed to an argument) in a command line and if so returns
- * ${.CURDIR} so caller can chdir() so that the assumptions made by
- * the Makefile hold true.
- *
- * If ${.MAKE} does not contain any '/', then ${.MAKE:T} is skipped.
- *
- * The chdir() only happens in the child process, and does nothing if
- * MAKEOBJDIRPREFIX and MAKEOBJDIR are not in the environment so it
- * should not break anything.  Also if NOCHECKMAKECHDIR is set we
- * do nothing - to ensure historic semantics can be retained.
- */
-static int  Check_Cwd_Off = 0;
-
-static char *
-Check_Cwd_av(int ac, char **av, int copy)
-{
-    static char *make[4];
-    static char *cur_dir = NULL;
-    char **mp;
-    char *cp;
-    int is_cmd, next_cmd;
-    int i;
-    int n;
-
-    if (Check_Cwd_Off) {
-	if (DEBUG(CWD))
-	    fprintf(debug_file, "check_cwd: check is off.\n");
-	return NULL;
-    }
-    
-    if (make[0] == NULL) {
-	if (Var_Exists("NOCHECKMAKECHDIR", VAR_GLOBAL)) {
-	    Check_Cwd_Off = 1;
-	    if (DEBUG(CWD))
-		fprintf(debug_file, "check_cwd: turning check off.\n");
-	    return NULL;
-	}
-	    
-        make[1] = Var_Value(".MAKE", VAR_GLOBAL, &cp);
-        if ((make[0] = strrchr(make[1], '/')) == NULL) {
-            make[0] = make[1];
-            make[1] = NULL;
-        } else
-            ++make[0];
-        make[2] = NULL;
-        cur_dir = Var_Value(".CURDIR", VAR_GLOBAL, &cp);
-    }
-    if (ac == 0 || av == NULL) {
-	if (DEBUG(CWD))
-	    fprintf(debug_file, "check_cwd: empty command.\n");
-        return NULL;			/* initialization only */
-    }
-
-    if (getenv("MAKEOBJDIR") == NULL &&
-        getenv("MAKEOBJDIRPREFIX") == NULL) {
-	if (DEBUG(CWD))
-	    fprintf(debug_file, "check_cwd: no obj dirs.\n");
-        return NULL;
-    }
-
-    
-    next_cmd = 1;
-    for (i = 0; i < ac; ++i) {
-	is_cmd = next_cmd;
-
-	n = strlen(av[i]);
-	cp = &(av[i])[n - 1];
-	if (strspn(av[i], "|&;") == (size_t)n) {
-	    next_cmd = 1;
-	    continue;
-	} else if (*cp == ';' || *cp == '&' || *cp == '|' || *cp == ')') {
-	    next_cmd = 1;
-	    if (copy) {
-		do {
-		    *cp-- = '\0';
-		} while (*cp == ';' || *cp == '&' || *cp == '|' ||
-			 *cp == ')' || *cp == '}') ;
-	    } else {
-		/*
-		 * XXX this should not happen.
-		 */
-		fprintf(stderr, "%s: WARNING: raw arg ends in shell meta '%s'\n",
-		    progname, av[i]);
-	    }
-	} else
-	    next_cmd = 0;
-
-	cp = av[i];
-	if (*cp == ';' || *cp == '&' || *cp == '|')
-	    is_cmd = 1;
-	
-	if (DEBUG(CWD))
-	    fprintf(debug_file, "av[%d] == %s '%s'",
-		i, (is_cmd) ? "cmd" : "arg", av[i]);
-	if (is_cmd != 0) {
-	    if (*cp == '(' || *cp == '{' ||
-		*cp == ';' || *cp == '&' || *cp == '|') {
-		do {
-		    ++cp;
-		} while (*cp == '(' || *cp == '{' ||
-			 *cp == ';' || *cp == '&' || *cp == '|');
-		if (*cp == '\0') {
-		    next_cmd = 1;
-		    continue;
-		}
-	    }
-	    if (strcmp(cp, "cd") == 0 || strcmp(cp, "chdir") == 0) {
-		if (DEBUG(CWD))
-		    fprintf(debug_file, " == cd, done.\n");
-		return NULL;
-	    }
-	    for (mp = make; *mp != NULL; ++mp) {
-		n = strlen(*mp);
-		if (strcmp(cp, *mp) == 0) {
-		    if (DEBUG(CWD))
-			fprintf(debug_file, " %s == '%s', chdir(%s)\n",
-			    cp, *mp, cur_dir);
-		    return cur_dir;
-		}
-	    }
-	}
-	if (DEBUG(CWD))
-	    fprintf(debug_file, "\n");
-    }
-    return NULL;
-}
-
-char *
-Check_Cwd_Cmd(const char *cmd)
-{
-    char *cp, *bp;
-    char **av;
-    int ac;
-
-    if (Check_Cwd_Off)
-	return NULL;
-    
-    if (cmd) {
-	av = brk_string(cmd, &ac, TRUE, &bp);
-	if (DEBUG(CWD))
-	    fprintf(debug_file, "splitting: '%s' -> %d words\n",
-		cmd, ac);
-    } else {
-	ac = 0;
-	av = NULL;
-	bp = NULL;
-    }
-    cp = Check_Cwd_av(ac, av, 1);
-    if (bp)
-	free(bp);
-    if (av)
-	free(av);
-    return cp;
-}
-
-void
-Check_Cwd(const char **argv)
-{
-    char *cp;
-    int ac;
-    
-    if (Check_Cwd_Off)
-	return;
-    
-    for (ac = 0; argv[ac] != NULL; ++ac)
-	/* NOTHING */;
-    if (ac == 3 && *argv[1] == '-') {
-	cp =  Check_Cwd_Cmd(argv[2]);
-    } else {
-	cp = Check_Cwd_av(ac, UNCONST(argv), 0);
-    }
-    if (cp) {
-	chdir(cp);
-    }
-}
 
 /*-
  * Cmd_Exec --

Reply via email to