mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-12 07:41:14 +00:00
llvm-strings: ensure that the last string is correctly printed
We would ignore the last string that appeared if the file ended with a printable character. Ensure that we get the last string. llvm-svn: 286706
This commit is contained in:
parent
73caa383e6
commit
b89c12e248
2
test/tools/llvm-strings/terminator-neg.test
Normal file
2
test/tools/llvm-strings/terminator-neg.test
Normal file
@ -0,0 +1,2 @@
|
||||
RUN: echo -n abc | llvm-strings - | FileCheck -allow-empty %s
|
||||
CHECK-NOT: abc
|
2
test/tools/llvm-strings/terminator.test
Normal file
2
test/tools/llvm-strings/terminator.test
Normal file
@ -0,0 +1,2 @@
|
||||
RUN: echo -n abcdefg | llvm-strings - | FileCheck %s
|
||||
CHECK: abcdefg
|
@ -33,8 +33,8 @@ static cl::list<std::string> InputFileNames(cl::Positional,
|
||||
cl::ZeroOrMore);
|
||||
|
||||
static void dump(raw_ostream &OS, StringRef Contents) {
|
||||
const char *S = nullptr;
|
||||
for (const char *P = Contents.begin(), *E = Contents.end(); P < E; ++P) {
|
||||
const char *P = nullptr, *E = nullptr, *S = nullptr;
|
||||
for (P = Contents.begin(), E = Contents.end(); P < E; ++P) {
|
||||
if (std::isgraph(*P) || std::isblank(*P)) {
|
||||
if (S == nullptr)
|
||||
S = P;
|
||||
@ -44,6 +44,8 @@ static void dump(raw_ostream &OS, StringRef Contents) {
|
||||
S = nullptr;
|
||||
}
|
||||
}
|
||||
if (S && E - S > 3)
|
||||
OS << StringRef(S, E - S) << '\n';
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
Loading…
x
Reference in New Issue
Block a user