From cbad2174a9fc3650f84d945f60e8693468b3a289 Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Tue, 31 Mar 2026 00:46:27 +0200 Subject: [PATCH] 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 Reviewed-by: waddlesplash Tested-by: Commit checker robot --- src/apps/text_search/Grepper.cpp | 7 ++++++- src/apps/text_search/Grepper.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/apps/text_search/Grepper.cpp b/src/apps/text_search/Grepper.cpp index 3b9a1add4b..86beb53451 100644 --- a/src/apps/text_search/Grepper.cpp +++ b/src/apps/text_search/Grepper.cpp @@ -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) diff --git a/src/apps/text_search/Grepper.h b/src/apps/text_search/Grepper.h index dd59edf8df..71eefe0ca6 100644 --- a/src/apps/text_search/Grepper.h +++ b/src/apps/text_search/Grepper.h @@ -49,6 +49,7 @@ private: BMessenger fTarget; bool fRegularExpression : 1; bool fCaseSensitive : 1; + bool fTextOnly : 1; uint32 fEncoding; // The supplier of files to grep