[PPL-devel] [GIT] ppl/ppl(master): Do not mix plain char and numeric values.

Enea Zaffanella zaffanella at cs.unipr.it
Wed Nov 2 14:02:38 CET 2011


Module: ppl/ppl
Branch: master
Commit: aacd89e5ee21cb50aeb5311b017f9f1d66cc952c
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=aacd89e5ee21cb50aeb5311b017f9f1d66cc952c

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Wed Nov  2 14:00:48 2011 +0100

Do not mix plain char and numeric values.
Detected by ECLAIR service utypflag.

---

 src/Variable.cc |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/Variable.cc b/src/Variable.cc
index 19d907b..d8aec32 100644
--- a/src/Variable.cc
+++ b/src/Variable.cc
@@ -38,8 +38,10 @@ PPL::Variable::OK() const {
 void
 PPL::Variable::default_output_function(std::ostream& s, const Variable& v) {
   dimension_type varid = v.id();
-  s << static_cast<char>('A' + varid % 26);
-  if (dimension_type i = varid / 26)
+  static const char var_name_letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+  const dimension_type num_letters = sizeof(var_name_letters) - 1;
+  s << var_name_letters[varid % num_letters];
+  if (dimension_type i = varid / num_letters)
     s << i;
 }
 




More information about the PPL-devel mailing list