about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-12 23:29:34 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-12 23:29:34 -0700
commitd03028a3035fc514a694a89dcec9429625c9217c (patch)
tree3e375c345803e175fe390d0124a0084b834423b7 /cpp
parent0f996b7ba88f988e961a644bb85e3e3b5afe4a41 (diff)
downloadmu-d03028a3035fc514a694a89dcec9429625c9217c.tar.gz
1057
Diffstat (limited to 'cpp')
-rw-r--r--cpp/002trace13
-rw-r--r--cpp/002trace.tests5
2 files changed, 10 insertions, 8 deletions
diff --git a/cpp/002trace b/cpp/002trace
index 3a25502f..2e906b29 100644
--- a/cpp/002trace
+++ b/cpp/002trace
@@ -111,10 +111,12 @@ struct trace_stream {
   // be sure to call this before messing with curr_stream or curr_layer or frame
   void newline() {
     if (!curr_stream) return;
-    past_lines.push_back(pair<string, pair<int, string> >(curr_layer, pair<int, string>(frame[curr_layer], curr_stream->str())));
+    string curr_contents = curr_stream->str();
+    curr_contents.erase(curr_contents.find_last_not_of("\r\n")+1);
+    past_lines.push_back(pair<string, pair<int, string> >(curr_layer, pair<int, string>(frame[curr_layer], curr_contents)));
     if (curr_layer == dump_layer || curr_layer == "dump" || dump_layer == "all" ||
         (!Hide_warnings && curr_layer == "warn"))
-      cerr << curr_layer << '/' << frame[curr_layer] << ": " << with_newline(curr_stream->str());
+      cerr << curr_layer << '/' << frame[curr_layer] << ": " << curr_contents << '\n';
     delete curr_stream;
     curr_stream = NULL;
   }
@@ -127,7 +129,7 @@ struct trace_stream {
     parse_layer_and_frame(layer, &real_layer, &frame);
     for (vector<pair<string, pair<int, string> > >::iterator p = past_lines.begin(); p != past_lines.end(); ++p)
       if (layer.empty() || prefix_match(real_layer, p->first))
-        output << p->first << "/" << p->second.first << ": " << with_newline(p->second.second);
+        output << p->first << "/" << p->second.first << ": " << p->second.second << '\n';
     return output.str();
   }
 
@@ -145,11 +147,6 @@ struct trace_stream {
     }
     dump.close();
   }
-
-  string with_newline(string s) {
-    if (s[s.size()-1] != '\n') return s+'\n';
-    return s;
-  }
 };
 
 
diff --git a/cpp/002trace.tests b/cpp/002trace.tests
index 00705346..0acf8807 100644
--- a/cpp/002trace.tests
+++ b/cpp/002trace.tests
@@ -16,6 +16,11 @@ void test_trace_check_ignores_other_lines() {
   CHECK_TRACE_CONTENTS("test layer 1", "foo");
 }
 
+void test_trace_ignores_trailing_whitespace() {
+  trace("test layer 1") << "foo\n";
+  CHECK_TRACE_CONTENTS("test layer 1", "foo");
+}
+
 void test_trace_check_always_finds_empty_lines() {
   CHECK_TRACE_CONTENTS("test layer 1", "");
 }
;id=614ea44bc2708a687ba10b162a6dc70e48dfac59'>614ea44b ^
13ba3def ^











614ea44b ^
13ba3def ^








96db91f8 ^

e4630643 ^

aa088845 ^
48e40252 ^














614ea44b ^
de92036d ^
13ba3def ^

5aa38b52 ^
13ba3def ^
fc4a98dc ^

13ba3def ^
35064671 ^
13ba3def ^

5aa38b52 ^






5c7ed3d6 ^





5aa38b52 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107