summaryrefslogtreecommitdiff
path: root/gpsutils.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-02-19 11:03:40 -0500
committerEric S. Raymond <esr@thyrsus.com>2011-02-19 11:03:40 -0500
commit7ec2ee0d6dcf1e02b0e24a159802608b6e0ae09d (patch)
treebe27e7142a732b0a70a5c6feeeeda46e61a9da2c /gpsutils.c
parentf96e3c83d48904a54f9e990831f8dcad62969aad (diff)
downloadgpsd-7ec2ee0d6dcf1e02b0e24a159802608b6e0ae09d.tar.gz
Bulletproof a formatting function against C library variations.
Diffstat (limited to 'gpsutils.c')
-rw-r--r--gpsutils.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/gpsutils.c b/gpsutils.c
index a99d5827..7c5f3516 100644
--- a/gpsutils.c
+++ b/gpsutils.c
@@ -7,6 +7,7 @@
#include <time.h>
#include <sys/time.h>
#include <stdlib.h>
+#include <string.h>
#include <math.h>
#include "gpsd.h"
@@ -152,7 +153,7 @@ double iso8601_to_unix( /*@in@*/ char *isotime)
(void)strftime(timestr, sizeof(timestr), "%Y-%m-%dT%H:%M:%S", &when);
(void)snprintf(fractstr, sizeof(fractstr), "%.2f", fractional);
/* add fractional part, ignore leading 0; "0.2" -> ".2" */
- (void)snprintf(isotime, len, "%s%sZ", timestr, fractstr + 1);
+ (void)snprintf(isotime, len, "%s%sZ", timestr, strchr(fractstr, '.'));
return isotime;
}
/* *INDENT-ON* */