]> www.ginac.de Git - ginac.git/blobdiff - ginac/add.cpp
some more comments and cleanups to mul::expand() and ncmul::expand()
[ginac.git] / ginac / add.cpp
index 28eeff52799a2751046ee60b844f6ca1562d979c..7764d3683fb5e97a0ccb618b71fcfe9aa7ea2cd3 100644 (file)
@@ -151,7 +151,7 @@ void add::print(const print_context & c, unsigned level) const
                        }
                
                        // Separator is "+", except if the following expression would have a leading minus sign
-                       it++;
+                       ++it;
                        if (it != itend && !(it->coeff.compare(_num0()) < 0 || (it->coeff.compare(_num1()) == 0 && is_exactly_a<numeric>(it->rest) && it->rest.compare(_num0()) < 0)))
                                c.s << "+";
                }
@@ -215,7 +215,7 @@ void add::print(const print_context & c, unsigned level) const
                                        c.s << '*';
                        }
                        it->rest.print(c, precedence());
-                       it++;
+                       ++it;
                }
 
                if (precedence() <= level) {
@@ -511,16 +511,13 @@ ex add::recombine_pair_to_ex(const expair & p) const
 
 ex add::expand(unsigned options) const
 {
-       if (flags & status_flags::expanded)
-               return *this;
-       
        epvector *vp = expandchildren(options);
        if (vp == NULL) {
                // the terms have not changed, so it is safe to declare this expanded
-               return this->setflag(status_flags::expanded);
+               return (options == 0) ? setflag(status_flags::expanded) : *this;
        }
        
-       return (new add(vp, overall_coeff))->setflag(status_flags::expanded | status_flags::dynallocated);
+       return (new add(vp, overall_coeff))->setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0));
 }
 
 } // namespace GiNaC