aboutsummaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/text/internal/ucd
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/text/internal/ucd')
-rw-r--r--vendor/golang.org/x/text/internal/ucd/ucd.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/vendor/golang.org/x/text/internal/ucd/ucd.go b/vendor/golang.org/x/text/internal/ucd/ucd.go
index 2b0d1a1..60b27d5 100644
--- a/vendor/golang.org/x/text/internal/ucd/ucd.go
+++ b/vendor/golang.org/x/text/internal/ucd/ucd.go
@@ -78,6 +78,14 @@ func Part(f func(p *Parser)) Option {
}
}
+// The CommentHandler option passes comments that are on a line by itself to
+// a given handler.
+func CommentHandler(f func(s string)) Option {
+ return func(p *Parser) {
+ p.commentHandler = f
+ }
+}
+
// A Parser parses Unicode Character Database (UCD) files.
type Parser struct {
scanner *bufio.Scanner
@@ -92,7 +100,8 @@ type Parser struct {
parsedRange bool
rangeStart, rangeEnd rune
- partHandler func(p *Parser)
+ partHandler func(p *Parser)
+ commentHandler func(s string)
}
func (p *Parser) setError(err error) {
@@ -138,7 +147,13 @@ func (p *Parser) Next() bool {
for p.scanner.Scan() {
b := p.scanner.Bytes()
- if len(b) == 0 || b[0] == '#' {
+ if len(b) == 0 {
+ continue
+ }
+ if b[0] == '#' {
+ if p.commentHandler != nil {
+ p.commentHandler(strings.TrimSpace(string(b[1:])))
+ }
continue
}