From 15f27702f1e1c5e07652d0d182304b1840918d11 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Wed, 3 Jan 2018 15:01:13 +0000 Subject: [PATCH] minor changes to IP6Address>>fromString: --- moo/kernel/Socket.moo | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/moo/kernel/Socket.moo b/moo/kernel/Socket.moo index fbd962b..0f3c93b 100644 --- a/moo/kernel/Socket.moo +++ b/moo/kernel/Socket.moo @@ -100,13 +100,14 @@ class(#byte) IP6Address(IPAddress) method __fromString: str { - | pos size ch tgpos v1 val curtok saw_xdigit colonpos | + | pos size mysize ch tgpos v1 val curtok saw_xdigit colonpos | pos := 0. size := str size. + mysize := self basicSize. ## handle leading :: specially - if (size > 0 and: [ (str at: pos) == $: ]) + if (size > 0 and: [(str at: pos) == $:]) { pos := pos + 1. if (pos >= size or: [ (str at: pos) ~~ $:]) { ^Error.Code.EINVAL }. @@ -161,11 +162,12 @@ class(#byte) IP6Address(IPAddress) continue. }. - (*if (ch == $. and: []) + if (ch == $. and: [tgpos + 4 <= mysize] { - saw_xdigit := true. + tgpos := tgpos + 4. + saw_xdigit := false. break. - }.*) + }. ## invalid character in the address @@ -183,10 +185,10 @@ class(#byte) IP6Address(IPAddress) if (colonpos >= 0) { ## double colon position - self basicShiftFrom: colonpos to: (colonpos + (self basicSize - tgpos)) count: (tgpos - colonpos). - ##tgpos := tgpos + (self basicSize - tgpos). + self basicShiftFrom: colonpos to: (colonpos + (mysize - tgpos)) count: (tgpos - colonpos). + ##tgpos := tgpos + (mysize - tgpos). } - elsif (tgpos ~~ (self basicSize)) + elsif (tgpos ~~ mysize) { ^Error.Code.EINVAL }.