about summary refs log tree commit diff stats
path: root/003trace.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-07 15:49:40 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-07 15:49:40 -0700
commit05d177737c980aad2fcdb54765433e02021ab1e0 (patch)
tree3b146349a2674db7e585f396bfb5eb0062c4ccd9 /003trace.cc
parent0487a30e7078861ed7de42bdb21b5c71fb9b54a1 (diff)
downloadmu-05d177737c980aad2fcdb54765433e02021ab1e0.tar.gz
1299 - stop using [] in any vector
Useful check:

  $ grep "[^ '\"]\[[^\"]" *.cc \
    |perl -pwe 's/\Wargv\[|\WTests\[|\Wframe\[|\WMemory\[|\WName\[|\WSurrounding_space\[|\WRecipe\[|\WType\[|\WRecipe_number\[|\WType_number\[|\WBefore_fragments\[|\WAfter_fragments\[//g' \
    |perl -pwe 's/\Wargv\[|\WTests\[|\Wframe\[|\WMemory\[|\WName\[|\WSurrounding_space\[|\WRecipe\[|\WType\[|\WRecipe_number\[|\WType_number\[|\WBefore_fragments\[|\WAfter_fragments\[//g' \
    |grep '[^ ]\['
Diffstat (limited to '003trace.cc')
-rw-r--r--003trace.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/003trace.cc b/003trace.cc
index 77d51fc4..585ab413 100644
--- a/003trace.cc
+++ b/003trace.cc
@@ -215,12 +215,12 @@ void trace_all(const string& label, const list<string>& in) {
 bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expected) {  // missing layer == anywhere, frame, hierarchical layers
   vector<string> expected_lines = split(expected, "");
   index_t curr_expected_line = 0;
-  while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
+  while (curr_expected_line < expected_lines.size() && expected_lines.at(curr_expected_line).empty())
     ++curr_expected_line;
   if (curr_expected_line == expected_lines.size()) return true;
   Trace_stream->newline();
   string layer, frame, contents;
-  parse_layer_frame_contents(expected_lines[curr_expected_line], &layer, &frame, &contents);
+  parse_layer_frame_contents(expected_lines.at(curr_expected_line), &layer, &frame, &contents);
   for (vector<pair<string, pair<int, string> > >::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) {
     if (!layer.empty() && !prefix_match(layer, p->first))
       continue;
@@ -232,10 +232,10 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expecte
       continue;
 
     ++curr_expected_line;
-    while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
+    while (curr_expected_line < expected_lines.size() && expected_lines.at(curr_expected_line).empty())
       ++curr_expected_line;
     if (curr_expected_line == expected_lines.size()) return true;
-    parse_layer_frame_contents(expected_lines[curr_expected_line], &layer, &frame, &contents);
+    parse_layer_frame_contents(expected_lines.at(curr_expected_line), &layer, &frame, &contents);
   }
 
   ++Num_failures;
@@ -281,7 +281,7 @@ void parse_layer_and_frame(const string& orig, string* layer, string* frame) {
 bool check_trace_contents(string FUNCTION, string FILE, int LINE, string layer, string expected) {  // empty layer == everything, multiple layers, hierarchical layers
   vector<string> expected_lines = split(expected, "");
   index_t curr_expected_line = 0;
-  while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
+  while (curr_expected_line < expected_lines.size() && expected_lines.at(curr_expected_line).empty())
     ++curr_expected_line;
   if (curr_expected_line == expected_lines.size()) return true;
   Trace_stream->newline();
@@ -289,16 +289,16 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string layer,
   for (vector<pair<string, pair<int, string> > >::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) {
     if (!layer.empty() && !any_prefix_match(layers, p->first))
       continue;
-    if (p->second.second != expected_lines[curr_expected_line])
+    if (p->second.second != expected_lines.at(curr_expected_line))
       continue;
     ++curr_expected_line;
-    while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
+    while (curr_expected_line < expected_lines.size() && expected_lines.at(curr_expected_line).empty())
       ++curr_expected_line;
     if (curr_expected_line == expected_lines.size()) return true;
   }
 
   ++Num_failures;
-  cerr << "\nF " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << expected_lines[curr_expected_line] << "] in trace:\n";
+  cerr << "\nF " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << expected_lines.at(curr_expected_line) << "] in trace:\n";
   DUMP(layer);
   Passed = false;
   return false;
@@ -350,7 +350,7 @@ bool trace_doesnt_contain(string layer, string line) {
 
 bool trace_doesnt_contain(string expected) {
   vector<string> tmp = split(expected, ": ");
-  return trace_doesnt_contain(tmp[0], tmp[1]);
+  return trace_doesnt_contain(tmp.at(0), tmp.at(1));
 }
 
 bool trace_doesnt_contain(string layer, int frame, string line) {
@@ -380,7 +380,7 @@ struct lease_trace_frame {
 bool check_trace_contents(string FUNCTION, string FILE, int LINE, string layer, int frame, string expected) {  // multiple layers, hierarchical layers
   vector<string> expected_lines = split(expected, "");  // hack: doesn't handle newlines in embedded in lines
   index_t curr_expected_line = 0;
-  while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
+  while (curr_expected_line < expected_lines.size() && expected_lines.at(curr_expected_line).empty())
     ++curr_expected_line;
   if (curr_expected_line == expected_lines.size()) return true;
   Trace_stream->newline();
@@ -390,16 +390,16 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string layer,
       continue;
     if (p->second.first != frame)
       continue;
-    if (p->second.second != expected_lines[curr_expected_line])
+    if (p->second.second != expected_lines.at(curr_expected_line))
       continue;
     ++curr_expected_line;
-    while (curr_expected_line < expected_lines.size() && expected_lines[curr_expected_line].empty())
+    while (curr_expected_line < expected_lines.size() && expected_lines.at(curr_expected_line).empty())
       ++curr_expected_line;
     if (curr_expected_line == expected_lines.size()) return true;
   }
 
   ++Num_failures;
-  cerr << "\nF " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << expected_lines[curr_expected_line] << "] in trace/" << frame << ":\n";
+  cerr << "\nF " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << expected_lines.at(curr_expected_line) << "] in trace/" << frame << ":\n";
   DUMP(layer);
   Passed = false;
   return false;
@@ -426,7 +426,7 @@ vector<string> split(string s, string delim) {
 
 bool any_prefix_match(const vector<string>& pats, const string& needle) {
   if (pats.empty()) return false;
-  if (*pats[0].rbegin() != '/')
+  if (*pats.at(0).rbegin() != '/')
     // prefix match not requested
     return find(pats.begin(), pats.end(), needle) != pats.end();
   // first pat ends in a '/'; assume all pats do.