de-lint. disable c++ parentheses warnings. fix casts in AROSPDFApp.cc
[AROS-Contrib.git] / regina / cmath.c
blob9eb3de38d5174f7bd4c18723cf84259ed023fa0f
1 /*
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.
27 #include "rexx.h"
28 #include <math.h>
29 #include <stdio.h>
30 #include <string.h>
32 #ifdef SunKludges
33 double strtod( const char *, char ** ) ;
34 #endif
36 double myatof( const tsd_t *TSD, const streng *string )
38 char *str,*ptr ;
39 double answer ;
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 */
49 if (*ptr)
50 exiterror( ERR_BAD_ARITHMETIC, 0 ) ;
51 FreeTSD( str ) ;
53 return answer ;
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++) ;
74 if (cptr>=eptr)
75 return 0 ;
77 for (;cptr<eptr && rx_isdigit(*cptr); cptr++) ;
78 for (;cptr<eptr && rx_isspace(*cptr); cptr++) ;
79 return (cptr==eptr) ;