From 500ca5b8fc6cd17e224f154de0914e95f080f51e Mon Sep 17 00:00:00 2001 From: couriersud Date: Tue, 17 Sep 2019 21:05:01 +0200 Subject: netlist code maintenance. (nw) - remove a lot of c library use and instead use c++ - improved pstring compatibility to std::string - prepare removal of pstream --- src/lib/netlist/plib/putil.cpp | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 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..fd5ab040cca 100644 --- a/src/lib/netlist/plib/putil.cpp +++ b/src/lib/netlist/plib/putil.cpp @@ -6,8 +6,8 @@ #include "ptypes.h" #include -#include -#include +//#include +//#include #include namespace plib @@ -137,30 +137,15 @@ namespace plib int penum_base::from_string_int(const char *str, const char *x) { int cnt = 0; - const char *cur = str; - std::size_t lx = strlen(x); - while (*str) + for (auto s : psplit(str, ",", false)) { - if (*str == ',') - { - std::ptrdiff_t l = str-cur; - if (static_cast(l) == lx) - if (strncmp(cur, x, lx) == 0) - return cnt; - } - else if (*str == ' ') - { - cur = str + 1; - cnt++; - } - str++; - } - std::ptrdiff_t l = str-cur; - if (static_cast(l) == lx) - if (strncmp(cur, x, lx) == 0) + if (s == x) return cnt; + cnt++; + } return -1; } + std::string penum_base::nthstr(int n, const char *str) { return psplit(str, ",", false)[static_cast(n)]; -- cgit v1.2.3-70-g09d2