Skip to content

Commit bfeb05a

Browse files
committed
csparser: preserve events with unknown location
1 parent 8f77d0e commit bfeb05a

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

csparser.cc

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class LineReader {
3636
input_(input),
3737
lineNo_(0),
3838
reTrailLoc_("^(path:|/).*(:[0-9]+|<.*>):$"),
39-
rePathPref_("^path:"),
40-
reUnkownLoc_("^<unknown>")
39+
rePathPref_("^path:")
4140
{
4241
}
4342

@@ -52,7 +51,6 @@ class LineReader {
5251
int lineNo_;
5352
const boost::regex reTrailLoc_;
5453
const boost::regex rePathPref_;
55-
const boost::regex reUnkownLoc_;
5654

5755
bool getLinePriv(std::string *pDst);
5856
};
@@ -66,24 +64,21 @@ bool LineReader::getLinePriv(std::string *pDst) {
6664
}
6765

6866
bool LineReader::getLine(std::string *pDst) {
69-
do {
70-
std::string line;
71-
if (!this->getLinePriv(&line))
72-
return false;
73-
74-
std::string nextLine;
75-
while (boost::regex_search(line, reTrailLoc_)
76-
&& this->getLinePriv(&nextLine))
77-
{
78-
// merge the current line with the next line
79-
nextLine.insert(/* pos */ 0U, " ");
80-
line += nextLine;
81-
}
67+
std::string line;
68+
if (!this->getLinePriv(&line))
69+
return false;
8270

83-
// remove the "path:" prefix if matched
84-
*pDst = boost::regex_replace(line, rePathPref_, "");
71+
std::string nextLine;
72+
while (boost::regex_search(line, reTrailLoc_)
73+
&& this->getLinePriv(&nextLine))
74+
{
75+
// merge the current line with the next line
76+
nextLine.insert(/* pos */ 0U, " ");
77+
line += nextLine;
8578
}
86-
while (boost::regex_search(*pDst, reUnkownLoc_));
79+
80+
// remove the "path:" prefix if matched
81+
*pDst = boost::regex_replace(line, rePathPref_, "");
8782

8883
return true;
8984
}

tests/csgrep/27-cov-format-errors-stdout.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Error: RESOURCE_LEAK:
1919
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:853:9: if_end: End of if statement
2020
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:857:9: cond_true: Condition "sock == -1", taking true branch
2121
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:859:13: continue: Continuing loop
22+
<unknown>: loop: Looping back
2223
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:843:5: cond_true: Condition "rp != NULL", taking true branch
2324
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:846:9: cond_false: Condition "!addr", taking false branch
2425
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:848:9: if_end: End of if statement
@@ -38,6 +39,7 @@ Error: RESOURCE_LEAK:
3839
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:885:16: else_branch: Reached else branch
3940
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:886:13: cond_false: Condition "internal_tcp_connect(sock, rp->ai_addr, rp->ai_addrlen) == 0", taking false branch
4041
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:888:13: if_end: End of if statement
42+
<unknown>: loop: Jumping back to the beginning of the loop
4143
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:843:5: loop_begin: Jumped back to beginning of loop
4244
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:843:5: cond_true: Condition "rp != NULL", taking true branch
4345
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:846:9: cond_false: Condition "!addr", taking false branch
@@ -62,6 +64,7 @@ Error: RESOURCE_LEAK:
6264
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:791:26: noescape: "internal_tcp_connect(int, struct sockaddr const *, socklen_t)" does not free or save its handle parameter "sock".
6365
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:886:13: cond_true: Condition "internal_tcp_connect(sock, rp->ai_addr, rp->ai_addrlen) == 0", taking true branch
6466
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:887:17: break: Breaking from loop
67+
<unknown>: loop_end: Reached end of loop
6568
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:897:5: cond_true: Condition "res", taking true branch
6669
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:900:5: return_handle: Returning opened handle "sock".
6770
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:906:5: return_handle_fn: Directly returning handle opened by "crm_remote_tcp_connect_async".
@@ -96,6 +99,7 @@ Error: RESOURCE_LEAK:
9699
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:853:9: if_end: End of if statement
97100
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:857:9: cond_true: Condition "sock == -1", taking true branch
98101
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:859:13: continue: Continuing loop
102+
<unknown>: loop: Looping back
99103
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:843:5: cond_true: Condition "rp != NULL", taking true branch
100104
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:846:9: cond_false: Condition "!addr", taking false branch
101105
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:848:9: if_end: End of if statement
@@ -115,6 +119,7 @@ Error: RESOURCE_LEAK:
115119
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:885:16: else_branch: Reached else branch
116120
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:886:13: cond_false: Condition "internal_tcp_connect(sock, rp->ai_addr, rp->ai_addrlen) == 0", taking false branch
117121
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:888:13: if_end: End of if statement
122+
<unknown>: loop: Jumping back to the beginning of the loop
118123
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:843:5: loop_begin: Jumped back to beginning of loop
119124
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:843:5: cond_true: Condition "rp != NULL", taking true branch
120125
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:846:9: cond_false: Condition "!addr", taking false branch
@@ -139,6 +144,7 @@ Error: RESOURCE_LEAK:
139144
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:791:26: noescape: "internal_tcp_connect(int, struct sockaddr const *, socklen_t)" does not free or save its handle parameter "sock".
140145
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:886:13: cond_true: Condition "internal_tcp_connect(sock, rp->ai_addr, rp->ai_addrlen) == 0", taking true branch
141146
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:887:17: break: Breaking from loop
147+
<unknown>: loop_end: Reached end of loop
142148
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:897:5: cond_true: Condition "res", taking true branch
143149
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:900:5: return_handle: Returning opened handle "sock".
144150
/builddir/build/BUILD/pacemaker-97629ded958f76652350569a54303b3cd25d1d7e/lib/common/remote.c:906:5: return_handle_fn: Directly returning handle opened by "crm_remote_tcp_connect_async".

0 commit comments

Comments
 (0)