From d6a381f8c9a4b998167fb3ab30f28b5bf1482d4c Mon Sep 17 00:00:00 2001 From: Greg Lehey Date: Thu, 13 Dec 2012 01:44:58 +0000 Subject: [PATCH] Reluctantly remove one of the most extraordinary numeric conversion routines I have ever seen and replace with something far more boring. --- usr.bin/calendar/parsedata.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/usr.bin/calendar/parsedata.c b/usr.bin/calendar/parsedata.c index 63e43957d61b..4d45385d3d1d 100644 --- a/usr.bin/calendar/parsedata.c +++ b/usr.bin/calendar/parsedata.c @@ -940,15 +940,13 @@ indextooffset(char *s) { int i; struct fixs *n; + char *es; if (s[0] == '+' || s[0] == '-') { - char ss[9]; - for (i = -100; i < 100; i++) { - sprintf(ss, "%s%d", (i > 0) ? "+" : "", i); - if (strcmp(ss, s) == 0) - return (i); - } - return (0); + i = strtod (s, &es); + if (*es != '\0') /* trailing junk */ + errx (1, "Invalid specifier format: %s\n", s); + return (i); } for (i = 0; i < 6; i++) {