[PPL-devel] [GIT] ppl/ppl(master): Added helper is_space(), to be used instead of directly calling isspace().

Enea Zaffanella zaffanella at cs.unipr.it
Fri Feb 17 09:22:39 CET 2012


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

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Fri Feb 17 08:50:34 2012 +0100

Added helper is_space(), to be used instead of directly calling isspace().

---

 src/Interval.templates.hh |    6 +++---
 src/checked.cc            |    2 +-
 src/globals.defs.hh       |    3 +++
 src/globals.inlines.hh    |    6 ++++++
 src/wrap_string.cc        |    6 +++---
 5 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/Interval.templates.hh b/src/Interval.templates.hh
index 8a77acc..b1425ec 100644
--- a/src/Interval.templates.hh
+++ b/src/Interval.templates.hh
@@ -241,7 +241,7 @@ operator>>(std::istream& is, Interval<Boundary, Info>& x) {
   do {
     if (!is.get(c))
       goto fail;
-  } while (isspace(c));
+  } while (is_space(c));
 
   // Get the opening parenthesis and handle the empty interval case.
   if (c == '(')
@@ -270,7 +270,7 @@ operator>>(std::istream& is, Interval<Boundary, Info>& x) {
   do {
     if (!is.get(c))
       goto fail;
-  } while (isspace(c));
+  } while (is_space(c));
   if (c != ',')
     goto unexpected;
 
@@ -284,7 +284,7 @@ operator>>(std::istream& is, Interval<Boundary, Info>& x) {
   do {
     if (!is.get(c))
       goto fail;
-  } while (isspace(c));
+  } while (is_space(c));
   if (c == ')')
     upper_open = true;
   else if (c != ']') {
diff --git a/src/checked.cc b/src/checked.cc
index e35ed75..2fc1900 100644
--- a/src/checked.cc
+++ b/src/checked.cc
@@ -147,7 +147,7 @@ parse_number_part(std::istream& is, number_struct& numer) {
   do {
     if (!is.get(c))
       return V_CVT_STR_UNK;
-  } while (isspace(c));
+  } while (is_space(c));
   switch (c) {
   case '-':
     numer.neg_mantissa = true;
diff --git a/src/globals.defs.hh b/src/globals.defs.hh
index b2bf946..cafe55a 100644
--- a/src/globals.defs.hh
+++ b/src/globals.defs.hh
@@ -350,6 +350,9 @@ struct Recycle_Input {
 	      << "for " PPL_XSTR(class_prefix) << "." << std::endl;	\
   }
 
+//! Returns <CODE>true</CODE> if \p c is any kind of space character.
+bool is_space(char c);
+
 template <typename T, long long v, typename Enable = void>
 struct Fit : public False {
 };
diff --git a/src/globals.inlines.hh b/src/globals.inlines.hh
index f132ea5..97bde3f 100644
--- a/src/globals.inlines.hh
+++ b/src/globals.inlines.hh
@@ -26,6 +26,7 @@ site: http://bugseng.com/products/ppl/ . */
 
 #include <limits>
 #include <cassert>
+#include <cctype>
 
 namespace Parma_Polyhedra_Library {
 
@@ -120,6 +121,11 @@ total_memory_in_bytes(const mpq_class& x) {
   return sizeof(x) + external_memory_in_bytes(x);
 }
 
+inline bool
+is_space(char c) {
+  return isspace(c) != 0;
+}
+
 } // namespace Parma_Polyhedra_Library
 
 #endif // !defined(PPL_globals_inlines_hh)
diff --git a/src/wrap_string.cc b/src/wrap_string.cc
index 04f431e..1845f8d 100644
--- a/src/wrap_string.cc
+++ b/src/wrap_string.cc
@@ -51,7 +51,7 @@ wrap_string(const std::string& src_string,
       }
       if (src[i] == ',' && i < line_length)
 	last_comma = i;
-      if (isspace(src[i]) && (i == 0 || !isspace(src[i-1])))
+      if (is_space(src[i]) && (i == 0 || !is_space(src[i-1])))
 	last_space = i;
     }
     if (split_pos < 0) {
@@ -65,7 +65,7 @@ wrap_string(const std::string& src_string,
 	    ++i;
 	    break;
 	  }
-	  if (isspace(src[i]))
+	  if (is_space(src[i]))
 	    break;
 	}
 	split_pos = i;
@@ -75,7 +75,7 @@ wrap_string(const std::string& src_string,
 	dst_string.append(indent_depth, ' ');
     dst_string.append(src, split_pos);
     src += split_pos;
-    if (isspace(*src))
+    if (is_space(*src))
       ++src;
     while (*src == ' ')
       ++src;




More information about the PPL-devel mailing list