@@ -150,7 +150,7 @@ bool IPAddress::fromString4(const char *address)
150150
151151bool IPAddress::fromString6 (const char *address) {
152152uint32_t acc =0 ;// Accumulator
153- int dots =0 ,doubledots = -1 ;
153+ int colons =0 ,double_colons = -1 ;
154154
155155while (*address)
156156 {
@@ -165,7 +165,7 @@ bool IPAddress::fromString6(const char *address) {
165165 }
166166else if (c ==' :' ) {
167167if (*address ==' :' ) {
168- if (doubledots >=0 ) {
168+ if (double_colons >=0 ) {
169169// :: allowed once
170170return false ;
171171 }
@@ -174,41 +174,41 @@ bool IPAddress::fromString6(const char *address) {
174174return false ;
175175 }
176176// remember location
177- doubledots =dots + !!acc;
177+ double_colons =colons + !!acc;
178178 address++;
179179 }else if (*address ==' \0 ' ) {
180180// can't end with a single colon
181181return false ;
182182 }
183- if (dots ==7 )
183+ if (colons ==7 )
184184// too many separators
185185return false ;
186- _address.bytes [dots *2 ] = acc >>8 ;
187- _address.bytes [dots *2 +1 ] = acc &0xff ;
188- dots ++;
186+ _address.bytes [colons *2 ] = acc >>8 ;
187+ _address.bytes [colons *2 +1 ] = acc &0xff ;
188+ colons ++;
189189 acc =0 ;
190190 }
191191else
192192// Invalid char
193193return false ;
194194 }
195195
196- if (doubledots == -1 &&dots !=7 ) {
196+ if (double_colons == -1 &&colons !=7 ) {
197197// Too few separators
198198return false ;
199199 }
200- if (doubledots > -1 &&dots >6 ) {
201- // Too many segments
200+ if (double_colons > -1 &&colons >6 ) {
201+ // Too many segments (double colon must be at least one zero field)
202202return false ;
203203 }
204- _address.bytes [dots *2 ] = acc >>8 ;
205- _address.bytes [dots *2 +1 ] = acc &0xff ;
206- dots ++;
207-
208- if (doubledots != -1 ) {
209- for (int i =dots *2 -doubledots *2 -1 ; i >=0 ; i--)
210- _address.bytes [16 -dots *2 +doubledots *2 + i] = _address.bytes [doubledots *2 + i];
211- for (int i =doubledots *2 ; i <16 -dots *2 +doubledots *2 ; i++)
204+ _address.bytes [colons *2 ] = acc >>8 ;
205+ _address.bytes [colons *2 +1 ] = acc &0xff ;
206+ colons ++;
207+
208+ if (double_colons != -1 ) {
209+ for (int i =colons *2 -double_colons *2 -1 ; i >=0 ; i--)
210+ _address.bytes [16 -colons *2 +double_colons *2 + i] = _address.bytes [double_colons *2 + i];
211+ for (int i =double_colons *2 ; i <16 -colons *2 +double_colons *2 ; i++)
212212 _address.bytes [i] =0 ;
213213 }
214214