2 * The Regina Rexx Interpreter
3 * Copyright (C) 1992-1994 Anders Christensen <anders@pvv.unit.no>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * More attention should be paid to overflow and underflow conditions.
22 * This *is* done in some of the routines for the GCC compiler, but should
23 * be done in an ANSI-compatible manner.
33 double strtod( const char *, char ** ) ;
36 double myatof( const tsd_t
*TSD
, const streng
*string
)
41 str
= str_ofTSD(string
) ;
42 answer
= strtod(str
,&ptr
) ;
44 /* remove leading spaces */
45 for (;(*ptr
)&&(rx_isspace(*ptr
));ptr
++) ;
46 #ifdef SUNOS_STRTOD_BUG
47 for (;*ptr
=='0';ptr
++) ;
48 #endif /* SUNOS_STRTOD_BUG */
50 exiterror( ERR_BAD_ARITHMETIC
, 0 ) ;
58 * Takes 'string' as parameter, analyze whether it is an integer, and
59 * return a boolean variable which is true iff 'string' is a legal
60 * integer. The format of a legal integer is (the regexpr):
61 * [ ]*([-+][ ]*)?[0-9]+[ ]*
63 int myisinteger( const streng
*string
)
65 const char *cptr
=NULL
, *eptr
=NULL
;
67 cptr
= string
->value
;
68 eptr
= cptr
+ string
->len
;
70 for (;cptr
<eptr
&& rx_isspace(*cptr
); cptr
++) ;
71 if (cptr
<eptr
&& (*cptr
=='-' || *cptr
=='+'))
72 for (cptr
++; cptr
<eptr
&& rx_isspace(*cptr
); cptr
++) ;
77 for (;cptr
<eptr
&& rx_isdigit(*cptr
); cptr
++) ;
78 for (;cptr
<eptr
&& rx_isspace(*cptr
); cptr
++) ;