Changeset 5483
- Timestamp:
- May 31, 2017, 10:44:04 AM (21 months ago)
- Location:
- icGREP/icgrep-devel/icgrep
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
icGREP/icgrep-devel/icgrep/grep_engine.cpp
r5482 r5483 117 117 static std::stringstream * resultStrs = nullptr; 118 118 static std::vector<std::string> inputFiles; 119 static std::vector<std::string> linePrefix; 119 120 120 121 void initFileResult(std::vector<std::string> filenames){ 121 122 const int n = filenames.size(); 123 linePrefix.resize(n); 122 124 if ((n > 1) && !NoFilenameFlag) { 123 125 WithFilenameFlag = true; 126 } 127 std::string fileSuffix; 128 if (WithFilenameFlag) { 129 if (NullFlag) { 130 fileSuffix = std::string("\0", 1); 131 } 132 else if ((Mode == NormalMode) && InitialTabFlag && !(LineNumberFlag || ByteOffsetFlag)) { 133 fileSuffix = "\t:"; 134 } 135 else { 136 fileSuffix = ":"; 137 } 124 138 } 125 139 inputFiles = filenames; 126 140 resultStrs = new std::stringstream[n]; 127 141 total_count = new int[n]; 128 for (unsigned i = 0; i < inputFiles.size(); ++i){ 142 for (unsigned i = 0; i < inputFiles.size(); ++i) { 143 if (WithFilenameFlag) { 144 if (inputFiles[i] == "-") { 145 linePrefix[i] = LabelFlag + fileSuffix; 146 } 147 else { 148 linePrefix[i] = inputFiles[i] + fileSuffix; 149 } 150 } 129 151 total_count[i] = 0; 130 152 } 131 132 153 } 133 154 … … 142 163 143 164 if (WithFilenameFlag) { 144 resultStrs[fileIdx] << inputFiles[fileIdx] << ':';165 resultStrs[fileIdx] << linePrefix[fileIdx]; 145 166 } 146 167 if (LineNumberFlag) { 147 168 // Internally line numbers are counted from 0. For display, adjust 148 169 // the line number so that lines are numbered from 1. 149 resultStrs[fileIdx] << lineNum+1 << ":"; 170 if (InitialTabFlag) { 171 resultStrs[fileIdx] << lineNum+1 << "\t:"; 172 } 173 else { 174 resultStrs[fileIdx] << lineNum+1 << ":"; 175 } 150 176 } 151 177 … … 206 232 } else { 207 233 for (unsigned i = 0; i < inputFiles.size(); ++i){ 208 std::cout << inputFiles[i] << ':'<< total_CountOnly[i] << std::endl;234 std::cout << linePrefix[i] << total_CountOnly[i] << std::endl; 209 235 total += total_CountOnly[i]; 210 236 }; … … 217 243 for (unsigned i = 0; i < inputFiles.size(); ++i) { 218 244 if (total_CountOnly[i] == requiredCount) { 219 std::cout << inputFiles[i] << std::endl; 245 std::cout << linePrefix[i]; 246 if (!NullFlag) { 247 std::cout << "\n"; 248 } 220 249 } 221 250 total += total_CountOnly[i]; -
icGREP/icgrep-devel/icgrep/grep_interface.cpp
r5480 r5483 188 188 189 189 std::string LabelFlag; 190 static cl::opt<std::string, true> LabelOption("label", cl::location(LabelFlag), cl::desc("Set a label for input lines matched from stdin."), cl::cat(Output_Options)); 190 static cl::opt<std::string, true> LabelOption("label", cl::location(LabelFlag), cl::init("(standard input)"), 191 cl::desc("Set a label for input lines matched from stdin."), cl::cat(Output_Options)); 191 192 192 193 bool LineBufferedFlag; … … 289 290 llvm::report_fatal_error("Sorry, -s is not yet supported.\n"); 290 291 } 291 if (NullFlag) {292 llvm::report_fatal_error("Sorry, -Z is not yet supported.\n");293 }294 292 if (ByteOffsetFlag) { 295 293 llvm::report_fatal_error("Sorry, -b is not yet supported.\n"); … … 298 296 llvm::report_fatal_error("Sorry, -u is not yet supported.\n"); 299 297 } 300 if (InitialTabFlag) {301 llvm::report_fatal_error("Sorry, -T is not yet supported.\n");302 }303 298 if (OnlyMatchingFlag) { 304 299 llvm::report_fatal_error("Sorry, -o is not yet supported.\n"); … … 316 311 llvm::report_fatal_error("Sorry, -C is not yet supported.\n"); 317 312 } 318 if (LabelFlag!="") {319 llvm::report_fatal_error("Sorry, -label is not yet supported.\n");320 }321 313 if (ColorFlag!=neverColor) { 322 314 llvm::report_fatal_error("Sorry, -color is not yet supported.\n");
Note: See TracChangeset
for help on using the changeset viewer.