> Le 15 avr. 2017 à 13:00, Janus Weil <ja...@gcc.gnu.org> a écrit :
> 
> Hi Dominique,
> 
> if I'm not mistaken, the cleanup of module file in the testsuite is
> done automatically by now, right? Couldn't one do the same also for
> submodules?
> 
> Cheers,
> Janus
> 

This is indeed doable, but before I’ld like to improve the module cleanup with 
the following patch (+remove all the non-necessary module cleanup)

--- ../_clean/gcc/testsuite/lib/fortran-modules.exp     2017-01-01 
17:38:58.000000000 +0100
+++ gcc/testsuite/lib/fortran-modules.exp       2017-01-03 09:19:02.000000000 
+0100
@@ -79,10 +79,11 @@ proc list-module-names { files } {
 
 proc list-module-names-1 { file } {
     set result {}
-    set tmp [grep $file "^\[ \t\]*((#)?\[ 
\t\]*include|\[mM\]\[oO\]\[dD\]\[uU\]\[lL\]\[eE\](?!\[ 
\t\]+\[pP\]\[rR\]\[oO\]\[cC\]\[eE\]\[dD\]\[uU\]\[rR\]\[eE\]\[ \t\]+))\[ 
\t\]+.*" line]
+    if {[file isdirectory $file]} {return}
+    set tmp [igrep $file "^\[ \t\]*((#)?\[ \t\]*include|module(?!\[ 
\t\]+procedure\[ \t\]+))\[ \t\]+.*" line]
     if {![string match "" $tmp]} {
        foreach i $tmp {
-           regexp "(\[0-9\]+)\[ \t\]+(?:(?:#)?\[ \t\]*include\[ 
\t\]+)\[\"\](\[^\"\]*)\[\"\]" $i dummy lineno include_file
+           regexp -nocase "(\[0-9\]+)\[ \t\]+(?:(?:#)?\[ \t\]*include\[ 
\t\]+)\[\"\'\](\[^\"\'\]*)\[\"\'\]" $i dummy lineno include_file
            if {[info exists include_file]} {
                set dir [file dirname $file]
                set inc "$dir/$include_file"
@@ -99,7 +100,7 @@ proc list-module-names-1 { file } {
                }
                continue
            }
-           regexp "(\[0-9\]+)\[ 
\t\]+(?:(\[mM\]\[oO\]\[dD\]\[uU\]\[lL\]\[eE\]\[ 
\t\]+(?!\[pP\]\[rR\]\[oO\]\[cC\]\[eE\]\[dD\]\[uU\]\[rR\]\[eE\]\[ \t\]+)))(\[^ 
\t;\]*)" $i i lineno keyword mod
+           regexp -nocase "(\[0-9\]+)\[ \t\]+(?:(\module\[ \t\]+(?!procedure\[ 
\t\]+)))(\[^ \t;\]*)" $i i lineno keyword mod
            if {![info exists lineno]} {
                continue
            }
@@ -111,3 +112,54 @@ proc list-module-names-1 { file } {
     }
     return $result
 }
+
+# Looks for case insensitive occurrences of a string in a file.
+#     return:list of lines that matched or NULL if none match.
+#     args:  first arg is the filename,
+#            second is the pattern,
+#            third are any options.
+#     Options: line  - puts line numbers of match in list
+#
+proc igrep { args } {
+
+    set file [lindex $args 0]
+    set pattern [lindex $args 1]
+
+    verbose "Grepping $file for the pattern \"$pattern\"" 3
+
+    set argc [llength $args]
+    if { $argc > 2 } {
+        for { set i 2 } { $i < $argc } { incr i } {
+            append options [lindex $args $i]
+            append options " "
+        }
+    } else {
+        set options ""
+    }
+
+    set i 0
+    set fd [open $file r]
+    while { [gets $fd cur_line]>=0 } {
+        incr i
+        if {[regexp -nocase -- "$pattern" $cur_line match]} {
+            if {![string match "" $options]} {
+                foreach opt $options {
+                    switch $opt {
+                        "line" {
+                            lappend grep_out [concat $i $match]
+                        }
+                    }
+                }
+            } else {
+                lappend grep_out $match
+            }
+        }
+    }
+    close $fd
+    unset fd
+    unset i
+    if {![info exists grep_out]} {
+        set grep_out ""
+    }
+    return $grep_out
+}

Dominique

Reply via email to