From b380514764cf857469bae61c11143a19f79a74c5 Mon Sep 17 00:00:00 2001 From: andreasnaive Date: Mon, 25 Mar 2019 23:13:40 +0100 Subject: Revert "conflict resolution (nw)" This reverts commit c24473ddff715ecec2e258a6eb38960cf8c8e98e, reversing changes made to 009cba4fb8102102168ef32870892438327f3705. --- src/lib/netlist/plib/putil.cpp | 75 +++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 41 deletions(-) (limited to 'src/lib/netlist/plib/putil.cpp') diff --git a/src/lib/netlist/plib/putil.cpp b/src/lib/netlist/plib/putil.cpp index b62cbf60865..c34102417ec 100644 --- a/src/lib/netlist/plib/putil.cpp +++ b/src/lib/netlist/plib/putil.cpp @@ -2,13 +2,13 @@ // copyright-holders:Couriersud #include "putil.h" -#include "plists.h" #include "ptypes.h" +#include "plists.h" -#include #include -#include +#include #include +#include namespace plib { @@ -17,7 +17,7 @@ namespace plib const pstring buildpath(std::initializer_list list ) { pstring ret = ""; - for( const auto &elem : list ) + for( auto elem : list ) { if (ret == "") ret = elem; @@ -33,12 +33,12 @@ namespace plib const pstring environment(const pstring &var, const pstring &default_val) { - if (std::getenv(var.c_str()) == nullptr) + if (getenv(var.c_str()) == nullptr) return default_val; else - return pstring(std::getenv(var.c_str())); + return pstring(getenv(var.c_str()), pstring::UTF8); } - } // namespace util + } std::vector psplit(const pstring &str, const pstring &onstr, bool ignore_empty) { @@ -64,36 +64,6 @@ namespace plib return ret; } - std::vector psplit_r(const std::string &stri, - const std::string &token, - const std::size_t maxsplit) - { - std::string str(stri); - std::vector result; - std::size_t splits = 0; - - while(str.size()) - { - std::size_t index = str.rfind(token); - bool found = index!=std::string::npos; - if (found) - splits++; - if ((splits <= maxsplit || maxsplit == 0) && found) - { - result.push_back(str.substr(index+token.size())); - str = str.substr(0, index); - if (str.size()==0) - result.push_back(str); - } - else - { - result.push_back(str); - str = ""; - } - } - return result; - } - std::vector psplit(const pstring &str, const std::vector &onstrl) { pstring col = ""; @@ -102,7 +72,7 @@ namespace plib auto i = str.begin(); while (i != str.end()) { - auto p = static_cast(-1); + std::size_t p = static_cast(-1); for (std::size_t j=0; j < onstrl.size(); j++) { if (std::equal(onstrl[j].begin(), onstrl[j].end(), i)) @@ -122,7 +92,7 @@ namespace plib } else { - pstring::value_type c = *i; + pstring::code_t c = *i; col += c; i++; } @@ -161,8 +131,31 @@ namespace plib return cnt; return -1; } - std::string penum_base::nthstr(int n, const char *str) + pstring penum_base::nthstr(int n, const char *str) { - return psplit(str, ",", false)[static_cast(n)]; + char buf[64]; + char *bufp = buf; + int cur = 0; + while (*str) + { + if (cur == n) + { + if (*str == ',') + { + *bufp = 0; + return pstring(buf, pstring::UTF8); + } + else if (*str != ' ') + *bufp++ = *str; + } + else + { + if (*str == ',') + cur++; + } + str++; + } + *bufp = 0; + return pstring(buf, pstring::UTF8); } } // namespace plib -- cgit v1.2.3-70-g09d2