diff options
author | 2016-07-21 11:05:55 +0200 | |
---|---|---|
committer | 2016-07-21 11:05:55 +0200 | |
commit | 1e40d95e8b47d834d1ede706921dc19850aaaff2 (patch) | |
tree | f2e74d4451a527313fdc52f49b10955153f1dbd5 /src/lib/netlist/plib/putil.cpp | |
parent | 7a69d48edd6e1f59c92271eb7fa217eaf0a714c7 (diff) |
Netlist updates:
- Removed trampolines (OUTLOGIC, INPLOGIC and friends).
- Started using doxygen comment and documentation style. Added doxygen
files to documentation folder.
- Refactored code triggered by doxygen output.
- Moved internal and support classes into namespace detail.
- Use an anordered map in parser.
- -Wconversion fixes - All done now.
- Fixed -Wold-style-cast warnings in netlist code.
- Added iterators to pstring.
- Moved two macros, added more RAII and improved exceptions. Fixed some
bugs in parser code.
- Fixed a number of bugs in parser code and exception handling.
[Couriersud]
Diffstat (limited to 'src/lib/netlist/plib/putil.cpp')
-rw-r--r-- | src/lib/netlist/plib/putil.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/lib/netlist/plib/putil.cpp b/src/lib/netlist/plib/putil.cpp index e8951d05aa9..f3f9b4c15ea 100644 --- a/src/lib/netlist/plib/putil.cpp +++ b/src/lib/netlist/plib/putil.cpp @@ -43,21 +43,20 @@ namespace plib pstring_vector_t::pstring_vector_t(const pstring &str, const pstring &onstr, bool ignore_empty) : std::vector<pstring>() { - int p = 0; - int pn; + pstring::iterator p = str.begin(); + pstring::iterator pn = str.find(onstr, p); - pn = str.find(onstr, p); - while (pn>=0) + while (pn != str.end()) { - pstring t = str.substr(p, pn - p); + pstring t = str.substr(p, pn); if (!ignore_empty || t.len() != 0) this->push_back(t); p = pn + onstr.len(); pn = str.find(onstr, p); } - if (p < (int) str.len()) + if (p != str.end()) { - pstring t = str.substr(p); + pstring t = str.substr(p, str.end()); if (!ignore_empty || t.len() != 0) this->push_back(t); } @@ -71,7 +70,7 @@ namespace plib unsigned i = 0; while (i<str.blen()) { - int p = -1; + std::size_t p = static_cast<std::size_t>(-1); for (std::size_t j=0; j < onstrl.size(); j++) { if (std::memcmp(onstrl[j].cstr(), &(str.cstr()[i]), onstrl[j].blen())==0) @@ -80,7 +79,7 @@ namespace plib break; } } - if (p>=0) + if (p != static_cast<std::size_t>(-1)) { if (col != "") this->push_back(col); @@ -105,13 +104,13 @@ namespace plib { int cnt = 0; const char *cur = str; - int lx = strlen(x); + std::size_t lx = strlen(x); while (*str) { if (*str == ',') { - int l = str-cur; - if (l == lx) + std::ptrdiff_t l = str-cur; + if (static_cast<std::size_t>(l) == lx) if (strncmp(cur, x, lx) == 0) return cnt; } @@ -122,8 +121,8 @@ namespace plib } str++; } - int l = str-cur; - if (l == lx) + std::ptrdiff_t l = str-cur; + if (static_cast<std::size_t>(l) == lx) if (strncmp(cur, x, lx) == 0) return cnt; return -1; |