2 * atolfp - convert an ascii string to an l_fp number
8 #include "ntp_string.h"
13 static u_long ten_to_the_n[10] = {
33 register const char *cp;
34 register u_long dec_i;
35 register u_long dec_f;
39 static const char *digits = "0123456789";
47 * We understand numbers of the form:
49 * [spaces][-|+][digits][.][digits][spaces|\n|\0]
51 while (isspace((int)*cp))
62 if (*cp != '.' && !isdigit((int)*cp))
65 while (*cp != '\0' && (ind = strchr(digits, *cp)) != NULL) {
66 dec_i = (dec_i << 3) + (dec_i << 1); /* multiply by 10 */
67 dec_i += (ind - digits);
71 if (*cp != '\0' && !isspace((int)*cp)) {
75 while (ndec < 9 && *cp != '\0'
76 && (ind = strchr(digits, *cp)) != NULL) {
78 dec_f = (dec_f << 3) + (dec_f << 1); /* *10 */
79 dec_f += (ind - digits);
83 while (isdigit((int)*cp))
86 if (*cp != '\0' && !isspace((int)*cp))
93 register u_long ten_fact;
95 ten_fact = ten_to_the_n[ndec];
101 if (dec_f >= ten_fact) {
107 if ((dec_f << 1) > ten_fact)