]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgo/go/mime/grammar.go
Add Go frontend, libgo library, and Go testsuite.
[thirdparty/gcc.git] / libgo / go / mime / grammar.go
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.
4
5 package mime
6
7 import (
8 "strings"
9 )
10
11 // isTSpecial returns true if rune is in 'tspecials' as defined by RFC
12 // 1531 and RFC 2045.
13 func isTSpecial(rune int) bool {
14 return strings.IndexRune(`()<>@,;:\"/[]?=`, rune) != -1
15 }
16
17 // IsTokenChar returns true if rune is in 'token' as defined by RFC
18 // 1531 and RFC 2045.
19 func IsTokenChar(rune int) bool {
20 // token := 1*<any (US-ASCII) CHAR except SPACE, CTLs,
21 // or tspecials>
22 return rune > 0x20 && rune < 0x7f && !isTSpecial(rune)
23 }
24
25 // IsQText returns true if rune is in 'qtext' as defined by RFC 822.
26 func IsQText(rune int) bool {
27 // CHAR = <any ASCII character> ; ( 0-177, 0.-127.)
28 // qtext = <any CHAR excepting <">, ; => may be folded
29 // "\" & CR, and including
30 // linear-white-space>
31 switch rune {
32 case '"', '\\', '\r':
33 return false
34 }
35 return rune < 0x80
36 }