about summary refs log tree commit diff stats
path: root/003trace.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-09-12 14:39:20 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-09-12 14:39:20 -0700
commit7be15b8b4ac500face0c01294cad28c489dfcfbf (patch)
tree06284ec0a987efd6d7cfc8e87d2f2ec0e5481d4e /003trace.cc
parentfa94f4d92340f001560b16dd0c2e5681ca5db031 (diff)
downloadmu-7be15b8b4ac500face0c01294cad28c489dfcfbf.tar.gz
2184 - bugfix in trace_count
It was reading lines like this in scenarios:

  -warn: f: error error

as:

  -warn: f

which was causing them to be silently ignored.

Also found an insane preprocessor expansion from not parenthesizing
preprocessor arguments. SIZE(end+delim) worked even when end was an
integer, but it happily didn't ever get the wrong answer.
Diffstat (limited to '003trace.cc')
-rw-r--r--003trace.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/003trace.cc b/003trace.cc
index 4426bbd3..00764d4f 100644
--- a/003trace.cc
+++ b/003trace.cc
@@ -278,7 +278,7 @@ bool trace_doesnt_contain(string layer, string line) {
 }
 
 bool trace_doesnt_contain(string expected) {
-  vector<string> tmp = split(expected, ": ");
+  vector<string> tmp = split_first(expected, ": ");
   return trace_doesnt_contain(tmp.at(0), tmp.at(1));
 }
 
@@ -295,12 +295,21 @@ vector<string> split(string s, string delim) {
       break;
     }
     result.push_back(string(s, begin, end-begin));
-    begin = SIZE(end+delim);
+    begin = end+SIZE(delim);
     end = s.find(delim, begin);
   }
   return result;
 }
 
+vector<string> split_first(string s, string delim) {
+  vector<string> result;
+  size_t end=s.find(delim);
+  result.push_back(string(s, 0, end));
+  if (end != string::npos)
+    result.push_back(string(s, end+SIZE(delim), string::npos));
+  return result;
+}
+
 string trim(const string& s) {
   string::const_iterator first = s.begin();
   while (first != s.end() && isspace(*first))