4 * atolfp - convert an ascii string to an l_fp number
10 #include "ntp_string.h"
15 static u_long ten_to_the_n
[10] = {
35 register const char *cp
;
36 register u_long dec_i
;
37 register u_long dec_f
;
41 static const char *digits
= "0123456789";
49 * We understand numbers of the form:
51 * [spaces][-|+][digits][.][digits][spaces|\n|\0]
53 while (isspace((int)*cp
))
64 if (*cp
!= '.' && !isdigit((int)*cp
))
67 while (*cp
!= '\0' && (ind
= strchr(digits
, *cp
)) != NULL
) {
68 dec_i
= (dec_i
<< 3) + (dec_i
<< 1); /* multiply by 10 */
69 dec_i
+= (ind
- digits
);
73 if (*cp
!= '\0' && !isspace((int)*cp
)) {
77 while (ndec
< 9 && *cp
!= '\0'
78 && (ind
= strchr(digits
, *cp
)) != NULL
) {
80 dec_f
= (dec_f
<< 3) + (dec_f
<< 1); /* *10 */
81 dec_f
+= (ind
- digits
);
85 while (isdigit((int)*cp
))
88 if (*cp
!= '\0' && !isspace((int)*cp
))
95 register u_long ten_fact
;
97 ten_fact
= ten_to_the_n
[ndec
];
103 if (dec_f
>= ten_fact
) {
109 if ((dec_f
<< 1) > ten_fact
)