2001-05-17 02:59:29 +08:00
|
|
|
#include "config.h"
|
1998-02-01 09:37:08 +08:00
|
|
|
#include <ctype.h>
|
|
|
|
#include "f2c.h"
|
|
|
|
#include "fio.h"
|
|
|
|
|
|
|
|
extern int f__cursor;
|
|
|
|
#undef abs
|
|
|
|
#undef min
|
|
|
|
#undef max
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "fmt.h"
|
|
|
|
#include "fp.h"
|
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
static int
|
|
|
|
rd_Z (Uint * n, int w, ftnlen len)
|
1998-02-01 09:37:08 +08:00
|
|
|
{
|
2002-06-01 20:38:32 +08:00
|
|
|
long x[9];
|
|
|
|
char *s, *s0, *s1, *se, *t;
|
|
|
|
int ch, i, w1, w2;
|
|
|
|
static char hex[256];
|
|
|
|
static int one = 1;
|
|
|
|
int bad = 0;
|
1998-02-01 09:37:08 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
if (!hex['0'])
|
|
|
|
{
|
|
|
|
s = "0123456789";
|
dfe.c (s_rdfe, s_wdfe): Wrap parentheses around assignment used as truth value.
* libI77/dfe.c (s_rdfe, s_wdfe): Wrap parentheses around
assignment used as truth value.
* libI77/due.c (s_rdue, s_wdue): Likewise.
* libI77/endfile.c (f_end): Likewise.
* libI77/iio.c (s_rsfi, s_wsfi): Likewise.
* libI77/lread.c (ERR, l_C, nmL_getc, s_rsle): Likewise.
* libI77/lwrite.c (l_g, l_put): Likewise.
* libI77/open.c (f_open): Likewise.
* libI77/rdfmt.c (rd_Z): Likewise.
* libI77/rsfe.c (s_rsfe): Likewise.
* libI77/rsne.c (hash, mk_hashtab, nl_init, getname, getdimen,
x_rsne, s_rsne): Likewise.
* libI77/sue.c (s_rsue, s_wsue): Likewise.
* libI77/wref.c (wrt_E, wrt_F): Likewise.
* libI77/wsfe.c (s_wsfe): Likewise.
* libI77/wsle.c (s_wsle): Likewise.
* libI77/wsne.c (s_wsne): Likewise.
From-SVN: r54172
2002-06-02 22:34:31 +08:00
|
|
|
while ((ch = *s++))
|
2002-06-01 20:38:32 +08:00
|
|
|
hex[ch] = ch - '0' + 1;
|
|
|
|
s = "ABCDEF";
|
dfe.c (s_rdfe, s_wdfe): Wrap parentheses around assignment used as truth value.
* libI77/dfe.c (s_rdfe, s_wdfe): Wrap parentheses around
assignment used as truth value.
* libI77/due.c (s_rdue, s_wdue): Likewise.
* libI77/endfile.c (f_end): Likewise.
* libI77/iio.c (s_rsfi, s_wsfi): Likewise.
* libI77/lread.c (ERR, l_C, nmL_getc, s_rsle): Likewise.
* libI77/lwrite.c (l_g, l_put): Likewise.
* libI77/open.c (f_open): Likewise.
* libI77/rdfmt.c (rd_Z): Likewise.
* libI77/rsfe.c (s_rsfe): Likewise.
* libI77/rsne.c (hash, mk_hashtab, nl_init, getname, getdimen,
x_rsne, s_rsne): Likewise.
* libI77/sue.c (s_rsue, s_wsue): Likewise.
* libI77/wref.c (wrt_E, wrt_F): Likewise.
* libI77/wsfe.c (s_wsfe): Likewise.
* libI77/wsle.c (s_wsle): Likewise.
* libI77/wsne.c (s_wsne): Likewise.
From-SVN: r54172
2002-06-02 22:34:31 +08:00
|
|
|
while ((ch = *s++))
|
2002-06-01 20:38:32 +08:00
|
|
|
hex[ch] = hex[ch + 'a' - 'A'] = ch - 'A' + 11;
|
|
|
|
}
|
|
|
|
s = s0 = (char *) x;
|
|
|
|
s1 = (char *) &x[4];
|
|
|
|
se = (char *) &x[8];
|
2002-06-02 20:54:28 +08:00
|
|
|
if (len > 4 * (ftnlen) sizeof (long))
|
2002-06-01 20:38:32 +08:00
|
|
|
return errno = 117;
|
|
|
|
while (w)
|
|
|
|
{
|
|
|
|
GET (ch);
|
|
|
|
if (ch == ',' || ch == '\n')
|
|
|
|
break;
|
|
|
|
w--;
|
|
|
|
if (ch > ' ')
|
|
|
|
{
|
|
|
|
if (!hex[ch & 0xff])
|
|
|
|
bad++;
|
|
|
|
*s++ = ch;
|
|
|
|
if (s == se)
|
|
|
|
{
|
|
|
|
/* discard excess characters */
|
|
|
|
for (t = s0, s = s1; t < s1;)
|
|
|
|
*t++ = *s++;
|
|
|
|
s = s1;
|
|
|
|
}
|
1998-02-01 09:37:08 +08:00
|
|
|
}
|
2002-06-01 20:38:32 +08:00
|
|
|
}
|
|
|
|
if (bad)
|
|
|
|
return errno = 115;
|
|
|
|
w = (int) len;
|
|
|
|
w1 = s - s0;
|
2002-06-04 10:24:26 +08:00
|
|
|
w2 = (w1 + 1) >> 1;
|
2002-06-01 20:38:32 +08:00
|
|
|
t = (char *) n;
|
|
|
|
if (*(char *) &one)
|
|
|
|
{
|
|
|
|
/* little endian */
|
|
|
|
t += w - 1;
|
|
|
|
i = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i = 1;
|
|
|
|
for (; w > w2; t += i, --w)
|
|
|
|
*t = 0;
|
|
|
|
if (!w)
|
|
|
|
return 0;
|
|
|
|
if (w < w2)
|
|
|
|
s0 = s - (w << 1);
|
|
|
|
else if (w1 & 1)
|
|
|
|
{
|
|
|
|
*t = hex[*s0++ & 0xff] - 1;
|
|
|
|
if (!--w)
|
|
|
|
return 0;
|
|
|
|
t += i;
|
|
|
|
}
|
|
|
|
do
|
|
|
|
{
|
2002-06-04 10:24:26 +08:00
|
|
|
*t = (hex[*s0 & 0xff] - 1) << 4 | (hex[s0[1] & 0xff] - 1);
|
2002-06-01 20:38:32 +08:00
|
|
|
t += i;
|
|
|
|
s0 += 2;
|
|
|
|
}
|
|
|
|
while (--w);
|
|
|
|
return 0;
|
|
|
|
}
|
1998-02-01 09:37:08 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
static int
|
|
|
|
rd_I (Uint * n, int w, ftnlen len, register int base)
|
1999-05-03 16:35:22 +08:00
|
|
|
{
|
2002-06-02 20:59:22 +08:00
|
|
|
int ch, sign;
|
2002-06-01 20:38:32 +08:00
|
|
|
longint x = 0;
|
1999-05-03 16:35:22 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
if (w <= 0)
|
|
|
|
goto have_x;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
GET (ch);
|
|
|
|
if (ch != ' ')
|
|
|
|
break;
|
|
|
|
if (!--w)
|
|
|
|
goto have_x;
|
|
|
|
}
|
|
|
|
sign = 0;
|
|
|
|
switch (ch)
|
|
|
|
{
|
|
|
|
case ',':
|
|
|
|
case '\n':
|
|
|
|
w = 0;
|
|
|
|
goto have_x;
|
|
|
|
case '-':
|
|
|
|
sign = 1;
|
|
|
|
case '+':
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (ch >= '0' && ch <= '9')
|
|
|
|
{
|
|
|
|
x = ch - '0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
goto have_x;
|
|
|
|
}
|
|
|
|
while (--w)
|
|
|
|
{
|
|
|
|
GET (ch);
|
|
|
|
if (ch >= '0' && ch <= '9')
|
|
|
|
{
|
|
|
|
x = x * base + ch - '0';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (ch != ' ')
|
|
|
|
{
|
|
|
|
if (ch == '\n' || ch == ',')
|
|
|
|
w = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (f__cblank)
|
|
|
|
x *= base;
|
|
|
|
}
|
|
|
|
if (sign)
|
|
|
|
x = -x;
|
|
|
|
have_x:
|
|
|
|
if (len == sizeof (integer))
|
|
|
|
n->il = x;
|
|
|
|
else if (len == sizeof (char))
|
|
|
|
n->ic = (char) x;
|
1998-02-01 09:37:08 +08:00
|
|
|
#ifdef Allow_TYQUAD
|
2002-06-01 20:38:32 +08:00
|
|
|
else if (len == sizeof (longint))
|
|
|
|
n->ili = x;
|
1998-02-01 09:37:08 +08:00
|
|
|
#endif
|
2002-06-01 20:38:32 +08:00
|
|
|
else
|
|
|
|
n->is = (short) x;
|
|
|
|
if (w)
|
|
|
|
{
|
|
|
|
while (--w)
|
|
|
|
GET (ch);
|
|
|
|
return errno = 115;
|
|
|
|
}
|
|
|
|
return 0;
|
1998-02-01 09:37:08 +08:00
|
|
|
}
|
1999-05-03 16:35:22 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
static int
|
|
|
|
rd_L (ftnint * n, int w, ftnlen len)
|
|
|
|
{
|
|
|
|
int ch, dot, lv;
|
1999-05-03 16:35:22 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
if (w <= 0)
|
|
|
|
goto bad;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
GET (ch);
|
|
|
|
--w;
|
|
|
|
if (ch != ' ')
|
|
|
|
break;
|
|
|
|
if (!w)
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
dot = 0;
|
|
|
|
retry:
|
|
|
|
switch (ch)
|
|
|
|
{
|
|
|
|
case '.':
|
|
|
|
if (dot++ || !w)
|
|
|
|
goto bad;
|
|
|
|
GET (ch);
|
|
|
|
--w;
|
|
|
|
goto retry;
|
|
|
|
case 't':
|
|
|
|
case 'T':
|
|
|
|
lv = 1;
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
case 'F':
|
|
|
|
lv = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
bad:
|
|
|
|
for (; w > 0; --w)
|
|
|
|
GET (ch);
|
|
|
|
/* no break */
|
|
|
|
case ',':
|
|
|
|
case '\n':
|
|
|
|
return errno = 116;
|
|
|
|
}
|
|
|
|
/* The switch statement that was here
|
|
|
|
didn't cut it: It broke down for targets
|
|
|
|
where sizeof(char) == sizeof(short). */
|
|
|
|
if (len == sizeof (char))
|
|
|
|
*(char *) n = (char) lv;
|
|
|
|
else if (len == sizeof (short))
|
|
|
|
*(short *) n = (short) lv;
|
|
|
|
else
|
|
|
|
*n = lv;
|
|
|
|
while (w-- > 0)
|
|
|
|
{
|
|
|
|
GET (ch);
|
|
|
|
if (ch == ',' || ch == '\n')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
1998-02-01 09:37:08 +08:00
|
|
|
}
|
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
static int
|
|
|
|
rd_F (ufloat * p, int w, int d, ftnlen len)
|
1998-02-01 09:37:08 +08:00
|
|
|
{
|
2002-06-01 20:38:32 +08:00
|
|
|
char s[FMAX + EXPMAXDIGS + 4];
|
|
|
|
register int ch;
|
|
|
|
register char *sp, *spe, *sp1;
|
|
|
|
double x;
|
|
|
|
int scale1, se;
|
|
|
|
long e, exp;
|
1998-02-01 09:37:08 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
sp1 = sp = s;
|
|
|
|
spe = sp + FMAX;
|
|
|
|
exp = -d;
|
|
|
|
x = 0.;
|
1998-02-01 09:37:08 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
GET (ch);
|
|
|
|
w--;
|
|
|
|
}
|
|
|
|
while (ch == ' ' && w);
|
|
|
|
switch (ch)
|
|
|
|
{
|
|
|
|
case '-':
|
|
|
|
*sp++ = ch;
|
|
|
|
sp1++;
|
|
|
|
spe++;
|
|
|
|
case '+':
|
|
|
|
if (!w)
|
|
|
|
goto zero;
|
|
|
|
--w;
|
|
|
|
GET (ch);
|
|
|
|
}
|
|
|
|
while (ch == ' ')
|
|
|
|
{
|
|
|
|
blankdrop:
|
|
|
|
if (!w--)
|
|
|
|
goto zero;
|
|
|
|
GET (ch);
|
|
|
|
}
|
|
|
|
while (ch == '0')
|
|
|
|
{
|
|
|
|
if (!w--)
|
|
|
|
goto zero;
|
|
|
|
GET (ch);
|
|
|
|
}
|
|
|
|
if (ch == ' ' && f__cblank)
|
|
|
|
goto blankdrop;
|
|
|
|
scale1 = f__scale;
|
|
|
|
while (isdigit (ch))
|
|
|
|
{
|
|
|
|
digloop1:
|
|
|
|
if (sp < spe)
|
|
|
|
*sp++ = ch;
|
|
|
|
else
|
|
|
|
++exp;
|
|
|
|
digloop1e:
|
|
|
|
if (!w--)
|
|
|
|
goto done;
|
|
|
|
GET (ch);
|
|
|
|
}
|
|
|
|
if (ch == ' ')
|
|
|
|
{
|
|
|
|
if (f__cblank)
|
|
|
|
{
|
|
|
|
ch = '0';
|
|
|
|
goto digloop1;
|
|
|
|
}
|
|
|
|
goto digloop1e;
|
|
|
|
}
|
|
|
|
if (ch == '.')
|
|
|
|
{
|
|
|
|
exp += d;
|
|
|
|
if (!w--)
|
|
|
|
goto done;
|
|
|
|
GET (ch);
|
|
|
|
if (sp == sp1)
|
|
|
|
{ /* no digits yet */
|
|
|
|
while (ch == '0')
|
|
|
|
{
|
|
|
|
skip01:
|
|
|
|
--exp;
|
|
|
|
skip0:
|
|
|
|
if (!w--)
|
|
|
|
goto done;
|
|
|
|
GET (ch);
|
|
|
|
}
|
|
|
|
if (ch == ' ')
|
|
|
|
{
|
|
|
|
if (f__cblank)
|
|
|
|
goto skip01;
|
|
|
|
goto skip0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (isdigit (ch))
|
|
|
|
{
|
|
|
|
digloop2:
|
|
|
|
if (sp < spe)
|
|
|
|
{
|
|
|
|
*sp++ = ch;
|
|
|
|
--exp;
|
|
|
|
}
|
|
|
|
digloop2e:
|
|
|
|
if (!w--)
|
|
|
|
goto done;
|
|
|
|
GET (ch);
|
|
|
|
}
|
|
|
|
if (ch == ' ')
|
|
|
|
{
|
|
|
|
if (f__cblank)
|
|
|
|
{
|
|
|
|
ch = '0';
|
|
|
|
goto digloop2;
|
|
|
|
}
|
|
|
|
goto digloop2e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (ch)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
se = 1;
|
|
|
|
goto signonly;
|
|
|
|
case '+':
|
|
|
|
se = 0;
|
|
|
|
goto signonly;
|
|
|
|
case 'e':
|
|
|
|
case 'E':
|
|
|
|
case 'd':
|
|
|
|
case 'D':
|
|
|
|
if (!w--)
|
|
|
|
goto bad;
|
|
|
|
GET (ch);
|
|
|
|
while (ch == ' ')
|
|
|
|
{
|
|
|
|
if (!w--)
|
|
|
|
goto bad;
|
|
|
|
GET (ch);
|
|
|
|
}
|
|
|
|
se = 0;
|
|
|
|
switch (ch)
|
|
|
|
{
|
|
|
|
case '-':
|
|
|
|
se = 1;
|
|
|
|
case '+':
|
|
|
|
signonly:
|
|
|
|
if (!w--)
|
|
|
|
goto bad;
|
|
|
|
GET (ch);
|
|
|
|
}
|
|
|
|
while (ch == ' ')
|
|
|
|
{
|
|
|
|
if (!w--)
|
|
|
|
goto bad;
|
|
|
|
GET (ch);
|
|
|
|
}
|
|
|
|
if (!isdigit (ch))
|
|
|
|
goto bad;
|
1998-02-01 09:37:08 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
e = ch - '0';
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (!w--)
|
|
|
|
{
|
|
|
|
ch = '\n';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
GET (ch);
|
|
|
|
if (!isdigit (ch))
|
|
|
|
{
|
|
|
|
if (ch == ' ')
|
|
|
|
{
|
|
|
|
if (f__cblank)
|
|
|
|
ch = '0';
|
|
|
|
else
|
|
|
|
continue;
|
1998-02-01 09:37:08 +08:00
|
|
|
}
|
2002-06-01 20:38:32 +08:00
|
|
|
else
|
1998-02-01 09:37:08 +08:00
|
|
|
break;
|
2002-06-01 20:38:32 +08:00
|
|
|
}
|
|
|
|
e = 10 * e + ch - '0';
|
|
|
|
if (e > EXPMAX && sp > sp1)
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
if (se)
|
|
|
|
exp -= e;
|
|
|
|
else
|
|
|
|
exp += e;
|
|
|
|
scale1 = 0;
|
|
|
|
}
|
|
|
|
switch (ch)
|
|
|
|
{
|
|
|
|
case '\n':
|
|
|
|
case ',':
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
bad:
|
|
|
|
return (errno = 115);
|
|
|
|
}
|
1998-02-01 09:37:08 +08:00
|
|
|
done:
|
2002-06-01 20:38:32 +08:00
|
|
|
if (sp > sp1)
|
|
|
|
{
|
|
|
|
while (*--sp == '0')
|
|
|
|
++exp;
|
|
|
|
if (exp -= scale1)
|
|
|
|
sprintf (sp + 1, "e%ld", exp);
|
|
|
|
else
|
|
|
|
sp[1] = 0;
|
|
|
|
x = atof (s);
|
|
|
|
}
|
1998-02-01 09:37:08 +08:00
|
|
|
zero:
|
2002-06-01 20:38:32 +08:00
|
|
|
if (len == sizeof (real))
|
|
|
|
p->pf = x;
|
|
|
|
else
|
|
|
|
p->pd = x;
|
|
|
|
return (0);
|
|
|
|
}
|
1998-02-01 09:37:08 +08:00
|
|
|
|
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
static int
|
|
|
|
rd_A (char *p, ftnlen len)
|
|
|
|
{
|
|
|
|
int i, ch;
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
GET (ch);
|
|
|
|
*p++ = VAL (ch);
|
|
|
|
}
|
|
|
|
return (0);
|
1998-02-01 09:37:08 +08:00
|
|
|
}
|
2002-06-01 20:38:32 +08:00
|
|
|
static int
|
|
|
|
rd_AW (char *p, int w, ftnlen len)
|
|
|
|
{
|
|
|
|
int i, ch;
|
|
|
|
if (w >= len)
|
|
|
|
{
|
|
|
|
for (i = 0; i < w - len; i++)
|
|
|
|
GET (ch);
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
GET (ch);
|
|
|
|
*p++ = VAL (ch);
|
1998-02-01 09:37:08 +08:00
|
|
|
}
|
2002-06-01 20:38:32 +08:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
for (i = 0; i < w; i++)
|
|
|
|
{
|
|
|
|
GET (ch);
|
|
|
|
*p++ = VAL (ch);
|
|
|
|
}
|
|
|
|
for (i = 0; i < len - w; i++)
|
|
|
|
*p++ = ' ';
|
|
|
|
return (0);
|
1998-02-01 09:37:08 +08:00
|
|
|
}
|
2002-06-01 20:38:32 +08:00
|
|
|
static int
|
|
|
|
rd_H (int n, char *s)
|
|
|
|
{
|
|
|
|
int i, ch;
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
if ((ch = (*f__getn) ()) < 0)
|
|
|
|
return (ch);
|
|
|
|
else
|
|
|
|
*s++ = ch == '\n' ? ' ' : ch;
|
|
|
|
return (1);
|
1998-02-01 09:37:08 +08:00
|
|
|
}
|
2002-06-01 20:38:32 +08:00
|
|
|
static int
|
|
|
|
rd_POS (char *s)
|
|
|
|
{
|
|
|
|
char quote;
|
|
|
|
int ch;
|
|
|
|
quote = *s++;
|
|
|
|
for (; *s; s++)
|
|
|
|
if (*s == quote && *(s + 1) != quote)
|
|
|
|
break;
|
|
|
|
else if ((ch = (*f__getn) ()) < 0)
|
|
|
|
return (ch);
|
|
|
|
else
|
|
|
|
*s = ch == '\n' ? ' ' : ch;
|
|
|
|
return (1);
|
1998-02-01 09:37:08 +08:00
|
|
|
}
|
2002-06-01 20:38:32 +08:00
|
|
|
|
main.c (main): Avoid implicit int.
* libF77/main.c (main): Avoid implicit int.
* libI77/dfe.c (y_rsk, y_getc, c_dfe): Likewise.
* libI77/due.c (c_due): Likewise.
* libI77/err.c (f__canseek, f__nowreading, f__nowwriting):
Likewise.
* libI77/fmt.c (op_gen, ne_d, e_d, pars_f, type_f, en_fio):
Likewise.
* libI77/iio.c (z_getc, z_rnew, c_si, z_wnew): Likewise.
* libI77/lread.c (t_getc, c_le, l_read): Likewise.
* libI77/lwrite.c (l_write): Likewise.
* libI77/open.c (fk_open): Likewise.
* libI77/rdfmt.c (rd_ed, rd_ned): Likewise.
* libI77/rsfe.c (xrd_SL, x_getc, x_endp, x_rev): Likewise.
* libI77/rsne.c (t_getc, x_rsne): Likewise.
* libI77/sfe.c (c_sfe): Likewise.
* libI77/sue.c (c_sue): Likewise.
* libI77/uio.c (do_us): Likewise.
* libI77/wref.c (wrt_E, wrt_F): Likewise.
* libI77/wrtfmt.c (wrt_L, w_ed, w_ned): Likewise.
From-SVN: r54169
2002-06-02 21:01:12 +08:00
|
|
|
int
|
2002-06-01 20:38:32 +08:00
|
|
|
rd_ed (struct syl * p, char *ptr, ftnlen len)
|
|
|
|
{
|
|
|
|
int ch;
|
|
|
|
for (; f__cursor > 0; f__cursor--)
|
|
|
|
if ((ch = (*f__getn) ()) < 0)
|
|
|
|
return (ch);
|
|
|
|
if (f__cursor < 0)
|
|
|
|
{
|
|
|
|
if (f__recpos + f__cursor < 0) /*err(elist->cierr,110,"fmt") */
|
|
|
|
f__cursor = -f__recpos; /* is this in the standard? */
|
|
|
|
if (f__external == 0)
|
1998-02-01 09:37:08 +08:00
|
|
|
{
|
2002-06-01 20:38:32 +08:00
|
|
|
extern char *f__icptr;
|
|
|
|
f__icptr += f__cursor;
|
|
|
|
}
|
|
|
|
else if (f__curunit && f__curunit->useek)
|
|
|
|
FSEEK (f__cf, (off_t) f__cursor, SEEK_CUR);
|
|
|
|
else
|
|
|
|
err (f__elist->cierr, 106, "fmt");
|
|
|
|
f__recpos += f__cursor;
|
|
|
|
f__cursor = 0;
|
|
|
|
}
|
|
|
|
switch (p->op)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
fprintf (stderr, "rd_ed, unexpected code: %d\n", p->op);
|
|
|
|
sig_die (f__fmtbuf, 1);
|
|
|
|
case IM:
|
|
|
|
case I:
|
|
|
|
ch = rd_I ((Uint *) ptr, p->p1, len, 10);
|
|
|
|
break;
|
1998-02-01 09:37:08 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
/* O and OM don't work right for character, double, complex, */
|
|
|
|
/* or doublecomplex, and they differ from Fortran 90 in */
|
|
|
|
/* showing a minus sign for negative values. */
|
1998-02-01 09:37:08 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
case OM:
|
|
|
|
case O:
|
|
|
|
ch = rd_I ((Uint *) ptr, p->p1, len, 8);
|
|
|
|
break;
|
|
|
|
case L:
|
|
|
|
ch = rd_L ((ftnint *) ptr, p->p1, len);
|
|
|
|
break;
|
|
|
|
case A:
|
|
|
|
ch = rd_A (ptr, len);
|
|
|
|
break;
|
|
|
|
case AW:
|
|
|
|
ch = rd_AW (ptr, p->p1, len);
|
|
|
|
break;
|
|
|
|
case E:
|
|
|
|
case EE:
|
|
|
|
case D:
|
|
|
|
case G:
|
|
|
|
case GE:
|
|
|
|
case F:
|
|
|
|
ch = rd_F ((ufloat *) ptr, p->p1, p->p2.i[0], len);
|
|
|
|
break;
|
1998-02-01 09:37:08 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
/* Z and ZM assume 8-bit bytes. */
|
1998-02-01 09:37:08 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
case ZM:
|
|
|
|
case Z:
|
|
|
|
ch = rd_Z ((Uint *) ptr, p->p1, len);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ch == 0)
|
|
|
|
return (ch);
|
|
|
|
else if (ch == EOF)
|
|
|
|
return (EOF);
|
|
|
|
if (f__cf)
|
|
|
|
clearerr (f__cf);
|
|
|
|
return (errno);
|
1998-02-01 09:37:08 +08:00
|
|
|
}
|
2002-06-01 20:38:32 +08:00
|
|
|
|
main.c (main): Avoid implicit int.
* libF77/main.c (main): Avoid implicit int.
* libI77/dfe.c (y_rsk, y_getc, c_dfe): Likewise.
* libI77/due.c (c_due): Likewise.
* libI77/err.c (f__canseek, f__nowreading, f__nowwriting):
Likewise.
* libI77/fmt.c (op_gen, ne_d, e_d, pars_f, type_f, en_fio):
Likewise.
* libI77/iio.c (z_getc, z_rnew, c_si, z_wnew): Likewise.
* libI77/lread.c (t_getc, c_le, l_read): Likewise.
* libI77/lwrite.c (l_write): Likewise.
* libI77/open.c (fk_open): Likewise.
* libI77/rdfmt.c (rd_ed, rd_ned): Likewise.
* libI77/rsfe.c (xrd_SL, x_getc, x_endp, x_rev): Likewise.
* libI77/rsne.c (t_getc, x_rsne): Likewise.
* libI77/sfe.c (c_sfe): Likewise.
* libI77/sue.c (c_sue): Likewise.
* libI77/uio.c (do_us): Likewise.
* libI77/wref.c (wrt_E, wrt_F): Likewise.
* libI77/wrtfmt.c (wrt_L, w_ed, w_ned): Likewise.
From-SVN: r54169
2002-06-02 21:01:12 +08:00
|
|
|
int
|
2002-06-01 20:38:32 +08:00
|
|
|
rd_ned (struct syl * p)
|
1998-02-01 09:37:08 +08:00
|
|
|
{
|
2002-06-01 20:38:32 +08:00
|
|
|
switch (p->op)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
fprintf (stderr, "rd_ned, unexpected code: %d\n", p->op);
|
|
|
|
sig_die (f__fmtbuf, 1);
|
|
|
|
case APOS:
|
|
|
|
return (rd_POS (p->p2.s));
|
|
|
|
case H:
|
|
|
|
return (rd_H (p->p1, p->p2.s));
|
|
|
|
case SLASH:
|
|
|
|
return ((*f__donewrec) ());
|
|
|
|
case TR:
|
|
|
|
case X:
|
|
|
|
f__cursor += p->p1;
|
|
|
|
return (1);
|
|
|
|
case T:
|
|
|
|
f__cursor = p->p1 - f__recpos - 1;
|
|
|
|
return (1);
|
|
|
|
case TL:
|
|
|
|
f__cursor -= p->p1;
|
|
|
|
if (f__cursor < -f__recpos) /* TL1000, 1X */
|
|
|
|
f__cursor = -f__recpos;
|
|
|
|
return (1);
|
|
|
|
}
|
1998-02-01 09:37:08 +08:00
|
|
|
}
|