[SV 31155] Parse order-only tokens in second expansion results.
authorPaul Smith <psmith@gnu.org>
Sun, 22 Sep 2013 20:59:04 +0000 (16:59 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 22 Sep 2013 21:10:35 +0000 (17:10 -0400)
ChangeLog
implicit.c
tests/ChangeLog
tests/scripts/features/se_implicit

index 816a2ad23a1da229e357ae73713c76e83ae259a4..e96feef11934ad714b0abd157a06e0f01d3eedb4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2013-09-22  Paul Smith  <psmith@gnu.org>
 
+       * implicit.c (pattern_search): After second expansion be sure to
+       handle order-only markers inside the expansion properly.
+       Fixes Savannah bug #31155.
+
        * guile.c (guile_define_module): Technically a void* cannot
        contain a pointer-to-function and some compilers warn about this.
        Cast the function pointers.
index f0bb38546fee73c85d387873a58acd1cbaa97b3a..5fedec08a0b7da2b0a549c809b4d31c6faf6d8e2 100644 (file)
@@ -574,6 +574,7 @@ pattern_search (struct file *file, int archive,
                 {
                   int add_dir = 0;
                   unsigned int len;
+                  struct dep **dptr;
 
                   nptr = get_next_word (nptr, &len);
                   if (nptr == 0)
@@ -616,6 +617,9 @@ pattern_search (struct file *file, int archive,
                         add_dir = 1;
                     }
 
+                  /* Set up for the next word.  */
+                  nptr += len;
+
                   /* Initialize and set file variables if we haven't already
                      done so. */
                   if (!file_vars_initialized)
@@ -634,20 +638,33 @@ pattern_search (struct file *file, int archive,
 
                   /* Perform the 2nd expansion.  */
                   p = variable_expand_for_file (depname, file);
+                  dptr = &dl;
 
-                  /* Parse the expanded string. */
-                  dl = PARSE_FILE_SEQ (&p, struct dep, order_only ? MAP_NUL : MAP_PIPE,
-                                       add_dir ? dir : NULL, PARSEFS_NONE);
-
-                  for (d = dl; d != NULL; d = d->next)
+                  /* Parse the results into a deps list.  */
+                  do
                     {
-                      ++deps_found;
-                      if (order_only)
-                        d->ignore_mtime = 1;
-                    }
+                      /* Parse the expanded string. */
+                      struct dep *dp = PARSE_FILE_SEQ (&p, struct dep,
+                                                       order_only ? MAP_NUL : MAP_PIPE,
+                                                       add_dir ? dir : NULL, PARSEFS_NONE);
+                      *dptr = dp;
 
-                  /* Set up for the next word.  */
-                  nptr += len;
+                      for (d = dp; d != NULL; d = d->next)
+                        {
+                          ++deps_found;
+                          if (order_only)
+                            d->ignore_mtime = 1;
+                          dptr = &d->next;
+                        }
+
+                      /* If we stopped due to an order-only token, note it.  */
+                      if (*p == '|')
+                        {
+                          order_only = 1;
+                          ++p;
+                        }
+                    }
+                  while (*p != '\0');
                 }
 
               /* If there are more than max_pattern_deps prerequisites (due to
index ad746d2a330d9972e6d622ebef128ec0de1b0b7a..eaeb7c0ef07464a19f346ca3ec03ef2b27668f49 100644 (file)
@@ -1,5 +1,9 @@
 2013-09-22  Paul Smith  <psmith@gnu.org>
 
+       * scripts/features/se_implicit: Verify that order-only tokens
+       inside second expansion are parsed correctly.
+       Test for Savannah bug #31155.
+
        * run_make_tests.pl (set_more_defaults): If we can't find
        gnumake.h based on the make program we might be running from a
        remote build directory.  Parse the Makefile for the right path.
index 0a31948adf8c0eb5f22004a9cb11f3c23759a8a3..ec09d8daae51ad6b4e21fba4fc82ad5a5ee40f6f 100644 (file)
@@ -244,5 +244,17 @@ sim_%: \
 
 unlink('a');
 
+# Ensure that order-only tokens embedded in second expansions are parsed
+run_make_test(q!
+.SECONDEXPANSION:
+PREREQS=p1|p2
+P2=p2
+all : foo bar
+f%o: $$(PREREQS) ; @echo '$@' from '$^' and '$|'
+b%r: p1|$$(P2)   ; @echo '$@' from '$^' and '$|'
+p% : ; : $@
+!,
+              "", ": p1\n: p2\nfoo from p1 and p2\nbar from p1 and p2\n");
+
 # This tells the test driver that the perl test script executed properly.
 1;