From: Jens Vollinga Date: Sun, 22 May 2011 14:19:17 +0000 (+0200) Subject: This patch fixes a bug on machines where char is unsigned by default, by X-Git-Tag: release_1-6-0~1 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=2205b83add319eb883b416c96a14b5866667baaa;ds=sidebyside This patch fixes a bug on machines where char is unsigned by default, by extending the type of clifford_max_label to include all 257 possible return values. Thanks to Martin Guy for the bug report and patch. --- diff --git a/ginac/add.cpp b/ginac/add.cpp index 42364c07..eb965b6b 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -308,7 +308,7 @@ ex add::coeff(const ex & s, int n) const { std::auto_ptr coeffseq(new epvector); std::auto_ptr coeffseq_cliff(new epvector); - char rl = clifford_max_label(s); + int rl = clifford_max_label(s); bool do_clifford = (rl != -1); bool nonscalar = false; diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 2d1e40d3..301d40c1 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -1132,7 +1132,7 @@ ex remove_dirac_ONE(const ex & e, unsigned char rl, unsigned options) return e1; } -char clifford_max_label(const ex & e, bool ignore_ONE) +int clifford_max_label(const ex & e, bool ignore_ONE) { if (is_a(e)) if (ignore_ONE && is_a(e.op(0))) @@ -1140,7 +1140,7 @@ char clifford_max_label(const ex & e, bool ignore_ONE) else return ex_to(e).get_representation_label(); else { - char rl = -1; + int rl = -1; for (size_t i=0; i < e.nops(); i++) rl = (rl > clifford_max_label(e.op(i), ignore_ONE)) ? rl : clifford_max_label(e.op(i), ignore_ONE); return rl; diff --git a/ginac/clifford.h b/ginac/clifford.h index 57e919e1..81e49b01 100644 --- a/ginac/clifford.h +++ b/ginac/clifford.h @@ -301,7 +301,7 @@ ex remove_dirac_ONE(const ex & e, unsigned char rl = 0, unsigned options = 0); * * @param e Expression to be processed * @ignore_ONE defines if clifford_ONE should be ignored in the search*/ -char clifford_max_label(const ex & e, bool ignore_ONE = false); +int clifford_max_label(const ex & e, bool ignore_ONE = false); /** Calculation of the norm in the Clifford algebra. */ ex clifford_norm(const ex & e);