Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77731 - trunk/boost/graph
From: jewillco_at_[hidden]
Date: 2012-04-03 00:42:27


Author: jewillco
Date: 2012-04-03 00:42:25 EDT (Tue, 03 Apr 2012)
New Revision: 77731
URL: http://svn.boost.org/trac/boost/changeset/77731

Log:
Changed to manual token-testing code to avoid use of Boost.Xpressive (allowing use on more compilers)
Text files modified:
   trunk/boost/graph/graphviz.hpp | 36 ++++++++++++++++++++++++++++++++++--
   1 files changed, 34 insertions(+), 2 deletions(-)

Modified: trunk/boost/graph/graphviz.hpp
==============================================================================
--- trunk/boost/graph/graphviz.hpp (original)
+++ trunk/boost/graph/graphviz.hpp 2012-04-03 00:42:25 EDT (Tue, 03 Apr 2012)
@@ -15,6 +15,7 @@
 #include <map>
 #include <iostream>
 #include <fstream>
+#include <cctype>
 #include <stdio.h> // for FILE
 #include <boost/property_map/property_map.hpp>
 #include <boost/tuple/tuple.hpp>
@@ -31,7 +32,9 @@
 #include <boost/lexical_cast.hpp>
 #include <boost/static_assert.hpp>
 #include <boost/algorithm/string/replace.hpp>
+#if 0
 #include <boost/xpressive/xpressive_static.hpp>
+#endif
 #include <boost/foreach.hpp>
 
 namespace boost {
@@ -65,10 +68,39 @@
 
   template <typename T>
   inline std::string escape_dot_string(const T& obj) {
+ std::string s(boost::lexical_cast<std::string>(obj));
+#if 0
     using namespace boost::xpressive;
     static sregex valid_unquoted_id = (((alpha | '_') >> *_w) | (!as_xpr('-') >> (('.' >> *_d) | (+_d >> !('.' >> *_d)))));
- std::string s(boost::lexical_cast<std::string>(obj));
- if (regex_match(s, valid_unquoted_id)) {
+ bool ok = regex_match(s, valid_unquoted_id);
+#else
+ bool ok;
+ using std::isdigit; using std::isalpha;
+ if (s.empty()) {
+ ok = false;
+ } else if (isdigit(s[0]) || s[0] == '-' || s[0] == '.') { // Number
+ size_t startpos = (s[0] == '-' ? 1 : 0);
+ size_t dot_maybe = s.find('.', startpos);
+ if (dot_maybe != std::string::npos && s.find('.', dot_maybe + 1) != std::string::npos) {
+ ok = false; // Has two decimal points
+ } else {
+ for (size_t i = startpos; i < s.size(); ++i) {
+ if (!(isdigit(s[i]) || s[i] == '.')) {ok = false; break;}
+ }
+ }
+ } else if (isalpha(s[0]) || s[0] == '_') { // Identifier
+ ok = true;
+ for (size_t i = 1; i < s.size(); ++i) {
+ if (!(isalpha(s[i]) || isdigit(s[i]) || s[i] == '_')) {
+ ok = false;
+ break;
+ }
+ }
+ } else {
+ ok = false;
+ }
+#endif
+ if (ok) {
       return s;
     } else {
       boost::algorithm::replace_all(s, "\"", "\\\"");


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk