about summary refs log tree commit diff
path: root/resolv/res_debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'resolv/res_debug.c')
-rw-r--r--resolv/res_debug.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/resolv/res_debug.c b/resolv/res_debug.c
index fa2ca80c34..3afe8c23a8 100644
--- a/resolv/res_debug.c
+++ b/resolv/res_debug.c
@@ -1146,40 +1146,47 @@ static u_int8_t
 precsize_aton(strptr)
 	char **strptr;
 {
-	unsigned int mval = 0, cmval = 0;
 	u_int8_t retval = 0;
-	register char *cp;
-	register int exponent;
-	register int mantissa;
+	char *cp;
+	int exponent = 0;
+	int mantissa = 0;
 
 	cp = *strptr;
+	while (isdigit(*cp)) {
+		if (mantissa == 0)
+			mantissa = *cp - '0';
+		else
+			exponent++;
+		cp++;
+	}
 
-	while (isdigit(*cp))
-		mval = mval * 10 + (*cp++ - '0');
-
-	if (*cp == '.') {		/* centimeters */
+	if (*cp == '.') {
 		cp++;
 		if (isdigit(*cp)) {
-			cmval = (*cp++ - '0') * 10;
+			if (mantissa == 0)
+				mantissa = *cp - '0';
+			else
+				exponent++;
+			cp++;
+
 			if (isdigit(*cp)) {
-				cmval += (*cp++ - '0');
+				if (mantissa == 0)
+					mantissa = *cp - '0';
+				else
+					exponent++;
+				cp++;
 			}
+			else
+				exponent++;
 		}
 	}
-	cmval = (mval * 100) + cmval;
-
-	for (exponent = 0; exponent < 9; exponent++)
-		if (cmval < poweroften[exponent+1])
-			break;
-
-	mantissa = cmval / poweroften[exponent];
-	if (mantissa > 9)
-		mantissa = 9;
+	else
+		exponent += 2;
 
+	if (mantissa == 0)
+		exponent = 0;
 	retval = (mantissa << 4) | exponent;
-
 	*strptr = cp;
-
 	return (retval);
 }