Fix spelling errors (#10379)
This commit is contained in:
parent
bfeade9791
commit
095eaacf21
4 changed files with 23 additions and 23 deletions
|
|
@ -233,7 +233,7 @@ proc parseIPv4Address(addressStr: string): IpAddress =
|
|||
var
|
||||
byteCount = 0
|
||||
currentByte:uint16 = 0
|
||||
seperatorValid = false
|
||||
separatorValid = false
|
||||
|
||||
result.family = IpAddressFamily.IPv4
|
||||
|
||||
|
|
@ -244,20 +244,20 @@ proc parseIPv4Address(addressStr: string): IpAddress =
|
|||
if currentByte > 255'u16:
|
||||
raise newException(ValueError,
|
||||
"Invalid IP Address. Value is out of range")
|
||||
seperatorValid = true
|
||||
separatorValid = true
|
||||
elif addressStr[i] == '.': # IPv4 address separator
|
||||
if not seperatorValid or byteCount >= 3:
|
||||
if not separatorValid or byteCount >= 3:
|
||||
raise newException(ValueError,
|
||||
"Invalid IP Address. The address consists of too many groups")
|
||||
result.address_v4[byteCount] = cast[uint8](currentByte)
|
||||
currentByte = 0
|
||||
byteCount.inc
|
||||
seperatorValid = false
|
||||
separatorValid = false
|
||||
else:
|
||||
raise newException(ValueError,
|
||||
"Invalid IP Address. Address contains an invalid character")
|
||||
|
||||
if byteCount != 3 or not seperatorValid:
|
||||
if byteCount != 3 or not separatorValid:
|
||||
raise newException(ValueError, "Invalid IP Address")
|
||||
result.address_v4[byteCount] = cast[uint8](currentByte)
|
||||
|
||||
|
|
@ -272,7 +272,7 @@ proc parseIPv6Address(addressStr: string): IpAddress =
|
|||
groupCount = 0
|
||||
currentGroupStart = 0
|
||||
currentShort:uint32 = 0
|
||||
seperatorValid = true
|
||||
separatorValid = true
|
||||
dualColonGroup = -1
|
||||
lastWasColon = false
|
||||
v4StartPos = -1
|
||||
|
|
@ -280,15 +280,15 @@ proc parseIPv6Address(addressStr: string): IpAddress =
|
|||
|
||||
for i,c in addressStr:
|
||||
if c == ':':
|
||||
if not seperatorValid:
|
||||
if not separatorValid:
|
||||
raise newException(ValueError,
|
||||
"Invalid IP Address. Address contains an invalid seperator")
|
||||
"Invalid IP Address. Address contains an invalid separator")
|
||||
if lastWasColon:
|
||||
if dualColonGroup != -1:
|
||||
raise newException(ValueError,
|
||||
"Invalid IP Address. Address contains more than one \"::\" seperator")
|
||||
"Invalid IP Address. Address contains more than one \"::\" separator")
|
||||
dualColonGroup = groupCount
|
||||
seperatorValid = false
|
||||
separatorValid = false
|
||||
elif i != 0 and i != high(addressStr):
|
||||
if groupCount >= 8:
|
||||
raise newException(ValueError,
|
||||
|
|
@ -297,7 +297,7 @@ proc parseIPv6Address(addressStr: string): IpAddress =
|
|||
result.address_v6[groupCount*2+1] = cast[uint8](currentShort and 0xFF)
|
||||
currentShort = 0
|
||||
groupCount.inc()
|
||||
if dualColonGroup != -1: seperatorValid = false
|
||||
if dualColonGroup != -1: separatorValid = false
|
||||
elif i == 0: # only valid if address starts with ::
|
||||
if addressStr[1] != ':':
|
||||
raise newException(ValueError,
|
||||
|
|
@ -309,11 +309,11 @@ proc parseIPv6Address(addressStr: string): IpAddress =
|
|||
lastWasColon = true
|
||||
currentGroupStart = i + 1
|
||||
elif c == '.': # Switch to parse IPv4 mode
|
||||
if i < 3 or not seperatorValid or groupCount >= 7:
|
||||
if i < 3 or not separatorValid or groupCount >= 7:
|
||||
raise newException(ValueError, "Invalid IP Address")
|
||||
v4StartPos = currentGroupStart
|
||||
currentShort = 0
|
||||
seperatorValid = false
|
||||
separatorValid = false
|
||||
break
|
||||
elif c in strutils.HexDigits:
|
||||
if c in strutils.Digits: # Normal digit
|
||||
|
|
@ -326,14 +326,14 @@ proc parseIPv6Address(addressStr: string): IpAddress =
|
|||
raise newException(ValueError,
|
||||
"Invalid IP Address. Value is out of range")
|
||||
lastWasColon = false
|
||||
seperatorValid = true
|
||||
separatorValid = true
|
||||
else:
|
||||
raise newException(ValueError,
|
||||
"Invalid IP Address. Address contains an invalid character")
|
||||
|
||||
|
||||
if v4StartPos == -1: # Don't parse v4. Copy the remaining v6 stuff
|
||||
if seperatorValid: # Copy remaining data
|
||||
if separatorValid: # Copy remaining data
|
||||
if groupCount >= 8:
|
||||
raise newException(ValueError,
|
||||
"Invalid IP Address. The address consists of too many groups")
|
||||
|
|
@ -347,19 +347,19 @@ proc parseIPv6Address(addressStr: string): IpAddress =
|
|||
if currentShort > 255'u32:
|
||||
raise newException(ValueError,
|
||||
"Invalid IP Address. Value is out of range")
|
||||
seperatorValid = true
|
||||
separatorValid = true
|
||||
elif c == '.': # IPv4 address separator
|
||||
if not seperatorValid or byteCount >= 3:
|
||||
if not separatorValid or byteCount >= 3:
|
||||
raise newException(ValueError, "Invalid IP Address")
|
||||
result.address_v6[groupCount*2 + byteCount] = cast[uint8](currentShort)
|
||||
currentShort = 0
|
||||
byteCount.inc()
|
||||
seperatorValid = false
|
||||
separatorValid = false
|
||||
else: # Invalid character
|
||||
raise newException(ValueError,
|
||||
"Invalid IP Address. Address contains an invalid character")
|
||||
|
||||
if byteCount != 3 or not seperatorValid:
|
||||
if byteCount != 3 or not separatorValid:
|
||||
raise newException(ValueError, "Invalid IP Address")
|
||||
result.address_v6[groupCount*2 + byteCount] = cast[uint8](currentShort)
|
||||
groupCount += 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue