summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-strings/llvm-strings.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2016-11-12 03:39:21 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2016-11-12 03:39:21 +0000
commit2729786ffff8e74acbc179155364a30897d1affd (patch)
tree72bb9436c49f307afe8f568cdd8fbde51e299a10 /llvm/tools/llvm-strings/llvm-strings.cpp
parent4dcf92a27ec70670f23ced082e3bbcf28f1dbc71 (diff)
downloadbcm5719-llvm-2729786ffff8e74acbc179155364a30897d1affd.tar.gz
bcm5719-llvm-2729786ffff8e74acbc179155364a30897d1affd.zip
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
Diffstat (limited to 'llvm/tools/llvm-strings/llvm-strings.cpp')
-rw-r--r--llvm/tools/llvm-strings/llvm-strings.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/tools/llvm-strings/llvm-strings.cpp b/llvm/tools/llvm-strings/llvm-strings.cpp
index d590b7012b6..dbabf08a52f 100644
--- a/llvm/tools/llvm-strings/llvm-strings.cpp
+++ b/llvm/tools/llvm-strings/llvm-strings.cpp
@@ -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 {
OpenPOWER on IntegriCloud