Whitespce cleanup: Remove whitespace at end-on-line, remove tabs, wrap
[senf.git] / senf / Utils / Console / Parse.cc
index 7f0c5ba..f9b2d21 100644 (file)
@@ -1,6 +1,6 @@
 // $Id$
 //
-// Copyright (C) 2008 
+// Copyright (C) 2008
 // Fraunhofer Institute for Open Communication Systems (FOKUS)
 // Competence Center NETwork research (NET), St. Augustin, GERMANY
 //     Stefan Bund <g0dil@berlios.de>
@@ -95,7 +95,7 @@ namespace detail {
         void popDirectory()
             { info_->clear();
               info_->builtin(ParseCommandInfo::BuiltinPOPD); }
-        
+
         void builtin_exit()
             { info_->clear();
               info_->builtin(ParseCommandInfo::BuiltinEXIT); }
@@ -145,15 +145,15 @@ prefix_ std::ostream & senf::console::operator<<(std::ostream & os, Token const
         "Word" };
     // The real table is:
     //     static const int bitPosition[32] = {
-    //          0,  1, 28,  2, 29, 14, 24,  3, 30, 22, 20, 15, 25, 17,  4,  8, 
+    //          0,  1, 28,  2, 29, 14, 24,  3, 30, 22, 20, 15, 25, 17,  4,  8,
     //         31, 27, 13, 23, 21, 19, 16,  7, 26, 12, 18,  6, 11,  5, 10,  9 };
     // However, we have replaced all values >= sizeof(tokenTypeName) with 0
     // and have added 1 to all the remaining values
     static const int bitPosition[32] = {
-        1, 2, 0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 5, 9, 
+        1, 2, 0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 5, 9,
         0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 7, 0, 6, 0, 10 };
     // We need to check token.type() against 0 explicitly since 0 and 1 will both be mapped to 0
-    os << tokenTypeName[ token.type() 
+    os << tokenTypeName[ token.type()
                          ? bitPosition[(((token.type() & -token.type()) * 0x077CB531UL) >> 27) & 31]
                          : 0 ]
        << "('"
@@ -183,7 +183,7 @@ prefix_ std::ostream & senf::console::operator<<(std::ostream & stream,
         char const * builtins[] = { 0, "cd", "ls", "lr", "pushd", "popd", "exit", "help" };
         stream << "builtin-" << builtins[info.builtin()];
     }
-        
+
     ParseCommandInfo::ArgumentsRange args (info.arguments());
     for (ParseCommandInfo::argument_iterator i (args.begin()); i != args.end(); ++i) {
         ParseCommandInfo::token_iterator j (i->begin());
@@ -262,9 +262,9 @@ struct senf::console::CommandParser::Impl
 #endif
 
 namespace {
-    
+
     template <class Error>
-    void throwParserError(Error const & err) 
+    void throwParserError(Error const & err)
     {
         static char const * msg [] = { "end of statement expected",
                                        "path expected",
@@ -277,7 +277,7 @@ namespace {
 
 }
 
-namespace boost { 
+namespace boost {
 namespace spirit {
 
     template <>
@@ -318,7 +318,7 @@ prefix_ senf::console::CommandParser::~CommandParser()
 // we would need to expose the Impl member to the public, which we don't want to do.
 
 template <class Iterator>
-prefix_ Iterator senf::console::CommandParser::parseLoop(Iterator npb, Iterator npe, 
+prefix_ Iterator senf::console::CommandParser::parseLoop(Iterator npb, Iterator npe,
                                                          std::string const & source, Callback cb)
 {
     typedef boost::spirit::position_iterator<
@@ -333,7 +333,7 @@ prefix_ Iterator senf::console::CommandParser::parseLoop(Iterator npb, Iterator
         result = boost::spirit::parse(
             b, e, * impl().grammar.use_parser<Impl::Grammar::SkipParser>());
         b = result.stop;
-        if (b == e) 
+        if (b == e)
             return e.base();
         info.clear();
         try {
@@ -349,7 +349,7 @@ prefix_ Iterator senf::console::CommandParser::parseLoop(Iterator npb, Iterator
         }
         // Otherwise the error handling in the parser is broken
         SENF_ASSERT( result.hit );
-        if (! info.empty()) 
+        if (! info.empty())
             try {
                 cb(info);
             }
@@ -369,9 +369,9 @@ prefix_ void senf::console::CommandParser::parse(std::string const & command, Ca
 
 prefix_ void senf::console::CommandParser::parseFile(std::string const & filename, Callback cb)
 {
-    // file_iterator sets errno to EINVAL and returns error when file size is 0 
-    // so we check the file size before 
-    struct stat statBuf; 
+    // file_iterator sets errno to EINVAL and returns error when file size is 0
+    // so we check the file size before
+    struct stat statBuf;
     if (stat( filename.c_str(), &statBuf) != 0)
         throw SystemException(filename, errno SENF_EXC_DEBUGINFO);
     if (statBuf.st_size == 0) return;
@@ -379,7 +379,7 @@ prefix_ void senf::console::CommandParser::parseFile(std::string const & filenam
     if (!i) {
         if (errno == 0)
             // hmm.. errno==0 but the file_iterator is false; something is wrong but we
-            // do not know what exactly, so we throw a SystemeException with EINVAL 
+            // do not know what exactly, so we throw a SystemeException with EINVAL
             throw SystemException(filename, EINVAL SENF_EXC_DEBUGINFO);
         else
             throw SystemException(filename, errno SENF_EXC_DEBUGINFO);
@@ -398,7 +398,7 @@ prefix_ void senf::console::CommandParser::parseArguments(std::string const & ar
     detail::ParseDispatcher::BindInfo bind (impl().dispatcher, info);
     boost::spirit::parse_info<PositionIterator> result;
     try {
-        result = boost::spirit::parse( b, e, 
+        result = boost::spirit::parse( b, e,
                                        impl().grammar.use_parser<Impl::Grammar::ArgumentsParser>(),
                                        impl().grammar.use_parser<Impl::Grammar::SkipParser>() );
     }
@@ -422,7 +422,7 @@ prefix_ void senf::console::CommandParser::parsePath(std::string const & path,
     detail::ParseDispatcher::BindInfo bind (impl().dispatcher, info);
     boost::spirit::parse_info<PositionIterator> result;
     try {
-        result = boost::spirit::parse( b, e, 
+        result = boost::spirit::parse( b, e,
                                        impl().grammar.use_parser<Impl::Grammar::PathParser>(),
                                        impl().grammar.use_parser<Impl::Grammar::SkipParser>() );
     }
@@ -453,7 +453,7 @@ prefix_ std::string::size_type
 senf::console::CommandParser::parseIncremental(std::string const & commands, Callback cb)
 {
     SetIncremental si (*this);
-    return std::distance( commands.begin(), 
+    return std::distance( commands.begin(),
                           parseLoop(commands.begin(), commands.end(), "<unknown>", cb) );
 }