From 1e40d95e8b47d834d1ede706921dc19850aaaff2 Mon Sep 17 00:00:00 2001 From: couriersud Date: Thu, 21 Jul 2016 11:05:55 +0200 Subject: 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] --- src/lib/netlist/plib/putil.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 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 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() { - 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(-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(-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(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(l) == lx) if (strncmp(cur, x, lx) == 0) return cnt; return -1; -- cgit v1.2.3-70-g09d2