A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/arduino/arduino-cli/commit/4891dedb4934fb211ec2e90939f717dc25357ba9 below:

fixed prototype generation when included libraries contains v… · arduino/arduino-cli@4891ded · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+145668

-2

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+145668

-2

lines changed Original file line number Diff line number Diff line change

@@ -74,7 +74,7 @@ func PreprocessSketchWithCtags(

74 74

}

75 75 76 76

if src, err := ctagsTarget.ReadFile(); err == nil {

77 -

filteredSource := filterSketchSource(sketch, bytes.NewReader(src), false)

77 +

filteredSource := filterSketchSource(sketch, bytes.NewReader(src), false, stderr)

78 78

if err := ctagsTarget.WriteFile([]byte(filteredSource)); err != nil {

79 79

return &Result{args: result.Args(), stdout: stdout.Bytes(), stderr: stderr.Bytes()}, err

80 80

}

@@ -208,7 +208,7 @@ func RunCTags(ctx context.Context, sourceFile *paths.Path, buildProperties *prop

208 208

return stdout, stderr, args, err

209 209

}

210 210 211 -

func filterSketchSource(sketch *sketch.Sketch, source io.Reader, removeLineMarkers bool) string {

211 +

func filterSketchSource(sketch *sketch.Sketch, source io.Reader, removeLineMarkers bool, stderr *bytes.Buffer) string {

212 212

fileNames := paths.NewPathList()

213 213

fileNames.Add(sketch.MainFile)

214 214

fileNames.AddAll(sketch.OtherSketchFiles)

@@ -217,6 +217,11 @@ func filterSketchSource(sketch *sketch.Sketch, source io.Reader, removeLineMarke

217 217

filtered := ""

218 218 219 219

scanner := bufio.NewScanner(source)

220 + 221 +

var buf []byte

222 +

const maxTokenSize = 1024 * 1024 // 1 MB

223 +

scanner.Buffer(buf, maxTokenSize)

224 + 220 225

for scanner.Scan() {

221 226

line := scanner.Text()

222 227

if filename := cpp.ParseLineMarker(line); filename != nil {

@@ -230,6 +235,11 @@ func filterSketchSource(sketch *sketch.Sketch, source io.Reader, removeLineMarke

230 235

filtered += line + "\n"

231 236

}

232 237

}

238 +

if errors.Is(scanner.Err(), bufio.ErrTooLong) {

239 +

fmt.Fprintf(stderr, "%s: %s",

240 +

i18n.Tr("An error occurred adding prototypes"),

241 +

i18n.Tr("line too long\n"))

242 +

}

233 243 234 244

return filtered

235 245

}

Original file line number Diff line number Diff line change

@@ -0,0 +1,42 @@

1 +

// This file is part of arduino-cli.

2 +

//

3 +

// Copyright 2025 ARDUINO SA (http://www.arduino.cc/)

4 +

//

5 +

// This software is released under the GNU General Public License version 3,

6 +

// which covers the main part of arduino-cli.

7 +

// The terms of this license can be found at:

8 +

// https://www.gnu.org/licenses/gpl-3.0.en.html

9 +

//

10 +

// You can be released from the requirements of the above licenses by purchasing

11 +

// a commercial license. Buying such a license is mandatory if you want to

12 +

// modify or otherwise use the software for commercial activities involving the

13 +

// Arduino software without disclosing the source code of your own applications.

14 +

// To purchase a commercial license, send an email to license@arduino.cc.

15 + 16 +

package preprocessor

17 + 18 +

import (

19 +

"bytes"

20 +

"fmt"

21 +

"testing"

22 + 23 +

"github.com/arduino/arduino-cli/internal/arduino/sketch"

24 +

"github.com/arduino/go-paths-helper"

25 +

"github.com/stretchr/testify/require"

26 +

)

27 + 28 +

func TestCtagsSketchFilter(t *testing.T) {

29 +

sourcePath := paths.New("testdata", "sketch_merged.cpp")

30 +

f, err := sourcePath.Open()

31 +

require.NoError(t, err)

32 +

t.Cleanup(func() { f.Close() })

33 + 34 +

sketch := &sketch.Sketch{

35 +

MainFile: paths.New("/home/megabug/Arduino/Test/Test.ino"),

36 +

}

37 +

stderr := bytes.NewBuffer(nil)

38 +

res := filterSketchSource(sketch, f, false, stderr)

39 +

require.Empty(t, stderr)

40 +

require.NotEmpty(t, res)

41 +

fmt.Println(res)

42 +

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4