TextSearch: in text only mode, disable grep file type checking
Without, grep would do its own file type check, which could clash with the one done by our own FileIterator, based on MIME type. Improve a bit overall performance. Change-Id: Ib0ef814e89b076b93e2e7b215f079cad8137128f Reviewed-on: https://review.haiku-os.org/c/haiku/+/10630 Reviewed-by: nephele nephele <[email protected]> Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -94,8 +94,8 @@ Grepper::Grepper(const char* pattern, const char* glob, const Model* model,
|
||||
fTarget(target),
|
||||
fRegularExpression(model->fRegularExpression),
|
||||
fCaseSensitive(model->fCaseSensitive),
|
||||
fTextOnly(model->fTextOnly),
|
||||
fEncoding(model->fEncoding),
|
||||
|
||||
fIterator(iterator),
|
||||
fRunnerThreadId(-1),
|
||||
fXargsInput(-1),
|
||||
@@ -270,6 +270,11 @@ Grepper::_RunnerThread()
|
||||
argv[argc++] = "grep";
|
||||
argv[argc++] = "-n"; // need matching line(s) number(s)
|
||||
argv[argc++] = "-H"; // need filename prefix
|
||||
if (fTextOnly) {
|
||||
// assume all files are already checked as text files by Files Iterator
|
||||
// so don't let grep consider any of them as binary file
|
||||
argv[argc++] = "--text";
|
||||
}
|
||||
if (! fCaseSensitive)
|
||||
argv[argc++] = "-i";
|
||||
if (! fRegularExpression)
|
||||
|
||||
@@ -49,6 +49,7 @@ private:
|
||||
BMessenger fTarget;
|
||||
bool fRegularExpression : 1;
|
||||
bool fCaseSensitive : 1;
|
||||
bool fTextOnly : 1;
|
||||
uint32 fEncoding;
|
||||
|
||||
// The supplier of files to grep
|
||||
|
||||
Reference in New Issue
Block a user