File: comment_token.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.17.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 384,244 kB
  • sloc: java: 13,538; makefile: 400; sh: 137
file content (35 lines) | stat: -rw-r--r-- 578 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package ini

// isComment will return whether or not the next byte(s) is a
// comment.
func isComment(b []rune) bool {
	if len(b) == 0 {
		return false
	}

	switch b[0] {
	case ';':
		return true
	case '#':
		return true
	}

	return false
}

// newCommentToken will create a comment token and
// return how many bytes were read.
func newCommentToken(b []rune) (Token, int, error) {
	i := 0
	for ; i < len(b); i++ {
		if b[i] == '\n' {
			break
		}

		if len(b)-i > 2 && b[i] == '\r' && b[i+1] == '\n' {
			break
		}
	}

	return newToken(TokenComment, b[:i], NoneType), i, nil
}