Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prpgrep not searching some objects properly #283

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 1 addition & 35 deletions Tools/src/prpgrep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,12 @@
#include <string_theory/stdio>
#include <list>

static char lnbuf[4096];
static char* lnbuf_ptr = &lnbuf[4096];

static ST::string GetLine(hsStream* S)
{
if (lnbuf_ptr >= &lnbuf[4096]) {
size_t len = S->size() - S->pos();
if (len > 4096)
len = 4096;
S->read(len, lnbuf);
if (len < 4096)
lnbuf[len] = 0;
lnbuf_ptr = lnbuf;
}

char* bp = lnbuf_ptr;
while (true) {
if (bp >= &lnbuf[4096]) {
ST::string prefix(lnbuf_ptr, bp - lnbuf_ptr);
lnbuf_ptr = &lnbuf[4096];
return prefix + GetLine(S);
} else if (*bp == '\n' || *bp == 0) {
ST::string ln(lnbuf_ptr, bp - lnbuf_ptr);
lnbuf_ptr = bp + 1;
return ln;
}
bp++;
}

// Should never get here...
return ST::string();
}

static void DoSearch(hsStream* S, const ST::string& pattern,
const ST::string& filename, const plKey& key)
{
unsigned int ln = 1;
lnbuf_ptr = &lnbuf[4096];
while (!S->eof()) {
ST::string text = GetLine(S);
ST::string text = S->readLine();
if (text.find(pattern) >= 0) {
// Strip initial whitespace
const char* txtout = text.c_str();
Expand Down
Loading