aboutsummaryrefslogtreecommitdiff
path: root/lib/inet_pton.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/inet_pton.c')
-rw-r--r--lib/inet_pton.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/lib/inet_pton.c b/lib/inet_pton.c
index 163df3ce3..e7ad83bbb 100644
--- a/lib/inet_pton.c
+++ b/lib/inet_pton.c
@@ -111,26 +111,28 @@ inet_pton4(const char *src, unsigned char *dst)
while ((ch = *src++) != '\0') {
const char *pch;
- if ((pch = strchr(digits, ch)) != NULL) {
+ if((pch = strchr(digits, ch)) != NULL) {
unsigned int val = *tp * 10 + (unsigned int)(pch - digits);
- if (val > 255)
+ if(val > 255)
return (0);
*tp = (unsigned char)val;
- if (! saw_digit) {
- if (++octets > 4)
+ if(! saw_digit) {
+ if(++octets > 4)
return (0);
saw_digit = 1;
}
- } else if (ch == '.' && saw_digit) {
- if (octets == 4)
+ }
+ else if(ch == '.' && saw_digit) {
+ if(octets == 4)
return (0);
*++tp = 0;
saw_digit = 0;
- } else
+ }
+ else
return (0);
}
- if (octets < 4)
+ if(octets < 4)
return (0);
/* bcopy(tmp, dst, INADDRSZ); */
memcpy(dst, tmp, INADDRSZ);
@@ -165,8 +167,8 @@ inet_pton6(const char *src, unsigned char *dst)
endp = tp + IN6ADDRSZ;
colonp = NULL;
/* Leading :: requires some special handling. */
- if (*src == ':')
- if (*++src != ':')
+ if(*src == ':')
+ if(*++src != ':')
return (0);
curtok = src;
saw_xdigit = 0;
@@ -174,25 +176,25 @@ inet_pton6(const char *src, unsigned char *dst)
while ((ch = *src++) != '\0') {
const char *pch;
- if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
+ if((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
pch = strchr((xdigits = xdigits_u), ch);
- if (pch != NULL) {
+ if(pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
- if (val > 0xffff)
+ if(val > 0xffff)
return (0);
saw_xdigit = 1;
continue;
}
- if (ch == ':') {
+ if(ch == ':') {
curtok = src;
- if (!saw_xdigit) {
- if (colonp)
+ if(!saw_xdigit) {
+ if(colonp)
return (0);
colonp = tp;
continue;
}
- if (tp + INT16SZ > endp)
+ if(tp + INT16SZ > endp)
return (0);
*tp++ = (unsigned char) (val >> 8) & 0xff;
*tp++ = (unsigned char) val & 0xff;
@@ -200,7 +202,7 @@ inet_pton6(const char *src, unsigned char *dst)
val = 0;
continue;
}
- if (ch == '.' && ((tp + INADDRSZ) <= endp) &&
+ if(ch == '.' && ((tp + INADDRSZ) <= endp) &&
inet_pton4(curtok, tp) > 0) {
tp += INADDRSZ;
saw_xdigit = 0;
@@ -208,13 +210,13 @@ inet_pton6(const char *src, unsigned char *dst)
}
return (0);
}
- if (saw_xdigit) {
- if (tp + INT16SZ > endp)
+ if(saw_xdigit) {
+ if(tp + INT16SZ > endp)
return (0);
*tp++ = (unsigned char) (val >> 8) & 0xff;
*tp++ = (unsigned char) val & 0xff;
}
- if (colonp != NULL) {
+ if(colonp != NULL) {
/*
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
@@ -228,7 +230,7 @@ inet_pton6(const char *src, unsigned char *dst)
}
tp = endp;
}
- if (tp != endp)
+ if(tp != endp)
return (0);
/* bcopy(tmp, dst, IN6ADDRSZ); */
memcpy(dst, tmp, IN6ADDRSZ);