From c43c09f42cab4e9f7ac577fb24b34486317974ce Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 18 Feb 2002 09:22:07 +0000 Subject: [PATCH] Improve exception output and work around a bug in gcc3.0.1 where a \0 character was appended to what one gets from a strstream.str() call. git-svn-id: https://svn.dealii.org/trunk@5522 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/numerics/data_out.h | 8 +++++--- deal.II/deal.II/include/numerics/data_out_stack.h | 11 +++++++---- deal.II/deal.II/source/numerics/data_out.cc | 9 ++++++--- deal.II/deal.II/source/numerics/data_out_stack.cc | 5 ++++- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/deal.II/deal.II/include/numerics/data_out.h b/deal.II/deal.II/include/numerics/data_out.h index 6f545cc725..901d3d5905 100644 --- a/deal.II/deal.II/include/numerics/data_out.h +++ b/deal.II/deal.II/include/numerics/data_out.h @@ -380,12 +380,14 @@ class DataOut_DoFData : public DataOutInterface /** * Exception */ - DeclException1 (ExcInvalidCharacter, - std::string, + DeclException2 (ExcInvalidCharacter, + std::string, size_t, << "Please use only the characters [a-zA-Z0-9_<>()] for" << std::endl << "description strings since some graphics formats will only accept these." << std::endl - << "The string you gave was <" << arg1 << ">."); + << "The string you gave was <" << arg1 + << ">, the invalid character is <" << arg1[arg2] + << ">." << std::endl); /** * Exception */ diff --git a/deal.II/deal.II/include/numerics/data_out_stack.h b/deal.II/deal.II/include/numerics/data_out_stack.h index 2ce4e639ec..9cbed62642 100644 --- a/deal.II/deal.II/include/numerics/data_out_stack.h +++ b/deal.II/deal.II/include/numerics/data_out_stack.h @@ -297,11 +297,14 @@ class DataOutStack : public DataOutInterface /** * Exception */ - DeclException1 (ExcInvalidCharacter, - std::string, + DeclException2 (ExcInvalidCharacter, + std::string, size_t, << "Please use only the characters [a-zA-Z0-9_<>()] for" << std::endl - << "description strings since AVS will only accept these." << std::endl - << "The string you gave was <" << arg1 << ">."); + << "description strings since some graphics formats will only accept these." + << std::endl + << "The string you gave was <" << arg1 + << ">, the invalid character is <" << arg1[arg2] + << ">." << std::endl); /** * Exception */ diff --git a/deal.II/deal.II/source/numerics/data_out.cc b/deal.II/deal.II/source/numerics/data_out.cc index 8035bd65c8..7779bfce78 100644 --- a/deal.II/deal.II/source/numerics/data_out.cc +++ b/deal.II/deal.II/source/numerics/data_out.cc @@ -169,7 +169,10 @@ add_data_vector (const VECTOR &vec, Assert (names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789_<>()") == std::string::npos, - ExcInvalidCharacter (names[i])); + ExcInvalidCharacter (names[i], + names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789_<>()"))); DataEntry new_entry (&vec, names); if (actual_type == type_dof_data) @@ -210,8 +213,8 @@ add_data_vector (const VECTOR &vec, #else std::ostrstream namebuf; #endif - namebuf << name << '_' << i << std::ends; - names[i] = namebuf.str(); + namebuf << '_' << i << std::ends; + names[i] = name + namebuf.str().c_str(); }; }; diff --git a/deal.II/deal.II/source/numerics/data_out_stack.cc b/deal.II/deal.II/source/numerics/data_out_stack.cc index b7e08a559f..b5a3359e09 100644 --- a/deal.II/deal.II/source/numerics/data_out_stack.cc +++ b/deal.II/deal.II/source/numerics/data_out_stack.cc @@ -158,7 +158,10 @@ void DataOutStack::add_data_vector (const Vector &vec, Assert (names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789_<>()") == std::string::npos, - ExcInvalidCharacter (names[i])); + ExcInvalidCharacter (names[i], + names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789_<>()"))); if (vec.size() == dof_handler->n_dofs()) { -- 2.39.5