File tree 1 file changed +8
-7
lines changed
1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 30
30
package builder
31
31
32
32
import (
33
- "arduino.cc/builder/types"
34
- "arduino.cc/builder/utils"
33
+ "bufio"
35
34
"strconv"
36
35
"strings"
36
+
37
+ "arduino.cc/builder/types"
38
+ "arduino.cc/builder/utils"
37
39
)
38
40
39
41
type FilterSketchSource struct {
40
- Source * string
42
+ Source * string
41
43
}
42
44
43
45
func (s * FilterSketchSource ) Run (ctx * types.Context ) error {
44
- lines := strings .Split (* s .Source , "\n " )
45
-
46
46
fileNames := []string {ctx .Sketch .MainFile .Name }
47
47
for _ , file := range ctx .Sketch .OtherSketchFiles {
48
48
fileNames = append (fileNames , file .Name )
@@ -51,7 +51,9 @@ func (s *FilterSketchSource) Run(ctx *types.Context) error {
51
51
inSketch := false
52
52
filtered := ""
53
53
54
- for _ , line := range lines {
54
+ scanner := bufio .NewScanner (strings .NewReader (* s .Source ))
55
+ for scanner .Scan () {
56
+ line := scanner .Text ()
55
57
filename := parseLineMarker (line )
56
58
if filename != "" {
57
59
inSketch = utils .SliceContains (fileNames , filename )
@@ -96,4 +98,3 @@ func parseLineMarker(line string) string {
96
98
}
97
99
return ""
98
100
}
99
-
You can’t perform that action at this time.
0 commit comments