www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/07/16/06:33:06

Date: Thu, 16 Jul 1998 13:32:49 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: DJ Delorie <dj AT delorie DOT com>
cc: djgpp-workers AT delorie DOT com, Kbwms AT aol DOT com
Subject: Re: 2.02 alpha 980712
In-Reply-To: <199807131253.IAA16812@delorie.com>
Message-ID: <Pine.SUN.3.91.980716133205.17398P-100000@is>
MIME-Version: 1.0

Here's a patch which corrects `strtod' behavior in cases like
"-211.8+", "0e+1" and "3.e+".  Many thanks to K.B. Williams
<Kbwms AT aol DOT com> for help in testing this.

*** src/libc/ansi/stdlib/strtod.c~0	Thu Jan  1 23:10:54 1998
--- src/libc/ansi/stdlib/strtod.c	Sat Jul 11 10:38:36 1998
*************** strtod(const char *s, char **sret)
*** 24,29 ****
--- 24,32 ----
    e = 0;
    esign = 1;
  
+   if (sret)
+     *sret = unconst(s, char *);
+ 
    while ((*s == ' ') || (*s == '\t'))
      s++;
  
*************** strtod(const char *s, char **sret)
*** 56,67 ****
      }
    }
  
!   if (flags == 0 || r == 0)
!   {
!     if (sret)
!       *sret = unconst(s, char *);
      return 0;
!   }
  
    if ((*s == 'e') || (*s == 'E'))
    {
--- 59,69 ----
      }
    }
  
!   if (flags == 0)
      return 0;
! 
!   if (sret)
!     *sret = unconst(s, char *);
  
    if ((*s == 'e') || (*s == 'E'))
    {
*************** strtod(const char *s, char **sret)
*** 74,84 ****
        esign = -1;
      }
      if ((*s < '0') || (*s > '9'))
!     {
!       if (sret)
! 	*sret = unconst(s, char *);
!       return r;
!     }
  
      while ((*s >= '0') && (*s <= '9'))
      {
--- 76,82 ----
        esign = -1;
      }
      if ((*s < '0') || (*s > '9'))
!       return r * sign;
  
      while ((*s >= '0') && (*s <= '9'))
      {

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019