I have great deals of aesthetic workshop c++ task data I want to have the ability to Change Address Sanitizer on and also off for and also its actually sluggish doing it all by hand. I’m attempting to compose a go program that loopholes via all the xml aspects in the vcxproj till its locate the below area and after that inserts like below. << EnableASAN>> real<
<< PropertyGroup Problem="'$( Setup)|$( System)'==' Debug|x64'" Tag=" Setup">
<> < ConfigurationType>> Application<.
<< CharacterSet>> MultiByte<.
<< PlatformToolset>> v143<.
<< EnableASAN>> real<.
<.
This is the code I have thus far to locate the best PropertyGroup today I have no concept just how to place an xml component right here. Can anybody aim me in the best best instructions just how to do this if its feasible.
I assume you can attempt rhe vsproj as a simple message data and after that search for the needed token in the read line. For instance:
plan primary
import (
" bufio"
" fmt"
" log"
" os"
" strings"
)func printLines( filePath string, lines [] string) mistake {
f, err:= os.Create( filePath)
if err!= nil {
return err
}
postpone f.Close()
for _, worth:= array lines {
fmt.Fprintln( f, worth)
}
return nil
}func primary() {
f, err:= os.Open(" project1.vcxproj")if err!= nil {
fmt.Println( err)
}
postpone f.Close()
fileScanner:= bufio.NewScanner( f)fileScanner.Split( bufio.ScanLines)
lines:= make([] string, 0)
located:= incorrectfor fileScanner.Scan() {
line:= fileScanner.Text()if strings.Contains( line, "PropertyGroup Problem="'$( Setup)|$( System)'==' Debug|x64'" Tag=" Setup"") && & &! located { located && =real.} if located & & strings.Contains( line," " ){lines= append( lines>," < EnableASAN>> real "). located = incorrect. } lines= append( lines, line).} if err:= printLines (" project2.vcxproj", lines); err!= nil { log.Fatal( err).}}(* )Jeffsmith(* ). (Jeffrey Smith).
Jeffsmith
( Jeffrey Smith).
made some adjustments so it would not compose the EnableASAN component once again if existing however does function many thanks for that. fileScanner:= bufio.NewScanner( f).
fileScanner.Split( bufio.ScanLines).
lines:= make(
string, 0).
located:= incorrect.
asanTrue:= incorrect.
for fileScanner.Scan() {
line:= fileScanner.Text().
if strings.Contains( line, "PropertyGroup Problem="'$( Setup)|$( System)'==' Debug|x64'" Tag=" Setup"") && & &! located {
located= real.} if strings.Contains( line," < EnableASAN>> real ") {
asanTrue= real.} if located & & strings.Contains( line," ") & &! asanTrue {
lines = append( lines, "<< EnableASAN>> real<").
located = incorrect.
}
lines = append( lines, line).
}
if err:= printLines( s, lines); err!= nil {
log.Fatal( err).
}