https://gcc.gnu.org/g:cc90f6578a078383ad2ab73d60af11ea78a8705b

commit r16-8918-gcc90f6578a078383ad2ab73d60af11ea78a8705b
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]>

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 2a7b8b0de938..223bb9dc2125 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