Dropping of leading colon must be performed after the "IPv6:" prefix
is stripped.
Also fixed a couple of wrong comments.
g_assert (text != NULL);
g_assert (target != NULL);
+ p = text;
if (len == 0) {
len = strlen (text);
}
- /* Ignore trailing semicolon */
- if (text[0] == ':') {
- p = text + 1;
- len--;
- }
- else {
- p = text;
- }
-
/* Check IPv6 scope */
if ((percent = memchr (p, '%', len)) != NULL && percent > p) {
len = percent - p; /* Ignore scope */
len -= sizeof ("IPv6:") - 1;
}
+ /* Ignore leading colon */
+ if (len > 0 && *p == ':') {
+ p++;
+ len--;
+ }
+
for (/* void */; len; len--) {
t = *p++;
}
if (++nibbles > 4) {
- /* Too many dots */
+ /* Too many digits */
return FALSE;
}