
Module: ppl/ppl Branch: master Commit: 099b4c25383b66fd3958f0b74c85dbdbc1dfc01b URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=099b4c25383b6...
Author: Roberto Bagnara bagnara@cs.unipr.it Date: Fri Mar 27 08:41:52 2009 +0100
ascii_load() methods now perform more stringent checks on the input.
---
src/Bit_Matrix.cc | 2 +- src/Congruence.cc | 2 +- src/Congruence_System.cc | 2 +- src/Constraint_System.cc | 4 ++-- src/Generator_System.cc | 6 ++++-- src/Grid_Generator_System.cc | 2 +- src/Linear_Row.cc | 2 +- src/Linear_System.cc | 2 +- src/Matrix.cc | 2 +- src/Row.cc | 4 ++-- 10 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/Bit_Matrix.cc b/src/Bit_Matrix.cc index 5a96467..ac126c5 100644 --- a/src/Bit_Matrix.cc +++ b/src/Bit_Matrix.cc @@ -161,7 +161,7 @@ PPL::Bit_Matrix::ascii_load(std::istream& s) { std::string str; if (!(s >> nrows)) return false; - if (!(s >> str)) + if (!(s >> str) || str != "x") return false; if (!(s >> ncols)) return false; diff --git a/src/Congruence.cc b/src/Congruence.cc index cf79d40..3967117 100644 --- a/src/Congruence.cc +++ b/src/Congruence.cc @@ -240,7 +240,7 @@ PPL::Congruence::ascii_load(std::istream& s) { for (dimension_type col = 0; col < new_size - 1; ++col) if (!(s >> x[col])) return false; - if (!(s >> str) || (str.compare("m") != 0)) + if (!(s >> str) || str != "m") return false; if (!(s >> x[new_size-1])) return false; diff --git a/src/Congruence_System.cc b/src/Congruence_System.cc index 7462706..aecb8bc 100644 --- a/src/Congruence_System.cc +++ b/src/Congruence_System.cc @@ -408,7 +408,7 @@ PPL::Congruence_System::ascii_load(std::istream& s) { dimension_type num_columns; if (!(s >> num_rows)) return false; - if (!(s >> str)) + if (!(s >> str) || str != "x") return false; if (!(s >> num_columns)) return false; diff --git a/src/Constraint_System.cc b/src/Constraint_System.cc index 21240aa..bb477d5 100644 --- a/src/Constraint_System.cc +++ b/src/Constraint_System.cc @@ -518,7 +518,7 @@ PPL::Constraint_System::ascii_load(std::istream& s) { dimension_type ncols; if (!(s >> nrows)) return false; - if (!(s >> str)) + if (!(s >> str) || str != "x") return false; if (!(s >> ncols)) return false; @@ -544,7 +544,7 @@ PPL::Constraint_System::ascii_load(std::istream& s) { return false; if (str == "=") x[i].set_is_equality(); - else + else if (str == ">=" || str == ">") x[i].set_is_inequality();
// Checking for equality of actual and declared types. diff --git a/src/Generator_System.cc b/src/Generator_System.cc index b95835b..4793f5d 100644 --- a/src/Generator_System.cc +++ b/src/Generator_System.cc @@ -886,7 +886,7 @@ PPL::Generator_System::ascii_load(std::istream& s) { dimension_type ncols; if (!(s >> nrows)) return false; - if (!(s >> str)) + if (!(s >> str) || str != "x") return false; if (!(s >> ncols)) return false; @@ -912,8 +912,10 @@ PPL::Generator_System::ascii_load(std::istream& s) { return false; if (str == "L") x[i].set_is_line(); - else + else if (str == "R" || str == "P" || str == "C") x[i].set_is_ray_or_point(); + else + return false;
// Checking for equality of actual and declared types. switch (x[i].type()) { diff --git a/src/Grid_Generator_System.cc b/src/Grid_Generator_System.cc index 3056eb5..165cbf3 100644 --- a/src/Grid_Generator_System.cc +++ b/src/Grid_Generator_System.cc @@ -218,7 +218,7 @@ PPL::Grid_Generator_System::ascii_load(std::istream& s) { if (!(s >> num_rows)) return false; std::string str; - if (!(s >> str)) + if (!(s >> str) || str != "x") return false; if (!(s >> num_columns)) return false; diff --git a/src/Linear_Row.cc b/src/Linear_Row.cc index 7829f79..f536abe 100644 --- a/src/Linear_Row.cc +++ b/src/Linear_Row.cc @@ -211,7 +211,7 @@ PPL::Linear_Row::ascii_load(std::istream& s) { for (dimension_type col = 0; col < new_size; ++col) if (!(s >> x[col])) return false; - if (!(s >> str) || (str.compare("f") != 0)) + if (!(s >> str) || str != "f") return false; return flags().ascii_load(s); } diff --git a/src/Linear_System.cc b/src/Linear_System.cc index a402bcd..f5e651d 100644 --- a/src/Linear_System.cc +++ b/src/Linear_System.cc @@ -152,7 +152,7 @@ PPL::Linear_System::ascii_load(std::istream& s) { dimension_type ncols; if (!(s >> nrows)) return false; - if (!(s >> str)) + if (!(s >> str) || str != "x") return false; if (!(s >> ncols)) return false; diff --git a/src/Matrix.cc b/src/Matrix.cc index fc81df1..19eae9d 100644 --- a/src/Matrix.cc +++ b/src/Matrix.cc @@ -303,7 +303,7 @@ PPL::Matrix::ascii_load(std::istream& s) { dimension_type x_num_cols; if (!(s >> x_num_rows)) return false; - if (!(s >> str) || (str.compare("x") != 0)) + if (!(s >> str) || str != "x") return false; if (!(s >> x_num_cols)) return false; diff --git a/src/Row.cc b/src/Row.cc index 39d292f..addd828 100644 --- a/src/Row.cc +++ b/src/Row.cc @@ -149,7 +149,7 @@ bool PPL::Row::Flags::ascii_load(std::istream& s) { std::string str; std::streamsize sz = s.width(2); - if (!(s >> str) || (str.compare("0x") != 0)) + if (!(s >> str) || str != "0x") return false; s.width(sz); std::istream::fmtflags f = s.setf(std::istream::hex); @@ -193,7 +193,7 @@ PPL::Row::ascii_load(std::istream& s) { for (dimension_type col = 0; col < new_size; ++col) if (!(s >> x[col])) return false; - if (!(s >> str) || (str.compare("f") != 0)) + if (!(s >> str) || str != "f") return false; return flags().ascii_load(s); }