summaryrefslogtreecommitdiff
path: root/libgo/go/net/parse.go
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-10-26 23:57:58 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-10-26 23:57:58 +0000
commitfa5d125b5cfa5c935e46d27a2cbcd71ae37687ac (patch)
tree19d182df05ead7ff8ba7ee00a7d57555e1383fdf /libgo/go/net/parse.go
parente3d46e67996cf20ca3a75fccbb5a0007bfa3f992 (diff)
downloadgcc-fa5d125b5cfa5c935e46d27a2cbcd71ae37687ac.tar.gz
Update Go library to last weekly.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180552 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/net/parse.go')
-rw-r--r--libgo/go/net/parse.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/libgo/go/net/parse.go b/libgo/go/net/parse.go
index de46830d292..0d30a7ac609 100644
--- a/libgo/go/net/parse.go
+++ b/libgo/go/net/parse.go
@@ -159,6 +159,18 @@ func xtoi(s string, i0 int) (n int, i int, ok bool) {
return n, i, true
}
+// xtoi2 converts the next two hex digits of s into a byte.
+// If s is longer than 2 bytes then the third byte must be e.
+// If the first two bytes of s are not hex digits or the third byte
+// does not match e, false is returned.
+func xtoi2(s string, e byte) (byte, bool) {
+ if len(s) > 2 && s[2] != e {
+ return 0, false
+ }
+ n, ei, ok := xtoi(s[:2], 0)
+ return byte(n), ok && ei == 2
+}
+
// Integer to decimal.
func itoa(i int) string {
var buf [30]byte
@@ -181,6 +193,37 @@ func itoa(i int) string {
return string(buf[n:])
}
+// Convert i to decimal string.
+func itod(i uint) string {
+ if i == 0 {
+ return "0"
+ }
+
+ // Assemble decimal in reverse order.
+ var b [32]byte
+ bp := len(b)
+ for ; i > 0; i /= 10 {
+ bp--
+ b[bp] = byte(i%10) + '0'
+ }
+
+ return string(b[bp:])
+}
+
+// Convert i to hexadecimal string.
+func itox(i uint, min int) string {
+ // Assemble hexadecimal in reverse order.
+ var b [32]byte
+ bp := len(b)
+ for ; i > 0 || min > 0; i /= 16 {
+ bp--
+ b[bp] = "0123456789abcdef"[byte(i%16)]
+ min--
+ }
+
+ return string(b[bp:])
+}
+
// Number of occurrences of b in s.
func count(s string, b byte) int {
n := 0