Commit 5b63fa54 authored by Hugo Moreau's avatar Hugo Moreau
Browse files

Automatizing blackbox with formula

If blackbox is set to auto, the blackbox functions are defined with the
formula.

 * main.go,
   tools/formulae.go : Here.
parent e8b90b25
Pipeline #26917 passed with stage
in 2 minutes and 23 seconds
......@@ -630,6 +630,9 @@ func main() {
}
if *ignorefunc != "" {
if *formulae == "" && len(flag.Args()) >= 2 && *ignorefunc == "auto" {
*ignorefunc = tools.Formuala(flag.Args()[0], flag.Args()[1])
}
var unspacify = regexp.MustCompile(` *`)
s := unspacify.ReplaceAllString(*ignorefunc, "")
toIgnore = strings.Split(s, ";")
......
......@@ -8,6 +8,31 @@ import (
"regexp"
)
func Formuala(inputfile, formula string) string {
src, err := ioutil.ReadFile(inputfile)
if err != nil {
fmt.Println(os.Stderr, err)
os.Exit(2)
}
callMap := BuildCallgraph(string(src))
neededFuncMap := make(map[string]bool)
for key, _ := range callMap {
neededFuncMap[key] = false
}
neededFuncMap["main"] = true
r, _ := regexp.Compile("\".*?\"")
parseFormulaeLine(formula, r, neededFuncMap)
notsameway := []string{}
callerNeeded("main", callMap, neededFuncMap, notsameway)
blackbox := ""
for key, val := range neededFuncMap {
if !val {
blackbox += key + ";"
}
}
return blackbox
}
func Formulae(inputfile, formulae string) string {
src, err := ioutil.ReadFile(inputfile)
if err != nil {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment