summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1993-02-04 18:23:19 +0000
committerRoland McGrath <roland@redhat.com>1993-02-04 18:23:19 +0000
commitaf73694245bac3c2f7cc4e183d80ea10b678b1d7 (patch)
tree7015c13d89a8db893088187b7a45df6cf6c471a3
parenta4f557cb63f9e716a758a677f3cdc727c0c9e988 (diff)
downloadgunmake-af73694245bac3c2f7cc4e183d80ea10b678b1d7.tar.gz
Formerly main.c.~71~
-rw-r--r--main.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/main.c b/main.c
index c736881..8201724 100644
--- a/main.c
+++ b/main.c
@@ -325,6 +325,10 @@ struct stringlist *other_args = 0;
char *program;
+/* Our current directory after processing all -C options. */
+
+char *starting_directory;
+
/* Value of the MAKELEVEL variable at startup (or 0). */
unsigned int makelevel;
@@ -597,6 +601,25 @@ main (argc, argv, envp)
construct_include_path (include_directories == 0 ? (char **) 0
: include_directories->list);
+ /* Figure out where we are now, after chdir'ing. */
+ if (directories == 0)
+ /* We didn't move, so we're still in the same place. */
+ starting_directory = current_directory;
+ else
+ {
+ if (getcwd (current_directory, GET_PATH_MAX) == 0)
+ {
+#ifdef HAVE_GETCWD
+ perror_with_name ("getcwd: ", "");
+#else
+ error ("getwd: %s", current_directory);
+#endif
+ starting_directory = 0;
+ }
+ else
+ starting_directory = current_directory;
+ }
+
/* Tell the user where he is. */
if (print_directory_flag)
@@ -1344,7 +1367,7 @@ decode_env_switches (envar, len)
args[(value[0] == '-' ? 0 : 1) + len + 1] = '\0';
/* Allocate a vector that is definitely big enough. */
- argv = (char **) alloca (1 + len * sizeof (char *));
+ argv = (char **) alloca ((1 + len + 1) * sizeof (char *));
/* getopt will look at the arguments starting at ARGV[1].
Prepend a spacer word. */
@@ -1619,7 +1642,6 @@ log_working_directory (entering)
int entering;
{
static int entered = 0;
- PATH_VAR (pwdbuf);
char *message = entering ? "Entering" : "Leaving";
if (entering)
@@ -1637,15 +1659,8 @@ log_working_directory (entering)
else
printf ("%s[%u]: %s ", program, makelevel, message);
- if (getcwd (pwdbuf, GET_PATH_MAX) == 0)
- {
-#ifdef HAVE_GETCWD
- perror_with_name ("getcwd: ", "");
-#else
- error ("getwd: %s", pwdbuf);
-#endif
- puts ("an unknown directory");
- }
+ if (starting_directory == 0)
+ puts ("an unknown directory");
else
- printf ("directory `%s'\n", pwdbuf);
+ printf ("directory `%s'\n", starting_directory);
}