Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Dec 2012 01:44:59 +0000 (UTC)
From:      Greg Lehey <grog@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r244166 - head/usr.bin/calendar
Message-ID:  <201212130144.qBD1ixxP006877@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: grog
Date: Thu Dec 13 01:44:58 2012
New Revision: 244166
URL: http://svnweb.freebsd.org/changeset/base/244166

Log:
  Reluctantly remove one of the most extraordinary numeric conversion
  routines I have ever seen and replace with something far more boring.

Modified:
  head/usr.bin/calendar/parsedata.c

Modified: head/usr.bin/calendar/parsedata.c
==============================================================================
--- head/usr.bin/calendar/parsedata.c	Thu Dec 13 01:39:49 2012	(r244165)
+++ head/usr.bin/calendar/parsedata.c	Thu Dec 13 01:44:58 2012	(r244166)
@@ -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++) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212130144.qBD1ixxP006877>