]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/testsuite: remove trailing \r from rust_llvm_version result
authorAndrew Burgess <aburgess@redhat.com>
Fri, 31 May 2024 21:03:06 +0000 (22:03 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Wed, 5 Jun 2024 09:19:35 +0000 (10:19 +0100)
commitf95540d91f4c3df373c0f9e212030154658d7f6f
tree4ecc2246f5bee64e23fbb147a0e227adbff99e5a
parent5260dcf0c6c4bd403fe5f82bb6109e89858ea974
gdb/testsuite: remove trailing \r from rust_llvm_version result

I noticed that the value returned by rust_llvm_version had a trailing
carriage return.  I don't think this is causing any problems right
now, but looking at the code I don't think this was the desired
behaviour.

The current code runs 'rustc --version --verbose', splits the output
at each '\n' and then loops over every line looking for the line that
contains the LLVM version.

There are two problems here.  First, at the end of each captured line
we have '\r\n', so when we split the lines on '\n', each of the lines
will still end with a '\r' character.

Second, though we loop over the lines, when we try to compare the line
contents we actually compare the unsplit full output.  Luckily this
still finds the match, but this renders the loop over lines redundant.

This commit makes two fixes:

 1. I use regsub to convert all '\r\n' sequences to '\n'; now when we
    split on '\n' the lines will not end in '\r'.

 2. Within the loop over lines block I now check the line contents
    rather than the unsplit full output; now we capture a value
    without a trailing '\r'.

There's only one test (gdb.rust/simple.exp) that uses
rust_llvm_version, and it doesn't care if there's a trailing '\r' or
not, so this change should make no difference there.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/testsuite/lib/rust-support.exp