Read a digit token from the raw string stop reading when a space is encountered or the end of the string.
(raw string, start, limit int)
| 979 | // Read a digit token from the raw string |
| 980 | // stop reading when a space is encountered or the end of the string. |
| 981 | func readCandidateDigitToken(raw string, start, limit int) (int, int, error) { |
| 982 | var val int |
| 983 | for i, char := range raw[start:] { |
| 984 | if char == 0x20 { // SP |
| 985 | return val, start + i + 1, nil |
| 986 | } |
| 987 | |
| 988 | if i == limit { |
| 989 | //nolint: err113 // handled by caller |
| 990 | return 0, 0, fmt.Errorf("token too long: %s expected 1x%d", raw[start:start+i], limit) |
| 991 | } |
| 992 | |
| 993 | if char < '0' || char > '9' { |
| 994 | return 0, 0, fmt.Errorf("invalid digit token: %c", char) //nolint: err113 // handled by caller |
| 995 | } |
| 996 | |
| 997 | val = val*10 + int(char-'0') |
| 998 | } |
| 999 | |
| 1000 | return val, len(raw), nil |
| 1001 | } |
| 1002 | |
| 1003 | // Read and validate RFC 4566 port from the raw string. |
| 1004 | func readCandidatePort(raw string, start int) (int, int, error) { |
no test coverage detected
searching dependent graphs…