From 2729786ffff8e74acbc179155364a30897d1affd Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sat, 12 Nov 2016 03:39:21 +0000 Subject: 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 --- llvm/tools/llvm-strings/llvm-strings.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'llvm/tools/llvm-strings') 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 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 { -- cgit v1.2.3