/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1990-1995, by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This file contains the common part of string_to_decimal, func_to_decimal,
* and file_to_decimal. NEXT must be defined to cause CURRENT to contain the
* next input character. ATEOF must be defined to be == EOF if an input
* file is at EOF, != EOF otherwise.
*/
{
int sigfound;
int ids = 0;
int i;
* before point, after point. */
char decpt;
char *pfast;
* string. */
if (fortran_conventions != 0)
decpt = '.';
else
#ifdef PRE41
decpt = '.';
#else
#endif
NEXT;
} /* Skip white space. */
if (fortran_conventions >= 2) {
/*
* All white space - valid zero for Fortran formatted input.
*/
*pform = whitespace_form;
else
goto done;
}
}
if (CURRENT == '+') {
NEXT;
NEXT;
}
*pform = fixed_int_form;
NEXT;
goto number;
} else
switch (CURRENT) {
case ' ':
if (fortran_conventions < 2)
goto firstdefault;
case '0':
*pform = fixed_int_form;
NEXT;
} /* Ignore leading zeros. */
else
sigfound = 0; /* 0 = only zeros found yet. */
goto number;
case 'i':
case 'I':
{ /* Try infinity. */
NEXT;
is = 1;
while (is <= 7 &&
NEXT;
is++;
}
is++; /* To account for infstring
* indexing starting at 0.
*/
}
* valid infinity. */
if (iagree > 3) {
nmax++; /* 1083219 */
}
} else { /* INFINITYxxx */
*pform = infinity_form;
}
}
else {
nmax++; /* 1083219 */
}
goto done;
}
case 'n':
case 'N':
{ /* Try NaN. */
int is;
NEXT;
is = 1;
while (is <= 3 &&
NEXT;
is++;
}
* valid NaN. */
sigfound = 1;
}
* parenthesis. */
sigfound = 1;
NEXT;
}
* string. */
NEXT;
}
if (CURRENT == ')') {
NEXT;
*pform = nanstring_form;
}
else {
nmax++; /* 1083219 */
}
}
else {
nmax++; /* 1083219 */
}
goto done;
}
default:
NEXT; /* Try number. */
goto afterpoint;
}
goto done;
}
* store it all: fake
* end of string. */
* program to terminate
* again. */
} else {
for (i = 0; (i < nzbp); i++)
}
*pform = fixed_int_form;
sigfound = 1;
nzbp = 0;
NEXT;
* common case. */
nfast = 0;
do {
NEXT;
}
}
if (CURRENT == '0')
goto nextnumberzero; /* common case */
good--; /* look out if we fell off end */
goto nextnumber;
} else
switch (CURRENT) {
case ' ':
if (fortran_conventions < 2)
goto numberdefault;
if (fortran_conventions == 2) {
NEXT;
goto nextnumber;
}
case '0':
*pform = fixed_int_form;
* substring. */
if (CURRENT == ' ') {
if (fortran_conventions < 2) {
goto numberdefault;
}
if (fortran_conventions == 2) {
nzbp--; /* Undo effect of
* following nzbp++ */
}
}
nzbp++;
NEXT;
}
goto nextnumber;
case 'E':
case 'e':
* bad format */
goto done;
if (sigfound > 0)
goto exponent;
case '+':
case '-':
case 'D':
case 'd':
case 'Q':
case 'q':
if (fortran_conventions != 0)
goto efound;
default:
NEXT;
goto afterpoint;
}
if (sigfound > 0)
goto done;
}
if (sigfound >= 0) { /* Better accept the point as good, but don't
* accept the next character after. */
good++;
}
switch (*pform) { /* Revise *pform now that point has been
* found. */
case invalid_form:
case whitespace_form:
break;
case fixed_int_form:
break;
}
if (*pform == fixed_intdot_form)
* far. */
sigfound = 1;
} else { /* Significant digits have begun. */
* store it all: fake
* end of string. */
* termination. */
* program to terminate
* again. */
} else {
}
}
nzbp = 0;
nzap = 0;
NEXT;
* common case. */
nfast = 0;
do {
NEXT;
}
good--; /* look out if we fell off end */
}
if (CURRENT == '0')
goto zeroafterpoint;
goto switchafterpoint;
} else
switch (CURRENT) {
case ' ':
if (fortran_conventions < 2)
goto afterpointdefault;
if (fortran_conventions == 2) {
/*
* To pass FCVS, all blanks after point must
* count as if zero seen.
*/
if (sigfound == -1)
sigfound = 0;
NEXT;
goto switchafterpoint;
}
case '0':
if (*pform == fixed_intdot_form)
if (sigfound == -1)
sigfound = 0;
nzap++;
NEXT;
* Fortran. */
if (fortran_conventions < 2) {
goto afterpointdefault;
}
if (fortran_conventions == 2) {
nzap--; /* Undo following nzap++ */
}
}
nzap++;
NEXT;
}
if (*good != '0')
good--;
goto switchafterpoint;
case 'E':
case 'e':
* bad! */
goto done;
if (sigfound > 0)
goto exponent;
case '+':
case '-':
case 'D':
case 'd':
case 'Q':
case 'q':
if (fortran_conventions != 0)
goto efound2;
default:
if (sigfound > 0)
goto done;
}
{
* following blanks. */
NEXT; /* Pass the EeDd. */
if (fortran_conventions >= 2)
while (CURRENT == ' ') {
NEXT;
}
}
if (CURRENT == '+') {
NEXT;
* exponent. */
NEXT;
explicitsign = 1;
}
* exponent. */
if (fortran_conventions < 2)
goto doneexp;
if (fortran_conventions == 2) {
NEXT;
goto exploop;
}
CURRENT = '0';
}
if (explicitexponent <= 400000000) {
}
NEXT;
switch (*pform) {
case whitespace_form:
case fixed_int_form:
break;
case fixed_intdot_form:
break;
case fixed_dotfrac_form:
break;
case fixed_intdotfrac_form:
break;
}
exploop: ;
}
if (explicitsign == 1)
else
}
done:
* blanks found. */
* to now. */
while (CURRENT == ' ') {
NEXT;
}
}
}
if (sigfound < 1)
} else { /* No valid token found. */
*pform = invalid_form;
* nan. */
}
}