[C++] Fix merge_output_pattern.mk
diff --git a/dep.cc b/dep.cc
index 4e51349..efa6608 100644
--- a/dep.cc
+++ b/dep.cc
@@ -158,9 +158,8 @@
       r->cmds = old_rule.cmds;
     }
 
-    // If the latter rule has a command (regardless of the
-    // commands in oldRule), inputs in the latter rule has a
-    // priority.
+    // If the latter rule has a command (regardless of the commands in
+    // |old_rule|), inputs in the latter rule has a priority.
     if (rule.cmds.empty()) {
       r->inputs = old_rule.inputs;
       copy(rule.inputs.begin(), rule.inputs.end(),
diff --git a/rule.cc b/rule.cc
index f37ff40..7cb2981 100644
--- a/rule.cc
+++ b/rule.cc
@@ -135,7 +135,7 @@
   StringPiece third = rest.substr(index+1);
 
   for (StringPiece tok : WordScanner(second)) {
-    rule->output_patterns.push_back(tok);
+    rule->output_patterns.push_back(Intern(tok));
   }
 
   if (rule->output_patterns.empty()) {
@@ -158,6 +158,10 @@
     v.push_back(StringPrintf("order_only_inputs=[%s]",
                              JoinStrings(order_only_inputs, ",").c_str()));
   }
+  if (!output_patterns.empty()) {
+    v.push_back(StringPrintf("output_patterns=[%s]",
+                             JoinStrings(output_patterns, ",").c_str()));
+  }
   if (is_double_colon)
     v.push_back("is_double_colon");
   if (is_suffix_rule)
diff --git a/testcase/merge_output_pattern.mk b/testcase/merge_output_pattern.mk
index ea51e78..c6b685c 100644
--- a/testcase/merge_output_pattern.mk
+++ b/testcase/merge_output_pattern.mk
@@ -3,6 +3,7 @@
 foo.o: %.o: %.c
 
 foo.o: foo.h
+	echo $^
 	cp $< $@
 
 foo.h foo.c: