diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-02-19 11:03:40 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-02-19 11:03:40 -0500 |
commit | 7ec2ee0d6dcf1e02b0e24a159802608b6e0ae09d (patch) | |
tree | be27e7142a732b0a70a5c6feeeeda46e61a9da2c /gpsutils.c | |
parent | f96e3c83d48904a54f9e990831f8dcad62969aad (diff) | |
download | gpsd-7ec2ee0d6dcf1e02b0e24a159802608b6e0ae09d.tar.gz |
Bulletproof a formatting function against C library variations.
Diffstat (limited to 'gpsutils.c')
-rw-r--r-- | gpsutils.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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* */ |