Skip to content

Commit 64ac601

Browse files
committed
csgrep: silently drop scan properties when printing stats only
1 parent 45154be commit 64ac601

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

csgrep.cc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@
3232
#include <boost/program_options.hpp>
3333
#include <boost/regex.hpp>
3434

35-
class FilePrinter: public AbstractWriter {
35+
class StatWriter: public AbstractWriter {
36+
public:
37+
/// silently drop scan properties when printing stats only
38+
virtual void setScanProps(const TScanProps &) { }
39+
};
40+
41+
class FilePrinter: public StatWriter {
3642
private:
3743
std::string file_;
3844

@@ -50,7 +56,7 @@ class FilePrinter: public AbstractWriter {
5056
}
5157
};
5258

53-
class GroupPrinter: public AbstractWriter {
59+
class GroupPrinter: public StatWriter {
5460
private:
5561
std::string file_;
5662

@@ -70,15 +76,15 @@ class GroupPrinter: public AbstractWriter {
7076
}
7177
};
7278

73-
class KeyEventPrinter: public AbstractWriter {
79+
class KeyEventPrinter: public StatWriter {
7480
protected:
7581
virtual void handleDef(const Defect &def) {
7682
const DefEvent &keyEvent = def.events[def.keyEventIdx];
7783
std::cout << def.checker << "\t" << keyEvent.event << "\n";
7884
}
7985
};
8086

81-
class DefCounter: public AbstractWriter {
87+
class DefCounter: public StatWriter {
8288
private:
8389
typedef std::map<std::string, int> TMap;
8490
TMap cnt_;
@@ -101,7 +107,7 @@ class DefCounter: public AbstractWriter {
101107
}
102108
};
103109

104-
class EvtCounter: public AbstractWriter {
110+
class EvtCounter: public StatWriter {
105111
private:
106112
typedef std::pair<std::string, std::string> TKey;
107113
typedef std::map<TKey, int> TMap;
@@ -131,7 +137,7 @@ class EvtCounter: public AbstractWriter {
131137
}
132138
};
133139

134-
class FileDefCounter: public AbstractWriter {
140+
class FileDefCounter: public StatWriter {
135141
private:
136142
typedef std::map<std::string, DefCounter *> TMap;
137143
TMap cntMap_;

0 commit comments

Comments
 (0)