~pac72/ubuntu/lucid/ddd/devel

« back to all changes in this revision

Viewing changes to libiberty/strtod.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Schepler
  • Date: 2004-07-22 03:49:37 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040722034937-cysl08t1jvba4jrx
Tags: 1:3.3.9-3
USERINFO has been renamed to USERINFO.txt; adjust debian/rules code
to match, to get correct information on the About DDD dialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Implementation of strtod for systems with atof.
2
 
   Copyright (C) 1991, 1995 Free Software Foundation, Inc.
 
2
   Copyright (C) 1991, 1995, 2002 Free Software Foundation, Inc.
3
3
 
4
4
This file is part of the libiberty library.  This library is free
5
5
software; you can redistribute it and/or modify it under the
22
22
This exception does not however invalidate any other reasons why
23
23
the executable file might be covered by the GNU General Public License. */
24
24
 
25
 
#include <ctype.h>
 
25
/*
 
26
 
 
27
@deftypefn Supplemental double strtod (const char *@var{string}, char **@var{endptr})
 
28
 
 
29
This ISO C function converts the initial portion of @var{string} to a
 
30
@code{double}.  If @var{endptr} is not @code{NULL}, a pointer to the
 
31
character after the last character used in the conversion is stored in
 
32
the location referenced by @var{endptr}.  If no conversion is
 
33
performed, zero is returned and the value of @var{string} is stored in
 
34
the location referenced by @var{endptr}.
 
35
 
 
36
@end deftypefn
 
37
 
 
38
*/
 
39
 
 
40
#include "ansidecl.h"
 
41
#include "safe-ctype.h"
26
42
 
27
43
extern double atof ();
28
44
 
42
58
  
43
59
  p = str;
44
60
  
45
 
  while (isspace (*p))
 
61
  while (ISSPACE (*p))
46
62
    ++p;
47
63
  
48
64
  if (*p == '+' || *p == '-')
59
75
          && (p[6] == 't' || p[6] == 'T')
60
76
          && (p[7] == 'y' || p[7] == 'Y'))
61
77
        {
62
 
          *ptr = p + 7;
 
78
          *ptr = p + 8;
63
79
          return atof (str);
64
80
        }
65
81
      else
88
104
    }
89
105
 
90
106
  /* digits, with 0 or 1 periods in it.  */
91
 
  if (isdigit (*p) || *p == '.')
 
107
  if (ISDIGIT (*p) || *p == '.')
92
108
    {
93
109
      int got_dot = 0;
94
 
      while (isdigit (*p) || (!got_dot && *p == '.'))
 
110
      while (ISDIGIT (*p) || (!got_dot && *p == '.'))
95
111
        {
96
112
          if (*p == '.')
97
113
            got_dot = 1;
105
121
          i = 1;
106
122
          if (p[i] == '+' || p[i] == '-')
107
123
            ++i;
108
 
          if (isdigit (p[i]))
 
124
          if (ISDIGIT (p[i]))
109
125
            {
110
 
              while (isdigit (p[i]))
 
126
              while (ISDIGIT (p[i]))
111
127
                ++i;
112
128
              *ptr = p + i;
113
129
              return atof (str);