summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/putil.cpp
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2019-09-17 21:05:01 +0200
committer couriersud <couriersud@gmx.org>2019-09-17 21:05:01 +0200
commit500ca5b8fc6cd17e224f154de0914e95f080f51e (patch)
tree8708ae27ba19ab8164bef760577ef269e11e631b /src/lib/netlist/plib/putil.cpp
parent4495c351139f13d46e087c448e3b2418491485e2 (diff)
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
Diffstat (limited to 'src/lib/netlist/plib/putil.cpp')
-rw-r--r--src/lib/netlist/plib/putil.cpp29
1 files changed, 7 insertions, 22 deletions
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 <algorithm>
-#include <cstdlib>
-#include <cstring>
+//#include <cstdlib>
+//#include <cstring>
#include <initializer_list>
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<std::size_t>(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<std::size_t>(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<std::size_t>(n)];