[haiku-commits] Re: haiku: hrev48969 - src/apps/text_search

  • From: Rene Gollent <anevilyak@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 1 Apr 2015 16:19:50 -0400

On Wed, Apr 1, 2015 at 1:36 PM, <waddlesplash@xxxxxxxxx> wrote:

+ int32 index = 0, lines = 1; // First line is 1 not 0
+ while (true) {
+ int32 newPos;
+ if (fCaseSensitive)
+ newPos = contents.FindFirst(fPattern, index);
+ else
+ newPos = contents.IFindFirst(fPattern, index);
+ if (newPos == B_ERROR)
+ break;
+
+ lines += _CountLines(contents, index, newPos);
+ BString linenoAndLine;
+ linenoAndLine.SetToFormat("%" B_PRId32 ":%s", lines,
_GetLine(contents, newPos).String());
+ message.AddString("text", linenoAndLine);
+
+ index = newPos + 1;
}

I might further note, this is completely broken because 1) it will
print the same line repeatedly if the pattern is matched several times
on the same line, and 2) unlike grep, {I}FindFirst() doesn't support
wild cards/regular expressions, so this is a pretty significant drop
in functionality. Please revert.

Rene

Other related posts: