Flush stdout after printing directory info.
authorPaul Smith <psmith@gnu.org>
Thu, 10 Feb 2005 00:10:57 +0000 (00:10 +0000)
committerPaul Smith <psmith@gnu.org>
Thu, 10 Feb 2005 00:10:57 +0000 (00:10 +0000)
Fix references to MINGW #define constants.
Remove WINDOWS32 ifdef from sub_proc.h.
Only add variables to the command line for recursion once.
New features in run_make_test: #PWD# and #MAKEPATH# replacements.
Test the multi-variable fix in the recursion regression test.

ChangeLog
dir.c
main.c
tests/ChangeLog
tests/run_make_tests.pl
tests/scripts/features/recursion
w32/include/sub_proc.h

index 09f0ffedd4f0f646b76d1f72cc6c085fb554f3c3..dc4c8993f566945995913688df751777fe2185d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,22 @@
        Also, the ftp://ftp.gnu.org/GNUinfo site was removed so I'm
        downloading the .texi files from Savannah now.
 
+       Fixed these issues reported by Markus Mauhart <qwe123@chello.at>:
+
+       * main.c (handle_non_switch_argument): Only add variables to
+       command_variables if they're not already there: duplicate settings
+       waste space and can be confusing to read.
+
+       * w32/include/sub_proc.h: Remove WINDOWS32.  It's not needed since
+       this header is never included by non-WINDOWS32 code, and it
+       requires <config.h> to define which isn't always included first.
+
+       * dir.c (read_dirstream) [MINGW]: Use proper macro names when
+       testing MINGW32 versions.
+
+       * main.c (log_working_directory): flush stdout to be sure the WD
+       change is printed before any stderr messages show up.
+
 2005-02-01  Paul D. Smith  <psmith@gnu.org>
 
        * maintMakefile (po_repo): Update the GNU translation site URL.
diff --git a/dir.c b/dir.c
index 9ab4ffc7ce0841073dbb426c8045d0f205f76f15..976e0b49f62d3f3c6c41b2ea64c8539cb30b2e48 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -1131,8 +1131,8 @@ read_dirstream (__ptr_t stream)
            }
          d = (struct dirent *) buf;
 #ifdef __MINGW32__
-# if __MINGW32_VERSION_MAJOR < 3 || (__MINGW32_VERSION_MAJOR == 3 && \
-                                    __MINGW32_VERSION_MINOR == 0)
+# if __MINGW32_MAJOR_VERSION < 3 || (__MINGW32_MAJOR_VERSION == 3 && \
+                                    __MINGW32_MINOR_VERSION == 0)
          d->d_name = xmalloc(len);
 # endif
 #endif
diff --git a/main.c b/main.c
index 10869085730332902150e835ae3e9f30e37d48ed..726729bec026bddd92d890c302b9a1e01a8a0ce9 100644 (file)
--- a/main.c
+++ b/main.c
@@ -2150,13 +2150,21 @@ handle_non_switch_argument (char *arg, int env)
   v = try_variable_definition (0, arg, o_command, 0);
   if (v != 0)
     {
-      /* It is indeed a variable definition.  Record a pointer to
-        the variable for later use in define_makeflags.  */
-      struct command_variable *cv
-       = (struct command_variable *) xmalloc (sizeof (*cv));
-      cv->variable = v;
-      cv->next = command_variables;
-      command_variables = cv;
+      /* It is indeed a variable definition.  If we don't already have this
+        one, record a pointer to the variable for later use in
+        define_makeflags.  */
+      struct command_variable *cv;
+
+      for (cv = command_variables; cv != 0; cv = cv->next)
+        if (cv->variable == v)
+          break;
+
+      if (! cv) {
+        cv = (struct command_variable *) xmalloc (sizeof (*cv));
+        cv->variable = v;
+        cv->next = command_variables;
+        command_variables = cv;
+      }
     }
   else if (! env)
     {
@@ -2907,4 +2915,7 @@ log_working_directory (int entering)
       else
         printf (_("%s[%u]: Leaving directory `%s'\n"),
                 program, makelevel, starting_directory);
+
+  /* Flush stdout to be sure this comes before any stderr output.  */
+  fflush (stdout);
 }
index 9f68a05f556de2d2af6e203595446b4b7d0eafe4..ffaf1b15ad16f10e5795c370c85806b51def0ae0 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-09  Paul D. Smith  <psmith@gnu.org>
+
+       * scripts/features/recursion: Test command line variable settings:
+       only one instance of a given variable should be provided.
+
 2004-11-30  Boris Kolpackov  <boris@kolpackov.net>
 
        * tests/scripts/functions/abspath: New file: test `abspath'
index 9b9104f02565675050fcf9cd19d8317274a48ae2..aeba4e8ff204d7e411b36b009bceecfd7a80ccec 100755 (executable)
@@ -81,7 +81,9 @@ sub run_make_test
     # Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to
     # make
     $makestring =~ s/#MAKEFILE#/$makefile/g;
+    $makestring =~ s/#MAKEPATH#/$mkpath/g;
     $makestring =~ s/#MAKE#/$make_name/g;
+    $makestring =~ s/#PWD#/$pwd/g;
 
     # Populate the makefile!
     open(MAKEFILE, "> $makefile") || die "Failed to open $makefile: $!\n";
@@ -93,7 +95,9 @@ sub run_make_test
 
   $answer && $answer !~ /\n$/s and $answer .= "\n";
   $answer =~ s/#MAKEFILE#/$makefile/g;
+  $answer =~ s/#MAKEPATH#/$mkpath/g;
   $answer =~ s/#MAKE#/$make_name/g;
+  $answer =~ s/#PWD#/$pwd/g;
 
   &run_make_with_options($makefile, $options, &get_logfile(0), $err_code);
   &compare_output($answer, &get_logfile(1));
index 444f7ce933839c18d1c0e8361802ef14bf10b2b3..b9dfd4f42fc74cf58f6708d27f4e7a0e5be0647e 100644 (file)
@@ -1,61 +1,55 @@
 #                                                                    -*-perl-*-
-$description = "The following test creates a makefile to ...\n";
+$description = "Test recursion.";
 
 $details = "DETAILS";
 
-open(MAKEFILE,"> $makefile");
-
-# The Contents of the MAKEFILE ...
-
-print MAKEFILE "all: \n"
-              ."\t\$(MAKE) -f $makefile foo \n"
-              ."foo: \n"
-              ."\t\@echo \$(MAKE) \n"
-              ."\t\@echo MAKELEVEL = \$(MAKELEVEL)\n"
-              ."\t\$(MAKE) -f $makefile last \n"
-              ."last: \n"
-              ."\t\@echo \$(MAKE) \n"
-              ."\t\@echo MAKELEVEL = \$(MAKELEVEL) \n"
-              ."\t\@echo THE END\n";
-
-# END of Contents of MAKEFILE
-
-close(MAKEFILE);
-
-if ($vos)
-{
-   $answer = "$make_name: Entering directory \`$pwd\'\n"
-            ."make 'CFLAGS=-O' -f $makefile foo \n"
-            ."make CFLAGS=-O\n"
-            ."MAKELEVEL = 0\n"
-            ."make 'CFLAGS=-O' -f $makefile last \n"
-            ."make CFLAGS=-O\n"
-            ."MAKELEVEL = 0\n"
-            ."THE END\n"
-            ."$make_name: Leaving directory `$pwd'\n";
-}
-else
-{
-   $answer = "$make_name: Entering directory `$pwd'\n"
-            ."$mkpath -f $makefile foo \n"
-            ."${make_name}[1]: Entering directory `$pwd'\n"
-            ."$mkpath\n"
-            ."MAKELEVEL = 1\n"
-            ."$mkpath -f $makefile last \n"
-            ."${make_name}[2]: Entering directory `$pwd'\n"
-            ."$mkpath\n"
-            ."MAKELEVEL = 2\n"
-            ."THE END\n"
-            ."${make_name}[2]: Leaving directory `$pwd'\n"
-            ."${make_name}[1]: Leaving directory `$pwd'\n"
-            ."$make_name: Leaving directory `$pwd'\n";
-}
-
-$mkoptions = "CFLAGS=-O -w";
-$mkoptions .= " -j 2" if ($parallel_jobs);
-
-&run_make_with_options($makefile,$mkoptions,&get_logfile,0);
-
-&compare_output($answer,&get_logfile(1));
+# Test some basic recursion.
+run_make_test('
+all:
+       $(MAKE) -f #MAKEFILE# foo
+foo:
+       @echo $(MAKE)
+       @echo MAKELEVEL = $(MAKELEVEL)
+       $(MAKE) -f #MAKEFILE# last
+last:
+       @echo $(MAKE)
+       @echo MAKELEVEL = $(MAKELEVEL)
+       @echo THE END
+',
+              ('CFLAGS=-O -w' . ($parallel_jobs ? '-j 2' : '')),
+              ($vos
+               ? "#MAKE#: Entering directory `#PWD#'
+make 'CFLAGS=-O' -f #MAKEFILE# foo
+make CFLAGS=-O
+MAKELEVEL = 0
+make 'CFLAGS=-O' -f #MAKEFILE# last
+make CFLAGS=-O
+MAKELEVEL = 0
+THE END
+#MAKE#: Leaving directory `#PWD#'"
+               : "#MAKE#: Entering directory `#PWD#'
+#MAKEPATH# -f #MAKEFILE# foo
+#MAKE#[1]: Entering directory `#PWD#'
+#MAKEPATH#
+MAKELEVEL = 1
+#MAKEPATH# -f #MAKEFILE# last
+#MAKE#[2]: Entering directory `#PWD#'
+#MAKEPATH#
+MAKELEVEL = 2
+THE END
+#MAKE#[2]: Leaving directory `#PWD#'
+#MAKE#[1]: Leaving directory `#PWD#'
+#MAKE#: Leaving directory `#PWD#'"));
+
+
+# Test command line overrides.
+run_make_test('
+recur: all ; @$(MAKE) --no-print-directory -f #MAKEFILE# a=AA all
+all: ; @echo "MAKEOVERRIDES = $(MAKEOVERRIDES)"
+',
+              'a=ZZ',
+              'MAKEOVERRIDES = a=ZZ
+MAKEOVERRIDES = a=AA
+');
 
 1;
index d7478bb1c4760e7f2c3f90213fdeffa4a325f2f1..2654b34b32c4d0ea405ebd0e13f9bf35bb86616e 100644 (file)
@@ -2,7 +2,7 @@
 #define SUB_PROC_H\r
 \r
 /*\r
- * Component Name: \r
+ * Component Name:\r
  *\r
  * $Date$\r
  *\r
@@ -13,8 +13,6 @@
 \r
 /* $Id$ */\r
 \r
-#ifdef WINDOWS32\r
-\r
 #define EXTERN_DECL(entry, args) extern entry args\r
 #define VOID_DECL void\r
 \r
@@ -23,7 +21,7 @@ EXTERN_DECL(HANDLE process_init_fd, (HANDLE stdinh, HANDLE stdouth,
        HANDLE stderrh));\r
 EXTERN_DECL(long process_begin, (HANDLE proc, char **argv, char **envp,\r
        char *exec_path, char *as_user));\r
-EXTERN_DECL(long process_pipe_io, (HANDLE proc, char *stdin_data, \r
+EXTERN_DECL(long process_pipe_io, (HANDLE proc, char *stdin_data,\r
        int stdin_data_len));\r
 EXTERN_DECL(long process_file_io, (HANDLE proc));\r
 EXTERN_DECL(void process_cleanup, (HANDLE proc));\r
@@ -44,4 +42,3 @@ EXTERN_DECL(int process_errcnt, (HANDLE proc));
 EXTERN_DECL(void process_pipes, (HANDLE proc, int pipes[3]));\r
 \r
 #endif\r
-#endif\r