@@ -43,11 +43,11 @@ var DebugPreprocessor bool
43
43
func PreprocessSketchWithCtags (
44
44
sketch * sketch.Sketch , buildPath * paths.Path , includes paths.PathList ,
45
45
lineOffset int , buildProperties * properties.Map , onlyUpdateCompilationDatabase bool ,
46
- ) (Result , error ) {
46
+ ) (* Result , error ) {
47
47
// Create a temporary working directory
48
48
tmpDir , err := paths .MkTempDir ("" , "" )
49
49
if err != nil {
50
- return Result {} , err
50
+ return nil , err
51
51
}
52
52
defer tmpDir .RemoveAll ()
53
53
ctagsTarget := tmpDir .Join ("sketch_merged.cpp" )
@@ -61,32 +61,32 @@ func PreprocessSketchWithCtags(
61
61
stderr .Write (result .Stderr ())
62
62
if err != nil {
63
63
if ! onlyUpdateCompilationDatabase {
64
- return Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
64
+ return & Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
65
65
}
66
66
67
67
// Do not bail out if we are generating the compile commands database
68
68
stderr .WriteString (fmt .Sprintf ("%s: %s" ,
69
69
tr ("An error occurred adding prototypes" ),
70
70
tr ("the compilation database may be incomplete or inaccurate" )))
71
71
if err := sourceFile .CopyTo (ctagsTarget ); err != nil {
72
- return Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
72
+ return & Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
73
73
}
74
74
}
75
75
76
76
if src , err := ctagsTarget .ReadFile (); err == nil {
77
77
filteredSource := filterSketchSource (sketch , bytes .NewReader (src ), false )
78
78
if err := ctagsTarget .WriteFile ([]byte (filteredSource )); err != nil {
79
- return Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
79
+ return & Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
80
80
}
81
81
} else {
82
- return Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
82
+ return & Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
83
83
}
84
84
85
85
// Run CTags on gcc-preprocessed source
86
86
ctagsOutput , ctagsStdErr , err := RunCTags (ctagsTarget , buildProperties )
87
87
stderr .Write (ctagsStdErr )
88
88
if err != nil {
89
- return Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
89
+ return & Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
90
90
}
91
91
92
92
// Parse CTags output
@@ -101,13 +101,13 @@ func PreprocessSketchWithCtags(
101
101
if sourceData , err := sourceFile .ReadFile (); err == nil {
102
102
source = string (sourceData )
103
103
} else {
104
- return Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
104
+ return & Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
105
105
}
106
106
source = strings .ReplaceAll (source , "\r \n " , "\n " )
107
107
source = strings .ReplaceAll (source , "\r " , "\n " )
108
108
sourceRows := strings .Split (source , "\n " )
109
109
if isFirstFunctionOutsideOfSource (firstFunctionLine , sourceRows ) {
110
- return Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, nil
110
+ return & Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, nil
111
111
}
112
112
113
113
insertionLine := firstFunctionLine + lineOffset - 1
@@ -133,7 +133,7 @@ func PreprocessSketchWithCtags(
133
133
134
134
// Write back arduino-preprocess output to the sourceFile
135
135
err = sourceFile .WriteFile ([]byte (preprocessedSource ))
136
- return Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
136
+ return & Result {args : result .Args (), stdout : stdout .Bytes (), stderr : stderr .Bytes ()}, err
137
137
}
138
138
139
139
func composePrototypeSection (line int , prototypes []* ctags.Prototype ) string {
0 commit comments