Skip to content

Commit

Permalink
CtagsFileSaver: Look for the hashtag as character, not string
Browse files Browse the repository at this point in the history
TestCTagsRunner* use the #line directive generated file as source instead than # $linenumber.
Searching fot the '#' as first char make tests passing
  • Loading branch information
facchinm committed May 3, 2016
1 parent 1740c63 commit e1ed222
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/arduino.cc/builder/ctags_target_file_saver.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ func saveLinesContainingDirectivesAndSketch(src string, tofind []string) string
if saveLine || startsWithHashtag(line) {
minimizedString += line + "\n"
}
if containsAny(line, tofind) && isPreprocessorLineMarker(line) {
if containsAny(line, tofind) && isLineMarker(line) {
saveLine = true
}
if saveLine && !containsAny(line, tofind) && isPreprocessorLineMarker(line) {
if saveLine && !containsAny(line, tofind) && isLineMarker(line) {
saveLine = false
}
}
Expand All @@ -106,10 +106,10 @@ func startsWithHashtag(src string) bool {
return false
}

func isPreprocessorLineMarker(src string) bool {
func isLineMarker(src string) bool {
trimmedStr := strings.TrimSpace(src)
splittedStr := strings.Split(trimmedStr, " ")
if len(splittedStr) > 2 && splittedStr[0] == "#" {
if len(splittedStr) > 2 && splittedStr[0][0] == '#' {
_, err := strconv.Atoi(splittedStr[1])
if err == nil {
return true
Expand Down

0 comments on commit e1ed222

Please sign in to comment.