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