Repository: trafficserver Updated Branches: refs/heads/master 97068fb84 -> adae7cd16
TS-3068: Remove usage of Boost Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/adae7cd1 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/adae7cd1 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/adae7cd1 Branch: refs/heads/master Commit: adae7cd1603e52950832b72aa17d52c8146faead Parents: 97068fb Author: Phil Sorber <[email protected]> Authored: Tue Sep 9 13:51:22 2014 -0600 Committer: Phil Sorber <[email protected]> Committed: Thu Oct 2 13:21:38 2014 -0600 ---------------------------------------------------------------------- CHANGES | 2 + build/ax_boost_base.m4 | 258 -------------------------- configure.ac | 7 - lib/tsconfig/Errata.cc | 38 ---- lib/tsconfig/Errata.h | 69 ------- plugins/header_rewrite/Makefile.am | 8 +- plugins/header_rewrite/conditions.cc | 9 +- plugins/header_rewrite/conditions.h | 1 - plugins/header_rewrite/header_rewrite.cc | 10 +- plugins/header_rewrite/parser.cc | 50 +++-- 10 files changed, 55 insertions(+), 397 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/adae7cd1/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index af2c24d..c21cedc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ -*- coding: utf-8 -*- Changes with Apache Traffic Server 5.2.0 + *) [TS=3068] Remove usage of Boost. + *) [TS-2289] Removed old unused AIO modes. *) [TS-3098] Fix the ability to configure keep-alive on post to the origin http://git-wip-us.apache.org/repos/asf/trafficserver/blob/adae7cd1/build/ax_boost_base.m4 ---------------------------------------------------------------------- diff --git a/build/ax_boost_base.m4 b/build/ax_boost_base.m4 deleted file mode 100644 index 54a2a1b..0000000 --- a/build/ax_boost_base.m4 +++ /dev/null @@ -1,258 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_boost_base.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# DESCRIPTION -# -# Test for the Boost C++ libraries of a particular version (or newer) -# -# If no path to the installed boost library is given the macro searchs -# under /usr, /usr/local, /opt and /opt/local and evaluates the -# $BOOST_ROOT environment variable. Further documentation is available at -# <http://randspringer.de/boost/index.html>. -# -# This macro calls: -# -# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS) -# -# And sets: -# -# HAVE_BOOST -# -# LICENSE -# -# Copyright (c) 2008 Thomas Porschberg <[email protected]> -# Copyright (c) 2009 Peter Adolphs -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 20 - -AC_DEFUN([AX_BOOST_BASE], -[ -AC_ARG_WITH([boost], - [AS_HELP_STRING([--with-boost@<:@=ARG@:>@], - [use Boost library from a standard location (ARG=yes), - from the specified location (ARG=<path>), - or disable it (ARG=no) - @<:@ARG=yes@:>@ ])], - [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then - want_boost="yes" - ac_boost_path="" - else - want_boost="yes" - ac_boost_path="$withval" - fi - ], - [want_boost="yes"]) - - -AC_ARG_WITH([boost-libdir], - AS_HELP_STRING([--with-boost-libdir=LIB_DIR], - [Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]), - [ - if test -d "$withval" - then - ac_boost_lib_path="$withval" - else - AC_MSG_ERROR(--with-boost-libdir expected directory name) - fi - ], - [ac_boost_lib_path=""] -) - -if test "x$want_boost" = "xyes"; then - boost_lib_version_req=ifelse([$1], ,1.20.0,$1) - boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` - boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` - boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` - boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` - if test "x$boost_lib_version_req_sub_minor" = "x" ; then - boost_lib_version_req_sub_minor="0" - fi - WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` - AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req) - succeeded=no - - dnl On 64-bit systems check for system libraries in both lib64 and lib. - dnl The former is specified by FHS, but e.g. Debian does not adhere to - dnl this (as it rises problems for generic multi-arch support). - dnl The last entry in the list is chosen by default when no libraries - dnl are found, e.g. when only header-only libraries are installed! - libsubdirs="lib" - ax_arch=`uname -m` - if test $ax_arch = x86_64 -o $ax_arch = ppc64 -o $ax_arch = s390x -o $ax_arch = sparc64; then - libsubdirs="lib64 lib lib64" - fi - - dnl first we check the system location for boost libraries - dnl this location ist chosen if boost libraries are installed with the --layout=system option - dnl or if you install boost with RPM - if test "$ac_boost_path" != ""; then - BOOST_CPPFLAGS="-I$ac_boost_path/include" - for ac_boost_path_tmp in $libsubdirs; do - if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then - BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp" - break - fi - done - elif test "$cross_compiling" != yes; then - for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do - if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then - for libsubdir in $libsubdirs ; do - if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi - done - BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir" - BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" - break; - fi - done - fi - - dnl overwrite ld flags if we have required special directory with - dnl --with-boost-libdir parameter - if test "$ac_boost_lib_path" != ""; then - BOOST_LDFLAGS="-L$ac_boost_lib_path" - fi - - CPPFLAGS_SAVED="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - - LDFLAGS_SAVED="$LDFLAGS" - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_REQUIRE([AC_PROG_CXX]) - AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include <boost/version.hpp> - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ - AC_MSG_RESULT(yes) - succeeded=yes - found_system=yes - ],[ - ]) - AC_LANG_POP([C++]) - - - - dnl if we found no boost with system layout we search for boost libraries - dnl built and installed without the --layout=system option or for a staged(not installed) version - if test "x$succeeded" != "xyes"; then - _version=0 - if test "$ac_boost_path" != ""; then - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` - V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then - _version=$_version_tmp - fi - VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` - BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" - done - fi - else - if test "$cross_compiling" != yes; then - for ac_boost_path in /usr /usr/local /opt /opt/local ; do - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` - V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then - _version=$_version_tmp - best_path=$ac_boost_path - fi - done - fi - done - - VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` - BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" - if test "$ac_boost_lib_path" = ""; then - for libsubdir in $libsubdirs ; do - if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi - done - BOOST_LDFLAGS="-L$best_path/$libsubdir" - fi - fi - - if test "x$BOOST_ROOT" != "x"; then - for libsubdir in $libsubdirs ; do - if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi - done - if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then - version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'` - stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` - stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` - V_CHECK=`expr $stage_version_shorten \>\= $_version` - if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then - AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) - BOOST_CPPFLAGS="-I$BOOST_ROOT" - BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir" - fi - fi - fi - fi - - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include <boost/version.hpp> - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ - AC_MSG_RESULT(yes) - succeeded=yes - found_system=yes - ],[ - ]) - AC_LANG_POP([C++]) - fi - - if test "$succeeded" != "yes" ; then - if test "$_version" = "0" ; then - AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]]) - else - AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).]) - fi - # execute ACTION-IF-NOT-FOUND (if present): - ifelse([$3], , :, [$3]) - else - AC_SUBST(BOOST_CPPFLAGS) - AC_SUBST(BOOST_LDFLAGS) - AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) - # execute ACTION-IF-FOUND (if present): - ifelse([$2], , :, [$2]) - fi - - CPPFLAGS="$CPPFLAGS_SAVED" - LDFLAGS="$LDFLAGS_SAVED" -fi - -]) http://git-wip-us.apache.org/repos/asf/trafficserver/blob/adae7cd1/configure.ac ---------------------------------------------------------------------- diff --git a/configure.ac b/configure.ac index da6c85f..3c30f2f 100644 --- a/configure.ac +++ b/configure.ac @@ -1107,13 +1107,6 @@ AX_LIB_CURL([7.19], [ ) # -# The header_rewrite module depends on boost. -AX_BOOST_BASE([1.33], - [ AM_CONDITIONAL([BUILD_HAVE_BOOST], [true]) ], - [ AM_CONDITIONAL([BUILD_HAVE_BOOST], [false]) ] -) - -# # Check for SSL presence and usability TS_CHECK_CRYPTO http://git-wip-us.apache.org/repos/asf/trafficserver/blob/adae7cd1/lib/tsconfig/Errata.cc ---------------------------------------------------------------------- diff --git a/lib/tsconfig/Errata.cc b/lib/tsconfig/Errata.cc index a3035f3..a4733a7 100644 --- a/lib/tsconfig/Errata.cc +++ b/lib/tsconfig/Errata.cc @@ -255,43 +255,5 @@ std::ostream& operator<< (std::ostream& os, Errata const& err) { return err.write(os, 0, 0, 2, "> "); } -# if USING_BOOST - -std::ostream& -errata::format(std::ostream& s, std::string const& fmt, std::string const& glue) const { - return this->format(s, boost::format(fmt), glue); -} - -std::ostream& -errata::format(std::ostream& s, boost::format const& fmt, std::string const& glue) const { - if (_data) { - bool inside = false; - boost::format f(fmt); - f.exceptions(boost::io::all_error_bits ^ boost::io::too_many_args_bit); - const_iterator spot(this->begin()), limit(this->end()); - while (spot != limit) { - if (inside) s << glue; - s << ( f % spot->_id % spot->_text ); - inside = true; - ++spot; - } - } - return s; -} - -std::string -errata::format(std::string const& fmt, std::string const& glue) const { - return this->format(boost::format(fmt), glue); -} - -std::string -errata::format(boost::format const& fmt, std::string const& glue) const { - std::ostringstream s; - this->format(s, fmt, glue); - return s.str(); -} - -# endif - } // namespace ts http://git-wip-us.apache.org/repos/asf/trafficserver/blob/adae7cd1/lib/tsconfig/Errata.h ---------------------------------------------------------------------- diff --git a/lib/tsconfig/Errata.h b/lib/tsconfig/Errata.h index 6f56a7d..2861503 100644 --- a/lib/tsconfig/Errata.h +++ b/lib/tsconfig/Errata.h @@ -72,11 +72,6 @@ # include "NumericType.h" # include "IntrusivePtr.h" -# if USING_BOOST -# include <boost/function.hpp> -# include <boost/format/format_fwd.hpp> -# endif - namespace ts { /** Class to hold a stack of error messages (the "errata"). @@ -336,70 +331,6 @@ public: char const* lead ///< Leading text for nested @c Errata. ) const; -# if USING_BOOST - /// Functor type for sink. - typedef boost::function<void (Errata const&)> SinkFunctor; - - // Wrapper class to support registering functions as sinks. - struct SinkFunctorWrapper : public Sink { - /// Constructor. - SinkFunctionWrapper(SinkHandlerFunctor f) : m_f(f) { } - /// Operator to invoke the function. - virtual void operator() (Errata const& e) const { m_f(e); } - SinkHandlerFunctor m_f; ///< Client supplied handler. - }; - - /// Register a sink function for abandonded erratum. - static void registerSink(SinkFunctor const& f) { - registerSink(Sink::Handle(new SinkFunctorWrapper(f))); - } - - /// Generate formatted output. - /// For each message in the stack, invoke @c boost::format passing - /// @a fmt as the format string and the message ID and message text as - /// two values. It is not an error to elide either or both. @a glue is - /// sent to the stream @a s between every pair of messages. - /// @return The stream @a s. - std::ostream& format( - std::ostream& s, ///< Output stream - boost::format const& fmt, ///< Format string - std::string const& glue = DEFAULT_GLUE ///< Glue - ) const; - - /// Generate formatted output. - /// A convenience overload so clients do not have to include the Boost.Format headers. - /// @return The formatted output. - /// @see std::ostream& format ( std::ostream& s, boost::format const& fmt, std::string const& glue ). - std::ostream& format( - std::ostream& s, ///< Output stream - std::string const& fmt, ///< Format string - std::string const& glue = DEFAULT_GLUE ///< Glue - ) const; - - /// Generate formatted output. - /// For each message in the stack, invoke @c boost::format passing - /// @a fmt as the format string and the message ID and message text as - /// two values. It is not an error to elide either or both. @a glue is - /// added between every pair of messages. - /// @note This is identical to the stream variant except the output - /// is put in a string instead of a stream. - /// @return The formatted output. - /// @see std::ostream& format ( std::ostream& s, boost::format const& fmt, std::string const& glue ). - std::string format( - boost::format const& fmt, ///< Format string - std::string const& glue = DEFAULT_GLUE ///< Glue - ) const; - - /// Generate formatted output. - /// A convenience overload so clients do not have to include the Boost.Format headers. - /// @return The formatted output. - /// @see std::string format ( boost::format const& fmt, std::string const& glue ). - std::string format( - std::string const& fmt, ///< Format string - std::string const& glue = DEFAULT_GLUE ///< Glue - ) const; -# endif // USING_BOOST - protected: /// Construct from implementation pointer. /// Used internally by nested classes. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/adae7cd1/plugins/header_rewrite/Makefile.am ---------------------------------------------------------------------- diff --git a/plugins/header_rewrite/Makefile.am b/plugins/header_rewrite/Makefile.am index 4ba0875..4a6ca58 100644 --- a/plugins/header_rewrite/Makefile.am +++ b/plugins/header_rewrite/Makefile.am @@ -16,10 +16,6 @@ include $(top_srcdir)/build/plugins.mk -if BUILD_HAVE_BOOST - -AM_CPPFLAGS += $(BOOST_CPPFLAGS) - pkglib_LTLIBRARIES = header_rewrite.la header_rewrite_la_SOURCES = \ condition.cc \ @@ -37,6 +33,4 @@ header_rewrite_la_SOURCES = \ ruleset.cc \ statement.cc -header_rewrite_la_LDFLAGS = $(BOOST_LDFLAGS) $(TS_PLUGIN_LDFLAGS) - -endif +header_rewrite_la_LDFLAGS = $(TS_PLUGIN_LDFLAGS) http://git-wip-us.apache.org/repos/asf/trafficserver/blob/adae7cd1/plugins/header_rewrite/conditions.cc ---------------------------------------------------------------------- diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc index 6bc97fa..0f78ace 100644 --- a/plugins/header_rewrite/conditions.cc +++ b/plugins/header_rewrite/conditions.cc @@ -22,6 +22,7 @@ #include <sys/time.h> #include <unistd.h> #include <arpa/inet.h> +#include <sstream> #include "ts/ts.h" @@ -64,7 +65,9 @@ ConditionStatus::eval(const Resources& res) void ConditionStatus::append_value(std::string& s, const Resources& res) { - s += boost::lexical_cast<std::string>(res.resp_status); + std::ostringstream oss; + oss << res.resp_status; + s += oss.str(); TSDebug(PLUGIN_NAME, "Appending STATUS(%d) to evaluation value -> %s", res.resp_status, s.c_str()); } @@ -99,7 +102,9 @@ ConditionRandom::eval(const Resources& /* res ATS_UNUSED */) void ConditionRandom::append_value(std::string& s, const Resources& /* res ATS_UNUSED */) { - s += boost::lexical_cast<std::string>(rand_r(&_seed) % _max); + std::ostringstream oss; + oss << rand_r(&_seed) % _max; + s += oss.str(); TSDebug(PLUGIN_NAME, "Appending RANDOM(%d) to evaluation value -> %s", _max, s.c_str()); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/adae7cd1/plugins/header_rewrite/conditions.h ---------------------------------------------------------------------- diff --git a/plugins/header_rewrite/conditions.h b/plugins/header_rewrite/conditions.h index 55e0106..0b76f42 100644 --- a/plugins/header_rewrite/conditions.h +++ b/plugins/header_rewrite/conditions.h @@ -23,7 +23,6 @@ #define __CONDITIONS_H__ 1 #include <string> -#include <boost/lexical_cast.hpp> #include <cstring> #include "ts/ts.h" http://git-wip-us.apache.org/repos/asf/trafficserver/blob/adae7cd1/plugins/header_rewrite/header_rewrite.cc ---------------------------------------------------------------------- diff --git a/plugins/header_rewrite/header_rewrite.cc b/plugins/header_rewrite/header_rewrite.cc index bb40398..1202545 100644 --- a/plugins/header_rewrite/header_rewrite.cc +++ b/plugins/header_rewrite/header_rewrite.cc @@ -17,7 +17,6 @@ */ #include <fstream> #include <string> -#include <boost/algorithm/string.hpp> #include "ts/ts.h" #include "ts/remap.h" @@ -152,7 +151,14 @@ RulesConfig::parse_config(const std::string fname, TSHttpHookID default_hook) ++lineno; // ToDo: we should probably use this for error messages ... TSDebug(PLUGIN_NAME_DBG, "Reading line: %d: %s", lineno, line.c_str()); - boost::trim(line); + while (std::isspace(line[0])) { + line.erase(0, 1); + } + + while (std::isspace(line[line.length() - 1])) { + line.erase(line.length() - 1, 1); + } + if (line.empty() || (line[0] == '#')) { continue; } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/adae7cd1/plugins/header_rewrite/parser.cc ---------------------------------------------------------------------- diff --git a/plugins/header_rewrite/parser.cc b/plugins/header_rewrite/parser.cc index a50e438..d85d0a4 100644 --- a/plugins/header_rewrite/parser.cc +++ b/plugins/header_rewrite/parser.cc @@ -20,17 +20,14 @@ // // #include <utility> -#include <boost/tokenizer.hpp> +#include <iostream> +#include <string> +#include <sstream> #include "ts/ts.h" #include "parser.h" -// Tokenizer separators -static boost::escaped_list_separator<char> token_sep('\\', ' ', '\"'); -static boost::char_separator<char> comma_sep(","); - - // This is the core "parser", parsing rule sets void Parser::preprocess(std::vector<std::string>& tokens) @@ -80,8 +77,11 @@ Parser::preprocess(std::vector<std::string>& tokens) if (m[m.size() - 1] == ']') { m = m.substr(1, m.size() - 2); if (m.find_first_of(',') != std::string::npos) { - boost::tokenizer<boost::char_separator<char> > mods(m, comma_sep); - std::copy(mods.begin(), mods.end(), std::back_inserter(_mods)); + std::istringstream iss(m); + std::string t; + while(getline(iss, t, ',')) { + _mods.push_back(t); + } } else { _mods.push_back(m); } @@ -103,13 +103,37 @@ Parser::Parser(const std::string& line) : if (line[0] == '#') { _empty = true; } else { - boost::tokenizer<boost::escaped_list_separator<char> > elem(line, token_sep); + std::string tmp = line; std::vector<std::string> tokens; + bool in_quotes = false; + int t = 0; + + for (unsigned int i = 0; i < tmp.size(); i++) { + if (tmp[i] == '\\') { + tmp.erase(i,1); + i++; + } + + if (tmp[i] == '\"') { + tmp.erase(i,1); + + if (in_quotes) { + in_quotes = false; + } else { + in_quotes = true; + } + } - for (boost::tokenizer<boost::escaped_list_separator<char> >::iterator it = elem.begin(); it != elem.end(); it++) { - // Skip "empty" tokens (tokenizer is a little brain dead IMO) - if ((*it) != "") - tokens.push_back(*it); + if ((tmp[i] == ' ' || i >= tmp.size() - 1) && !in_quotes) { + if (i == tmp.size() - 1) { + i++; + } + std::string s = tmp.substr(t, i - t); + t = i + 1; + if (s.size() > 0) { + tokens.push_back(s); + } + } } if (tokens.empty()) {
