* Fix CLN output of -2*a-2*b. (Chris Dams)
authorRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Tue, 27 Aug 2002 17:18:07 +0000 (17:18 +0000)
committerRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Tue, 27 Aug 2002 17:18:07 +0000 (17:18 +0000)
ginac/add.cpp

index 821649d..7c496bc 100644 (file)
@@ -141,9 +141,11 @@ void add::print(const print_context & c, unsigned level) const
                                it->rest.print(c, precedence());
                        }
                
-                       // Separator is "+", except if the following expression would have a leading minus sign
+                       // Separator is "+", except if the following expression would have a leading minus sign or the sign is sitting in parenthesis (as in a ctor)
                        ++it;
-                       if (it != itend && !(it->coeff.info(info_flags::negative) || (it->coeff.is_equal(_num1) && is_exactly_a<numeric>(it->rest) && it->rest.info(info_flags::negative))))
+                       if (it != itend
+                               && (is_a<print_csrc_cl_N>(c)  // sign inside ctor arguments
+                                       || !(it->coeff.info(info_flags::negative) || (it->coeff.is_equal(_num1) && is_exactly_a<numeric>(it->rest) && it->rest.info(info_flags::negative)))))
                                c.s << "+";
                }