(log_working_directory): Made global.

Print entering msg only once.
This commit is contained in:
Roland McGrath 1995-11-26 01:37:07 +00:00
parent 808f1c1cd2
commit 37cf6fdc18

42
main.c
View file

@ -43,7 +43,6 @@ extern double atof ();
#endif #endif
extern char *mktemp (); extern char *mktemp ();
static void log_working_directory ();
static void print_data_base (), print_version (); static void print_data_base (), print_version ();
static void decode_switches (), decode_env_switches (); static void decode_switches (), decode_env_switches ();
static void define_makeflags (); static void define_makeflags ();
@ -387,7 +386,7 @@ enter_command_line_file (name)
/* Skip following slashes: ".//foo" is "foo", not "/foo". */ /* Skip following slashes: ".//foo" is "foo", not "/foo". */
++name; ++name;
} }
if (*name == '\0') if (*name == '\0')
{ {
/* It was all slashes! Move back to the dot and truncate /* It was all slashes! Move back to the dot and truncate
@ -427,7 +426,7 @@ main (argc, argv, envp)
default_goal_file = 0; default_goal_file = 0;
reading_filename = 0; reading_filename = 0;
reading_lineno_ptr = 0; reading_lineno_ptr = 0;
#if !defined (HAVE_STRSIGNAL) && !defined (HAVE_SYS_SIGLIST) #if !defined (HAVE_STRSIGNAL) && !defined (HAVE_SYS_SIGLIST)
signame_init (); signame_init ();
#endif #endif
@ -489,7 +488,7 @@ main (argc, argv, envp)
argv[0] = ""; argv[0] = "";
if (argv[0][0] == '\0') if (argv[0][0] == '\0')
program = "make"; program = "make";
else else
{ {
program = rindex (argv[0], '/'); program = rindex (argv[0], '/');
#ifdef __MSDOS__ #ifdef __MSDOS__
@ -688,10 +687,6 @@ main (argc, argv, envp)
starting_directory = current_directory; starting_directory = current_directory;
} }
/* Tell the user where he is. */
if (print_directory_flag)
log_working_directory (1);
/* Read any stdin makefiles into temporary files. */ /* Read any stdin makefiles into temporary files. */
@ -920,7 +915,7 @@ main (argc, argv, envp)
d = d->next; d = d->next;
} }
} }
} }
/* Set up `MAKEFLAGS' specially while remaking makefiles. */ /* Set up `MAKEFLAGS' specially while remaking makefiles. */
define_makeflags (1, 1); define_makeflags (1, 1);
@ -932,11 +927,11 @@ main (argc, argv, envp)
#define BOGUS_UPDATE_STATUS 0 #define BOGUS_UPDATE_STATUS 0
assert (BOGUS_UPDATE_STATUS); assert (BOGUS_UPDATE_STATUS);
break; break;
case -1: case -1:
/* Did nothing. */ /* Did nothing. */
break; break;
case 2: case 2:
/* Failed to update. Figure out if we care. */ /* Failed to update. Figure out if we care. */
{ {
@ -1010,8 +1005,7 @@ main (argc, argv, envp)
if (print_data_base_flag) if (print_data_base_flag)
print_data_base (); print_data_base ();
if (print_directory_flag) log_working_directory (0);
log_working_directory (0);
if (makefiles != 0) if (makefiles != 0)
{ {
@ -1233,7 +1227,7 @@ handle_non_switch_argument (arg, env)
goals. */ goals. */
struct file *f = enter_command_line_file (arg); struct file *f = enter_command_line_file (arg);
f->cmd_target = 1; f->cmd_target = 1;
if (goals == 0) if (goals == 0)
{ {
goals = (struct dep *) xmalloc (sizeof (struct dep)); goals = (struct dep *) xmalloc (sizeof (struct dep));
@ -1375,13 +1369,13 @@ positive integral argument",
optarg = argv[optind++]; optarg = argv[optind++];
if (doit) if (doit)
*(double *) cs->value_ptr *(double *) cs->value_ptr
= (optarg != 0 ? atof (optarg) = (optarg != 0 ? atof (optarg)
: *(double *) cs->noarg_value); : *(double *) cs->noarg_value);
break; break;
} }
/* We've found the switch. Stop looking. */ /* We've found the switch. Stop looking. */
break; break;
} }
@ -1950,8 +1944,7 @@ die (status)
if (print_data_base_flag) if (print_data_base_flag)
print_data_base (); print_data_base ();
if (print_directory_flag) log_working_directory (0);
log_working_directory (0);
} }
exit (status); exit (status);
@ -1960,20 +1953,21 @@ die (status)
/* Write a message indicating that we've just entered or /* Write a message indicating that we've just entered or
left (according to ENTERING) the current directory. */ left (according to ENTERING) the current directory. */
static void void
log_working_directory (entering) log_working_directory (entering)
int entering; int entering;
{ {
static int entered = 0; static int entered = 0;
char *message = entering ? "Entering" : "Leaving"; char *message = entering ? "Entering" : "Leaving";
if (entering) /* Print nothing without the flag. Don't print the entering message
entered = 1; again if we already have. Don't print the leaving message if we
else if (!entered) haven't printed the entering message. */
/* Don't print the leaving message if we if (! print_directory_flag || entering == entered)
haven't printed the entering message. */
return; return;
entered = entering;
if (print_data_base_flag) if (print_data_base_flag)
fputs ("# ", stdout); fputs ("# ", stdout);