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++) {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to