Skip to content

Commit 20d6f63

Browse files
committed
[llvm-debuginfod-find] Fix test/behavior on Windows.
1 parent 28f9636 commit 20d6f63

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

llvm/lib/Debuginfod/Debuginfod.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,15 @@ static SmallVector<std::string, 0> getHeaders() {
195195
uint64_t LineNumber = 0;
196196
for (StringRef Line : llvm::split((*HeadersFile)->getBuffer(), '\n')) {
197197
LineNumber++;
198+
if (!Line.empty() && Line.back() == '\r')
199+
Line = Line.drop_back();
198200
if (!isHeader(Line)) {
199201
if (!all_of(Line, llvm::isSpace))
200202
WithColor::warning()
201203
<< "could not parse debuginfod header: " << Filename << ':'
202204
<< LineNumber << '\n';
203205
continue;
204206
}
205-
if (Line.back() == '\r')
206-
Line = Line.drop_back();
207207
Headers.emplace_back(Line);
208208
}
209209
return Headers;

llvm/test/tools/llvm-debuginfod-find/headers.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ REQUIRES: curl
22

33
RUN: %python %S/Inputs/capture_req.py llvm-debuginfod-find --debuginfo 0 \
44
RUN: | FileCheck --check-prefix NO-HEADERS %s
5-
RUN: DEBUGINFOD_HEADERS_FILE=bad %python %S/Inputs/capture_req.py \
5+
RUN: env DEBUGINFOD_HEADERS_FILE=bad %python %S/Inputs/capture_req.py \
66
RUN: llvm-debuginfod-find --debuginfo 0 \
77
RUN: | FileCheck --check-prefix NO-HEADERS %s
8-
RUN: DEBUGINFOD_HEADERS_FILE=%S/Inputs/headers %python %S/Inputs/capture_req.py \
8+
RUN: env DEBUGINFOD_HEADERS_FILE=%S/Inputs/headers %python %S/Inputs/capture_req.py \
99
RUN: llvm-debuginfod-find --debuginfo 0 \
1010
RUN: | FileCheck --check-prefix HEADERS %s
11-
RUN: DEBUGINFOD_HEADERS_FILE=%S/Inputs/headers DEBUGINFOD_URLS=fake not llvm-debuginfod-find --debuginfo 0 2>&1 \
11+
RUN: env DEBUGINFOD_HEADERS_FILE=%S/Inputs/headers DEBUGINFOD_URLS=fake not llvm-debuginfod-find --debuginfo 0 2>&1 \
1212
RUN: | FileCheck --check-prefix ERR -DHEADER_FILE=%S/Inputs/headers %s
1313

1414
NO-HEADERS: Accept: */*

0 commit comments

Comments
 (0)