OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [mime/] [grammar.go] - Blame information for rev 761

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// 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
// 1521 and RFC 2045.
13
func isTSpecial(r rune) bool {
14
        return strings.IndexRune(`()<>@,;:\"/[]?=`, r) != -1
15
}
16
 
17
// IsTokenChar returns true if rune is in 'token' as defined by RFC
18
// 1521 and RFC 2045.
19
func IsTokenChar(r rune) bool {
20
        // token := 1*
21
        //             or tspecials>
22
        return r > 0x20 && r < 0x7f && !isTSpecial(r)
23
}
24
 
25
// IsToken returns true if s is a 'token' as as defined by RFC 1521
26
// and RFC 2045.
27
func IsToken(s string) bool {
28
        if s == "" {
29
                return false
30
        }
31
        return strings.IndexFunc(s, isNotTokenChar) < 0
32
}
33
 
34
// IsQText returns true if rune is in 'qtext' as defined by RFC 822.
35
func IsQText(r int) bool {
36
        // CHAR        =          ; (  0-177,  0.-127.)
37
        // qtext       =  ,     ; => may be folded
38
        //                "\" & CR, and including
39
        //                linear-white-space>
40
        switch r {
41
        case '"', '\\', '\r':
42
                return false
43
        }
44
        return r < 0x80
45
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.