From 2707930a0c1a2f4642a0f9371b6674d0b23d1b67 Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Thu, 12 Nov 2009 13:18:27 +0100 Subject: Factored ParseArg --- lib/Utils/stringops.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lib/Utils/stringops.cpp (limited to 'lib/Utils/stringops.cpp') diff --git a/lib/Utils/stringops.cpp b/lib/Utils/stringops.cpp new file mode 100644 index 00000000..2304accc --- /dev/null +++ b/lib/Utils/stringops.cpp @@ -0,0 +1,32 @@ +#include "abrtlib.h" + +void parse_args(const char *psArgs, vector_string_t& pArgs, const char quote) +{ + unsigned ii; + bool is_quote = false; + std::string item; + + for (ii = 0; psArgs[ii]; ii++) + { + if (quote != -1 && psArgs[ii] == quote) + { + is_quote = !is_quote; + } + else if (psArgs[ii] == ',' && !is_quote) + { + printf("%s\n", item.c_str()); + pArgs.push_back(item); + item.clear(); + } + else + { + item += psArgs[ii]; + } + } + + if (item.size() != 0) + { + printf("%s\n", item.c_str()); + pArgs.push_back(item); + } +} -- cgit From 24830077af36c8e681d95f7d3f4867441174480f Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Thu, 12 Nov 2009 14:03:11 +0100 Subject: forgot erase debug information for me --- lib/Utils/stringops.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/Utils/stringops.cpp') diff --git a/lib/Utils/stringops.cpp b/lib/Utils/stringops.cpp index 2304accc..73084fc1 100644 --- a/lib/Utils/stringops.cpp +++ b/lib/Utils/stringops.cpp @@ -14,7 +14,6 @@ void parse_args(const char *psArgs, vector_string_t& pArgs, const char quote) } else if (psArgs[ii] == ',' && !is_quote) { - printf("%s\n", item.c_str()); pArgs.push_back(item); item.clear(); } @@ -26,7 +25,6 @@ void parse_args(const char *psArgs, vector_string_t& pArgs, const char quote) if (item.size() != 0) { - printf("%s\n", item.c_str()); pArgs.push_back(item); } } -- cgit