aboutsummaryrefslogtreecommitdiff
path: root/contrib/ntp/libntp/mstolfp.c
diff options
context:
space:
mode:
authorOllivier Robert <roberto@FreeBSD.org>2008-08-17 17:37:33 +0000
committerOllivier Robert <roberto@FreeBSD.org>2008-08-17 17:37:33 +0000
commitcce65f439697627afbccf5a67035a957bb4d784a (patch)
tree16d100fbc9dae63888d48b464e471ba0e5065193 /contrib/ntp/libntp/mstolfp.c
parent8c24a1e0ffd629427f94da1b681600008030c41a (diff)
Flatten the dist and various 4.n.n trees in preparation of future ntp imports.
Notes
Notes: svn path=/vendor/ntp/dist/; revision=181800
Diffstat (limited to 'contrib/ntp/libntp/mstolfp.c')
-rw-r--r--contrib/ntp/libntp/mstolfp.c100
1 files changed, 0 insertions, 100 deletions
diff --git a/contrib/ntp/libntp/mstolfp.c b/contrib/ntp/libntp/mstolfp.c
deleted file mode 100644
index e4e909df7dbe..000000000000
--- a/contrib/ntp/libntp/mstolfp.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * mstolfp - convert an ascii string in milliseconds to an l_fp number
- */
-#include <stdio.h>
-#include <ctype.h>
-
-#include "ntp_fp.h"
-#include "ntp_stdlib.h"
-
-int
-mstolfp(
- const char *str,
- l_fp *lfp
- )
-{
- register const char *cp;
- register char *bp;
- register const char *cpdec;
- char buf[100];
-
- /*
- * We understand numbers of the form:
- *
- * [spaces][-][digits][.][digits][spaces|\n|\0]
- *
- * This is one enormous hack. Since I didn't feel like
- * rewriting the decoding routine for milliseconds, what
- * is essentially done here is to make a copy of the string
- * with the decimal moved over three places so the seconds
- * decoding routine can be used.
- */
- bp = buf;
- cp = str;
- while (isspace((int)*cp))
- cp++;
-
- if (*cp == '-') {
- *bp++ = '-';
- cp++;
- }
-
- if (*cp != '.' && !isdigit((int)*cp))
- return 0;
-
-
- /*
- * Search forward for the decimal point or the end of the string.
- */
- cpdec = cp;
- while (isdigit((int)*cpdec))
- cpdec++;
-
- /*
- * Found something. If we have more than three digits copy the
- * excess over, else insert a leading 0.
- */
- if ((cpdec - cp) > 3) {
- do {
- *bp++ = (char)*cp++;
- } while ((cpdec - cp) > 3);
- } else {
- *bp++ = '0';
- }
-
- /*
- * Stick the decimal in. If we've got less than three digits in
- * front of the millisecond decimal we insert the appropriate number
- * of zeros.
- */
- *bp++ = '.';
- if ((cpdec - cp) < 3) {
- register int i = 3 - (cpdec - cp);
-
- do {
- *bp++ = '0';
- } while (--i > 0);
- }
-
- /*
- * Copy the remainder up to the millisecond decimal. If cpdec
- * is pointing at a decimal point, copy in the trailing number too.
- */
- while (cp < cpdec)
- *bp++ = (char)*cp++;
-
- if (*cp == '.') {
- cp++;
- while (isdigit((int)*cp))
- *bp++ = (char)*cp++;
- }
- *bp = '\0';
-
- /*
- * Check to make sure the string is properly terminated. If
- * so, give the buffer to the decoding routine.
- */
- if (*cp != '\0' && !isspace((int)*cp))
- return 0;
- return atolfp(buf, lfp);
-}