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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [strconv/] [atob.go] - Blame information for rev 774

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

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2009 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 strconv
6
 
7
// ParseBool returns the boolean value represented by the string.
8
// It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False.
9
// Any other value returns an error.
10
func ParseBool(str string) (value bool, err error) {
11
        switch str {
12
        case "1", "t", "T", "true", "TRUE", "True":
13
                return true, nil
14
        case "0", "f", "F", "false", "FALSE", "False":
15
                return false, nil
16
        }
17
        return false, syntaxError("ParseBool", str)
18
}
19
 
20
// FormatBool returns "true" or "false" according to the value of b
21
func FormatBool(b bool) string {
22
        if b {
23
                return "true"
24
        }
25
        return "false"
26
}
27
 
28
// AppendBool appends "true" or "false", according to the value of b,
29
// to dst and returns the extended buffer.
30
func AppendBool(dst []byte, b bool) []byte {
31
        if b {
32
                return append(dst, "true"...)
33
        }
34
        return append(dst, "false"...)
35
}

powered by: WebSVN 2.1.0

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