2018-01-29 Richard Biener <rguenther@suse.de>
[official-gcc.git] / libgo / go / mime / grammar.go
blob6a6f71dbd40ed8ad20e36dc5cc1761cb017ed344
1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package mime
7 import (
8 "strings"
11 // isTSpecial reports whether rune is in 'tspecials' as defined by RFC
12 // 1521 and RFC 2045.
13 func isTSpecial(r rune) bool {
14 return strings.ContainsRune(`()<>@,;:\"/[]?=`, r)
17 // isTokenChar reports whether rune is in 'token' as defined by RFC
18 // 1521 and RFC 2045.
19 func isTokenChar(r rune) bool {
20 // token := 1*<any (US-ASCII) CHAR except SPACE, CTLs,
21 // or tspecials>
22 return r > 0x20 && r < 0x7f && !isTSpecial(r)
25 // isToken reports whether s is a 'token' as defined by RFC 1521
26 // and RFC 2045.
27 func isToken(s string) bool {
28 if s == "" {
29 return false
31 return strings.IndexFunc(s, isNotTokenChar) < 0