https://gcc.gnu.org/g:16b2d4fb5505db3055e45ab30e9b3ef23367d66d

commit r15-11171-g16b2d4fb5505db3055e45ab30e9b3ef23367d66d
Author: Torbjörn SVENSSON <[email protected]>
Date:   Thu Apr 2 19:22:38 2026 +0200

    testsuite: scan for case sensitive file extensions in lto.exp
    
    On a case insensitive filesystem, like on Windows, the "glob" function
    in tcl returns an entry for each possible case that matches the
    expression.
    
    For example, `glob -nocomplain -types f -- "foo.{c,C}"` would return
    both "foo.c" and "foo.C" even if there were only a "foo.c" file in the
    directory.
    
    gcc/testsuite/ChangeLog:
    
            * lib/lto.exp: Make file listing case sensitive by doing case
            sensitive filter after directory listing.
    
    Signed-off-by: Torbjörn SVENSSON <[email protected]>
    (cherry picked from commit 8376a674e3564fc6f95f9965d22cf5f53981a7e3)

Diff:
---
 gcc/testsuite/lib/lto.exp | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/lib/lto.exp b/gcc/testsuite/lib/lto.exp
index fc8a0673cd0e..8facf828ceea 100644
--- a/gcc/testsuite/lib/lto.exp
+++ b/gcc/testsuite/lib/lto.exp
@@ -711,9 +711,19 @@ proc lto-execute-1 { src1 sid } {
     set i 1
     set done 0
     while { !$done } {
-       set names [glob -nocomplain -types f -- 
"${dir}/${base}_${i}.{c,C,ii,\[fF\]{,90,95,03,08},d,m,mm}"]
+       set prefix "${dir}/${base}_${i}"
+
+       # glob returns a case insensitive list if filesystem is case
+       # insensitive.  To have a case sensitive list, fetch the extended list
+       # and then filter it to avoid duplicates.
+       regsub -all {([.^$*+?()$${}|])} $prefix {\\\1} pattern
+       set pattern [format {^%s.(c|C|ii|[fF](|90|95|03|08)|d|m|mm)$} $pattern]
+       set names [lsearch -inline -all -regexp \
+         [glob -nocomplain -types f -- "${prefix}.*"] $pattern]
+
        if { [llength ${names}] > 1 } {
-           warning "lto-execute: more than one file matched 
${dir}/${base}_${i}.{c,C,ii,\[fF\]{,90,95,03,08},d,m,mm}"
+           warning "lto-execute: more than one file matched $pattern"
+           verbose "matching files: $names"
        }
        if { [llength ${names}] == 1 } {
            lappend src_list [lindex ${names} 0]

Reply via email to