mirror of
https://github.com/tinygo-org/net.git
synced 2026-08-11 23:23:38 +00:00
update 'net' package from 1.19.3 to 1.20.5
This commit is contained in:
committed by
deadprogram
parent
d0c97a5292
commit
c3616d9365
@@ -1,4 +1,4 @@
|
||||
// TINYGO: The following is copied from Go 1.19.3 official implementation.
|
||||
// TINYGO: The following is copied from Go 1.20.5 official implementation.
|
||||
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
@@ -238,7 +238,7 @@ func lowerASCII(b byte) byte {
|
||||
}
|
||||
|
||||
// trimSpace returns x without any leading or trailing ASCII whitespace.
|
||||
func trimSpace(x []byte) []byte {
|
||||
func trimSpace(x string) string {
|
||||
for len(x) > 0 && isSpace(x[0]) {
|
||||
x = x[1:]
|
||||
}
|
||||
@@ -255,37 +255,19 @@ func isSpace(b byte) bool {
|
||||
|
||||
// removeComment returns line, removing any '#' byte and any following
|
||||
// bytes.
|
||||
func removeComment(line []byte) []byte {
|
||||
if i := bytealg.IndexByte(line, '#'); i != -1 {
|
||||
func removeComment(line string) string {
|
||||
if i := bytealg.IndexByteString(line, '#'); i != -1 {
|
||||
return line[:i]
|
||||
}
|
||||
return line
|
||||
}
|
||||
|
||||
// foreachLine runs fn on each line of x.
|
||||
// Each line (except for possibly the last) ends in '\n'.
|
||||
// It returns the first non-nil error returned by fn.
|
||||
func foreachLine(x []byte, fn func(line []byte) error) error {
|
||||
for len(x) > 0 {
|
||||
nl := bytealg.IndexByte(x, '\n')
|
||||
if nl == -1 {
|
||||
return fn(x)
|
||||
}
|
||||
line := x[:nl+1]
|
||||
x = x[nl+1:]
|
||||
if err := fn(line); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// foreachField runs fn on each non-empty run of non-space bytes in x.
|
||||
// It returns the first non-nil error returned by fn.
|
||||
func foreachField(x []byte, fn func(field []byte) error) error {
|
||||
func foreachField(x string, fn func(field string) error) error {
|
||||
x = trimSpace(x)
|
||||
for len(x) > 0 {
|
||||
sp := bytealg.IndexByte(x, ' ')
|
||||
sp := bytealg.IndexByteString(x, ' ')
|
||||
if sp == -1 {
|
||||
return fn(x)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user