Monday, February 09, 2026

Search Source Files for Matching Key Phrases

 
##
# search all sources for pattern string
# returns a tagged list, those matching, and those not-matching
##
proc checkAllSources { {pattern USE_DOC_VAR} } {

    package require fileutil
    
    set FILES [fileutil::findByPattern ../src *.c] 
    
    foreach w [gnocl::widgets] {
        foreach f $FILES { 
            if { [string first /$w.c $f] != -1 } { 
                set fp [open $f r]
                set DATA [read $fp]
                close $fp

                if { [string first $pattern $DATA] != -1 } { 
                    lappend yes $f 
                } else {
                    lappend no $f
                    
                }
            }     
        }
    }
    return "yes {$yes} no {$no}"
}

puts [join [dict get [checkAllSources gnoclGetDocumentationVarArgs] yes] \n]

No comments: