diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2002-06-01 12:38:32 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2002-06-01 12:38:32 +0000 |
commit | 407c72cb298e71da241639399ee64e65308d21a1 (patch) | |
tree | c6c7b1fe59f3ddb8b8ccf102855193850daecdfc /libf2c | |
parent | 113dc14387308310e28710562f69f1bd624a7aaf (diff) | |
download | gcc-407c72cb298e71da241639399ee64e65308d21a1.zip gcc-407c72cb298e71da241639399ee64e65308d21a1.tar.gz gcc-407c72cb298e71da241639399ee64e65308d21a1.tar.bz2 |
*: Fix formatting.
* libF77/*: Fix formatting.
* libI77/*: Likewise.
* libU77/*: Likewise.
From-SVN: r54145
Diffstat (limited to 'libf2c')
215 files changed, 7058 insertions, 6078 deletions
diff --git a/libf2c/ChangeLog b/libf2c/ChangeLog index 22a6cf1..fdd3fd4 100644 --- a/libf2c/ChangeLog +++ b/libf2c/ChangeLog @@ -1,3 +1,9 @@ +Sat Jun 1 08:33:14 2002 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * libF77/*: Fix formatting. + * libI77/*: Likewise. + * libU77/*: Likewise. + Fri May 31 21:56:30 2002 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * g2c.hin, libF77/d_cnjg.c, libF77/main.c, libF77/r_cnjg.c, diff --git a/libf2c/libF77/F77_aloc.c b/libf2c/libF77/F77_aloc.c index 8716493..b286102 100644 --- a/libf2c/libF77/F77_aloc.c +++ b/libf2c/libF77/F77_aloc.c @@ -7,18 +7,18 @@ static integer memfailure = 3; #include <stdlib.h> -extern void G77_exit_0 (integer*); +extern void G77_exit_0 (integer *); - char * -F77_aloc(integer Len, char *whence) +char * +F77_aloc (integer Len, char *whence) { - char *rv; - unsigned int uLen = (unsigned int) Len; /* for K&R C */ + char *rv; + unsigned int uLen = (unsigned int) Len; /* for K&R C */ - if (!(rv = (char*)malloc(uLen))) { - fprintf(stderr, "malloc(%u) failure in %s\n", - uLen, whence); - G77_exit_0 (&memfailure); - } - return rv; - } + if (!(rv = (char *) malloc (uLen))) + { + fprintf (stderr, "malloc(%u) failure in %s\n", uLen, whence); + G77_exit_0 (&memfailure); + } + return rv; +} diff --git a/libf2c/libF77/abort_.c b/libf2c/libF77/abort_.c index ac277f6..761bc3b 100644 --- a/libf2c/libF77/abort_.c +++ b/libf2c/libF77/abort_.c @@ -1,10 +1,11 @@ #include <stdio.h> #include "f2c.h" -extern void sig_die(char*,int); +extern void sig_die (char *, int); -int G77_abort_0 (void) +int +G77_abort_0 (void) { -sig_die("Fortran abort routine called", 1); -return 0; /* not reached */ + sig_die ("Fortran abort routine called", 1); + return 0; /* not reached */ } diff --git a/libf2c/libF77/c_abs.c b/libf2c/libF77/c_abs.c index c1251e1..3fc4d7c 100644 --- a/libf2c/libF77/c_abs.c +++ b/libf2c/libF77/c_abs.c @@ -1,8 +1,9 @@ #include "f2c.h" -extern double f__cabs(double, double); +extern double f__cabs (double, double); -double c_abs(complex *z) +double +c_abs (complex * z) { -return( f__cabs( z->r, z->i ) ); + return (f__cabs (z->r, z->i)); } diff --git a/libf2c/libF77/c_cos.c b/libf2c/libF77/c_cos.c index eb2acc4..5965975 100644 --- a/libf2c/libF77/c_cos.c +++ b/libf2c/libF77/c_cos.c @@ -3,9 +3,10 @@ #undef abs #include "math.h" -void c_cos(complex *r, complex *z) +void +c_cos (complex * r, complex * z) { - double zi = z->i, zr = z->r; - r->r = cos(zr) * cosh(zi); - r->i = - sin(zr) * sinh(zi); - } + double zi = z->i, zr = z->r; + r->r = cos (zr) * cosh (zi); + r->i = -sin (zr) * sinh (zi); +} diff --git a/libf2c/libF77/c_div.c b/libf2c/libF77/c_div.c index 20763a3..b5ede0e 100644 --- a/libf2c/libF77/c_div.c +++ b/libf2c/libF77/c_div.c @@ -1,41 +1,43 @@ #include "f2c.h" -extern void sig_die(char*,int); -void c_div(complex *c, complex *a, complex *b) +extern void sig_die (char *, int); +void +c_div (complex * c, complex * a, complex * b) { - double ratio, den; - double abr, abi, cr; + double ratio, den; + double abr, abi, cr; - if( (abr = b->r) < 0.) - abr = - abr; - if( (abi = b->i) < 0.) - abi = - abi; - if( abr <= abi ) - { - if(abi == 0) { + if ((abr = b->r) < 0.) + abr = -abr; + if ((abi = b->i) < 0.) + abi = -abi; + if (abr <= abi) + { + if (abi == 0) + { #ifdef IEEE_COMPLEX_DIVIDE - float af, bf; - af = bf = abr; - if (a->i != 0 || a->r != 0) - af = 1.; - c->i = c->r = af / bf; - return; + float af, bf; + af = bf = abr; + if (a->i != 0 || a->r != 0) + af = 1.; + c->i = c->r = af / bf; + return; #else - sig_die("complex division by zero", 1); + sig_die ("complex division by zero", 1); #endif - } - ratio = (double)b->r / b->i ; - den = b->i * (1 + ratio*ratio); - cr = (a->r*ratio + a->i) / den; - c->i = (a->i*ratio - a->r) / den; - } - - else - { - ratio = (double)b->i / b->r ; - den = b->r * (1 + ratio*ratio); - cr = (a->r + a->i*ratio) / den; - c->i = (a->i - a->r*ratio) / den; - } - c->r = cr; } + ratio = (double) b->r / b->i; + den = b->i * (1 + ratio * ratio); + cr = (a->r * ratio + a->i) / den; + c->i = (a->i * ratio - a->r) / den; + } + + else + { + ratio = (double) b->i / b->r; + den = b->r * (1 + ratio * ratio); + cr = (a->r + a->i * ratio) / den; + c->i = (a->i - a->r * ratio) / den; + } + c->r = cr; +} diff --git a/libf2c/libF77/c_exp.c b/libf2c/libF77/c_exp.c index 3e281e9..56a8695 100644 --- a/libf2c/libF77/c_exp.c +++ b/libf2c/libF77/c_exp.c @@ -3,11 +3,12 @@ #undef abs #include "math.h" -void c_exp(complex *r, complex *z) +void +c_exp (complex * r, complex * z) { - double expx, zi = z->i; + double expx, zi = z->i; - expx = exp(z->r); - r->r = expx * cos(zi); - r->i = expx * sin(zi); - } + expx = exp (z->r); + r->r = expx * cos (zi); + r->i = expx * sin (zi); +} diff --git a/libf2c/libF77/c_log.c b/libf2c/libF77/c_log.c index 990b420..7d5b951 100644 --- a/libf2c/libF77/c_log.c +++ b/libf2c/libF77/c_log.c @@ -2,11 +2,12 @@ #undef abs #include "math.h" -extern double f__cabs(double, double); +extern double f__cabs (double, double); -void c_log(complex *r, complex *z) +void +c_log (complex * r, complex * z) { - double zi, zr; - r->i = atan2(zi = z->i, zr = z->r); - r->r = log( f__cabs(zr, zi) ); - } + double zi, zr; + r->i = atan2 (zi = z->i, zr = z->r); + r->r = log (f__cabs (zr, zi)); +} diff --git a/libf2c/libF77/c_sin.c b/libf2c/libF77/c_sin.c index 07ef4d6..44bce9f 100644 --- a/libf2c/libF77/c_sin.c +++ b/libf2c/libF77/c_sin.c @@ -3,9 +3,10 @@ #undef abs #include "math.h" -void c_sin(complex *r, complex *z) +void +c_sin (complex * r, complex * z) { - double zi = z->i, zr = z->r; - r->r = sin(zr) * cosh(zi); - r->i = cos(zr) * sinh(zi); - } + double zi = z->i, zr = z->r; + r->r = sin (zr) * cosh (zi); + r->i = cos (zr) * sinh (zi); +} diff --git a/libf2c/libF77/c_sqrt.c b/libf2c/libF77/c_sqrt.c index 3b9a30f..81b72fc 100644 --- a/libf2c/libF77/c_sqrt.c +++ b/libf2c/libF77/c_sqrt.c @@ -2,28 +2,29 @@ #undef abs #include "math.h" -extern double f__cabs(double, double); +extern double f__cabs (double, double); -void c_sqrt(complex *r, complex *z) +void +c_sqrt (complex * r, complex * z) { - double mag, t; - double zi = z->i, zr = z->r; + double mag, t; + double zi = z->i, zr = z->r; - if( (mag = f__cabs(zr, zi)) == 0.) - r->r = r->i = 0.; - else if(zr > 0) - { - r->r = t = sqrt(0.5 * (mag + zr) ); - t = zi / t; - r->i = 0.5 * t; - } - else - { - t = sqrt(0.5 * (mag - zr) ); - if(zi < 0) - t = -t; - r->i = t; - t = zi / t; - r->r = 0.5 * t; - } - } + if ((mag = f__cabs (zr, zi)) == 0.) + r->r = r->i = 0.; + else if (zr > 0) + { + r->r = t = sqrt (0.5 * (mag + zr)); + t = zi / t; + r->i = 0.5 * t; + } + else + { + t = sqrt (0.5 * (mag - zr)); + if (zi < 0) + t = -t; + r->i = t; + t = zi / t; + r->r = 0.5 * t; + } +} diff --git a/libf2c/libF77/cabs.c b/libf2c/libF77/cabs.c index 17276ab..5d2142e 100644 --- a/libf2c/libF77/cabs.c +++ b/libf2c/libF77/cabs.c @@ -1,22 +1,24 @@ #undef abs #include <math.h> -double f__cabs(double real, double imag) +double +f__cabs (double real, double imag) { -double temp; + double temp; -if(real < 0) - real = -real; -if(imag < 0) - imag = -imag; -if(imag > real){ - temp = real; - real = imag; - imag = temp; -} -if((real+imag) == real) - return(real); + if (real < 0) + real = -real; + if (imag < 0) + imag = -imag; + if (imag > real) + { + temp = real; + real = imag; + imag = temp; + } + if ((real + imag) == real) + return (real); -temp = imag/real; -temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/ -return(temp); + temp = imag / real; + temp = real * sqrt (1.0 + temp * temp); /*overflow!! */ + return (temp); } diff --git a/libf2c/libF77/d_abs.c b/libf2c/libF77/d_abs.c index 2927a5e..a43a5c7 100644 --- a/libf2c/libF77/d_abs.c +++ b/libf2c/libF77/d_abs.c @@ -1,8 +1,9 @@ #include "f2c.h" -double d_abs(doublereal *x) +double +d_abs (doublereal * x) { -if(*x >= 0) - return(*x); -return(- *x); + if (*x >= 0) + return (*x); + return (-*x); } diff --git a/libf2c/libF77/d_acos.c b/libf2c/libF77/d_acos.c index a87ff30..41c4f17 100644 --- a/libf2c/libF77/d_acos.c +++ b/libf2c/libF77/d_acos.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_acos(doublereal *x) +double +d_acos (doublereal * x) { -return( acos(*x) ); + return (acos (*x)); } diff --git a/libf2c/libF77/d_asin.c b/libf2c/libF77/d_asin.c index ea2815a..6560389 100644 --- a/libf2c/libF77/d_asin.c +++ b/libf2c/libF77/d_asin.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_asin(doublereal *x) +double +d_asin (doublereal * x) { -return( asin(*x) ); + return (asin (*x)); } diff --git a/libf2c/libF77/d_atan.c b/libf2c/libF77/d_atan.c index d1624fd..e25fa2e 100644 --- a/libf2c/libF77/d_atan.c +++ b/libf2c/libF77/d_atan.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_atan(doublereal *x) +double +d_atan (doublereal * x) { -return( atan(*x) ); + return (atan (*x)); } diff --git a/libf2c/libF77/d_atn2.c b/libf2c/libF77/d_atn2.c index 9a6ff8c..e0b2178 100644 --- a/libf2c/libF77/d_atn2.c +++ b/libf2c/libF77/d_atn2.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_atn2(doublereal *x, doublereal *y) +double +d_atn2 (doublereal * x, doublereal * y) { -return( atan2(*x,*y) ); + return (atan2 (*x, *y)); } diff --git a/libf2c/libF77/d_cnjg.c b/libf2c/libF77/d_cnjg.c index 36909ec..bc46ae6 100644 --- a/libf2c/libF77/d_cnjg.c +++ b/libf2c/libF77/d_cnjg.c @@ -1,9 +1,9 @@ #include "f2c.h" void -d_cnjg(doublecomplex *r, doublecomplex *z) +d_cnjg (doublecomplex * r, doublecomplex * z) { - doublereal zi = z->i; - r->r = z->r; - r->i = -zi; - } + doublereal zi = z->i; + r->r = z->r; + r->i = -zi; +} diff --git a/libf2c/libF77/d_cos.c b/libf2c/libF77/d_cos.c index 83f9198..010db6b5 100644 --- a/libf2c/libF77/d_cos.c +++ b/libf2c/libF77/d_cos.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_cos(doublereal *x) +double +d_cos (doublereal * x) { -return( cos(*x) ); + return (cos (*x)); } diff --git a/libf2c/libF77/d_cosh.c b/libf2c/libF77/d_cosh.c index c1bffcb..00938bd 100644 --- a/libf2c/libF77/d_cosh.c +++ b/libf2c/libF77/d_cosh.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_cosh(doublereal *x) +double +d_cosh (doublereal * x) { -return( cosh(*x) ); + return (cosh (*x)); } diff --git a/libf2c/libF77/d_dim.c b/libf2c/libF77/d_dim.c index a52ba76..a4274ca 100644 --- a/libf2c/libF77/d_dim.c +++ b/libf2c/libF77/d_dim.c @@ -1,6 +1,7 @@ #include "f2c.h" -double d_dim(doublereal *a, doublereal *b) +double +d_dim (doublereal * a, doublereal * b) { -return( *a > *b ? *a - *b : 0); + return (*a > *b ? *a - *b : 0); } diff --git a/libf2c/libF77/d_exp.c b/libf2c/libF77/d_exp.c index b4afe87..7b4f3e5 100644 --- a/libf2c/libF77/d_exp.c +++ b/libf2c/libF77/d_exp.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_exp(doublereal *x) +double +d_exp (doublereal * x) { -return( exp(*x) ); + return (exp (*x)); } diff --git a/libf2c/libF77/d_imag.c b/libf2c/libF77/d_imag.c index a53d00c..cc93764 100644 --- a/libf2c/libF77/d_imag.c +++ b/libf2c/libF77/d_imag.c @@ -1,6 +1,7 @@ #include "f2c.h" -double d_imag(doublecomplex *z) +double +d_imag (doublecomplex * z) { -return(z->i); + return (z->i); } diff --git a/libf2c/libF77/d_int.c b/libf2c/libF77/d_int.c index dca077c..f7ab8b0 100644 --- a/libf2c/libF77/d_int.c +++ b/libf2c/libF77/d_int.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_int(doublereal *x) +double +d_int (doublereal * x) { -return( (*x>0) ? floor(*x) : -floor(- *x) ); + return ((*x > 0) ? floor (*x) : -floor (-*x)); } diff --git a/libf2c/libF77/d_lg10.c b/libf2c/libF77/d_lg10.c index 32824b8..d0f86e5 100644 --- a/libf2c/libF77/d_lg10.c +++ b/libf2c/libF77/d_lg10.c @@ -4,7 +4,8 @@ #undef abs #include <math.h> -double d_lg10(doublereal *x) +double +d_lg10 (doublereal * x) { -return( log10e * log(*x) ); + return (log10e * log (*x)); } diff --git a/libf2c/libF77/d_log.c b/libf2c/libF77/d_log.c index 50bbefd..95dc767 100644 --- a/libf2c/libF77/d_log.c +++ b/libf2c/libF77/d_log.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_log(doublereal *x) +double +d_log (doublereal * x) { -return( log(*x) ); + return (log (*x)); } diff --git a/libf2c/libF77/d_mod.c b/libf2c/libF77/d_mod.c index bbc24ad..15cedef 100644 --- a/libf2c/libF77/d_mod.c +++ b/libf2c/libF77/d_mod.c @@ -1,31 +1,33 @@ #include "f2c.h" #ifdef IEEE_drem -double drem(double, double); +double drem (double, double); #else #undef abs #include <math.h> #endif -double d_mod(doublereal *x, doublereal *y) +double +d_mod (doublereal * x, doublereal * y) { #ifdef IEEE_drem - double xa, ya, z; - if ((ya = *y) < 0.) - ya = -ya; - z = drem(xa = *x, ya); - if (xa > 0) { - if (z < 0) - z += ya; - } - else if (z > 0) - z -= ya; - return z; + double xa, ya, z; + if ((ya = *y) < 0.) + ya = -ya; + z = drem (xa = *x, ya); + if (xa > 0) + { + if (z < 0) + z += ya; + } + else if (z > 0) + z -= ya; + return z; #else - double quotient; - if( (quotient = *x / *y) >= 0) - quotient = floor(quotient); - else - quotient = -floor(-quotient); - return(*x - (*y) * quotient ); + double quotient; + if ((quotient = *x / *y) >= 0) + quotient = floor (quotient); + else + quotient = -floor (-quotient); + return (*x - (*y) * quotient); #endif } diff --git a/libf2c/libF77/d_nint.c b/libf2c/libF77/d_nint.c index b74a15f..8be4275 100644 --- a/libf2c/libF77/d_nint.c +++ b/libf2c/libF77/d_nint.c @@ -2,8 +2,8 @@ #undef abs #include <math.h> -double d_nint(doublereal *x) +double +d_nint (doublereal * x) { -return( (*x)>=0 ? - floor(*x + .5) : -floor(.5 - *x) ); + return ((*x) >= 0 ? floor (*x + .5) : -floor (.5 - *x)); } diff --git a/libf2c/libF77/d_prod.c b/libf2c/libF77/d_prod.c index b39580f..11fe2c7 100644 --- a/libf2c/libF77/d_prod.c +++ b/libf2c/libF77/d_prod.c @@ -1,6 +1,7 @@ #include "f2c.h" -double d_prod(real *x, real *y) +double +d_prod (real * x, real * y) { -return( (*x) * (*y) ); + return ((*x) * (*y)); } diff --git a/libf2c/libF77/d_sign.c b/libf2c/libF77/d_sign.c index c77d843..da8d24b 100644 --- a/libf2c/libF77/d_sign.c +++ b/libf2c/libF77/d_sign.c @@ -1,8 +1,9 @@ #include "f2c.h" -double d_sign(doublereal *a, doublereal *b) +double +d_sign (doublereal * a, doublereal * b) { -double x; -x = (*a >= 0 ? *a : - *a); -return( *b >= 0 ? x : -x); + double x; + x = (*a >= 0 ? *a : -*a); + return (*b >= 0 ? x : -x); } diff --git a/libf2c/libF77/d_sin.c b/libf2c/libF77/d_sin.c index ed51ebd..24b37a4 100644 --- a/libf2c/libF77/d_sin.c +++ b/libf2c/libF77/d_sin.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_sin(doublereal *x) +double +d_sin (doublereal * x) { -return( sin(*x) ); + return (sin (*x)); } diff --git a/libf2c/libF77/d_sinh.c b/libf2c/libF77/d_sinh.c index b691dc0..dc9dc43 100644 --- a/libf2c/libF77/d_sinh.c +++ b/libf2c/libF77/d_sinh.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_sinh(doublereal *x) +double +d_sinh (doublereal * x) { -return( sinh(*x) ); + return (sinh (*x)); } diff --git a/libf2c/libF77/d_sqrt.c b/libf2c/libF77/d_sqrt.c index 760a524..0a45882 100644 --- a/libf2c/libF77/d_sqrt.c +++ b/libf2c/libF77/d_sqrt.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_sqrt(doublereal *x) +double +d_sqrt (doublereal * x) { -return( sqrt(*x) ); + return (sqrt (*x)); } diff --git a/libf2c/libF77/d_tan.c b/libf2c/libF77/d_tan.c index a93e58b..370c1b8 100644 --- a/libf2c/libF77/d_tan.c +++ b/libf2c/libF77/d_tan.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_tan(doublereal *x) +double +d_tan (doublereal * x) { -return( tan(*x) ); + return (tan (*x)); } diff --git a/libf2c/libF77/d_tanh.c b/libf2c/libF77/d_tanh.c index 06c44d0..df81ea0 100644 --- a/libf2c/libF77/d_tanh.c +++ b/libf2c/libF77/d_tanh.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double d_tanh(doublereal *x) +double +d_tanh (doublereal * x) { -return( tanh(*x) ); + return (tanh (*x)); } diff --git a/libf2c/libF77/derf_.c b/libf2c/libF77/derf_.c index cc41913..b78fde0 100644 --- a/libf2c/libF77/derf_.c +++ b/libf2c/libF77/derf_.c @@ -1,7 +1,8 @@ #include "f2c.h" -extern double erf(double); -double G77_derf_0 (doublereal *x) +extern double erf (double); +double +G77_derf_0 (doublereal * x) { -return( erf(*x) ); + return (erf (*x)); } diff --git a/libf2c/libF77/derfc_.c b/libf2c/libF77/derfc_.c index 0be1159..78e8e88 100644 --- a/libf2c/libF77/derfc_.c +++ b/libf2c/libF77/derfc_.c @@ -1,8 +1,9 @@ #include "f2c.h" -extern double erfc(double); +extern double erfc (double); -double G77_derfc_0 (doublereal *x) +double +G77_derfc_0 (doublereal * x) { -return( erfc(*x) ); + return (erfc (*x)); } diff --git a/libf2c/libF77/dtime_.c b/libf2c/libF77/dtime_.c index 9d5abf6..e2ea1c6 100644 --- a/libf2c/libF77/dtime_.c +++ b/libf2c/libF77/dtime_.c @@ -23,27 +23,27 @@ #endif #endif - double -dtime_(float *tarray) +double +dtime_ (float *tarray) { #ifdef USE_CLOCK #ifndef CLOCKS_PER_SECOND #define CLOCKS_PER_SECOND Hz #endif - static double t0; - double t = clock(); - tarray[1] = 0; - tarray[0] = (t - t0) / CLOCKS_PER_SECOND; - t0 = t; - return tarray[0]; + static double t0; + double t = clock (); + tarray[1] = 0; + tarray[0] = (t - t0) / CLOCKS_PER_SECOND; + t0 = t; + return tarray[0]; #else - struct tms t; - static struct tms t0; + struct tms t; + static struct tms t0; - times(&t); - tarray[0] = (double)(t.tms_utime - t0.tms_utime) / Hz; - tarray[1] = (double)(t.tms_stime - t0.tms_stime) / Hz; - t0 = t; - return tarray[0] + tarray[1]; + times (&t); + tarray[0] = (double) (t.tms_utime - t0.tms_utime) / Hz; + tarray[1] = (double) (t.tms_stime - t0.tms_stime) / Hz; + t0 = t; + return tarray[0] + tarray[1]; #endif - } +} diff --git a/libf2c/libF77/ef1asc_.c b/libf2c/libF77/ef1asc_.c index 2e12423..d9bea34 100644 --- a/libf2c/libF77/ef1asc_.c +++ b/libf2c/libF77/ef1asc_.c @@ -6,9 +6,10 @@ #define M ( (long) (sizeof(long) - 1) ) #define EVEN(x) ( ( (x)+ M) & (~M) ) -extern void s_copy(char*,char*,ftnlen,ftnlen); -int G77_ef1asc_0 (ftnint *a, ftnlen *la, ftnint *b, ftnlen *lb) +extern void s_copy (char *, char *, ftnlen, ftnlen); +int +G77_ef1asc_0 (ftnint * a, ftnlen * la, ftnint * b, ftnlen * lb) { -s_copy( (char *)a, (char *)b, EVEN(*la), *lb ); -return 0; /* ignored return value */ + s_copy ((char *) a, (char *) b, EVEN (*la), *lb); + return 0; /* ignored return value */ } diff --git a/libf2c/libF77/ef1cmc_.c b/libf2c/libF77/ef1cmc_.c index 79eabdf..2e102fb 100644 --- a/libf2c/libF77/ef1cmc_.c +++ b/libf2c/libF77/ef1cmc_.c @@ -2,8 +2,9 @@ #include "f2c.h" -extern integer s_cmp(char*,char*,ftnlen,ftnlen); -integer G77_ef1cmc_0 (ftnint *a, ftnlen *la, ftnint *b, ftnlen *lb) +extern integer s_cmp (char *, char *, ftnlen, ftnlen); +integer +G77_ef1cmc_0 (ftnint * a, ftnlen * la, ftnint * b, ftnlen * lb) { -return( s_cmp( (char *)a, (char *)b, *la, *lb) ); + return (s_cmp ((char *) a, (char *) b, *la, *lb)); } diff --git a/libf2c/libF77/erf_.c b/libf2c/libF77/erf_.c index e8a90ed..fadbfaf 100644 --- a/libf2c/libF77/erf_.c +++ b/libf2c/libF77/erf_.c @@ -1,7 +1,8 @@ #include "f2c.h" -extern double erf(double); -double G77_erf_0 (real *x) +extern double erf (double); +double +G77_erf_0 (real * x) { -return( erf(*x) ); + return (erf (*x)); } diff --git a/libf2c/libF77/erfc_.c b/libf2c/libF77/erfc_.c index 5f72479..7f3ff8a 100644 --- a/libf2c/libF77/erfc_.c +++ b/libf2c/libF77/erfc_.c @@ -1,7 +1,8 @@ #include "f2c.h" -extern double erfc(double); -double G77_erfc_0 (real *x) +extern double erfc (double); +double +G77_erfc_0 (real * x) { -return( erfc(*x) ); + return (erfc (*x)); } diff --git a/libf2c/libF77/etime_.c b/libf2c/libF77/etime_.c index 48a8f6b..cc64612 100644 --- a/libf2c/libF77/etime_.c +++ b/libf2c/libF77/etime_.c @@ -23,21 +23,21 @@ #endif #endif - double -etime_(float *tarray) +double +etime_ (float *tarray) { #ifdef USE_CLOCK #ifndef CLOCKS_PER_SECOND #define CLOCKS_PER_SECOND Hz #endif - double t = clock(); - tarray[1] = 0; - return tarray[0] = t / CLOCKS_PER_SECOND; + double t = clock (); + tarray[1] = 0; + return tarray[0] = t / CLOCKS_PER_SECOND; #else - struct tms t; + struct tms t; - times(&t); - return (tarray[0] = (double)t.tms_utime/Hz) - + (tarray[1] = (double)t.tms_stime/Hz); + times (&t); + return (tarray[0] = (double) t.tms_utime / Hz) + + (tarray[1] = (double) t.tms_stime / Hz); #endif - } +} diff --git a/libf2c/libF77/exit_.c b/libf2c/libF77/exit_.c index e86d070..adf3d85 100644 --- a/libf2c/libF77/exit_.c +++ b/libf2c/libF77/exit_.c @@ -13,13 +13,13 @@ #undef min #undef max #include <stdlib.h> -extern void f_exit(void); +extern void f_exit (void); - void -G77_exit_0 (integer *rc) +void +G77_exit_0 (integer * rc) { #ifdef NO_ONEXIT - f_exit(); + f_exit (); #endif - exit(*rc); - } + exit (*rc); +} diff --git a/libf2c/libF77/f2ch.add b/libf2c/libF77/f2ch.add index a2acc17..04b13e8 100644 --- a/libf2c/libF77/f2ch.add +++ b/libf2c/libF77/f2ch.add @@ -2,161 +2,162 @@ for compiling libF77 and libI77. */ #ifdef __cplusplus -extern "C" { -extern int abort_(void); -extern double c_abs(complex *); -extern void c_cos(complex *, complex *); -extern void c_div(complex *, complex *, complex *); -extern void c_exp(complex *, complex *); -extern void c_log(complex *, complex *); -extern void c_sin(complex *, complex *); -extern void c_sqrt(complex *, complex *); -extern double d_abs(double *); -extern double d_acos(double *); -extern double d_asin(double *); -extern double d_atan(double *); -extern double d_atn2(double *, double *); -extern void d_cnjg(doublecomplex *, doublecomplex *); -extern double d_cos(double *); -extern double d_cosh(double *); -extern double d_dim(double *, double *); -extern double d_exp(double *); -extern double d_imag(doublecomplex *); -extern double d_int(double *); -extern double d_lg10(double *); -extern double d_log(double *); -extern double d_mod(double *, double *); -extern double d_nint(double *); -extern double d_prod(float *, float *); -extern double d_sign(double *, double *); -extern double d_sin(double *); -extern double d_sinh(double *); -extern double d_sqrt(double *); -extern double d_tan(double *); -extern double d_tanh(double *); -extern double derf_(double *); -extern double derfc_(double *); -extern integer do_fio(ftnint *, char *, ftnlen); -extern integer do_lio(ftnint *, ftnint *, char *, ftnlen); -extern integer do_uio(ftnint *, char *, ftnlen); -extern integer e_rdfe(void); -extern integer e_rdue(void); -extern integer e_rsfe(void); -extern integer e_rsfi(void); -extern integer e_rsle(void); -extern integer e_rsli(void); -extern integer e_rsue(void); -extern integer e_wdfe(void); -extern integer e_wdue(void); -extern integer e_wsfe(void); -extern integer e_wsfi(void); -extern integer e_wsle(void); -extern integer e_wsli(void); -extern integer e_wsue(void); -extern int ef1asc_(ftnint *, ftnlen *, ftnint *, ftnlen *); -extern integer ef1cmc_(ftnint *, ftnlen *, ftnint *, ftnlen *); -extern double erf(double); -extern double erf_(float *); -extern double erfc(double); -extern double erfc_(float *); -extern integer f_back(alist *); -extern integer f_clos(cllist *); -extern integer f_end(alist *); -extern void f_exit(void); -extern integer f_inqu(inlist *); -extern integer f_open(olist *); -extern integer f_rew(alist *); -extern int flush_(void); -extern void getarg_(integer *, char *, ftnlen); -extern void getenv_(char *, char *, ftnlen, ftnlen); -extern short h_abs(short *); -extern short h_dim(short *, short *); -extern short h_dnnt(double *); -extern short h_indx(char *, char *, ftnlen, ftnlen); -extern short h_len(char *, ftnlen); -extern short h_mod(short *, short *); -extern short h_nint(float *); -extern short h_sign(short *, short *); -extern short hl_ge(char *, char *, ftnlen, ftnlen); -extern short hl_gt(char *, char *, ftnlen, ftnlen); -extern short hl_le(char *, char *, ftnlen, ftnlen); -extern short hl_lt(char *, char *, ftnlen, ftnlen); -extern integer i_abs(integer *); -extern integer i_dim(integer *, integer *); -extern integer i_dnnt(double *); -extern integer i_indx(char *, char *, ftnlen, ftnlen); -extern integer i_len(char *, ftnlen); -extern integer i_mod(integer *, integer *); -extern integer i_nint(float *); -extern integer i_sign(integer *, integer *); -extern integer iargc_(void); -extern ftnlen l_ge(char *, char *, ftnlen, ftnlen); -extern ftnlen l_gt(char *, char *, ftnlen, ftnlen); -extern ftnlen l_le(char *, char *, ftnlen, ftnlen); -extern ftnlen l_lt(char *, char *, ftnlen, ftnlen); -extern void pow_ci(complex *, complex *, integer *); -extern double pow_dd(double *, double *); -extern double pow_di(double *, integer *); -extern short pow_hh(short *, shortint *); -extern integer pow_ii(integer *, integer *); -extern double pow_ri(float *, integer *); -extern void pow_zi(doublecomplex *, doublecomplex *, integer *); -extern void pow_zz(doublecomplex *, doublecomplex *, doublecomplex *); -extern double r_abs(float *); -extern double r_acos(float *); -extern double r_asin(float *); -extern double r_atan(float *); -extern double r_atn2(float *, float *); -extern void r_cnjg(complex *, complex *); -extern double r_cos(float *); -extern double r_cosh(float *); -extern double r_dim(float *, float *); -extern double r_exp(float *); -extern double r_imag(complex *); -extern double r_int(float *); -extern double r_lg10(float *); -extern double r_log(float *); -extern double r_mod(float *, float *); -extern double r_nint(float *); -extern double r_sign(float *, float *); -extern double r_sin(float *); -extern double r_sinh(float *); -extern double r_sqrt(float *); -extern double r_tan(float *); -extern double r_tanh(float *); -extern void s_cat(char *, char **, integer *, integer *, ftnlen); -extern integer s_cmp(char *, char *, ftnlen, ftnlen); -extern void s_copy(char *, char *, ftnlen, ftnlen); -extern int s_paus(char *, ftnlen); -extern integer s_rdfe(cilist *); -extern integer s_rdue(cilist *); -extern integer s_rnge(char *, integer, char *, integer); -extern integer s_rsfe(cilist *); -extern integer s_rsfi(icilist *); -extern integer s_rsle(cilist *); -extern integer s_rsli(icilist *); -extern integer s_rsne(cilist *); -extern integer s_rsni(icilist *); -extern integer s_rsue(cilist *); -extern int s_stop(char *, ftnlen); -extern integer s_wdfe(cilist *); -extern integer s_wdue(cilist *); -extern integer s_wsfe(cilist *); -extern integer s_wsfi(icilist *); -extern integer s_wsle(cilist *); -extern integer s_wsli(icilist *); -extern integer s_wsne(cilist *); -extern integer s_wsni(icilist *); -extern integer s_wsue(cilist *); -extern void sig_die(char *, int); -extern integer signal_(integer *, void (*)(int)); -extern integer system_(char *, ftnlen); -extern double z_abs(doublecomplex *); -extern void z_cos(doublecomplex *, doublecomplex *); -extern void z_div(doublecomplex *, doublecomplex *, doublecomplex *); -extern void z_exp(doublecomplex *, doublecomplex *); -extern void z_log(doublecomplex *, doublecomplex *); -extern void z_sin(doublecomplex *, doublecomplex *); -extern void z_sqrt(doublecomplex *, doublecomplex *); - } +extern "C" +{ + extern int abort_ (void); + extern double c_abs (complex *); + extern void c_cos (complex *, complex *); + extern void c_div (complex *, complex *, complex *); + extern void c_exp (complex *, complex *); + extern void c_log (complex *, complex *); + extern void c_sin (complex *, complex *); + extern void c_sqrt (complex *, complex *); + extern double d_abs (double *); + extern double d_acos (double *); + extern double d_asin (double *); + extern double d_atan (double *); + extern double d_atn2 (double *, double *); + extern void d_cnjg (doublecomplex *, doublecomplex *); + extern double d_cos (double *); + extern double d_cosh (double *); + extern double d_dim (double *, double *); + extern double d_exp (double *); + extern double d_imag (doublecomplex *); + extern double d_int (double *); + extern double d_lg10 (double *); + extern double d_log (double *); + extern double d_mod (double *, double *); + extern double d_nint (double *); + extern double d_prod (float *, float *); + extern double d_sign (double *, double *); + extern double d_sin (double *); + extern double d_sinh (double *); + extern double d_sqrt (double *); + extern double d_tan (double *); + extern double d_tanh (double *); + extern double derf_ (double *); + extern double derfc_ (double *); + extern integer do_fio (ftnint *, char *, ftnlen); + extern integer do_lio (ftnint *, ftnint *, char *, ftnlen); + extern integer do_uio (ftnint *, char *, ftnlen); + extern integer e_rdfe (void); + extern integer e_rdue (void); + extern integer e_rsfe (void); + extern integer e_rsfi (void); + extern integer e_rsle (void); + extern integer e_rsli (void); + extern integer e_rsue (void); + extern integer e_wdfe (void); + extern integer e_wdue (void); + extern integer e_wsfe (void); + extern integer e_wsfi (void); + extern integer e_wsle (void); + extern integer e_wsli (void); + extern integer e_wsue (void); + extern int ef1asc_ (ftnint *, ftnlen *, ftnint *, ftnlen *); + extern integer ef1cmc_ (ftnint *, ftnlen *, ftnint *, ftnlen *); + extern double erf (double); + extern double erf_ (float *); + extern double erfc (double); + extern double erfc_ (float *); + extern integer f_back (alist *); + extern integer f_clos (cllist *); + extern integer f_end (alist *); + extern void f_exit (void); + extern integer f_inqu (inlist *); + extern integer f_open (olist *); + extern integer f_rew (alist *); + extern int flush_ (void); + extern void getarg_ (integer *, char *, ftnlen); + extern void getenv_ (char *, char *, ftnlen, ftnlen); + extern short h_abs (short *); + extern short h_dim (short *, short *); + extern short h_dnnt (double *); + extern short h_indx (char *, char *, ftnlen, ftnlen); + extern short h_len (char *, ftnlen); + extern short h_mod (short *, short *); + extern short h_nint (float *); + extern short h_sign (short *, short *); + extern short hl_ge (char *, char *, ftnlen, ftnlen); + extern short hl_gt (char *, char *, ftnlen, ftnlen); + extern short hl_le (char *, char *, ftnlen, ftnlen); + extern short hl_lt (char *, char *, ftnlen, ftnlen); + extern integer i_abs (integer *); + extern integer i_dim (integer *, integer *); + extern integer i_dnnt (double *); + extern integer i_indx (char *, char *, ftnlen, ftnlen); + extern integer i_len (char *, ftnlen); + extern integer i_mod (integer *, integer *); + extern integer i_nint (float *); + extern integer i_sign (integer *, integer *); + extern integer iargc_ (void); + extern ftnlen l_ge (char *, char *, ftnlen, ftnlen); + extern ftnlen l_gt (char *, char *, ftnlen, ftnlen); + extern ftnlen l_le (char *, char *, ftnlen, ftnlen); + extern ftnlen l_lt (char *, char *, ftnlen, ftnlen); + extern void pow_ci (complex *, complex *, integer *); + extern double pow_dd (double *, double *); + extern double pow_di (double *, integer *); + extern short pow_hh (short *, shortint *); + extern integer pow_ii (integer *, integer *); + extern double pow_ri (float *, integer *); + extern void pow_zi (doublecomplex *, doublecomplex *, integer *); + extern void pow_zz (doublecomplex *, doublecomplex *, doublecomplex *); + extern double r_abs (float *); + extern double r_acos (float *); + extern double r_asin (float *); + extern double r_atan (float *); + extern double r_atn2 (float *, float *); + extern void r_cnjg (complex *, complex *); + extern double r_cos (float *); + extern double r_cosh (float *); + extern double r_dim (float *, float *); + extern double r_exp (float *); + extern double r_imag (complex *); + extern double r_int (float *); + extern double r_lg10 (float *); + extern double r_log (float *); + extern double r_mod (float *, float *); + extern double r_nint (float *); + extern double r_sign (float *, float *); + extern double r_sin (float *); + extern double r_sinh (float *); + extern double r_sqrt (float *); + extern double r_tan (float *); + extern double r_tanh (float *); + extern void s_cat (char *, char **, integer *, integer *, ftnlen); + extern integer s_cmp (char *, char *, ftnlen, ftnlen); + extern void s_copy (char *, char *, ftnlen, ftnlen); + extern int s_paus (char *, ftnlen); + extern integer s_rdfe (cilist *); + extern integer s_rdue (cilist *); + extern integer s_rnge (char *, integer, char *, integer); + extern integer s_rsfe (cilist *); + extern integer s_rsfi (icilist *); + extern integer s_rsle (cilist *); + extern integer s_rsli (icilist *); + extern integer s_rsne (cilist *); + extern integer s_rsni (icilist *); + extern integer s_rsue (cilist *); + extern int s_stop (char *, ftnlen); + extern integer s_wdfe (cilist *); + extern integer s_wdue (cilist *); + extern integer s_wsfe (cilist *); + extern integer s_wsfi (icilist *); + extern integer s_wsle (cilist *); + extern integer s_wsli (icilist *); + extern integer s_wsne (cilist *); + extern integer s_wsni (icilist *); + extern integer s_wsue (cilist *); + extern void sig_die (char *, int); + extern integer signal_ (integer *, void (*)(int)); + extern integer system_ (char *, ftnlen); + extern double z_abs (doublecomplex *); + extern void z_cos (doublecomplex *, doublecomplex *); + extern void z_div (doublecomplex *, doublecomplex *, doublecomplex *); + extern void z_exp (doublecomplex *, doublecomplex *); + extern void z_log (doublecomplex *, doublecomplex *); + extern void z_sin (doublecomplex *, doublecomplex *); + extern void z_sqrt (doublecomplex *, doublecomplex *); +} #endif diff --git a/libf2c/libF77/getarg_.c b/libf2c/libF77/getarg_.c index c873596..b35043b 100644 --- a/libf2c/libF77/getarg_.c +++ b/libf2c/libF77/getarg_.c @@ -6,19 +6,20 @@ * variable argument c */ -void G77_getarg_0 (ftnint *n, register char *s, ftnlen ls) +void +G77_getarg_0 (ftnint * n, register char *s, ftnlen ls) { -extern int f__xargc; -extern char **f__xargv; -register char *t; -register int i; + extern int f__xargc; + extern char **f__xargv; + register char *t; + register int i; -if(*n>=0 && *n<f__xargc) - t = f__xargv[*n]; -else - t = ""; -for(i = 0; i<ls && *t!='\0' ; ++i) - *s++ = *t++; -for( ; i<ls ; ++i) - *s++ = ' '; + if (*n >= 0 && *n < f__xargc) + t = f__xargv[*n]; + else + t = ""; + for (i = 0; i < ls && *t != '\0'; ++i) + *s++ = *t++; + for (; i < ls; ++i) + *s++ = ' '; } diff --git a/libf2c/libF77/getenv_.c b/libf2c/libF77/getenv_.c index a1654ef..2a58b90 100644 --- a/libf2c/libF77/getenv_.c +++ b/libf2c/libF77/getenv_.c @@ -2,7 +2,7 @@ #undef abs #include <stdlib.h> #include <string.h> -extern char *F77_aloc(ftnlen, char*); +extern char *F77_aloc (ftnlen, char *); /* * getenv - f77 subroutine to return environment variables @@ -16,32 +16,34 @@ extern char *F77_aloc(ftnlen, char*); * if ENV_NAME is not defined */ - void +void G77_getenv_0 (char *fname, char *value, ftnlen flen, ftnlen vlen) { - char buf[256], *ep, *fp; - integer i; + char buf[256], *ep, *fp; + integer i; - if (flen <= 0) - goto add_blanks; - for(i = 0; i < sizeof(buf); i++) { - if (i == flen || (buf[i] = fname[i]) == ' ') { - buf[i] = 0; - ep = getenv(buf); - goto have_ep; - } - } - while(i < flen && fname[i] != ' ') - i++; - strncpy(fp = F77_aloc(i+1, "getenv_"), fname, (int)i); - fp[i] = 0; - ep = getenv(fp); - free(fp); - have_ep: - if (ep) - while(*ep && vlen-- > 0) - *value++ = *ep++; - add_blanks: - while(vlen-- > 0) - *value++ = ' '; + if (flen <= 0) + goto add_blanks; + for (i = 0; i < sizeof (buf); i++) + { + if (i == flen || (buf[i] = fname[i]) == ' ') + { + buf[i] = 0; + ep = getenv (buf); + goto have_ep; } + } + while (i < flen && fname[i] != ' ') + i++; + strncpy (fp = F77_aloc (i + 1, "getenv_"), fname, (int) i); + fp[i] = 0; + ep = getenv (fp); + free (fp); +have_ep: + if (ep) + while (*ep && vlen-- > 0) + *value++ = *ep++; +add_blanks: + while (vlen-- > 0) + *value++ = ' '; +} diff --git a/libf2c/libF77/h_abs.c b/libf2c/libF77/h_abs.c index e5f4d6b3..9db19ca 100644 --- a/libf2c/libF77/h_abs.c +++ b/libf2c/libF77/h_abs.c @@ -1,8 +1,9 @@ #include "f2c.h" -shortint h_abs(shortint *x) +shortint +h_abs (shortint * x) { -if(*x >= 0) - return(*x); -return(- *x); + if (*x >= 0) + return (*x); + return (-*x); } diff --git a/libf2c/libF77/h_dim.c b/libf2c/libF77/h_dim.c index 04cf55d..1519478 100644 --- a/libf2c/libF77/h_dim.c +++ b/libf2c/libF77/h_dim.c @@ -1,6 +1,7 @@ #include "f2c.h" -shortint h_dim(shortint *a, shortint *b) +shortint +h_dim (shortint * a, shortint * b) { -return( *a > *b ? *a - *b : 0); + return (*a > *b ? *a - *b : 0); } diff --git a/libf2c/libF77/h_dnnt.c b/libf2c/libF77/h_dnnt.c index 651d05c..46c83bb 100644 --- a/libf2c/libF77/h_dnnt.c +++ b/libf2c/libF77/h_dnnt.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -shortint h_dnnt(doublereal *x) +shortint +h_dnnt (doublereal * x) { -return (shortint)(*x >= 0. ? floor(*x + .5) : -floor(.5 - *x)); + return (shortint) (*x >= 0. ? floor (*x + .5) : -floor (.5 - *x)); } diff --git a/libf2c/libF77/h_indx.c b/libf2c/libF77/h_indx.c index a78c873..2353b2b 100644 --- a/libf2c/libF77/h_indx.c +++ b/libf2c/libF77/h_indx.c @@ -1,22 +1,23 @@ #include "f2c.h" -shortint h_indx(char *a, char *b, ftnlen la, ftnlen lb) +shortint +h_indx (char *a, char *b, ftnlen la, ftnlen lb) { -ftnlen i, n; -char *s, *t, *bend; + ftnlen i, n; + char *s, *t, *bend; -n = la - lb + 1; -bend = b + lb; + n = la - lb + 1; + bend = b + lb; -for(i = 0 ; i < n ; ++i) - { - s = a + i; - t = b; - while(t < bend) - if(*s++ != *t++) - goto no; - return((shortint)i+1); - no: ; - } -return(0); + for (i = 0; i < n; ++i) + { + s = a + i; + t = b; + while (t < bend) + if (*s++ != *t++) + goto no; + return ((shortint) i + 1); + no:; + } + return (0); } diff --git a/libf2c/libF77/h_len.c b/libf2c/libF77/h_len.c index 8c63116..0782af1 100644 --- a/libf2c/libF77/h_len.c +++ b/libf2c/libF77/h_len.c @@ -1,6 +1,7 @@ #include "f2c.h" -shortint h_len(char *s, ftnlen n) +shortint +h_len (char *s, ftnlen n) { -return(n); + return (n); } diff --git a/libf2c/libF77/h_mod.c b/libf2c/libF77/h_mod.c index 998ada7..c04e0df 100644 --- a/libf2c/libF77/h_mod.c +++ b/libf2c/libF77/h_mod.c @@ -1,6 +1,7 @@ #include "f2c.h" -shortint h_mod(short *a, short *b) +shortint +h_mod (short *a, short *b) { -return( *a % *b); + return (*a % *b); } diff --git a/libf2c/libF77/h_nint.c b/libf2c/libF77/h_nint.c index bdfee64..a8c366a 100644 --- a/libf2c/libF77/h_nint.c +++ b/libf2c/libF77/h_nint.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -shortint h_nint(real *x) +shortint +h_nint (real * x) { -return (shortint)(*x >= 0 ? floor(*x + .5) : -floor(.5 - *x)); + return (shortint) (*x >= 0 ? floor (*x + .5) : -floor (.5 - *x)); } diff --git a/libf2c/libF77/h_sign.c b/libf2c/libF77/h_sign.c index 7efc7ca..7040232 100644 --- a/libf2c/libF77/h_sign.c +++ b/libf2c/libF77/h_sign.c @@ -1,8 +1,9 @@ #include "f2c.h" -shortint h_sign(shortint *a, shortint *b) +shortint +h_sign (shortint * a, shortint * b) { -shortint x; -x = (*a >= 0 ? *a : - *a); -return( *b >= 0 ? x : -x); + shortint x; + x = (*a >= 0 ? *a : -*a); + return (*b >= 0 ? x : -x); } diff --git a/libf2c/libF77/hl_ge.c b/libf2c/libF77/hl_ge.c index 2415216..988686d 100644 --- a/libf2c/libF77/hl_ge.c +++ b/libf2c/libF77/hl_ge.c @@ -1,7 +1,8 @@ #include "f2c.h" -extern integer s_cmp(char *, char *, ftnlen, ftnlen); -shortlogical hl_ge(char *a, char *b, ftnlen la, ftnlen lb) +extern integer s_cmp (char *, char *, ftnlen, ftnlen); +shortlogical +hl_ge (char *a, char *b, ftnlen la, ftnlen lb) { -return(s_cmp(a,b,la,lb) >= 0); + return (s_cmp (a, b, la, lb) >= 0); } diff --git a/libf2c/libF77/hl_gt.c b/libf2c/libF77/hl_gt.c index bf5c420..0024ca7 100644 --- a/libf2c/libF77/hl_gt.c +++ b/libf2c/libF77/hl_gt.c @@ -1,7 +1,8 @@ #include "f2c.h" -extern integer s_cmp(char *, char *, ftnlen, ftnlen); -shortlogical hl_gt(char *a, char *b, ftnlen la, ftnlen lb) +extern integer s_cmp (char *, char *, ftnlen, ftnlen); +shortlogical +hl_gt (char *a, char *b, ftnlen la, ftnlen lb) { -return(s_cmp(a,b,la,lb) > 0); + return (s_cmp (a, b, la, lb) > 0); } diff --git a/libf2c/libF77/hl_le.c b/libf2c/libF77/hl_le.c index cb6fe05..76aa3e1 100644 --- a/libf2c/libF77/hl_le.c +++ b/libf2c/libF77/hl_le.c @@ -1,7 +1,8 @@ #include "f2c.h" -extern integer s_cmp(char *, char *, ftnlen, ftnlen); -shortlogical hl_le(char *a, char *b, ftnlen la, ftnlen lb) +extern integer s_cmp (char *, char *, ftnlen, ftnlen); +shortlogical +hl_le (char *a, char *b, ftnlen la, ftnlen lb) { -return(s_cmp(a,b,la,lb) <= 0); + return (s_cmp (a, b, la, lb) <= 0); } diff --git a/libf2c/libF77/hl_lt.c b/libf2c/libF77/hl_lt.c index f774c71..68a47fa 100644 --- a/libf2c/libF77/hl_lt.c +++ b/libf2c/libF77/hl_lt.c @@ -1,7 +1,8 @@ #include "f2c.h" -extern integer s_cmp(char *, char *, ftnlen, ftnlen); -shortlogical hl_lt(char *a, char *b, ftnlen la, ftnlen lb) +extern integer s_cmp (char *, char *, ftnlen, ftnlen); +shortlogical +hl_lt (char *a, char *b, ftnlen la, ftnlen lb) { -return(s_cmp(a,b,la,lb) < 0); + return (s_cmp (a, b, la, lb) < 0); } diff --git a/libf2c/libF77/i_abs.c b/libf2c/libF77/i_abs.c index 2f96f5c..2ed183a 100644 --- a/libf2c/libF77/i_abs.c +++ b/libf2c/libF77/i_abs.c @@ -1,8 +1,9 @@ #include "f2c.h" -integer i_abs(integer *x) +integer +i_abs (integer * x) { -if(*x >= 0) - return(*x); -return(- *x); + if (*x >= 0) + return (*x); + return (-*x); } diff --git a/libf2c/libF77/i_dim.c b/libf2c/libF77/i_dim.c index 68e8a3d..66ef7c9 100644 --- a/libf2c/libF77/i_dim.c +++ b/libf2c/libF77/i_dim.c @@ -1,6 +1,7 @@ #include "f2c.h" -integer i_dim(integer *a, integer *b) +integer +i_dim (integer * a, integer * b) { -return( *a > *b ? *a - *b : 0); + return (*a > *b ? *a - *b : 0); } diff --git a/libf2c/libF77/i_dnnt.c b/libf2c/libF77/i_dnnt.c index ed4fdff..7a3783d 100644 --- a/libf2c/libF77/i_dnnt.c +++ b/libf2c/libF77/i_dnnt.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -integer i_dnnt(doublereal *x) +integer +i_dnnt (doublereal * x) { -return (integer)(*x >= 0. ? floor(*x + .5) : -floor(.5 - *x)); + return (integer) (*x >= 0. ? floor (*x + .5) : -floor (.5 - *x)); } diff --git a/libf2c/libF77/i_indx.c b/libf2c/libF77/i_indx.c index 92c44aa..5b8e136 100644 --- a/libf2c/libF77/i_indx.c +++ b/libf2c/libF77/i_indx.c @@ -1,22 +1,23 @@ #include "f2c.h" -integer i_indx(char *a, char *b, ftnlen la, ftnlen lb) +integer +i_indx (char *a, char *b, ftnlen la, ftnlen lb) { -ftnlen i, n; -char *s, *t, *bend; + ftnlen i, n; + char *s, *t, *bend; -n = la - lb + 1; -bend = b + lb; + n = la - lb + 1; + bend = b + lb; -for(i = 0 ; i < n ; ++i) - { - s = a + i; - t = b; - while(t < bend) - if(*s++ != *t++) - goto no; - return(i+1); - no: ; - } -return(0); + for (i = 0; i < n; ++i) + { + s = a + i; + t = b; + while (t < bend) + if (*s++ != *t++) + goto no; + return (i + 1); + no:; + } + return (0); } diff --git a/libf2c/libF77/i_len.c b/libf2c/libF77/i_len.c index 0e9cfb7..3a43b86 100644 --- a/libf2c/libF77/i_len.c +++ b/libf2c/libF77/i_len.c @@ -1,6 +1,7 @@ #include "f2c.h" -integer i_len(char *s, ftnlen n) +integer +i_len (char *s, ftnlen n) { -return(n); + return (n); } diff --git a/libf2c/libF77/i_mod.c b/libf2c/libF77/i_mod.c index 2e574f7..7ed7b39 100644 --- a/libf2c/libF77/i_mod.c +++ b/libf2c/libF77/i_mod.c @@ -1,6 +1,7 @@ #include "f2c.h" -integer i_mod(integer *a, integer *b) +integer +i_mod (integer * a, integer * b) { -return( *a % *b); + return (*a % *b); } diff --git a/libf2c/libF77/i_nint.c b/libf2c/libF77/i_nint.c index 2698d5f..c4eaff4 100644 --- a/libf2c/libF77/i_nint.c +++ b/libf2c/libF77/i_nint.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -integer i_nint(real *x) +integer +i_nint (real * x) { -return (integer)(*x >= 0 ? floor(*x + .5) : -floor(.5 - *x)); + return (integer) (*x >= 0 ? floor (*x + .5) : -floor (.5 - *x)); } diff --git a/libf2c/libF77/i_sign.c b/libf2c/libF77/i_sign.c index 1db4729..cf09008 100644 --- a/libf2c/libF77/i_sign.c +++ b/libf2c/libF77/i_sign.c @@ -1,8 +1,9 @@ #include "f2c.h" -integer i_sign(integer *a, integer *b) +integer +i_sign (integer * a, integer * b) { -integer x; -x = (*a >= 0 ? *a : - *a); -return( *b >= 0 ? x : -x); + integer x; + x = (*a >= 0 ? *a : -*a); + return (*b >= 0 ? x : -x); } diff --git a/libf2c/libF77/iargc_.c b/libf2c/libF77/iargc_.c index a57c257..c316570 100644 --- a/libf2c/libF77/iargc_.c +++ b/libf2c/libF77/iargc_.c @@ -1,7 +1,8 @@ #include "f2c.h" -ftnint G77_iargc_0 (void) +ftnint +G77_iargc_0 (void) { -extern int f__xargc; -return ( f__xargc - 1 ); + extern int f__xargc; + return (f__xargc - 1); } diff --git a/libf2c/libF77/l_ge.c b/libf2c/libF77/l_ge.c index ffa2faa..78af8d0 100644 --- a/libf2c/libF77/l_ge.c +++ b/libf2c/libF77/l_ge.c @@ -1,7 +1,8 @@ #include "f2c.h" -extern integer s_cmp(char *, char *, ftnlen, ftnlen); -logical l_ge(char *a, char *b, ftnlen la, ftnlen lb) +extern integer s_cmp (char *, char *, ftnlen, ftnlen); +logical +l_ge (char *a, char *b, ftnlen la, ftnlen lb) { -return(s_cmp(a,b,la,lb) >= 0); + return (s_cmp (a, b, la, lb) >= 0); } diff --git a/libf2c/libF77/l_gt.c b/libf2c/libF77/l_gt.c index e0d3144..be7e489 100644 --- a/libf2c/libF77/l_gt.c +++ b/libf2c/libF77/l_gt.c @@ -1,7 +1,8 @@ #include "f2c.h" -extern integer s_cmp(char *, char *, ftnlen, ftnlen); -logical l_gt(char *a, char *b, ftnlen la, ftnlen lb) +extern integer s_cmp (char *, char *, ftnlen, ftnlen); +logical +l_gt (char *a, char *b, ftnlen la, ftnlen lb) { -return(s_cmp(a,b,la,lb) > 0); + return (s_cmp (a, b, la, lb) > 0); } diff --git a/libf2c/libF77/l_le.c b/libf2c/libF77/l_le.c index d3e9de8..d2886fb 100644 --- a/libf2c/libF77/l_le.c +++ b/libf2c/libF77/l_le.c @@ -1,7 +1,8 @@ #include "f2c.h" -extern integer s_cmp(char *, char *, ftnlen, ftnlen); -logical l_le(char *a, char *b, ftnlen la, ftnlen lb) +extern integer s_cmp (char *, char *, ftnlen, ftnlen); +logical +l_le (char *a, char *b, ftnlen la, ftnlen lb) { -return(s_cmp(a,b,la,lb) <= 0); + return (s_cmp (a, b, la, lb) <= 0); } diff --git a/libf2c/libF77/l_lt.c b/libf2c/libF77/l_lt.c index df28ec0..ff151f8 100644 --- a/libf2c/libF77/l_lt.c +++ b/libf2c/libF77/l_lt.c @@ -1,7 +1,8 @@ #include "f2c.h" -extern integer s_cmp(char *, char *, ftnlen, ftnlen); -logical l_lt(char *a, char *b, ftnlen la, ftnlen lb) +extern integer s_cmp (char *, char *, ftnlen, ftnlen); +logical +l_lt (char *a, char *b, ftnlen la, ftnlen lb) { -return(s_cmp(a,b,la,lb) < 0); + return (s_cmp (a, b, la, lb) < 0); } diff --git a/libf2c/libF77/lbitbits.c b/libf2c/libF77/lbitbits.c index 4536dc4..805d858 100644 --- a/libf2c/libF77/lbitbits.c +++ b/libf2c/libF77/lbitbits.c @@ -4,51 +4,55 @@ #define LONGBITS 32 #endif - integer -lbit_bits(integer a, integer b, integer len) +integer +lbit_bits (integer a, integer b, integer len) { - /* Assume 2's complement arithmetic */ + /* Assume 2's complement arithmetic */ - unsigned long x, y; + unsigned long x, y; - x = (unsigned long) a; - y = (unsigned long)-1L; - x >>= b; - y <<= len; - return (integer)(x & ~y); - } + x = (unsigned long) a; + y = (unsigned long) -1L; + x >>= b; + y <<= len; + return (integer) (x & ~y); +} - integer -lbit_cshift(integer a, integer b, integer len) +integer +lbit_cshift (integer a, integer b, integer len) { - unsigned long x, y, z; + unsigned long x, y, z; - x = (unsigned long)a; - if (len <= 0) { - if (len == 0) - return 0; - goto full_len; - } - if (len >= LONGBITS) { - full_len: - if (b >= 0) { - b %= LONGBITS; - return (integer)(x << b | x >> LONGBITS -b ); - } - b = -b; - b %= LONGBITS; - return (integer)(x << LONGBITS - b | x >> b); - } - y = z = (unsigned long)-1; - y <<= len; - z &= ~y; - y &= x; - x &= z; - if (b >= 0) { - b %= len; - return (integer)(y | z & (x << b | x >> len - b)); - } - b = -b; - b %= len; - return (integer)(y | z & (x >> b | x << len - b)); + x = (unsigned long) a; + if (len <= 0) + { + if (len == 0) + return 0; + goto full_len; + } + if (len >= LONGBITS) + { + full_len: + if (b >= 0) + { + b %= LONGBITS; + return (integer) (x << b | x >> LONGBITS - b); } + b = -b; + b %= LONGBITS; + return (integer) (x << LONGBITS - b | x >> b); + } + y = z = (unsigned long) -1; + y <<= len; + z &= ~y; + y &= x; + x &= z; + if (b >= 0) + { + b %= len; + return (integer) (y | z & (x << b | x >> len - b)); + } + b = -b; + b %= len; + return (integer) (y | z & (x >> b | x << len - b)); +} diff --git a/libf2c/libF77/lbitshft.c b/libf2c/libF77/lbitshft.c index daa1e76..bfbb7c0 100644 --- a/libf2c/libF77/lbitshft.c +++ b/libf2c/libF77/lbitshft.c @@ -1,7 +1,7 @@ #include "f2c.h" - integer -lbit_shift(integer a, integer b) +integer +lbit_shift (integer a, integer b) { - return b >= 0 ? a << b : (integer)((uinteger)a >> -b); - } + return b >= 0 ? a << b : (integer) ((uinteger) a >> -b); +} diff --git a/libf2c/libF77/main.c b/libf2c/libF77/main.c index 7bc76b0..c2dc887 100644 --- a/libf2c/libF77/main.c +++ b/libf2c/libF77/main.c @@ -5,28 +5,28 @@ #include <stdlib.h> -extern void f_exit(void); +extern void f_exit (void); #ifndef NO_ONEXIT #define ONEXIT atexit -extern int atexit(void (*)(void)); +extern int atexit (void (*)(void)); #endif -extern void f_init(void); -extern int MAIN__(void); +extern void f_init (void); +extern int MAIN__ (void); -main(int argc, char **argv) +main (int argc, char **argv) { -f_setarg(argc, argv); -f_setsig(); -f_init(); + f_setarg (argc, argv); + f_setsig (); + f_init (); #ifndef NO_ONEXIT -ONEXIT(f_exit); + ONEXIT (f_exit); #endif -MAIN__(); + MAIN__ (); #ifdef NO_ONEXIT -f_exit(); + f_exit (); #endif -exit(0); /* exit(0) rather than return(0) to bypass Cray bug */ -return 0; /* For compilers that complain of missing return values; */ - /* others will complain that this is unreachable code. */ + exit (0); /* exit(0) rather than return(0) to bypass Cray bug */ + return 0; /* For compilers that complain of missing return values; */ + /* others will complain that this is unreachable code. */ } diff --git a/libf2c/libF77/pow_ci.c b/libf2c/libF77/pow_ci.c index 98bb84f..1df3eb3 100644 --- a/libf2c/libF77/pow_ci.c +++ b/libf2c/libF77/pow_ci.c @@ -1,15 +1,16 @@ #include "f2c.h" -extern void pow_zi(doublecomplex*, doublecomplex*, integer*); -void pow_ci(complex *p, complex *a, integer *b) /* p = a**b */ +extern void pow_zi (doublecomplex *, doublecomplex *, integer *); +void +pow_ci (complex * p, complex * a, integer * b) /* p = a**b */ { -doublecomplex p1, a1; + doublecomplex p1, a1; -a1.r = a->r; -a1.i = a->i; + a1.r = a->r; + a1.i = a->i; -pow_zi(&p1, &a1, b); + pow_zi (&p1, &a1, b); -p->r = p1.r; -p->i = p1.i; + p->r = p1.r; + p->i = p1.i; } diff --git a/libf2c/libF77/pow_dd.c b/libf2c/libF77/pow_dd.c index 7c421fe..0ab208e 100644 --- a/libf2c/libF77/pow_dd.c +++ b/libf2c/libF77/pow_dd.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double pow_dd(doublereal *ap, doublereal *bp) +double +pow_dd (doublereal * ap, doublereal * bp) { -return(pow(*ap, *bp) ); + return (pow (*ap, *bp)); } diff --git a/libf2c/libF77/pow_di.c b/libf2c/libF77/pow_di.c index d396ed0..d2298a0 100644 --- a/libf2c/libF77/pow_di.c +++ b/libf2c/libF77/pow_di.c @@ -1,31 +1,32 @@ #include "f2c.h" -double pow_di(doublereal *ap, integer *bp) +double +pow_di (doublereal * ap, integer * bp) { -double pow, x; -integer n; -unsigned long u; + double pow, x; + integer n; + unsigned long u; -pow = 1; -x = *ap; -n = *bp; + pow = 1; + x = *ap; + n = *bp; -if(n != 0) + if (n != 0) + { + if (n < 0) { - if(n < 0) - { - n = -n; - x = 1/x; - } - for(u = n; ; ) - { - if(u & 01) - pow *= x; - if(u >>= 1) - x *= x; - else - break; - } + n = -n; + x = 1 / x; } -return(pow); + for (u = n;;) + { + if (u & 01) + pow *= x; + if (u >>= 1) + x *= x; + else + break; + } + } + return (pow); } diff --git a/libf2c/libF77/pow_hh.c b/libf2c/libF77/pow_hh.c index d734720..3379d8a 100644 --- a/libf2c/libF77/pow_hh.c +++ b/libf2c/libF77/pow_hh.c @@ -1,29 +1,31 @@ #include "f2c.h" -shortint pow_hh(shortint *ap, shortint *bp) +shortint +pow_hh (shortint * ap, shortint * bp) { - shortint pow, x, n; - unsigned u; + shortint pow, x, n; + unsigned u; - x = *ap; - n = *bp; + x = *ap; + n = *bp; - if (n <= 0) { - if (n == 0 || x == 1) - return 1; - if (x != -1) - return x == 0 ? 1/x : 0; - n = -n; - } - u = n; - for(pow = 1; ; ) - { - if(u & 01) - pow *= x; - if(u >>= 1) - x *= x; - else - break; - } - return(pow); - } + if (n <= 0) + { + if (n == 0 || x == 1) + return 1; + if (x != -1) + return x == 0 ? 1 / x : 0; + n = -n; + } + u = n; + for (pow = 1;;) + { + if (u & 01) + pow *= x; + if (u >>= 1) + x *= x; + else + break; + } + return (pow); +} diff --git a/libf2c/libF77/pow_ii.c b/libf2c/libF77/pow_ii.c index a895b23..9234745 100644 --- a/libf2c/libF77/pow_ii.c +++ b/libf2c/libF77/pow_ii.c @@ -1,29 +1,31 @@ #include "f2c.h" -integer pow_ii(integer *ap, integer *bp) +integer +pow_ii (integer * ap, integer * bp) { - integer pow, x, n; - unsigned long u; + integer pow, x, n; + unsigned long u; - x = *ap; - n = *bp; + x = *ap; + n = *bp; - if (n <= 0) { - if (n == 0 || x == 1) - return 1; - if (x != -1) - return x == 0 ? 1/x : 0; - n = -n; - } - u = n; - for(pow = 1; ; ) - { - if(u & 01) - pow *= x; - if(u >>= 1) - x *= x; - else - break; - } - return(pow); - } + if (n <= 0) + { + if (n == 0 || x == 1) + return 1; + if (x != -1) + return x == 0 ? 1 / x : 0; + n = -n; + } + u = n; + for (pow = 1;;) + { + if (u & 01) + pow *= x; + if (u >>= 1) + x *= x; + else + break; + } + return (pow); +} diff --git a/libf2c/libF77/pow_qq.c b/libf2c/libF77/pow_qq.c index df01f14..0cec5ca 100644 --- a/libf2c/libF77/pow_qq.c +++ b/libf2c/libF77/pow_qq.c @@ -1,29 +1,31 @@ #include "f2c.h" -longint pow_qq(longint *ap, longint *bp) +longint +pow_qq (longint * ap, longint * bp) { - longint pow, x, n; - unsigned long long u; /* system-dependent */ + longint pow, x, n; + unsigned long long u; /* system-dependent */ - x = *ap; - n = *bp; + x = *ap; + n = *bp; - if (n <= 0) { - if (n == 0 || x == 1) - return 1; - if (x != -1) - return x == 0 ? 1/x : 0; - n = -n; - } - u = n; - for(pow = 1; ; ) - { - if(u & 01) - pow *= x; - if(u >>= 1) - x *= x; - else - break; - } - return(pow); - } + if (n <= 0) + { + if (n == 0 || x == 1) + return 1; + if (x != -1) + return x == 0 ? 1 / x : 0; + n = -n; + } + u = n; + for (pow = 1;;) + { + if (u & 01) + pow *= x; + if (u >>= 1) + x *= x; + else + break; + } + return (pow); +} diff --git a/libf2c/libF77/pow_ri.c b/libf2c/libF77/pow_ri.c index c15347a..792db0c20 100644 --- a/libf2c/libF77/pow_ri.c +++ b/libf2c/libF77/pow_ri.c @@ -1,31 +1,32 @@ #include "f2c.h" -double pow_ri(real *ap, integer *bp) +double +pow_ri (real * ap, integer * bp) { -double pow, x; -integer n; -unsigned long u; + double pow, x; + integer n; + unsigned long u; -pow = 1; -x = *ap; -n = *bp; + pow = 1; + x = *ap; + n = *bp; -if(n != 0) + if (n != 0) + { + if (n < 0) { - if(n < 0) - { - n = -n; - x = 1/x; - } - for(u = n; ; ) - { - if(u & 01) - pow *= x; - if(u >>= 1) - x *= x; - else - break; - } + n = -n; + x = 1 / x; } -return(pow); + for (u = n;;) + { + if (u & 01) + pow *= x; + if (u >>= 1) + x *= x; + else + break; + } + } + return (pow); } diff --git a/libf2c/libF77/pow_zi.c b/libf2c/libF77/pow_zi.c index 3b52060..214db3d 100644 --- a/libf2c/libF77/pow_zi.c +++ b/libf2c/libF77/pow_zi.c @@ -1,49 +1,50 @@ #include "f2c.h" -extern void z_div(doublecomplex*, doublecomplex*, doublecomplex*); -void pow_zi(doublecomplex *p, doublecomplex *a, integer *b) /* p = a**b */ +extern void z_div (doublecomplex *, doublecomplex *, doublecomplex *); +void +pow_zi (doublecomplex * p, doublecomplex * a, integer * b) /* p = a**b */ { - integer n; - unsigned long u; - double t; - doublecomplex q, x; - static doublecomplex one = {1.0, 0.0}; + integer n; + unsigned long u; + double t; + doublecomplex q, x; + static doublecomplex one = { 1.0, 0.0 }; - n = *b; - q.r = 1; - q.i = 0; + n = *b; + q.r = 1; + q.i = 0; - if(n == 0) - goto done; - if(n < 0) - { - n = -n; - z_div(&x, &one, a); - } - else - { - x.r = a->r; - x.i = a->i; - } + if (n == 0) + goto done; + if (n < 0) + { + n = -n; + z_div (&x, &one, a); + } + else + { + x.r = a->r; + x.i = a->i; + } - for(u = n; ; ) - { - if(u & 01) - { - t = q.r * x.r - q.i * x.i; - q.i = q.r * x.i + q.i * x.r; - q.r = t; - } - if(u >>= 1) - { - t = x.r * x.r - x.i * x.i; - x.i = 2 * x.r * x.i; - x.r = t; - } - else - break; - } - done: - p->i = q.i; - p->r = q.r; + for (u = n;;) + { + if (u & 01) + { + t = q.r * x.r - q.i * x.i; + q.i = q.r * x.i + q.i * x.r; + q.r = t; } + if (u >>= 1) + { + t = x.r * x.r - x.i * x.i; + x.i = 2 * x.r * x.i; + x.r = t; + } + else + break; + } +done: + p->i = q.i; + p->r = q.r; +} diff --git a/libf2c/libF77/pow_zz.c b/libf2c/libF77/pow_zz.c index 5fc8c45..522b639 100644 --- a/libf2c/libF77/pow_zz.c +++ b/libf2c/libF77/pow_zz.c @@ -2,17 +2,18 @@ #undef abs #include <math.h> -extern double f__cabs(double,double); -void pow_zz(doublecomplex *r, doublecomplex *a, doublecomplex *b) +extern double f__cabs (double, double); +void +pow_zz (doublecomplex * r, doublecomplex * a, doublecomplex * b) { -double logr, logi, x, y; + double logr, logi, x, y; -logr = log( f__cabs(a->r, a->i) ); -logi = atan2(a->i, a->r); + logr = log (f__cabs (a->r, a->i)); + logi = atan2 (a->i, a->r); -x = exp( logr * b->r - logi * b->i ); -y = logr * b->i + logi * b->r; + x = exp (logr * b->r - logi * b->i); + y = logr * b->i + logi * b->r; -r->r = x * cos(y); -r->i = x * sin(y); + r->r = x * cos (y); + r->i = x * sin (y); } diff --git a/libf2c/libF77/qbitbits.c b/libf2c/libF77/qbitbits.c index ef87858..c2a87c2 100644 --- a/libf2c/libF77/qbitbits.c +++ b/libf2c/libF77/qbitbits.c @@ -8,51 +8,55 @@ #define LONG8BITS (2*LONGBITS) #endif - integer -qbit_bits(longint a, integer b, integer len) +integer +qbit_bits (longint a, integer b, integer len) { - /* Assume 2's complement arithmetic */ + /* Assume 2's complement arithmetic */ - ulongint x, y; + ulongint x, y; - x = (ulongint) a; - y = (ulongint)-1L; - x >>= b; - y <<= len; - return (longint)(x & y); - } + x = (ulongint) a; + y = (ulongint) - 1L; + x >>= b; + y <<= len; + return (longint) (x & y); +} - longint -qbit_cshift(longint a, integer b, integer len) +longint +qbit_cshift (longint a, integer b, integer len) { - ulongint x, y, z; + ulongint x, y, z; - x = (ulongint)a; - if (len <= 0) { - if (len == 0) - return 0; - goto full_len; - } - if (len >= LONG8BITS) { - full_len: - if (b >= 0) { - b %= LONG8BITS; - return (longint)(x << b | x >> LONG8BITS - b ); - } - b = -b; - b %= LONG8BITS; - return (longint)(x << LONG8BITS - b | x >> b); - } - y = z = (unsigned long)-1; - y <<= len; - z &= ~y; - y &= x; - x &= z; - if (b >= 0) { - b %= len; - return (longint)(y | z & (x << b | x >> len - b)); - } - b = -b; - b %= len; - return (longint)(y | z & (x >> b | x << len - b)); + x = (ulongint) a; + if (len <= 0) + { + if (len == 0) + return 0; + goto full_len; + } + if (len >= LONG8BITS) + { + full_len: + if (b >= 0) + { + b %= LONG8BITS; + return (longint) (x << b | x >> LONG8BITS - b); } + b = -b; + b %= LONG8BITS; + return (longint) (x << LONG8BITS - b | x >> b); + } + y = z = (unsigned long) -1; + y <<= len; + z &= ~y; + y &= x; + x &= z; + if (b >= 0) + { + b %= len; + return (longint) (y | z & (x << b | x >> len - b)); + } + b = -b; + b %= len; + return (longint) (y | z & (x >> b | x << len - b)); +} diff --git a/libf2c/libF77/qbitshft.c b/libf2c/libF77/qbitshft.c index 03ab5f2..ce740ed 100644 --- a/libf2c/libF77/qbitshft.c +++ b/libf2c/libF77/qbitshft.c @@ -1,7 +1,7 @@ #include "f2c.h" - longint -qbit_shift(longint a, integer b) +longint +qbit_shift (longint a, integer b) { - return b >= 0 ? a << b : (longint)((ulongint)a >> -b); - } + return b >= 0 ? a << b : (longint) ((ulongint) a >> -b); +} diff --git a/libf2c/libF77/r_abs.c b/libf2c/libF77/r_abs.c index 77c2abd..6f62724 100644 --- a/libf2c/libF77/r_abs.c +++ b/libf2c/libF77/r_abs.c @@ -1,8 +1,9 @@ #include "f2c.h" -double r_abs(real *x) +double +r_abs (real * x) { -if(*x >= 0) - return(*x); -return(- *x); + if (*x >= 0) + return (*x); + return (-*x); } diff --git a/libf2c/libF77/r_acos.c b/libf2c/libF77/r_acos.c index 79d7b6b..d761cfd 100644 --- a/libf2c/libF77/r_acos.c +++ b/libf2c/libF77/r_acos.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_acos(real *x) +double +r_acos (real * x) { -return( acos(*x) ); + return (acos (*x)); } diff --git a/libf2c/libF77/r_asin.c b/libf2c/libF77/r_asin.c index 83722ba..b8c73c7 100644 --- a/libf2c/libF77/r_asin.c +++ b/libf2c/libF77/r_asin.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_asin(real *x) +double +r_asin (real * x) { -return( asin(*x) ); + return (asin (*x)); } diff --git a/libf2c/libF77/r_atan.c b/libf2c/libF77/r_atan.c index f8262f2..33a6589 100644 --- a/libf2c/libF77/r_atan.c +++ b/libf2c/libF77/r_atan.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_atan(real *x) +double +r_atan (real * x) { -return( atan(*x) ); + return (atan (*x)); } diff --git a/libf2c/libF77/r_atn2.c b/libf2c/libF77/r_atn2.c index 0abc146..076d874 100644 --- a/libf2c/libF77/r_atn2.c +++ b/libf2c/libF77/r_atn2.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_atn2(real *x, real *y) +double +r_atn2 (real * x, real * y) { -return( atan2(*x,*y) ); + return (atan2 (*x, *y)); } diff --git a/libf2c/libF77/r_cnjg.c b/libf2c/libF77/r_cnjg.c index cb830a8..5f84929 100644 --- a/libf2c/libF77/r_cnjg.c +++ b/libf2c/libF77/r_cnjg.c @@ -1,9 +1,9 @@ #include "f2c.h" void -r_cnjg(complex *r, complex *z) +r_cnjg (complex * r, complex * z) { - real zi = z->i; - r->r = z->r; - r->i = -zi; - } + real zi = z->i; + r->r = z->r; + r->i = -zi; +} diff --git a/libf2c/libF77/r_cos.c b/libf2c/libF77/r_cos.c index 380e250..ed556e8 100644 --- a/libf2c/libF77/r_cos.c +++ b/libf2c/libF77/r_cos.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_cos(real *x) +double +r_cos (real * x) { -return( cos(*x) ); + return (cos (*x)); } diff --git a/libf2c/libF77/r_cosh.c b/libf2c/libF77/r_cosh.c index d133cf9..b22e0cf 100644 --- a/libf2c/libF77/r_cosh.c +++ b/libf2c/libF77/r_cosh.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_cosh(real *x) +double +r_cosh (real * x) { -return( cosh(*x) ); + return (cosh (*x)); } diff --git a/libf2c/libF77/r_dim.c b/libf2c/libF77/r_dim.c index fe3896b..48d2fc7 100644 --- a/libf2c/libF77/r_dim.c +++ b/libf2c/libF77/r_dim.c @@ -1,6 +1,7 @@ #include "f2c.h" -double r_dim(real *a, real *b) +double +r_dim (real * a, real * b) { -return( *a > *b ? *a - *b : 0); + return (*a > *b ? *a - *b : 0); } diff --git a/libf2c/libF77/r_exp.c b/libf2c/libF77/r_exp.c index 2a9581c..7c1ceea 100644 --- a/libf2c/libF77/r_exp.c +++ b/libf2c/libF77/r_exp.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_exp(real *x) +double +r_exp (real * x) { -return( exp(*x) ); + return (exp (*x)); } diff --git a/libf2c/libF77/r_imag.c b/libf2c/libF77/r_imag.c index 42042a9..784abc8 100644 --- a/libf2c/libF77/r_imag.c +++ b/libf2c/libF77/r_imag.c @@ -1,6 +1,7 @@ #include "f2c.h" -double r_imag(complex *z) +double +r_imag (complex * z) { -return(z->i); + return (z->i); } diff --git a/libf2c/libF77/r_int.c b/libf2c/libF77/r_int.c index b2a4747..3c1b28e 100644 --- a/libf2c/libF77/r_int.c +++ b/libf2c/libF77/r_int.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_int(real *x) +double +r_int (real * x) { -return( (*x>0) ? floor(*x) : -floor(- *x) ); + return ((*x > 0) ? floor (*x) : -floor (-*x)); } diff --git a/libf2c/libF77/r_lg10.c b/libf2c/libF77/r_lg10.c index 36336cb..563e73c 100644 --- a/libf2c/libF77/r_lg10.c +++ b/libf2c/libF77/r_lg10.c @@ -4,7 +4,8 @@ #undef abs #include <math.h> -double r_lg10(real *x) +double +r_lg10 (real * x) { -return( log10e * log(*x) ); + return (log10e * log (*x)); } diff --git a/libf2c/libF77/r_log.c b/libf2c/libF77/r_log.c index 3cc069d..eaaecc8 100644 --- a/libf2c/libF77/r_log.c +++ b/libf2c/libF77/r_log.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_log(real *x) +double +r_log (real * x) { -return( log(*x) ); + return (log (*x)); } diff --git a/libf2c/libF77/r_mod.c b/libf2c/libF77/r_mod.c index c2a1929..9518d66 100644 --- a/libf2c/libF77/r_mod.c +++ b/libf2c/libF77/r_mod.c @@ -1,31 +1,33 @@ #include "f2c.h" #ifdef IEEE_drem -double drem(double, double); +double drem (double, double); #else #undef abs #include <math.h> #endif -double r_mod(real *x, real *y) +double +r_mod (real * x, real * y) { #ifdef IEEE_drem - double xa, ya, z; - if ((ya = *y) < 0.) - ya = -ya; - z = drem(xa = *x, ya); - if (xa > 0) { - if (z < 0) - z += ya; - } - else if (z > 0) - z -= ya; - return z; + double xa, ya, z; + if ((ya = *y) < 0.) + ya = -ya; + z = drem (xa = *x, ya); + if (xa > 0) + { + if (z < 0) + z += ya; + } + else if (z > 0) + z -= ya; + return z; #else - double quotient; - if( (quotient = (double)*x / *y) >= 0) - quotient = floor(quotient); - else - quotient = -floor(-quotient); - return(*x - (*y) * quotient ); + double quotient; + if ((quotient = (double) *x / *y) >= 0) + quotient = floor (quotient); + else + quotient = -floor (-quotient); + return (*x - (*y) * quotient); #endif } diff --git a/libf2c/libF77/r_nint.c b/libf2c/libF77/r_nint.c index 79700c8..f2713d5 100644 --- a/libf2c/libF77/r_nint.c +++ b/libf2c/libF77/r_nint.c @@ -2,8 +2,8 @@ #undef abs #include <math.h> -double r_nint(real *x) +double +r_nint (real * x) { -return( (*x)>=0 ? - floor(*x + .5) : -floor(.5 - *x) ); + return ((*x) >= 0 ? floor (*x + .5) : -floor (.5 - *x)); } diff --git a/libf2c/libF77/r_sign.c b/libf2c/libF77/r_sign.c index 01defda..f53c6bf 100644 --- a/libf2c/libF77/r_sign.c +++ b/libf2c/libF77/r_sign.c @@ -1,8 +1,9 @@ #include "f2c.h" -double r_sign(real *a, real *b) +double +r_sign (real * a, real * b) { -double x; -x = (*a >= 0 ? *a : - *a); -return( *b >= 0 ? x : -x); + double x; + x = (*a >= 0 ? *a : -*a); + return (*b >= 0 ? x : -x); } diff --git a/libf2c/libF77/r_sin.c b/libf2c/libF77/r_sin.c index 9d7db2c..5a5ef13 100644 --- a/libf2c/libF77/r_sin.c +++ b/libf2c/libF77/r_sin.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_sin(real *x) +double +r_sin (real * x) { -return( sin(*x) ); + return (sin (*x)); } diff --git a/libf2c/libF77/r_sinh.c b/libf2c/libF77/r_sinh.c index 47b6ad8..723c7ab 100644 --- a/libf2c/libF77/r_sinh.c +++ b/libf2c/libF77/r_sinh.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_sinh(real *x) +double +r_sinh (real * x) { -return( sinh(*x) ); + return (sinh (*x)); } diff --git a/libf2c/libF77/r_sqrt.c b/libf2c/libF77/r_sqrt.c index 114cd1b..ed832ba 100644 --- a/libf2c/libF77/r_sqrt.c +++ b/libf2c/libF77/r_sqrt.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_sqrt(real *x) +double +r_sqrt (real * x) { -return( sqrt(*x) ); + return (sqrt (*x)); } diff --git a/libf2c/libF77/r_tan.c b/libf2c/libF77/r_tan.c index 455c964..4ef913e 100644 --- a/libf2c/libF77/r_tan.c +++ b/libf2c/libF77/r_tan.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_tan(real *x) +double +r_tan (real * x) { -return( tan(*x) ); + return (tan (*x)); } diff --git a/libf2c/libF77/r_tanh.c b/libf2c/libF77/r_tanh.c index 9fe150e..6f2552a 100644 --- a/libf2c/libF77/r_tanh.c +++ b/libf2c/libF77/r_tanh.c @@ -2,7 +2,8 @@ #undef abs #include <math.h> -double r_tanh(real *x) +double +r_tanh (real * x) { -return( tanh(*x) ); + return (tanh (*x)); } diff --git a/libf2c/libF77/s_cat.c b/libf2c/libF77/s_cat.c index d8c9333..4e8da1b 100644 --- a/libf2c/libF77/s_cat.c +++ b/libf2c/libF77/s_cat.c @@ -10,56 +10,61 @@ #undef min #undef max #include <stdlib.h> - extern char *F77_aloc(ftnlen, char*); +extern char *F77_aloc (ftnlen, char *); #include <string.h> #endif /* NO_OVERWRITE */ void -s_cat(char *lp, char *rpp[], ftnint rnp[], ftnint *np, ftnlen ll) +s_cat (char *lp, char *rpp[], ftnint rnp[], ftnint * np, ftnlen ll) { - ftnlen i, nc; - char *rp; - ftnlen n = *np; + ftnlen i, nc; + char *rp; + ftnlen n = *np; #ifndef NO_OVERWRITE - ftnlen L, m; - char *lp0, *lp1; + ftnlen L, m; + char *lp0, *lp1; - lp0 = 0; - lp1 = lp; - L = ll; - i = 0; - while(i < n) { - rp = rpp[i]; - m = rnp[i++]; - if (rp >= lp1 || rp + m <= lp) { - if ((L -= m) <= 0) { - n = i; - break; - } - lp1 += m; - continue; - } - lp0 = lp; - lp = lp1 = F77_aloc(L = ll, "s_cat"); - break; - } - lp1 = lp; + lp0 = 0; + lp1 = lp; + L = ll; + i = 0; + while (i < n) + { + rp = rpp[i]; + m = rnp[i++]; + if (rp >= lp1 || rp + m <= lp) + { + if ((L -= m) <= 0) + { + n = i; + break; + } + lp1 += m; + continue; + } + lp0 = lp; + lp = lp1 = F77_aloc (L = ll, "s_cat"); + break; + } + lp1 = lp; #endif /* NO_OVERWRITE */ - for(i = 0 ; i < n ; ++i) { - nc = ll; - if(rnp[i] < nc) - nc = rnp[i]; - ll -= nc; - rp = rpp[i]; - while(--nc >= 0) - *lp++ = *rp++; - } - while(--ll >= 0) - *lp++ = ' '; + for (i = 0; i < n; ++i) + { + nc = ll; + if (rnp[i] < nc) + nc = rnp[i]; + ll -= nc; + rp = rpp[i]; + while (--nc >= 0) + *lp++ = *rp++; + } + while (--ll >= 0) + *lp++ = ' '; #ifndef NO_OVERWRITE - if (lp0) { - memcpy(lp0, lp1, L); - free(lp1); - } + if (lp0) + { + memcpy (lp0, lp1, L); + free (lp1); + } #endif - } +} diff --git a/libf2c/libF77/s_cmp.c b/libf2c/libF77/s_cmp.c index febc586..5b43c9e 100644 --- a/libf2c/libF77/s_cmp.c +++ b/libf2c/libF77/s_cmp.c @@ -2,39 +2,48 @@ /* compare two strings */ -integer s_cmp(char *a0, char *b0, ftnlen la, ftnlen lb) +integer +s_cmp (char *a0, char *b0, ftnlen la, ftnlen lb) { -register unsigned char *a, *aend, *b, *bend; -a = (unsigned char *)a0; -b = (unsigned char *)b0; -aend = a + la; -bend = b + lb; + register unsigned char *a, *aend, *b, *bend; + a = (unsigned char *) a0; + b = (unsigned char *) b0; + aend = a + la; + bend = b + lb; -if(la <= lb) - { - while(a < aend) - if(*a != *b) - return( *a - *b ); - else - { ++a; ++b; } + if (la <= lb) + { + while (a < aend) + if (*a != *b) + return (*a - *b); + else + { + ++a; + ++b; + } - while(b < bend) - if(*b != ' ') - return( ' ' - *b ); - else ++b; - } + while (b < bend) + if (*b != ' ') + return (' ' - *b); + else + ++b; + } -else - { - while(b < bend) - if(*a == *b) - { ++a; ++b; } - else - return( *a - *b ); - while(a < aend) - if(*a != ' ') - return(*a - ' '); - else ++a; - } -return(0); + else + { + while (b < bend) + if (*a == *b) + { + ++a; + ++b; + } + else + return (*a - *b); + while (a < aend) + if (*a != ' ') + return (*a - ' '); + else + ++a; + } + return (0); } diff --git a/libf2c/libF77/s_copy.c b/libf2c/libF77/s_copy.c index a0c98ca..a91071e 100644 --- a/libf2c/libF77/s_copy.c +++ b/libf2c/libF77/s_copy.c @@ -8,40 +8,43 @@ /* assign strings: a = b */ -void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb) +void +s_copy (register char *a, register char *b, ftnlen la, ftnlen lb) { - register char *aend, *bend; + register char *aend, *bend; - aend = a + la; + aend = a + la; - if(la <= lb) + if (la <= lb) #ifndef NO_OVERWRITE - if (a <= b || a >= b + la) + if (a <= b || a >= b + la) #endif - while(a < aend) - *a++ = *b++; + while (a < aend) + *a++ = *b++; #ifndef NO_OVERWRITE - else - for(b += la; a < aend; ) - *--aend = *--b; + else + for (b += la; a < aend;) + *--aend = *--b; #endif - else { - bend = b + lb; + else + { + bend = b + lb; #ifndef NO_OVERWRITE - if (a <= b || a >= bend) + if (a <= b || a >= bend) #endif - while(b < bend) - *a++ = *b++; + while (b < bend) + *a++ = *b++; #ifndef NO_OVERWRITE - else { - a += lb; - while(b < bend) - *--a = *--bend; - a += lb; - } -#endif - while(a < aend) - *a++ = ' '; - } + else + { + a += lb; + while (b < bend) + *--a = *--bend; + a += lb; } +#endif + while (a < aend) + *a++ = ' '; + } +} diff --git a/libf2c/libF77/s_paus.c b/libf2c/libF77/s_paus.c index 34f4861..7969136 100644 --- a/libf2c/libF77/s_paus.c +++ b/libf2c/libF77/s_paus.c @@ -7,61 +7,65 @@ #undef min #undef max #include <stdlib.h> -extern int getpid(void), isatty(int), pause(void); +extern int getpid (void), isatty (int), pause (void); -extern void f_exit(void); +extern void f_exit (void); static void -waitpause(Sigarg) -{ Use_Sigarg; - return; - } +waitpause (Sigarg) +{ + Use_Sigarg; + return; +} static void -s_1paus(FILE *fin) +s_1paus (FILE * fin) { - fprintf(stderr, - "To resume execution, type go. Other input will terminate the job.\n"); - fflush(stderr); - if( getc(fin)!='g' || getc(fin)!='o' || getc(fin)!='\n' ) { - fprintf(stderr, "STOP\n"); + fprintf (stderr, + "To resume execution, type go. Other input will terminate the job.\n"); + fflush (stderr); + if (getc (fin) != 'g' || getc (fin) != 'o' || getc (fin) != '\n') + { + fprintf (stderr, "STOP\n"); #ifdef NO_ONEXIT - f_exit(); + f_exit (); #endif - exit(0); - } - } + exit (0); + } +} - int -s_paus(char *s, ftnlen n) +int +s_paus (char *s, ftnlen n) { - fprintf(stderr, "PAUSE "); - if(n > 0) - fprintf(stderr, " %.*s", (int)n, s); - fprintf(stderr, " statement executed\n"); - if( isatty(fileno(stdin)) ) - s_1paus(stdin); - else { + fprintf (stderr, "PAUSE "); + if (n > 0) + fprintf (stderr, " %.*s", (int) n, s); + fprintf (stderr, " statement executed\n"); + if (isatty (fileno (stdin))) + s_1paus (stdin); + else + { #if (defined (MSDOS) && !defined (GO32)) || defined (_WIN32) - FILE *fin; - fin = fopen("con", "r"); - if (!fin) { - fprintf(stderr, "s_paus: can't open con!\n"); - fflush(stderr); - exit(1); - } - s_1paus(fin); - fclose(fin); + FILE *fin; + fin = fopen ("con", "r"); + if (!fin) + { + fprintf (stderr, "s_paus: can't open con!\n"); + fflush (stderr); + exit (1); + } + s_1paus (fin); + fclose (fin); #else - fprintf(stderr, - "To resume execution, execute a kill -%d %d command\n", - PAUSESIG, getpid() ); - signal1(PAUSESIG, waitpause); - fflush(stderr); - pause(); + fprintf (stderr, + "To resume execution, execute a kill -%d %d command\n", + PAUSESIG, getpid ()); + signal1 (PAUSESIG, waitpause); + fflush (stderr); + pause (); #endif - } - fprintf(stderr, "Execution resumes after PAUSE.\n"); - fflush(stderr); - return 0; /* NOT REACHED */ + } + fprintf (stderr, "Execution resumes after PAUSE.\n"); + fflush (stderr); + return 0; /* NOT REACHED */ } diff --git a/libf2c/libF77/s_rnge.c b/libf2c/libF77/s_rnge.c index c58430e..6c054c7 100644 --- a/libf2c/libF77/s_rnge.c +++ b/libf2c/libF77/s_rnge.c @@ -3,19 +3,20 @@ /* called when a subscript is out of range */ -extern void sig_die(char*,int); -integer s_rnge(char *varn, ftnint offset, char *procn, ftnint line) +extern void sig_die (char *, int); +integer +s_rnge (char *varn, ftnint offset, char *procn, ftnint line) { -register int i; + register int i; -fprintf(stderr, "Subscript out of range on file line %ld, procedure ", - (long)line); -while((i = *procn) && i != '_' && i != ' ') - putc(*procn++, stderr); -fprintf(stderr, ".\nAttempt to access the %ld-th element of variable ", - (long)offset+1); -while((i = *varn) && i != ' ') - putc(*varn++, stderr); -sig_die(".", 1); -return 0; /* not reached */ + fprintf (stderr, "Subscript out of range on file line %ld, procedure ", + (long) line); + while ((i = *procn) && i != '_' && i != ' ') + putc (*procn++, stderr); + fprintf (stderr, ".\nAttempt to access the %ld-th element of variable ", + (long) offset + 1); + while ((i = *varn) && i != ' ') + putc (*varn++, stderr); + sig_die (".", 1); + return 0; /* not reached */ } diff --git a/libf2c/libF77/s_stop.c b/libf2c/libF77/s_stop.c index 391148f..571416b 100644 --- a/libf2c/libF77/s_stop.c +++ b/libf2c/libF77/s_stop.c @@ -5,27 +5,28 @@ #undef min #undef max #include <stdlib.h> -void f_exit(void); +void f_exit (void); -int s_stop(char *s, ftnlen n) +int +s_stop (char *s, ftnlen n) { -int i; + int i; -if(n > 0) - { - fprintf(stderr, "STOP "); - for(i = 0; i<n ; ++i) - putc(*s++, stderr); - fprintf(stderr, " statement executed\n"); - } + if (n > 0) + { + fprintf (stderr, "STOP "); + for (i = 0; i < n; ++i) + putc (*s++, stderr); + fprintf (stderr, " statement executed\n"); + } #ifdef NO_ONEXIT -f_exit(); + f_exit (); #endif -exit(0); + exit (0); /* We cannot avoid (useless) compiler diagnostics here: */ /* some compilers complain if there is no return statement, */ /* and others complain that this one cannot be reached. */ -return 0; /* NOT REACHED */ + return 0; /* NOT REACHED */ } diff --git a/libf2c/libF77/setarg.c b/libf2c/libF77/setarg.c index bd4d517..4951574 100644 --- a/libf2c/libF77/setarg.c +++ b/libf2c/libF77/setarg.c @@ -6,9 +6,9 @@ int f__xargc; char **f__xargv; - void -f_setarg(int argc, char **argv) +void +f_setarg (int argc, char **argv) { -f__xargc = argc; -f__xargv = argv; + f__xargc = argc; + f__xargv = argv; } diff --git a/libf2c/libF77/setsig.c b/libf2c/libF77/setsig.c index 6be89af..96826be 100644 --- a/libf2c/libF77/setsig.c +++ b/libf2c/libF77/setsig.c @@ -11,76 +11,76 @@ #include <stdlib.h> -extern void sig_die(char*, int); +extern void sig_die (char *, int); static void -sigfdie(Sigarg) +sigfdie (Sigarg) { -Use_Sigarg; -sig_die("Floating Exception", 1); + Use_Sigarg; + sig_die ("Floating Exception", 1); } static void -sigidie(Sigarg) +sigidie (Sigarg) { -Use_Sigarg; -sig_die("IOT Trap", 1); + Use_Sigarg; + sig_die ("IOT Trap", 1); } #ifdef SIGQUIT static void -sigqdie(Sigarg) +sigqdie (Sigarg) { -Use_Sigarg; -sig_die("Quit signal", 1); + Use_Sigarg; + sig_die ("Quit signal", 1); } #endif static void -sigindie(Sigarg) +sigindie (Sigarg) { -Use_Sigarg; -sig_die("Interrupt", 0); + Use_Sigarg; + sig_die ("Interrupt", 0); } static void -sigtdie(Sigarg) +sigtdie (Sigarg) { -Use_Sigarg; -sig_die("Killed", 0); + Use_Sigarg; + sig_die ("Killed", 0); } #ifdef SIGTRAP static void -sigtrdie(Sigarg) +sigtrdie (Sigarg) { -Use_Sigarg; -sig_die("Trace trap", 1); + Use_Sigarg; + sig_die ("Trace trap", 1); } #endif - void -f_setsig() +void +f_setsig () { -signal1(SIGFPE, sigfdie); /* ignore underflow, enable overflow */ + signal1 (SIGFPE, sigfdie); /* ignore underflow, enable overflow */ #ifdef SIGIOT -signal1(SIGIOT, sigidie); + signal1 (SIGIOT, sigidie); #endif #ifdef SIGTRAP -signal1(SIGTRAP, sigtrdie); + signal1 (SIGTRAP, sigtrdie); #endif #ifdef SIGQUIT -if(signal1(SIGQUIT,sigqdie) == SIG_IGN) - signal1(SIGQUIT, SIG_IGN); + if (signal1 (SIGQUIT, sigqdie) == SIG_IGN) + signal1 (SIGQUIT, SIG_IGN); #endif -if(signal1(SIGINT, sigindie) == SIG_IGN) - signal1(SIGINT, SIG_IGN); -signal1(SIGTERM,sigtdie); + if (signal1 (SIGINT, sigindie) == SIG_IGN) + signal1 (SIGINT, SIG_IGN); + signal1 (SIGTERM, sigtdie); #ifdef pdp11 - ldfps(01200); /* detect overflow as an exception */ + ldfps (01200); /* detect overflow as an exception */ #endif } diff --git a/libf2c/libF77/sig_die.c b/libf2c/libF77/sig_die.c index 7ed419a..622462e 100644 --- a/libf2c/libF77/sig_die.c +++ b/libf2c/libF77/sig_die.c @@ -8,28 +8,30 @@ #endif #include <stdlib.h> - extern void f_exit(void); +extern void f_exit (void); -void sig_die(register char *s, int kill) +void +sig_die (register char *s, int kill) { - /* print error message, then clear buffers */ - fprintf(stderr, "%s\n", s); + /* print error message, then clear buffers */ + fprintf (stderr, "%s\n", s); - if(kill) - { - fflush(stderr); - f_exit(); - fflush(stderr); - /* now get a core */ + if (kill) + { + fflush (stderr); + f_exit (); + fflush (stderr); + /* now get a core */ #ifdef SIGIOT - signal(SIGIOT, SIG_DFL); + signal (SIGIOT, SIG_DFL); #endif - abort(); - } - else { + abort (); + } + else + { #ifdef NO_ONEXIT - f_exit(); + f_exit (); #endif - exit(1); - } - } + exit (1); + } +} diff --git a/libf2c/libF77/signal1.h0 b/libf2c/libF77/signal1.h0 index e38a8ba..0e2fcf2 100644 --- a/libf2c/libF77/signal1.h0 +++ b/libf2c/libF77/signal1.h0 @@ -12,12 +12,12 @@ #endif #ifndef Sigarg_t #define Sigarg_t int -#endif /*Sigarg_t*/ +#endif /*Sigarg_t */ -#ifdef USE_SIG_PF /* compile with -DUSE_SIG_PF under IRIX */ +#ifdef USE_SIG_PF /* compile with -DUSE_SIG_PF under IRIX */ #define sig_pf SIG_PF #else -typedef Sigret_t (*sig_pf)(Sigarg_t); +typedef Sigret_t (*sig_pf) (Sigarg_t); #endif #define signal1(a,b) signal(a,(sig_pf)b) diff --git a/libf2c/libF77/signal_.c b/libf2c/libF77/signal_.c index ff496a1..f67831c 100644 --- a/libf2c/libF77/signal_.c +++ b/libf2c/libF77/signal_.c @@ -2,10 +2,10 @@ #include "signal1.h" void * -G77_signal_0 (integer *sigp, sig_pf proc) +G77_signal_0 (integer * sigp, sig_pf proc) { - int sig; - sig = (int)*sigp; + int sig; + sig = (int) *sigp; - return (void *) signal(sig, proc); - } + return (void *) signal (sig, proc); +} diff --git a/libf2c/libF77/system_.c b/libf2c/libF77/system_.c index ebb3041..b8d1d3d 100644 --- a/libf2c/libF77/system_.c +++ b/libf2c/libF77/system_.c @@ -6,24 +6,23 @@ #undef min #undef max #include <stdlib.h> -extern char *F77_aloc(ftnlen, char*); +extern char *F77_aloc (ftnlen, char *); - integer +integer G77_system_0 (register char *s, ftnlen n) { - char buff0[256], *buff; - register char *bp, *blast; - integer rv; + char buff0[256], *buff; + register char *bp, *blast; + integer rv; - buff = bp = n < sizeof(buff0) - ? buff0 : F77_aloc(n+1, "system_"); - blast = bp + n; + buff = bp = n < sizeof (buff0) ? buff0 : F77_aloc (n + 1, "system_"); + blast = bp + n; - while(bp < blast && *s) - *bp++ = *s++; - *bp = 0; - rv = system(buff); - if (buff != buff0) - free(buff); - return rv; - } + while (bp < blast && *s) + *bp++ = *s++; + *bp = 0; + rv = system (buff); + if (buff != buff0) + free (buff); + return rv; +} diff --git a/libf2c/libF77/z_abs.c b/libf2c/libF77/z_abs.c index 5037565..2419c0e 100644 --- a/libf2c/libF77/z_abs.c +++ b/libf2c/libF77/z_abs.c @@ -1,7 +1,8 @@ #include "f2c.h" -double f__cabs(double, double); -double z_abs(doublecomplex *z) +double f__cabs (double, double); +double +z_abs (doublecomplex * z) { -return( f__cabs( z->r, z->i ) ); + return (f__cabs (z->r, z->i)); } diff --git a/libf2c/libF77/z_cos.c b/libf2c/libF77/z_cos.c index 74ee2e4..0f4cd71 100644 --- a/libf2c/libF77/z_cos.c +++ b/libf2c/libF77/z_cos.c @@ -2,9 +2,10 @@ #undef abs #include "math.h" -void z_cos(doublecomplex *r, doublecomplex *z) +void +z_cos (doublecomplex * r, doublecomplex * z) { - double zi = z->i, zr = z->r; - r->r = cos(zr) * cosh(zi); - r->i = - sin(zr) * sinh(zi); - } + double zi = z->i, zr = z->r; + r->r = cos (zr) * cosh (zi); + r->i = -sin (zr) * sinh (zi); +} diff --git a/libf2c/libF77/z_div.c b/libf2c/libF77/z_div.c index d0b5944..a5fc527 100644 --- a/libf2c/libF77/z_div.c +++ b/libf2c/libF77/z_div.c @@ -1,39 +1,41 @@ #include "f2c.h" -extern void sig_die(char*, int); -void z_div(doublecomplex *c, doublecomplex *a, doublecomplex *b) +extern void sig_die (char *, int); +void +z_div (doublecomplex * c, doublecomplex * a, doublecomplex * b) { - double ratio, den; - double abr, abi, cr; + double ratio, den; + double abr, abi, cr; - if( (abr = b->r) < 0.) - abr = - abr; - if( (abi = b->i) < 0.) - abi = - abi; - if( abr <= abi ) - { - if(abi == 0) { + if ((abr = b->r) < 0.) + abr = -abr; + if ((abi = b->i) < 0.) + abi = -abi; + if (abr <= abi) + { + if (abi == 0) + { #ifdef IEEE_COMPLEX_DIVIDE - if (a->i != 0 || a->r != 0) - abi = 1.; - c->i = c->r = abi / abr; - return; + if (a->i != 0 || a->r != 0) + abi = 1.; + c->i = c->r = abi / abr; + return; #else - sig_die("complex division by zero", 1); + sig_die ("complex division by zero", 1); #endif - } - ratio = b->r / b->i ; - den = b->i * (1 + ratio*ratio); - cr = (a->r*ratio + a->i) / den; - c->i = (a->i*ratio - a->r) / den; - } - - else - { - ratio = b->i / b->r ; - den = b->r * (1 + ratio*ratio); - cr = (a->r + a->i*ratio) / den; - c->i = (a->i - a->r*ratio) / den; - } - c->r = cr; } + ratio = b->r / b->i; + den = b->i * (1 + ratio * ratio); + cr = (a->r * ratio + a->i) / den; + c->i = (a->i * ratio - a->r) / den; + } + + else + { + ratio = b->i / b->r; + den = b->r * (1 + ratio * ratio); + cr = (a->r + a->i * ratio) / den; + c->i = (a->i - a->r * ratio) / den; + } + c->r = cr; +} diff --git a/libf2c/libF77/z_exp.c b/libf2c/libF77/z_exp.c index 2dad121..16f51e7 100644 --- a/libf2c/libF77/z_exp.c +++ b/libf2c/libF77/z_exp.c @@ -2,11 +2,12 @@ #undef abs #include "math.h" -void z_exp(doublecomplex *r, doublecomplex *z) +void +z_exp (doublecomplex * r, doublecomplex * z) { - double expx, zi = z->i; + double expx, zi = z->i; - expx = exp(z->r); - r->r = expx * cos(zi); - r->i = expx * sin(zi); - } + expx = exp (z->r); + r->r = expx * cos (zi); + r->i = expx * sin (zi); +} diff --git a/libf2c/libF77/z_log.c b/libf2c/libF77/z_log.c index 09f8cd4..f56b12e 100644 --- a/libf2c/libF77/z_log.c +++ b/libf2c/libF77/z_log.c @@ -2,57 +2,58 @@ #undef abs #include "math.h" -extern double f__cabs(double, double); -void z_log(doublecomplex *r, doublecomplex *z) +extern double f__cabs (double, double); +void +z_log (doublecomplex * r, doublecomplex * z) { - double s, s0, t, t2, u, v; - double zi = z->i, zr = z->r; + double s, s0, t, t2, u, v; + double zi = z->i, zr = z->r; - r->i = atan2(zi, zr); + r->i = atan2 (zi, zr); #ifdef Pre20000310 - r->r = log( f__cabs( zr, zi ) ); + r->r = log (f__cabs (zr, zi)); #else - if (zi < 0) - zi = -zi; - if (zr < 0) - zr = -zr; - if (zr < zi) { - t = zi; - zi = zr; - zr = t; - } - t = zi/zr; - s = zr * sqrt(1 + t*t); - /* now s = f__cabs(zi,zr), and zr = |zr| >= |zi| = zi */ - if ((t = s - 1) < 0) - t = -t; - if (t > .01) - r->r = log(s); - else { + if (zi < 0) + zi = -zi; + if (zr < 0) + zr = -zr; + if (zr < zi) + { + t = zi; + zi = zr; + zr = t; + } + t = zi / zr; + s = zr * sqrt (1 + t * t); + /* now s = f__cabs(zi,zr), and zr = |zr| >= |zi| = zi */ + if ((t = s - 1) < 0) + t = -t; + if (t > .01) + r->r = log (s); + else + { #ifdef Comment - log(1+x) = x - x^2/2 + x^3/3 - x^4/4 + - ... - - = x(1 - x/2 + x^2/3 -+...) - - [sqrt(y^2 + z^2) - 1] * [sqrt(y^2 + z^2) + 1] = y^2 + z^2 - 1, so - - sqrt(y^2 + z^2) - 1 = (y^2 + z^2 - 1) / [sqrt(y^2 + z^2) + 1] - -#endif /*Comment*/ - - t = ((zr*zr - 1.) + zi*zi) / (s + 1); - t2 = t*t; - s = 1. - 0.5*t; - u = v = 1; - do { - s0 = s; - u *= t2; - v += 2; - s += u/v - t*u/(v+1); - } while(s > s0); - r->r = s*t; - } -#endif + log (1 + x) = x - x ^ 2 / 2 + x ^ 3 / 3 - x ^ 4 / 4 + -... + = x (1 - x / 2 + x ^ 2 / 3 - +...) + [sqrt (y ^ 2 + z ^ 2) - 1] *[sqrt (y ^ 2 + z ^ 2) + 1] = + y ^ 2 + z ^ 2 - 1, so sqrt (y ^ 2 + z ^ 2) - 1 = + (y ^ 2 + z ^ 2 - 1) /[sqrt (y ^ 2 + z ^ 2) + 1] +#endif /*Comment */ + t = ((zr * zr - 1.) + zi * zi) / (s + 1); + t2 = t * t; + s = 1. - 0.5 * t; + u = v = 1; + do + { + s0 = s; + u *= t2; + v += 2; + s += u / v - t * u / (v + 1); } + while (s > s0); + r->r = s * t; + } +#endif +} diff --git a/libf2c/libF77/z_sin.c b/libf2c/libF77/z_sin.c index 1294d22..8cb44cf 100644 --- a/libf2c/libF77/z_sin.c +++ b/libf2c/libF77/z_sin.c @@ -2,9 +2,10 @@ #undef abs #include "math.h" -void z_sin(doublecomplex *r, doublecomplex *z) +void +z_sin (doublecomplex * r, doublecomplex * z) { - double zi = z->i, zr = z->r; - r->r = sin(zr) * cosh(zi); - r->i = cos(zr) * sinh(zi); - } + double zi = z->i, zr = z->r; + r->r = sin (zr) * cosh (zi); + r->i = cos (zr) * sinh (zi); +} diff --git a/libf2c/libF77/z_sqrt.c b/libf2c/libF77/z_sqrt.c index 94560ed..954c2fa 100644 --- a/libf2c/libF77/z_sqrt.c +++ b/libf2c/libF77/z_sqrt.c @@ -2,23 +2,24 @@ #undef abs #include "math.h" -extern double f__cabs(double, double); -void z_sqrt(doublecomplex *r, doublecomplex *z) +extern double f__cabs (double, double); +void +z_sqrt (doublecomplex * r, doublecomplex * z) { - double mag, zi = z->i, zr = z->r; + double mag, zi = z->i, zr = z->r; - if( (mag = f__cabs(zr, zi)) == 0.) - r->r = r->i = 0.; - else if(zr > 0) - { - r->r = sqrt(0.5 * (mag + zr) ); - r->i = zi / r->r / 2; - } - else - { - r->i = sqrt(0.5 * (mag - zr) ); - if(zi < 0) - r->i = - r->i; - r->r = zi / r->i / 2; - } - } + if ((mag = f__cabs (zr, zi)) == 0.) + r->r = r->i = 0.; + else if (zr > 0) + { + r->r = sqrt (0.5 * (mag + zr)); + r->i = zi / r->r / 2; + } + else + { + r->i = sqrt (0.5 * (mag - zr)); + if (zi < 0) + r->i = -r->i; + r->r = zi / r->i / 2; + } +} diff --git a/libf2c/libI77/backspace.c b/libf2c/libI77/backspace.c index ba1dfa1..c31e711 100644 --- a/libf2c/libI77/backspace.c +++ b/libf2c/libI77/backspace.c @@ -2,69 +2,80 @@ #include <sys/types.h> #include "f2c.h" #include "fio.h" -integer f_back(alist *a) -{ unit *b; - off_t v, w, x, y, z; - uiolen n; - FILE *f; +integer +f_back (alist * a) +{ + unit *b; + off_t v, w, x, y, z; + uiolen n; + FILE *f; - f__curunit = b = &f__units[a->aunit]; /* curunit for error messages */ - if (f__init & 2) - f__fatal (131, "I/O recursion"); - if(a->aunit >= MXUNIT || a->aunit < 0) - err(a->aerr,101,"backspace"); - if(b->useek==0) err(a->aerr,106,"backspace"); - if(b->ufd == NULL) { - fk_open(1, 1, a->aunit); - return(0); - } - if(b->uend==1) - { b->uend=0; - return(0); - } - if(b->uwrt) { - t_runc(a); - if (f__nowreading(b)) - err(a->aerr,errno,"backspace"); - } - f = b->ufd; /* may have changed in t_runc() */ - if(b->url>0) - { - x=FTELL(f); - y = x % b->url; - if(y == 0) x--; - x /= b->url; - x *= b->url; - FSEEK(f,x,SEEK_SET); - return(0); - } + f__curunit = b = &f__units[a->aunit]; /* curunit for error messages */ + if (f__init & 2) + f__fatal (131, "I/O recursion"); + if (a->aunit >= MXUNIT || a->aunit < 0) + err (a->aerr, 101, "backspace"); + if (b->useek == 0) + err (a->aerr, 106, "backspace"); + if (b->ufd == NULL) + { + fk_open (1, 1, a->aunit); + return (0); + } + if (b->uend == 1) + { + b->uend = 0; + return (0); + } + if (b->uwrt) + { + t_runc (a); + if (f__nowreading (b)) + err (a->aerr, errno, "backspace"); + } + f = b->ufd; /* may have changed in t_runc() */ + if (b->url > 0) + { + x = FTELL (f); + y = x % b->url; + if (y == 0) + x--; + x /= b->url; + x *= b->url; + FSEEK (f, x, SEEK_SET); + return (0); + } - if(b->ufmt==0) - { FSEEK(f,-(off_t)sizeof(uiolen),SEEK_CUR); - fread((char *)&n,sizeof(uiolen),1,f); - FSEEK(f,-(off_t)n-2*sizeof(uiolen),SEEK_CUR); - return(0); + if (b->ufmt == 0) + { + FSEEK (f, -(off_t) sizeof (uiolen), SEEK_CUR); + fread ((char *) &n, sizeof (uiolen), 1, f); + FSEEK (f, -(off_t) n - 2 * sizeof (uiolen), SEEK_CUR); + return (0); + } + w = x = FTELL (f); + z = 0; +loop: + while (x) + { + x -= x < 64 ? x : 64; + FSEEK (f, x, SEEK_SET); + for (y = x; y < w; y++) + { + if (getc (f) != '\n') + continue; + v = FTELL (f); + if (v == w) + { + if (z) + goto break2; + goto loop; + } + z = v; } - w = x = FTELL(f); - z = 0; - loop: - while(x) { - x -= x < 64 ? x : 64; - FSEEK(f,x,SEEK_SET); - for(y = x; y < w; y++) { - if (getc(f) != '\n') - continue; - v = FTELL(f); - if (v == w) { - if (z) - goto break2; - goto loop; - } - z = v; - } - err(a->aerr,(EOF),"backspace"); - } - break2: - FSEEK(f, z, SEEK_SET); - return 0; + err (a->aerr, (EOF), "backspace"); + } +break2: + FSEEK (f, z, SEEK_SET); + return 0; } diff --git a/libf2c/libI77/close.c b/libf2c/libI77/close.c index 1530348..769c569 100644 --- a/libf2c/libI77/close.c +++ b/libf2c/libI77/close.c @@ -14,78 +14,88 @@ #if defined (MSDOS) && !defined (GO32) #include "io.h" #else -extern int unlink(const char*); +extern int unlink (const char *); #endif #endif -integer f_clos(cllist *a) -{ unit *b; +integer +f_clos (cllist * a) +{ + unit *b; - if (f__init & 2) - f__fatal (131, "I/O recursion"); - if(a->cunit >= MXUNIT) return(0); - b= &f__units[a->cunit]; - if(b->ufd==NULL) - goto done; - if (b->uscrtch == 1) - goto Delete; - if (!a->csta) - goto Keep; - switch(*a->csta) { - default: - Keep: - case 'k': - case 'K': - if(b->uwrt == 1) - t_runc((alist *)a); - if(b->ufnm) { - fclose(b->ufd); - free(b->ufnm); - } - break; - case 'd': - case 'D': - Delete: - fclose(b->ufd); - if(b->ufnm) { - unlink(b->ufnm); /*SYSDEP*/ - free(b->ufnm); - } - } - b->ufd=NULL; - done: - b->uend=0; - b->ufnm=NULL; - return(0); + if (f__init & 2) + f__fatal (131, "I/O recursion"); + if (a->cunit >= MXUNIT) + return (0); + b = &f__units[a->cunit]; + if (b->ufd == NULL) + goto done; + if (b->uscrtch == 1) + goto Delete; + if (!a->csta) + goto Keep; + switch (*a->csta) + { + default: + Keep: + case 'k': + case 'K': + if (b->uwrt == 1) + t_runc ((alist *) a); + if (b->ufnm) + { + fclose (b->ufd); + free (b->ufnm); } - void -f_exit(void) -{ int i; - static cllist xx; - if (! (f__init & 1)) - return; /* Not initialized, so no open units. */ - /* I/O no longer in progress. If, during an I/O operation (such - as waiting for the user to enter a line), there is an - interrupt (such as ^C to stop the program on a UNIX system), - f_exit() is called, but there is no longer any I/O in - progress. Without turning off this flag, f_clos() would - think that there is an I/O recursion in this circumstance. */ - f__init &= ~2; - if (!xx.cerr) { - xx.cerr=1; - xx.csta=NULL; - for(i=0;i<MXUNIT;i++) - { - xx.cunit=i; - (void) f_clos(&xx); - } + break; + case 'd': + case 'D': + Delete: + fclose (b->ufd); + if (b->ufnm) + { + unlink (b->ufnm); + /*SYSDEP*/ free (b->ufnm); } + } + b->ufd = NULL; +done: + b->uend = 0; + b->ufnm = NULL; + return (0); } - int + +void +f_exit (void) +{ + int i; + static cllist xx; + if (!(f__init & 1)) + return; /* Not initialized, so no open units. */ + /* I/O no longer in progress. If, during an I/O operation (such + as waiting for the user to enter a line), there is an + interrupt (such as ^C to stop the program on a UNIX system), + f_exit() is called, but there is no longer any I/O in + progress. Without turning off this flag, f_clos() would + think that there is an I/O recursion in this circumstance. */ + f__init &= ~2; + if (!xx.cerr) + { + xx.cerr = 1; + xx.csta = NULL; + for (i = 0; i < MXUNIT; i++) + { + xx.cunit = i; + (void) f_clos (&xx); + } + } +} +int G77_flush_0 (void) -{ int i; - for(i=0;i<MXUNIT;i++) - if(f__units[i].ufd != NULL && f__units[i].uwrt) - fflush(f__units[i].ufd); -return 0; +{ + int i; + for (i = 0; i < MXUNIT; i++) + if (f__units[i].ufd != NULL && f__units[i].uwrt) + fflush (f__units[i].ufd); + return 0; } diff --git a/libf2c/libI77/dfe.c b/libf2c/libI77/dfe.c index a9cc5bd..ba8004c 100644 --- a/libf2c/libI77/dfe.c +++ b/libf2c/libI77/dfe.c @@ -3,133 +3,151 @@ #include "fio.h" #include "fmt.h" -y_rsk(void) +y_rsk (void) { - if(f__curunit->uend || f__curunit->url <= f__recpos - || f__curunit->url == 1) return 0; - do { - getc(f__cf); - } while(++f__recpos < f__curunit->url); - return 0; + if (f__curunit->uend || f__curunit->url <= f__recpos + || f__curunit->url == 1) + return 0; + do + { + getc (f__cf); + } + while (++f__recpos < f__curunit->url); + return 0; } -y_getc(void) + +y_getc (void) { - int ch; - if(f__curunit->uend) return(-1); - if((ch=getc(f__cf))!=EOF) - { - f__recpos++; - if(f__curunit->url>=f__recpos || - f__curunit->url==1) - return(ch); - else return(' '); - } - if(feof(f__cf)) - { - f__curunit->uend=1; - errno=0; - return(-1); - } - err(f__elist->cierr,errno,"readingd"); + int ch; + if (f__curunit->uend) + return (-1); + if ((ch = getc (f__cf)) != EOF) + { + f__recpos++; + if (f__curunit->url >= f__recpos || f__curunit->url == 1) + return (ch); + else + return (' '); + } + if (feof (f__cf)) + { + f__curunit->uend = 1; + errno = 0; + return (-1); + } + err (f__elist->cierr, errno, "readingd"); } - static int -y_rev(void) +static int +y_rev (void) { - if (f__recpos < f__hiwater) - f__recpos = f__hiwater; - if (f__curunit->url > 1) - while(f__recpos < f__curunit->url) - (*f__putn)(' '); - if (f__recpos) - f__putbuf(0); - f__recpos = 0; - return(0); + if (f__recpos < f__hiwater) + f__recpos = f__hiwater; + if (f__curunit->url > 1) + while (f__recpos < f__curunit->url) + (*f__putn) (' '); + if (f__recpos) + f__putbuf (0); + f__recpos = 0; + return (0); } - static int -y_err(void) +static int +y_err (void) { - err(f__elist->cierr, 110, "dfe"); + err (f__elist->cierr, 110, "dfe"); } - static int -y_newrec(void) +static int +y_newrec (void) { - y_rev(); - f__hiwater = f__cursor = 0; - return(1); + y_rev (); + f__hiwater = f__cursor = 0; + return (1); } -c_dfe(cilist *a) +c_dfe (cilist * a) { - f__sequential=0; - f__formatted=f__external=1; - f__elist=a; - f__cursor=f__scale=f__recpos=0; - f__curunit = &f__units[a->ciunit]; - if(a->ciunit>MXUNIT || a->ciunit<0) - err(a->cierr,101,"startchk"); - if(f__curunit->ufd==NULL && fk_open(DIR,FMT,a->ciunit)) - err(a->cierr,104,"dfe"); - f__cf=f__curunit->ufd; - if(!f__curunit->ufmt) err(a->cierr,102,"dfe"); - if(!f__curunit->useek) err(a->cierr,104,"dfe"); - f__fmtbuf=a->cifmt; - if(a->cirec <= 0) - err(a->cierr,130,"dfe"); - FSEEK(f__cf,(off_t)f__curunit->url * (a->cirec-1),SEEK_SET); - f__curunit->uend = 0; - return(0); + f__sequential = 0; + f__formatted = f__external = 1; + f__elist = a; + f__cursor = f__scale = f__recpos = 0; + f__curunit = &f__units[a->ciunit]; + if (a->ciunit > MXUNIT || a->ciunit < 0) + err (a->cierr, 101, "startchk"); + if (f__curunit->ufd == NULL && fk_open (DIR, FMT, a->ciunit)) + err (a->cierr, 104, "dfe"); + f__cf = f__curunit->ufd; + if (!f__curunit->ufmt) + err (a->cierr, 102, "dfe"); + if (!f__curunit->useek) + err (a->cierr, 104, "dfe"); + f__fmtbuf = a->cifmt; + if (a->cirec <= 0) + err (a->cierr, 130, "dfe"); + FSEEK (f__cf, (off_t) f__curunit->url * (a->cirec - 1), SEEK_SET); + f__curunit->uend = 0; + return (0); } -integer s_rdfe(cilist *a) + +integer +s_rdfe (cilist * a) { - int n; - if(f__init != 1) f_init(); - f__init = 3; - f__reading=1; - if(n=c_dfe(a))return(n); - if(f__curunit->uwrt && f__nowreading(f__curunit)) - err(a->cierr,errno,"read start"); - f__getn = y_getc; - f__doed = rd_ed; - f__doned = rd_ned; - f__dorevert = f__donewrec = y_err; - f__doend = y_rsk; - if(pars_f(f__fmtbuf)<0) - err(a->cierr,100,"read start"); - fmt_bg(); - return(0); + int n; + if (f__init != 1) + f_init (); + f__init = 3; + f__reading = 1; + if (n = c_dfe (a)) + return (n); + if (f__curunit->uwrt && f__nowreading (f__curunit)) + err (a->cierr, errno, "read start"); + f__getn = y_getc; + f__doed = rd_ed; + f__doned = rd_ned; + f__dorevert = f__donewrec = y_err; + f__doend = y_rsk; + if (pars_f (f__fmtbuf) < 0) + err (a->cierr, 100, "read start"); + fmt_bg (); + return (0); } -integer s_wdfe(cilist *a) + +integer +s_wdfe (cilist * a) { - int n; - if(f__init != 1) f_init(); - f__init = 3; - f__reading=0; - if(n=c_dfe(a)) return(n); - if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) - err(a->cierr,errno,"startwrt"); - f__putn = x_putc; - f__doed = w_ed; - f__doned= w_ned; - f__dorevert = y_err; - f__donewrec = y_newrec; - f__doend = y_rev; - if(pars_f(f__fmtbuf)<0) - err(a->cierr,100,"startwrt"); - fmt_bg(); - return(0); + int n; + if (f__init != 1) + f_init (); + f__init = 3; + f__reading = 0; + if (n = c_dfe (a)) + return (n); + if (f__curunit->uwrt != 1 && f__nowwriting (f__curunit)) + err (a->cierr, errno, "startwrt"); + f__putn = x_putc; + f__doed = w_ed; + f__doned = w_ned; + f__dorevert = y_err; + f__donewrec = y_newrec; + f__doend = y_rev; + if (pars_f (f__fmtbuf) < 0) + err (a->cierr, 100, "startwrt"); + fmt_bg (); + return (0); } -integer e_rdfe(void) + +integer +e_rdfe (void) { - f__init = 1; - en_fio(); - return(0); + f__init = 1; + en_fio (); + return (0); } -integer e_wdfe(void) +integer +e_wdfe (void) { - f__init = 1; - return en_fio(); + f__init = 1; + return en_fio (); } diff --git a/libf2c/libI77/dolio.c b/libf2c/libI77/dolio.c index b0220b1..e50e900 100644 --- a/libf2c/libI77/dolio.c +++ b/libf2c/libI77/dolio.c @@ -1,9 +1,10 @@ #include "config.h" #include "f2c.h" -extern int (*f__lioproc)(ftnint*, char*, ftnlen, ftnint); +extern int (*f__lioproc) (ftnint *, char *, ftnlen, ftnint); -integer do_lio(ftnint *type, ftnint *number, char *ptr, ftnlen len) +integer +do_lio (ftnint * type, ftnint * number, char *ptr, ftnlen len) { - return((*f__lioproc)(number,ptr,len,*type)); + return ((*f__lioproc) (number, ptr, len, *type)); } diff --git a/libf2c/libI77/due.c b/libf2c/libI77/due.c index e532383..709136c 100644 --- a/libf2c/libI77/due.c +++ b/libf2c/libI77/due.c @@ -2,63 +2,78 @@ #include "f2c.h" #include "fio.h" -c_due(cilist *a) +c_due (cilist * a) { - if(f__init != 1) f_init(); - f__init = 3; - if(a->ciunit>=MXUNIT || a->ciunit<0) - err(a->cierr,101,"startio"); - f__sequential=f__formatted=f__recpos=0; - f__external=1; - f__curunit = &f__units[a->ciunit]; - if(a->ciunit>=MXUNIT || a->ciunit<0) - err(a->cierr,101,"startio"); - f__elist=a; - if(f__curunit->ufd==NULL && fk_open(DIR,UNF,a->ciunit) ) err(a->cierr,104,"due"); - f__cf=f__curunit->ufd; - if(f__curunit->ufmt) err(a->cierr,102,"cdue"); - if(!f__curunit->useek) err(a->cierr,104,"cdue"); - if(f__curunit->ufd==NULL) err(a->cierr,114,"cdue"); - if(a->cirec <= 0) - err(a->cierr,130,"due"); - FSEEK(f__cf,(off_t)(a->cirec-1)*f__curunit->url,SEEK_SET); - f__curunit->uend = 0; - return(0); + if (f__init != 1) + f_init (); + f__init = 3; + if (a->ciunit >= MXUNIT || a->ciunit < 0) + err (a->cierr, 101, "startio"); + f__sequential = f__formatted = f__recpos = 0; + f__external = 1; + f__curunit = &f__units[a->ciunit]; + if (a->ciunit >= MXUNIT || a->ciunit < 0) + err (a->cierr, 101, "startio"); + f__elist = a; + if (f__curunit->ufd == NULL && fk_open (DIR, UNF, a->ciunit)) + err (a->cierr, 104, "due"); + f__cf = f__curunit->ufd; + if (f__curunit->ufmt) + err (a->cierr, 102, "cdue"); + if (!f__curunit->useek) + err (a->cierr, 104, "cdue"); + if (f__curunit->ufd == NULL) + err (a->cierr, 114, "cdue"); + if (a->cirec <= 0) + err (a->cierr, 130, "due"); + FSEEK (f__cf, (off_t) (a->cirec - 1) * f__curunit->url, SEEK_SET); + f__curunit->uend = 0; + return (0); } -integer s_rdue(cilist *a) + +integer +s_rdue (cilist * a) { - int n; - f__reading=1; - if(n=c_due(a)) return(n); - if(f__curunit->uwrt && f__nowreading(f__curunit)) - err(a->cierr,errno,"read start"); - return(0); + int n; + f__reading = 1; + if (n = c_due (a)) + return (n); + if (f__curunit->uwrt && f__nowreading (f__curunit)) + err (a->cierr, errno, "read start"); + return (0); } -integer s_wdue(cilist *a) + +integer +s_wdue (cilist * a) { - int n; - f__reading=0; - if(n=c_due(a)) return(n); - if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) - err(a->cierr,errno,"write start"); - return(0); + int n; + f__reading = 0; + if (n = c_due (a)) + return (n); + if (f__curunit->uwrt != 1 && f__nowwriting (f__curunit)) + err (a->cierr, errno, "write start"); + return (0); } -integer e_rdue(void) + +integer +e_rdue (void) { - f__init = 1; - if(f__curunit->url==1 || f__recpos==f__curunit->url) - return(0); - FSEEK(f__cf,(off_t)(f__curunit->url-f__recpos),SEEK_CUR); - if(FTELL(f__cf)%f__curunit->url) - err(f__elist->cierr,200,"syserr"); - return(0); + f__init = 1; + if (f__curunit->url == 1 || f__recpos == f__curunit->url) + return (0); + FSEEK (f__cf, (off_t) (f__curunit->url - f__recpos), SEEK_CUR); + if (FTELL (f__cf) % f__curunit->url) + err (f__elist->cierr, 200, "syserr"); + return (0); } -integer e_wdue(void) + +integer +e_wdue (void) { - f__init = 1; + f__init = 1; #ifdef ALWAYS_FLUSH - if (fflush(f__cf)) - err(f__elist->cierr,errno,"write end"); + if (fflush (f__cf)) + err (f__elist->cierr, errno, "write end"); #endif - return(e_rdue()); + return (e_rdue ()); } diff --git a/libf2c/libI77/endfile.c b/libf2c/libI77/endfile.c index bd7f0c1..d429d2b 100644 --- a/libf2c/libI77/endfile.c +++ b/libf2c/libI77/endfile.c @@ -13,111 +13,118 @@ extern char *f__r_mode[], *f__w_mode[]; -integer f_end(alist *a) +integer +f_end (alist * a) { - unit *b; - FILE *tf; + unit *b; + FILE *tf; - if (f__init & 2) - f__fatal (131, "I/O recursion"); - if(a->aunit>=MXUNIT || a->aunit<0) err(a->aerr,101,"endfile"); - b = &f__units[a->aunit]; - if(b->ufd==NULL) { - char nbuf[10]; - sprintf(nbuf,"fort.%ld",(long)a->aunit); - if (tf = fopen(nbuf, f__w_mode[0])) - fclose(tf); - return(0); - } - b->uend=1; - return(b->useek ? t_runc(a) : 0); + if (f__init & 2) + f__fatal (131, "I/O recursion"); + if (a->aunit >= MXUNIT || a->aunit < 0) + err (a->aerr, 101, "endfile"); + b = &f__units[a->aunit]; + if (b->ufd == NULL) + { + char nbuf[10]; + sprintf (nbuf, "fort.%ld", (long) a->aunit); + if (tf = fopen (nbuf, f__w_mode[0])) + fclose (tf); + return (0); + } + b->uend = 1; + return (b->useek ? t_runc (a) : 0); } #ifndef HAVE_FTRUNCATE - static int -copy(FILE *from, register long len, FILE *to) +static int +copy (FILE * from, register long len, FILE * to) { - int len1; - char buf[BUFSIZ]; + int len1; + char buf[BUFSIZ]; - while(fread(buf, len1 = len > BUFSIZ ? BUFSIZ : (int)len, 1, from)) { - if (!fwrite(buf, len1, 1, to)) - return 1; - if ((len -= len1) <= 0) - break; - } - return 0; - } + while (fread (buf, len1 = len > BUFSIZ ? BUFSIZ : (int) len, 1, from)) + { + if (!fwrite (buf, len1, 1, to)) + return 1; + if ((len -= len1) <= 0) + break; + } + return 0; +} #endif /* !defined(HAVE_FTRUNCATE) */ - int -t_runc(alist *a) +int +t_runc (alist * a) { - off_t loc, len; - unit *b; - int rc; - FILE *bf; + off_t loc, len; + unit *b; + int rc; + FILE *bf; #ifndef HAVE_FTRUNCATE - FILE *tf; + FILE *tf; #endif /* !defined(HAVE_FTRUNCATE) */ - b = &f__units[a->aunit]; - if(b->url) - return(0); /*don't truncate direct files*/ - loc=FTELL(bf = b->ufd); - FSEEK(bf,0,SEEK_END); - len=FTELL(bf); - if (loc >= len || b->useek == 0 || b->ufnm == NULL) - return(0); + b = &f__units[a->aunit]; + if (b->url) + return (0); /*don't truncate direct files */ + loc = FTELL (bf = b->ufd); + FSEEK (bf, 0, SEEK_END); + len = FTELL (bf); + if (loc >= len || b->useek == 0 || b->ufnm == NULL) + return (0); #ifndef HAVE_FTRUNCATE - rc = 0; - fclose(b->ufd); - if (!loc) { - if (!(bf = fopen(b->ufnm, f__w_mode[b->ufmt]))) - rc = 1; - if (b->uwrt) - b->uwrt = 1; - goto done; - } - if (!(bf = fopen(b->ufnm, f__r_mode[0])) - || !(tf = tmpfile())) { + rc = 0; + fclose (b->ufd); + if (!loc) + { + if (!(bf = fopen (b->ufnm, f__w_mode[b->ufmt]))) + rc = 1; + if (b->uwrt) + b->uwrt = 1; + goto done; + } + if (!(bf = fopen (b->ufnm, f__r_mode[0])) || !(tf = tmpfile ())) + { #ifdef NON_UNIX_STDIO - bad: + bad: #endif - rc = 1; - goto done; - } - if (copy(bf, loc, tf)) { - bad1: - rc = 1; - goto done1; - } - if (!(bf = freopen(b->ufnm, f__w_mode[0], bf))) - goto bad1; - FSEEK(tf, 0, SEEK_SET); - if (copy(tf, loc, bf)) - goto bad1; - b->uwrt = 1; - b->urw = 2; + rc = 1; + goto done; + } + if (copy (bf, loc, tf)) + { + bad1: + rc = 1; + goto done1; + } + if (!(bf = freopen (b->ufnm, f__w_mode[0], bf))) + goto bad1; + FSEEK (tf, 0, SEEK_SET); + if (copy (tf, loc, bf)) + goto bad1; + b->uwrt = 1; + b->urw = 2; #ifdef NON_UNIX_STDIO - if (b->ufmt) { - fclose(bf); - if (!(bf = fopen(b->ufnm, f__w_mode[3]))) - goto bad; - FSEEK(bf,0,SEEK_END); - b->urw = 3; - } + if (b->ufmt) + { + fclose (bf); + if (!(bf = fopen (b->ufnm, f__w_mode[3]))) + goto bad; + FSEEK (bf, 0, SEEK_END); + b->urw = 3; + } #endif done1: - fclose(tf); + fclose (tf); done: - f__cf = b->ufd = bf; -#else /* !defined(HAVE_FTRUNCATE) */ - fflush(b->ufd); - rc = ftruncate(fileno(b->ufd), loc); - FSEEK(bf,loc,SEEK_SET); + f__cf = b->ufd = bf; +#else /* !defined(HAVE_FTRUNCATE) */ + fflush (b->ufd); + rc = ftruncate (fileno (b->ufd), loc); + FSEEK (bf, loc, SEEK_SET); #endif /* !defined(HAVE_FTRUNCATE) */ - if (rc) - err(a->aerr,111,"endfile"); - return 0; - } + if (rc) + err (a->aerr, 111, "endfile"); + return 0; +} diff --git a/libf2c/libI77/err.c b/libf2c/libI77/err.c index baffb69..94302f3 100644 --- a/libf2c/libI77/err.c +++ b/libf2c/libI77/err.c @@ -11,249 +11,266 @@ #undef max #include <stdlib.h> #include "fio.h" -#include "fmt.h" /* for struct syl */ +#include "fmt.h" /* for struct syl */ /*global definitions*/ -unit f__units[MXUNIT]; /*unit table*/ -int f__init; /*bit 0: set after initializations; - bit 1: set during I/O involving returns to - caller of library (or calls to user code)*/ -cilist *f__elist; /*active external io list*/ -icilist *f__svic; /*active internal io list*/ -flag f__reading; /*1 if reading, 0 if writing*/ -flag f__cplus,f__cblank; +unit f__units[MXUNIT]; /*unit table */ +int f__init; /*bit 0: set after initializations; + bit 1: set during I/O involving returns to + caller of library (or calls to user code) */ +cilist *f__elist; /*active external io list */ +icilist *f__svic; /*active internal io list */ +flag f__reading; /*1 if reading, 0 if writing */ +flag f__cplus, f__cblank; char *f__fmtbuf; int f__fmtlen; -flag f__external; /*1 if external io, 0 if internal */ -int (*f__getn)(void); /* for formatted input */ -void (*f__putn)(int); /* for formatted output */ -int (*f__doed)(struct syl*, char*, ftnlen),(*f__doned)(struct syl*); -int (*f__dorevert)(void),(*f__donewrec)(void),(*f__doend)(void); -flag f__sequential; /*1 if sequential io, 0 if direct*/ -flag f__formatted; /*1 if formatted io, 0 if unformatted*/ -FILE *f__cf; /*current file*/ -unit *f__curunit; /*current unit*/ -int f__recpos; /*place in current record*/ +flag f__external; /*1 if external io, 0 if internal */ +int (*f__getn) (void); /* for formatted input */ +void (*f__putn) (int); /* for formatted output */ +int (*f__doed) (struct syl *, char *, ftnlen), (*f__doned) (struct syl *); +int (*f__dorevert) (void), (*f__donewrec) (void), (*f__doend) (void); +flag f__sequential; /*1 if sequential io, 0 if direct */ +flag f__formatted; /*1 if formatted io, 0 if unformatted */ +FILE *f__cf; /*current file */ +unit *f__curunit; /*current unit */ +int f__recpos; /*place in current record */ int f__cursor, f__hiwater, f__scale; char *f__icptr; /*error messages*/ -char *F_err[] = -{ - "error in format", /* 100 */ - "illegal unit number", /* 101 */ - "formatted io not allowed", /* 102 */ - "unformatted io not allowed", /* 103 */ - "direct io not allowed", /* 104 */ - "sequential io not allowed", /* 105 */ - "can't backspace file", /* 106 */ - "null file name", /* 107 */ - "can't stat file", /* 108 */ - "unit not connected", /* 109 */ - "off end of record", /* 110 */ - "truncation failed in endfile", /* 111 */ - "incomprehensible list input", /* 112 */ - "out of free space", /* 113 */ - "unit not connected", /* 114 */ - "read unexpected character", /* 115 */ - "bad logical input field", /* 116 */ - "bad variable type", /* 117 */ - "bad namelist name", /* 118 */ - "variable not in namelist", /* 119 */ - "no end record", /* 120 */ - "variable count incorrect", /* 121 */ - "subscript for scalar variable", /* 122 */ - "invalid array section", /* 123 */ - "substring out of bounds", /* 124 */ - "subscript out of bounds", /* 125 */ - "can't read file", /* 126 */ - "can't write file", /* 127 */ - "'new' file exists", /* 128 */ - "can't append to file", /* 129 */ - "non-positive record number", /* 130 */ - "I/O started while already doing I/O", /* 131 */ - "Temporary file name (TMPDIR?) too long" /* 132 */ +char *F_err[] = { + "error in format", /* 100 */ + "illegal unit number", /* 101 */ + "formatted io not allowed", /* 102 */ + "unformatted io not allowed", /* 103 */ + "direct io not allowed", /* 104 */ + "sequential io not allowed", /* 105 */ + "can't backspace file", /* 106 */ + "null file name", /* 107 */ + "can't stat file", /* 108 */ + "unit not connected", /* 109 */ + "off end of record", /* 110 */ + "truncation failed in endfile", /* 111 */ + "incomprehensible list input", /* 112 */ + "out of free space", /* 113 */ + "unit not connected", /* 114 */ + "read unexpected character", /* 115 */ + "bad logical input field", /* 116 */ + "bad variable type", /* 117 */ + "bad namelist name", /* 118 */ + "variable not in namelist", /* 119 */ + "no end record", /* 120 */ + "variable count incorrect", /* 121 */ + "subscript for scalar variable", /* 122 */ + "invalid array section", /* 123 */ + "substring out of bounds", /* 124 */ + "subscript out of bounds", /* 125 */ + "can't read file", /* 126 */ + "can't write file", /* 127 */ + "'new' file exists", /* 128 */ + "can't append to file", /* 129 */ + "non-positive record number", /* 130 */ + "I/O started while already doing I/O", /* 131 */ + "Temporary file name (TMPDIR?) too long" /* 132 */ }; #define MAXERR (sizeof(F_err)/sizeof(char *)+100) -f__canseek(FILE *f) /*SYSDEP*/ +f__canseek (FILE * f) /*SYSDEP*/ { #ifdef NON_UNIX_STDIO - return !isatty(fileno(f)); + return !isatty (fileno (f)); #else - struct stat x; + struct stat x; - if (fstat(fileno(f),&x) < 0) - return(0); + if (fstat (fileno (f), &x) < 0) + return (0); #ifdef S_IFMT - switch(x.st_mode & S_IFMT) { - case S_IFDIR: - case S_IFREG: - if(x.st_nlink > 0) /* !pipe */ - return(1); - else - return(0); - case S_IFCHR: - if(isatty(fileno(f))) - return(0); - return(1); + switch (x.st_mode & S_IFMT) + { + case S_IFDIR: + case S_IFREG: + if (x.st_nlink > 0) /* !pipe */ + return (1); + else + return (0); + case S_IFCHR: + if (isatty (fileno (f))) + return (0); + return (1); #ifdef S_IFBLK - case S_IFBLK: - return(1); + case S_IFBLK: + return (1); #endif - } + } #else #ifdef S_ISDIR - /* POSIX version */ - if (S_ISREG(x.st_mode) || S_ISDIR(x.st_mode)) { - if(x.st_nlink > 0) /* !pipe */ - return(1); - else - return(0); - } - if (S_ISCHR(x.st_mode)) { - if(isatty(fileno(f))) - return(0); - return(1); - } - if (S_ISBLK(x.st_mode)) - return(1); + /* POSIX version */ + if (S_ISREG (x.st_mode) || S_ISDIR (x.st_mode)) + { + if (x.st_nlink > 0) /* !pipe */ + return (1); + else + return (0); + } + if (S_ISCHR (x.st_mode)) + { + if (isatty (fileno (f))) + return (0); + return (1); + } + if (S_ISBLK (x.st_mode)) + return (1); #else - Help! How does fstat work on this system? + Help ! How does fstat work on this system ? #endif #endif - return(0); /* who knows what it is? */ + return (0); /* who knows what it is? */ #endif } - void -f__fatal(int n, char *s) +void +f__fatal (int n, char *s) { - static int dead = 0; + static int dead = 0; - if(n<100 && n>=0) perror(s); /*SYSDEP*/ - else if(n >= (int)MAXERR || n < -1) - { fprintf(stderr,"%s: illegal error number %d\n",s,n); - } - else if(n == -1) fprintf(stderr,"%s: end of file\n",s); - else - fprintf(stderr,"%s: %s\n",s,F_err[n-100]); - if (dead) { - fprintf (stderr, "(libf2c f__fatal already called, aborting.)"); - abort(); + if (n < 100 && n >= 0) + perror (s); + /*SYSDEP*/ + else if (n >= (int) MAXERR || n < -1) + { + fprintf (stderr, "%s: illegal error number %d\n", s, n); + } + else if (n == -1) + fprintf (stderr, "%s: end of file\n", s); + else + fprintf (stderr, "%s: %s\n", s, F_err[n - 100]); + if (dead) + { + fprintf (stderr, "(libf2c f__fatal already called, aborting.)"); + abort (); + } + dead = 1; + if (f__init & 1) + { + if (f__curunit) + { + fprintf (stderr, "apparent state: unit %d ", + (int) (f__curunit - f__units)); + fprintf (stderr, f__curunit->ufnm ? "named %s\n" : "(unnamed)\n", + f__curunit->ufnm); } - dead = 1; - if (f__init & 1) { - if (f__curunit) { - fprintf(stderr,"apparent state: unit %d ", - (int)(f__curunit-f__units)); - fprintf(stderr, f__curunit->ufnm ? "named %s\n" : "(unnamed)\n", - f__curunit->ufnm); - } - else - fprintf(stderr,"apparent state: internal I/O\n"); - if (f__fmtbuf) - fprintf(stderr,"last format: %.*s\n",f__fmtlen,f__fmtbuf); - fprintf(stderr,"lately %s %s %s %s",f__reading?"reading":"writing", - f__sequential?"sequential":"direct",f__formatted?"formatted":"unformatted", - f__external?"external":"internal"); - } - f__init &= ~2; /* No longer doing I/O (no more user code to be called). */ - sig_die(" IO", 1); + else + fprintf (stderr, "apparent state: internal I/O\n"); + if (f__fmtbuf) + fprintf (stderr, "last format: %.*s\n", f__fmtlen, f__fmtbuf); + fprintf (stderr, "lately %s %s %s %s", + f__reading ? "reading" : "writing", + f__sequential ? "sequential" : "direct", + f__formatted ? "formatted" : "unformatted", + f__external ? "external" : "internal"); + } + f__init &= ~2; /* No longer doing I/O (no more user code to be called). */ + sig_die (" IO", 1); } + /*initialization routine*/ void -f_init(void) -{ unit *p; +f_init (void) +{ + unit *p; - if (f__init & 2) - f__fatal (131, "I/O recursion"); - f__init = 1; - p= &f__units[0]; - p->ufd=stderr; - p->useek=f__canseek(stderr); - p->ufmt=1; - p->uwrt=1; - p = &f__units[5]; - p->ufd=stdin; - p->useek=f__canseek(stdin); - p->ufmt=1; - p->uwrt=0; - p= &f__units[6]; - p->ufd=stdout; - p->useek=f__canseek(stdout); - p->ufmt=1; - p->uwrt=1; + if (f__init & 2) + f__fatal (131, "I/O recursion"); + f__init = 1; + p = &f__units[0]; + p->ufd = stderr; + p->useek = f__canseek (stderr); + p->ufmt = 1; + p->uwrt = 1; + p = &f__units[5]; + p->ufd = stdin; + p->useek = f__canseek (stdin); + p->ufmt = 1; + p->uwrt = 0; + p = &f__units[6]; + p->ufd = stdout; + p->useek = f__canseek (stdout); + p->ufmt = 1; + p->uwrt = 1; } -f__nowreading(unit *x) + +f__nowreading (unit * x) { - off_t loc; - int ufmt, urw; - extern char *f__r_mode[], *f__w_mode[]; + off_t loc; + int ufmt, urw; + extern char *f__r_mode[], *f__w_mode[]; - if (x->urw & 1) - goto done; - if (!x->ufnm) - goto cantread; - ufmt = x->url ? 0 : x->ufmt; - loc = FTELL(x->ufd); - urw = 3; - if (!freopen(x->ufnm, f__w_mode[ufmt|2], x->ufd)) { - urw = 1; - if(!freopen(x->ufnm, f__r_mode[ufmt], x->ufd)) { - cantread: - errno = 126; - return 1; - } - } - FSEEK(x->ufd,loc,SEEK_SET); - x->urw = urw; - done: - x->uwrt = 0; - return 0; + if (x->urw & 1) + goto done; + if (!x->ufnm) + goto cantread; + ufmt = x->url ? 0 : x->ufmt; + loc = FTELL (x->ufd); + urw = 3; + if (!freopen (x->ufnm, f__w_mode[ufmt | 2], x->ufd)) + { + urw = 1; + if (!freopen (x->ufnm, f__r_mode[ufmt], x->ufd)) + { + cantread: + errno = 126; + return 1; + } + } + FSEEK (x->ufd, loc, SEEK_SET); + x->urw = urw; +done: + x->uwrt = 0; + return 0; } -f__nowwriting(unit *x) + +f__nowwriting (unit * x) { - off_t loc; - int ufmt; - extern char *f__w_mode[]; + off_t loc; + int ufmt; + extern char *f__w_mode[]; - if (x->urw & 2) - goto done; - if (!x->ufnm) - goto cantwrite; - ufmt = x->url ? 0 : x->ufmt; - if (x->uwrt == 3) { /* just did write, rewind */ - if (!(f__cf = x->ufd = - freopen(x->ufnm,f__w_mode[ufmt],x->ufd))) - goto cantwrite; - x->urw = 2; - } - else { - loc=FTELL(x->ufd); - if (!(f__cf = x->ufd = - freopen(x->ufnm, f__w_mode[ufmt |= 2], x->ufd))) - { - x->ufd = NULL; - cantwrite: - errno = 127; - return(1); - } - x->urw = 3; - FSEEK(x->ufd,loc,SEEK_SET); - } - done: - x->uwrt = 1; - return 0; + if (x->urw & 2) + goto done; + if (!x->ufnm) + goto cantwrite; + ufmt = x->url ? 0 : x->ufmt; + if (x->uwrt == 3) + { /* just did write, rewind */ + if (!(f__cf = x->ufd = freopen (x->ufnm, f__w_mode[ufmt], x->ufd))) + goto cantwrite; + x->urw = 2; + } + else + { + loc = FTELL (x->ufd); + if (!(f__cf = x->ufd = freopen (x->ufnm, f__w_mode[ufmt |= 2], x->ufd))) + { + x->ufd = NULL; + cantwrite: + errno = 127; + return (1); + } + x->urw = 3; + FSEEK (x->ufd, loc, SEEK_SET); + } +done: + x->uwrt = 1; + return 0; } - int -err__fl(int f, int m, char *s) +int +err__fl (int f, int m, char *s) { - if (!f) - f__fatal(m, s); - if (f__doend) - (*f__doend)(); - f__init &= ~2; - return errno = m; - } + if (!f) + f__fatal (m, s); + if (f__doend) + (*f__doend) (); + f__init &= ~2; + return errno = m; +} diff --git a/libf2c/libI77/f2ch.add b/libf2c/libI77/f2ch.add index a2acc17..04b13e8 100644 --- a/libf2c/libI77/f2ch.add +++ b/libf2c/libI77/f2ch.add @@ -2,161 +2,162 @@ for compiling libF77 and libI77. */ #ifdef __cplusplus -extern "C" { -extern int abort_(void); -extern double c_abs(complex *); -extern void c_cos(complex *, complex *); -extern void c_div(complex *, complex *, complex *); -extern void c_exp(complex *, complex *); -extern void c_log(complex *, complex *); -extern void c_sin(complex *, complex *); -extern void c_sqrt(complex *, complex *); -extern double d_abs(double *); -extern double d_acos(double *); -extern double d_asin(double *); -extern double d_atan(double *); -extern double d_atn2(double *, double *); -extern void d_cnjg(doublecomplex *, doublecomplex *); -extern double d_cos(double *); -extern double d_cosh(double *); -extern double d_dim(double *, double *); -extern double d_exp(double *); -extern double d_imag(doublecomplex *); -extern double d_int(double *); -extern double d_lg10(double *); -extern double d_log(double *); -extern double d_mod(double *, double *); -extern double d_nint(double *); -extern double d_prod(float *, float *); -extern double d_sign(double *, double *); -extern double d_sin(double *); -extern double d_sinh(double *); -extern double d_sqrt(double *); -extern double d_tan(double *); -extern double d_tanh(double *); -extern double derf_(double *); -extern double derfc_(double *); -extern integer do_fio(ftnint *, char *, ftnlen); -extern integer do_lio(ftnint *, ftnint *, char *, ftnlen); -extern integer do_uio(ftnint *, char *, ftnlen); -extern integer e_rdfe(void); -extern integer e_rdue(void); -extern integer e_rsfe(void); -extern integer e_rsfi(void); -extern integer e_rsle(void); -extern integer e_rsli(void); -extern integer e_rsue(void); -extern integer e_wdfe(void); -extern integer e_wdue(void); -extern integer e_wsfe(void); -extern integer e_wsfi(void); -extern integer e_wsle(void); -extern integer e_wsli(void); -extern integer e_wsue(void); -extern int ef1asc_(ftnint *, ftnlen *, ftnint *, ftnlen *); -extern integer ef1cmc_(ftnint *, ftnlen *, ftnint *, ftnlen *); -extern double erf(double); -extern double erf_(float *); -extern double erfc(double); -extern double erfc_(float *); -extern integer f_back(alist *); -extern integer f_clos(cllist *); -extern integer f_end(alist *); -extern void f_exit(void); -extern integer f_inqu(inlist *); -extern integer f_open(olist *); -extern integer f_rew(alist *); -extern int flush_(void); -extern void getarg_(integer *, char *, ftnlen); -extern void getenv_(char *, char *, ftnlen, ftnlen); -extern short h_abs(short *); -extern short h_dim(short *, short *); -extern short h_dnnt(double *); -extern short h_indx(char *, char *, ftnlen, ftnlen); -extern short h_len(char *, ftnlen); -extern short h_mod(short *, short *); -extern short h_nint(float *); -extern short h_sign(short *, short *); -extern short hl_ge(char *, char *, ftnlen, ftnlen); -extern short hl_gt(char *, char *, ftnlen, ftnlen); -extern short hl_le(char *, char *, ftnlen, ftnlen); -extern short hl_lt(char *, char *, ftnlen, ftnlen); -extern integer i_abs(integer *); -extern integer i_dim(integer *, integer *); -extern integer i_dnnt(double *); -extern integer i_indx(char *, char *, ftnlen, ftnlen); -extern integer i_len(char *, ftnlen); -extern integer i_mod(integer *, integer *); -extern integer i_nint(float *); -extern integer i_sign(integer *, integer *); -extern integer iargc_(void); -extern ftnlen l_ge(char *, char *, ftnlen, ftnlen); -extern ftnlen l_gt(char *, char *, ftnlen, ftnlen); -extern ftnlen l_le(char *, char *, ftnlen, ftnlen); -extern ftnlen l_lt(char *, char *, ftnlen, ftnlen); -extern void pow_ci(complex *, complex *, integer *); -extern double pow_dd(double *, double *); -extern double pow_di(double *, integer *); -extern short pow_hh(short *, shortint *); -extern integer pow_ii(integer *, integer *); -extern double pow_ri(float *, integer *); -extern void pow_zi(doublecomplex *, doublecomplex *, integer *); -extern void pow_zz(doublecomplex *, doublecomplex *, doublecomplex *); -extern double r_abs(float *); -extern double r_acos(float *); -extern double r_asin(float *); -extern double r_atan(float *); -extern double r_atn2(float *, float *); -extern void r_cnjg(complex *, complex *); -extern double r_cos(float *); -extern double r_cosh(float *); -extern double r_dim(float *, float *); -extern double r_exp(float *); -extern double r_imag(complex *); -extern double r_int(float *); -extern double r_lg10(float *); -extern double r_log(float *); -extern double r_mod(float *, float *); -extern double r_nint(float *); -extern double r_sign(float *, float *); -extern double r_sin(float *); -extern double r_sinh(float *); -extern double r_sqrt(float *); -extern double r_tan(float *); -extern double r_tanh(float *); -extern void s_cat(char *, char **, integer *, integer *, ftnlen); -extern integer s_cmp(char *, char *, ftnlen, ftnlen); -extern void s_copy(char *, char *, ftnlen, ftnlen); -extern int s_paus(char *, ftnlen); -extern integer s_rdfe(cilist *); -extern integer s_rdue(cilist *); -extern integer s_rnge(char *, integer, char *, integer); -extern integer s_rsfe(cilist *); -extern integer s_rsfi(icilist *); -extern integer s_rsle(cilist *); -extern integer s_rsli(icilist *); -extern integer s_rsne(cilist *); -extern integer s_rsni(icilist *); -extern integer s_rsue(cilist *); -extern int s_stop(char *, ftnlen); -extern integer s_wdfe(cilist *); -extern integer s_wdue(cilist *); -extern integer s_wsfe(cilist *); -extern integer s_wsfi(icilist *); -extern integer s_wsle(cilist *); -extern integer s_wsli(icilist *); -extern integer s_wsne(cilist *); -extern integer s_wsni(icilist *); -extern integer s_wsue(cilist *); -extern void sig_die(char *, int); -extern integer signal_(integer *, void (*)(int)); -extern integer system_(char *, ftnlen); -extern double z_abs(doublecomplex *); -extern void z_cos(doublecomplex *, doublecomplex *); -extern void z_div(doublecomplex *, doublecomplex *, doublecomplex *); -extern void z_exp(doublecomplex *, doublecomplex *); -extern void z_log(doublecomplex *, doublecomplex *); -extern void z_sin(doublecomplex *, doublecomplex *); -extern void z_sqrt(doublecomplex *, doublecomplex *); - } +extern "C" +{ + extern int abort_ (void); + extern double c_abs (complex *); + extern void c_cos (complex *, complex *); + extern void c_div (complex *, complex *, complex *); + extern void c_exp (complex *, complex *); + extern void c_log (complex *, complex *); + extern void c_sin (complex *, complex *); + extern void c_sqrt (complex *, complex *); + extern double d_abs (double *); + extern double d_acos (double *); + extern double d_asin (double *); + extern double d_atan (double *); + extern double d_atn2 (double *, double *); + extern void d_cnjg (doublecomplex *, doublecomplex *); + extern double d_cos (double *); + extern double d_cosh (double *); + extern double d_dim (double *, double *); + extern double d_exp (double *); + extern double d_imag (doublecomplex *); + extern double d_int (double *); + extern double d_lg10 (double *); + extern double d_log (double *); + extern double d_mod (double *, double *); + extern double d_nint (double *); + extern double d_prod (float *, float *); + extern double d_sign (double *, double *); + extern double d_sin (double *); + extern double d_sinh (double *); + extern double d_sqrt (double *); + extern double d_tan (double *); + extern double d_tanh (double *); + extern double derf_ (double *); + extern double derfc_ (double *); + extern integer do_fio (ftnint *, char *, ftnlen); + extern integer do_lio (ftnint *, ftnint *, char *, ftnlen); + extern integer do_uio (ftnint *, char *, ftnlen); + extern integer e_rdfe (void); + extern integer e_rdue (void); + extern integer e_rsfe (void); + extern integer e_rsfi (void); + extern integer e_rsle (void); + extern integer e_rsli (void); + extern integer e_rsue (void); + extern integer e_wdfe (void); + extern integer e_wdue (void); + extern integer e_wsfe (void); + extern integer e_wsfi (void); + extern integer e_wsle (void); + extern integer e_wsli (void); + extern integer e_wsue (void); + extern int ef1asc_ (ftnint *, ftnlen *, ftnint *, ftnlen *); + extern integer ef1cmc_ (ftnint *, ftnlen *, ftnint *, ftnlen *); + extern double erf (double); + extern double erf_ (float *); + extern double erfc (double); + extern double erfc_ (float *); + extern integer f_back (alist *); + extern integer f_clos (cllist *); + extern integer f_end (alist *); + extern void f_exit (void); + extern integer f_inqu (inlist *); + extern integer f_open (olist *); + extern integer f_rew (alist *); + extern int flush_ (void); + extern void getarg_ (integer *, char *, ftnlen); + extern void getenv_ (char *, char *, ftnlen, ftnlen); + extern short h_abs (short *); + extern short h_dim (short *, short *); + extern short h_dnnt (double *); + extern short h_indx (char *, char *, ftnlen, ftnlen); + extern short h_len (char *, ftnlen); + extern short h_mod (short *, short *); + extern short h_nint (float *); + extern short h_sign (short *, short *); + extern short hl_ge (char *, char *, ftnlen, ftnlen); + extern short hl_gt (char *, char *, ftnlen, ftnlen); + extern short hl_le (char *, char *, ftnlen, ftnlen); + extern short hl_lt (char *, char *, ftnlen, ftnlen); + extern integer i_abs (integer *); + extern integer i_dim (integer *, integer *); + extern integer i_dnnt (double *); + extern integer i_indx (char *, char *, ftnlen, ftnlen); + extern integer i_len (char *, ftnlen); + extern integer i_mod (integer *, integer *); + extern integer i_nint (float *); + extern integer i_sign (integer *, integer *); + extern integer iargc_ (void); + extern ftnlen l_ge (char *, char *, ftnlen, ftnlen); + extern ftnlen l_gt (char *, char *, ftnlen, ftnlen); + extern ftnlen l_le (char *, char *, ftnlen, ftnlen); + extern ftnlen l_lt (char *, char *, ftnlen, ftnlen); + extern void pow_ci (complex *, complex *, integer *); + extern double pow_dd (double *, double *); + extern double pow_di (double *, integer *); + extern short pow_hh (short *, shortint *); + extern integer pow_ii (integer *, integer *); + extern double pow_ri (float *, integer *); + extern void pow_zi (doublecomplex *, doublecomplex *, integer *); + extern void pow_zz (doublecomplex *, doublecomplex *, doublecomplex *); + extern double r_abs (float *); + extern double r_acos (float *); + extern double r_asin (float *); + extern double r_atan (float *); + extern double r_atn2 (float *, float *); + extern void r_cnjg (complex *, complex *); + extern double r_cos (float *); + extern double r_cosh (float *); + extern double r_dim (float *, float *); + extern double r_exp (float *); + extern double r_imag (complex *); + extern double r_int (float *); + extern double r_lg10 (float *); + extern double r_log (float *); + extern double r_mod (float *, float *); + extern double r_nint (float *); + extern double r_sign (float *, float *); + extern double r_sin (float *); + extern double r_sinh (float *); + extern double r_sqrt (float *); + extern double r_tan (float *); + extern double r_tanh (float *); + extern void s_cat (char *, char **, integer *, integer *, ftnlen); + extern integer s_cmp (char *, char *, ftnlen, ftnlen); + extern void s_copy (char *, char *, ftnlen, ftnlen); + extern int s_paus (char *, ftnlen); + extern integer s_rdfe (cilist *); + extern integer s_rdue (cilist *); + extern integer s_rnge (char *, integer, char *, integer); + extern integer s_rsfe (cilist *); + extern integer s_rsfi (icilist *); + extern integer s_rsle (cilist *); + extern integer s_rsli (icilist *); + extern integer s_rsne (cilist *); + extern integer s_rsni (icilist *); + extern integer s_rsue (cilist *); + extern int s_stop (char *, ftnlen); + extern integer s_wdfe (cilist *); + extern integer s_wdue (cilist *); + extern integer s_wsfe (cilist *); + extern integer s_wsfi (icilist *); + extern integer s_wsle (cilist *); + extern integer s_wsli (icilist *); + extern integer s_wsne (cilist *); + extern integer s_wsni (icilist *); + extern integer s_wsue (cilist *); + extern void sig_die (char *, int); + extern integer signal_ (integer *, void (*)(int)); + extern integer system_ (char *, ftnlen); + extern double z_abs (doublecomplex *); + extern void z_cos (doublecomplex *, doublecomplex *); + extern void z_div (doublecomplex *, doublecomplex *, doublecomplex *); + extern void z_exp (doublecomplex *, doublecomplex *); + extern void z_log (doublecomplex *, doublecomplex *); + extern void z_sin (doublecomplex *, doublecomplex *); + extern void z_sqrt (doublecomplex *, doublecomplex *); +} #endif diff --git a/libf2c/libI77/fio.h b/libf2c/libI77/fio.h index 7b3d90c..7734f0c 100644 --- a/libf2c/libI77/fio.h +++ b/libf2c/libI77/fio.h @@ -39,46 +39,48 @@ typedef long uiolen; /*units*/ typedef struct -{ FILE *ufd; /*0=unconnected*/ - char *ufnm; +{ + FILE *ufd; /*0=unconnected */ + char *ufnm; #if !(defined (MSDOS) && !defined (GO32)) - long uinode; - int udev; + long uinode; + int udev; #endif - int url; /*0=sequential*/ - flag useek; /*true=can backspace, use dir, ...*/ - flag ufmt; - flag urw; /* (1 for can read) | (2 for can write) */ - flag ublnk; - flag uend; - flag uwrt; /*last io was write*/ - flag uscrtch; -} unit; + int url; /*0=sequential */ + flag useek; /*true=can backspace, use dir, ... */ + flag ufmt; + flag urw; /* (1 for can read) | (2 for can write) */ + flag ublnk; + flag uend; + flag uwrt; /*last io was write */ + flag uscrtch; +} +unit; extern int f__init; -extern cilist *f__elist; /*active external io list*/ -extern flag f__reading,f__external,f__sequential,f__formatted; -extern int (*f__getn)(void); /* for formatted input */ -extern void (*f__putn)(int); /* for formatted output */ -extern void x_putc(int); -extern long f__inode(char*,int*); -extern void sig_die(char*,int); -extern void f__fatal(int,char*); -extern int t_runc(alist*); -extern int f__nowreading(unit*), f__nowwriting(unit*); -extern int fk_open(int,int,ftnint); -extern int en_fio(void); -extern void f_init(void); -extern int (*f__donewrec)(void), t_putc(int), x_wSL(void); -extern void b_char(char*,char*,ftnlen), g_char(char*,ftnlen,char*); -extern int c_sfe(cilist*), z_rnew(void); -extern int isatty(int); -extern int err__fl(int,int,char*); -extern int xrd_SL(void); -extern int f__putbuf(int); -extern int (*f__doend)(void); -extern FILE *f__cf; /*current file*/ -extern unit *f__curunit; /*current unit*/ +extern cilist *f__elist; /*active external io list */ +extern flag f__reading, f__external, f__sequential, f__formatted; +extern int (*f__getn) (void); /* for formatted input */ +extern void (*f__putn) (int); /* for formatted output */ +extern void x_putc (int); +extern long f__inode (char *, int *); +extern void sig_die (char *, int); +extern void f__fatal (int, char *); +extern int t_runc (alist *); +extern int f__nowreading (unit *), f__nowwriting (unit *); +extern int fk_open (int, int, ftnint); +extern int en_fio (void); +extern void f_init (void); +extern int (*f__donewrec) (void), t_putc (int), x_wSL (void); +extern void b_char (char *, char *, ftnlen), g_char (char *, ftnlen, char *); +extern int c_sfe (cilist *), z_rnew (void); +extern int isatty (int); +extern int err__fl (int, int, char *); +extern int xrd_SL (void); +extern int f__putbuf (int); +extern int (*f__doend) (void); +extern FILE *f__cf; /*current file */ +extern unit *f__curunit; /*current unit */ extern unit f__units[]; #define err(f,m,s) do {if(f) {f__init &= ~2; errno= m;} else f__fatal(m,s); return(m);} while(0) #define errfl(f,m,s) do {return err__fl((int)f,m,s);} while(0) @@ -86,9 +88,9 @@ extern unit f__units[]; /*Table sizes*/ #define MXUNIT 100 -extern int f__recpos; /*position in current record*/ -extern int f__cursor; /* offset to move to */ -extern int f__hiwater; /* so TL doesn't confuse us */ +extern int f__recpos; /*position in current record */ +extern int f__cursor; /* offset to move to */ +extern int f__hiwater; /* so TL doesn't confuse us */ #define WRITE 1 #define READ 2 diff --git a/libf2c/libI77/fmt.c b/libf2c/libI77/fmt.c index 16c2862..7443cba 100644 --- a/libf2c/libI77/fmt.c +++ b/libf2c/libI77/fmt.c @@ -17,483 +17,584 @@ #endif #define GLITCH '\2' /* special quote character for stu */ -extern int f__cursor,f__scale; -extern flag f__cblank,f__cplus; /*blanks in I and compulsory plus*/ +extern int f__cursor, f__scale; +extern flag f__cblank, f__cplus; /*blanks in I and compulsory plus */ static struct syl f__syl[SYLMX]; -int f__parenlvl,f__pc,f__revloc; +int f__parenlvl, f__pc, f__revloc; - static -char *ap_end(char *s) -{ char quote; - quote= *s++; - for(;*s;s++) - { if(*s!=quote) continue; - if(*++s!=quote) return(s); - } - if(f__elist->cierr) { - errno = 100; - return(NULL); - } - f__fatal(100, "bad string"); - /*NOTREACHED*/ return 0; +static char * +ap_end (char *s) +{ + char quote; + quote = *s++; + for (; *s; s++) + { + if (*s != quote) + continue; + if (*++s != quote) + return (s); + } + if (f__elist->cierr) + { + errno = 100; + return (NULL); + } + f__fatal (100, "bad string"); + /*NOTREACHED*/ return 0; } - static -op_gen(int a, int b, int c, int d) -{ struct syl *p= &f__syl[f__pc]; - if(f__pc>=SYLMX) - { fprintf(stderr,"format too complicated:\n"); - sig_die(f__fmtbuf, 1); - } - p->op=a; - p->p1=b; - p->p2.i[0]=c; - p->p2.i[1]=d; - return(f__pc++); + +static +op_gen (int a, int b, int c, int d) +{ + struct syl *p = &f__syl[f__pc]; + if (f__pc >= SYLMX) + { + fprintf (stderr, "format too complicated:\n"); + sig_die (f__fmtbuf, 1); + } + p->op = a; + p->p1 = b; + p->p2.i[0] = c; + p->p2.i[1] = d; + return (f__pc++); } -static char *f_list(char*); -static char *gt_num(char *s, int *n, int n1) -{ int m=0,f__cnt=0; - char c; - for(c= *s;;c = *s) - { if(c==' ') - { s++; - continue; - } - if(c>'9' || c<'0') break; - m=10*m+c-'0'; - f__cnt++; - s++; +static char *f_list (char *); +static char * +gt_num (char *s, int *n, int n1) +{ + int m = 0, f__cnt = 0; + char c; + for (c = *s;; c = *s) + { + if (c == ' ') + { + s++; + continue; } - if(f__cnt==0) { - if (!n1) - s = 0; - *n=n1; - } - else *n=m; - return(s); + if (c > '9' || c < '0') + break; + m = 10 * m + c - '0'; + f__cnt++; + s++; + } + if (f__cnt == 0) + { + if (!n1) + s = 0; + *n = n1; + } + else + *n = m; + return (s); +} + +static char * +f_s (char *s, int curloc) +{ + skip (s); + if (*s++ != '(') + { + return (NULL); + } + if (f__parenlvl++ == 1) + f__revloc = curloc; + if (op_gen (RET1, curloc, 0, 0) < 0 || (s = f_list (s)) == NULL) + { + return (NULL); + } + return (s); } - static -char *f_s(char *s, int curloc) +static +ne_d (char *s, char **p) { - skip(s); - if(*s++!='(') + int n, x, sign = 0; + struct syl *sp; + switch (*s) + { + default: + return (0); + case ':': + (void) op_gen (COLON, 0, 0, 0); + break; + case '$': + (void) op_gen (NONL, 0, 0, 0); + break; + case 'B': + case 'b': + if (*++s == 'z' || *s == 'Z') + (void) op_gen (BZ, 0, 0, 0); + else + (void) op_gen (BN, 0, 0, 0); + break; + case 'S': + case 's': + if (*(s + 1) == 's' || *(s + 1) == 'S') { - return(NULL); + x = SS; + s++; } - if(f__parenlvl++ ==1) f__revloc=curloc; - if(op_gen(RET1,curloc,0,0)<0 || - (s=f_list(s))==NULL) + else if (*(s + 1) == 'p' || *(s + 1) == 'P') { - return(NULL); + x = SP; + s++; } - return(s); -} - - static -ne_d(char *s, char **p) -{ int n,x,sign=0; - struct syl *sp; - switch(*s) + else + x = S; + (void) op_gen (x, 0, 0, 0); + break; + case '/': + (void) op_gen (SLASH, 0, 0, 0); + break; + case '-': + sign = 1; + case '+': + s++; /*OUTRAGEOUS CODING TRICK */ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (!(s = gt_num (s, &n, 0))) + { + bad:*p = 0; + return 1; + } + switch (*s) { default: - return(0); - case ':': (void) op_gen(COLON,0,0,0); break; - case '$': - (void) op_gen(NONL, 0, 0, 0); break; - case 'B': - case 'b': - if(*++s=='z' || *s == 'Z') (void) op_gen(BZ,0,0,0); - else (void) op_gen(BN,0,0,0); - break; - case 'S': - case 's': - if(*(s+1)=='s' || *(s+1) == 'S') - { x=SS; - s++; - } - else if(*(s+1)=='p' || *(s+1) == 'P') - { x=SP; - s++; - } - else x=S; - (void) op_gen(x,0,0,0); - break; - case '/': (void) op_gen(SLASH,0,0,0); break; - case '-': sign=1; - case '+': s++; /*OUTRAGEOUS CODING TRICK*/ - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - if (!(s=gt_num(s,&n,0))) { - bad: *p = 0; - return 1; - } - switch(*s) - { - default: - return(0); - case 'P': - case 'p': if(sign) n= -n; (void) op_gen(P,n,0,0); break; - case 'X': - case 'x': (void) op_gen(X,n,0,0); break; - case 'H': - case 'h': - sp = &f__syl[op_gen(H,n,0,0)]; - sp->p2.s = s + 1; - s+=n; - break; - } - break; - case GLITCH: - case '"': - case '\'': - sp = &f__syl[op_gen(APOS,0,0,0)]; - sp->p2.s = s; - if((*p = ap_end(s)) == NULL) - return(0); - return(1); - case 'T': - case 't': - if(*(s+1)=='l' || *(s+1) == 'L') - { x=TL; - s++; - } - else if(*(s+1)=='r'|| *(s+1) == 'R') - { x=TR; - s++; - } - else x=T; - if (!(s=gt_num(s+1,&n,0))) - goto bad; - s--; - (void) op_gen(x,n,0,0); - break; - case 'X': - case 'x': (void) op_gen(X,1,0,0); break; + return (0); case 'P': - case 'p': (void) op_gen(P,1,0,0); break; + case 'p': + if (sign) + n = -n; + (void) op_gen (P, n, 0, 0); + break; + case 'X': + case 'x': + (void) op_gen (X, n, 0, 0); + break; + case 'H': + case 'h': + sp = &f__syl[op_gen (H, n, 0, 0)]; + sp->p2.s = s + 1; + s += n; + break; } - s++; - *p=s; - return(1); + break; + case GLITCH: + case '"': + case '\'': + sp = &f__syl[op_gen (APOS, 0, 0, 0)]; + sp->p2.s = s; + if ((*p = ap_end (s)) == NULL) + return (0); + return (1); + case 'T': + case 't': + if (*(s + 1) == 'l' || *(s + 1) == 'L') + { + x = TL; + s++; + } + else if (*(s + 1) == 'r' || *(s + 1) == 'R') + { + x = TR; + s++; + } + else + x = T; + if (!(s = gt_num (s + 1, &n, 0))) + goto bad; + s--; + (void) op_gen (x, n, 0, 0); + break; + case 'X': + case 'x': + (void) op_gen (X, 1, 0, 0); + break; + case 'P': + case 'p': + (void) op_gen (P, 1, 0, 0); + break; + } + s++; + *p = s; + return (1); } - static -e_d(char *s, char **p) -{ int i,im,n,w,d,e,found=0,x=0; - char *sv=s; - s=gt_num(s,&n,1); - (void) op_gen(STACK,n,0,0); - switch(*s++) +static +e_d (char *s, char **p) +{ + int i, im, n, w, d, e, found = 0, x = 0; + char *sv = s; + s = gt_num (s, &n, 1); + (void) op_gen (STACK, n, 0, 0); + switch (*s++) + { + default: + break; + case 'E': + case 'e': + x = 1; + case 'G': + case 'g': + found = 1; + if (!(s = gt_num (s, &w, 0))) + { + bad: + *p = 0; + return 1; + } + if (w == 0) + break; + if (*s == '.') { - default: break; - case 'E': - case 'e': x=1; - case 'G': - case 'g': - found=1; - if (!(s=gt_num(s,&w,0))) { - bad: - *p = 0; - return 1; - } - if(w==0) break; - if(*s=='.') { - if (!(s=gt_num(s+1,&d,0))) - goto bad; - } - else d=0; - if(*s!='E' && *s != 'e') - (void) op_gen(x==1?E:G,w,d,0); /* default is Ew.dE2 */ - else { - if (!(s=gt_num(s+1,&e,0))) - goto bad; - (void) op_gen(x==1?EE:GE,w,d,e); - } - break; - case 'O': - case 'o': - i = O; - im = OM; - goto finish_I; - case 'Z': - case 'z': - i = Z; - im = ZM; - goto finish_I; - case 'L': - case 'l': - found=1; - if (!(s=gt_num(s,&w,0))) - goto bad; - if(w==0) break; - (void) op_gen(L,w,0,0); - break; - case 'A': - case 'a': - found=1; - skip(s); - if(*s>='0' && *s<='9') - { s=gt_num(s,&w,1); - if(w==0) break; - (void) op_gen(AW,w,0,0); - break; - } - (void) op_gen(A,0,0,0); - break; - case 'F': - case 'f': - if (!(s=gt_num(s,&w,0))) - goto bad; - found=1; - if(w==0) break; - if(*s=='.') { - if (!(s=gt_num(s+1,&d,0))) - goto bad; - } - else d=0; - (void) op_gen(F,w,d,0); - break; - case 'D': - case 'd': - found=1; - if (!(s=gt_num(s,&w,0))) - goto bad; - if(w==0) break; - if(*s=='.') { - if (!(s=gt_num(s+1,&d,0))) - goto bad; - } - else d=0; - (void) op_gen(D,w,d,0); - break; - case 'I': - case 'i': - i = I; - im = IM; - finish_I: - if (!(s=gt_num(s,&w,0))) - goto bad; - found=1; - if(w==0) break; - if(*s!='.') - { (void) op_gen(i,w,0,0); - break; - } - if (!(s=gt_num(s+1,&d,0))) - goto bad; - (void) op_gen(im,w,d,0); - break; + if (!(s = gt_num (s + 1, &d, 0))) + goto bad; } - if(found==0) - { f__pc--; /*unSTACK*/ - *p=sv; - return(0); + else + d = 0; + if (*s != 'E' && *s != 'e') + (void) op_gen (x == 1 ? E : G, w, d, 0); /* default is Ew.dE2 */ + else + { + if (!(s = gt_num (s + 1, &e, 0))) + goto bad; + (void) op_gen (x == 1 ? EE : GE, w, d, e); + } + break; + case 'O': + case 'o': + i = O; + im = OM; + goto finish_I; + case 'Z': + case 'z': + i = Z; + im = ZM; + goto finish_I; + case 'L': + case 'l': + found = 1; + if (!(s = gt_num (s, &w, 0))) + goto bad; + if (w == 0) + break; + (void) op_gen (L, w, 0, 0); + break; + case 'A': + case 'a': + found = 1; + skip (s); + if (*s >= '0' && *s <= '9') + { + s = gt_num (s, &w, 1); + if (w == 0) + break; + (void) op_gen (AW, w, 0, 0); + break; + } + (void) op_gen (A, 0, 0, 0); + break; + case 'F': + case 'f': + if (!(s = gt_num (s, &w, 0))) + goto bad; + found = 1; + if (w == 0) + break; + if (*s == '.') + { + if (!(s = gt_num (s + 1, &d, 0))) + goto bad; + } + else + d = 0; + (void) op_gen (F, w, d, 0); + break; + case 'D': + case 'd': + found = 1; + if (!(s = gt_num (s, &w, 0))) + goto bad; + if (w == 0) + break; + if (*s == '.') + { + if (!(s = gt_num (s + 1, &d, 0))) + goto bad; } - *p=s; - return(1); + else + d = 0; + (void) op_gen (D, w, d, 0); + break; + case 'I': + case 'i': + i = I; + im = IM; + finish_I: + if (!(s = gt_num (s, &w, 0))) + goto bad; + found = 1; + if (w == 0) + break; + if (*s != '.') + { + (void) op_gen (i, w, 0, 0); + break; + } + if (!(s = gt_num (s + 1, &d, 0))) + goto bad; + (void) op_gen (im, w, d, 0); + break; + } + if (found == 0) + { + f__pc--; /*unSTACK */ + *p = sv; + return (0); + } + *p = s; + return (1); } - static -char *i_tem(char *s) -{ char *t; - int n,curloc; - if(*s==')') return(s); - if(ne_d(s,&t)) return(t); - if(e_d(s,&t)) return(t); - s=gt_num(s,&n,1); - if((curloc=op_gen(STACK,n,0,0))<0) return(NULL); - return(f_s(s,curloc)); +static char * +i_tem (char *s) +{ + char *t; + int n, curloc; + if (*s == ')') + return (s); + if (ne_d (s, &t)) + return (t); + if (e_d (s, &t)) + return (t); + s = gt_num (s, &n, 1); + if ((curloc = op_gen (STACK, n, 0, 0)) < 0) + return (NULL); + return (f_s (s, curloc)); } - static -char *f_list(char *s) +static char * +f_list (char *s) { - for(;*s!=0;) - { skip(s); - if((s=i_tem(s))==NULL) return(NULL); - skip(s); - if(*s==',') s++; - else if(*s==')') - { if(--f__parenlvl==0) - { - (void) op_gen(REVERT,f__revloc,0,0); - return(++s); - } - (void) op_gen(GOTO,0,0,0); - return(++s); - } + for (; *s != 0;) + { + skip (s); + if ((s = i_tem (s)) == NULL) + return (NULL); + skip (s); + if (*s == ',') + s++; + else if (*s == ')') + { + if (--f__parenlvl == 0) + { + (void) op_gen (REVERT, f__revloc, 0, 0); + return (++s); + } + (void) op_gen (GOTO, 0, 0, 0); + return (++s); } - return(NULL); + } + return (NULL); } -pars_f(char *s) +pars_f (char *s) { - char *e; + char *e; - f__parenlvl=f__revloc=f__pc=0; - if((e=f_s(s,0)) == NULL) - { - /* Try and delimit the format string. Parens within - hollerith and quoted strings have to match for this - to work, but it's probably adequate for most needs. - Note that this is needed because a valid CHARACTER - variable passed for FMT= can contain '(I)garbage', - where `garbage' is billions and billions of junk - characters, and it's up to the run-time library to - know where the format string ends by counting parens. - Meanwhile, still treat NUL byte as "hard stop", since - f2c still appends that at end of FORMAT-statement - strings. */ + f__parenlvl = f__revloc = f__pc = 0; + if ((e = f_s (s, 0)) == NULL) + { + /* Try and delimit the format string. Parens within + hollerith and quoted strings have to match for this + to work, but it's probably adequate for most needs. + Note that this is needed because a valid CHARACTER + variable passed for FMT= can contain '(I)garbage', + where `garbage' is billions and billions of junk + characters, and it's up to the run-time library to + know where the format string ends by counting parens. + Meanwhile, still treat NUL byte as "hard stop", since + f2c still appends that at end of FORMAT-statement + strings. */ - int level=0; + int level = 0; - for (f__fmtlen=0; - ((*s!=')') || (--level > 0)) - && (*s!='\0') - && (f__fmtlen<80); - ++s, ++f__fmtlen) - { - if (*s=='(') - ++level; - } - if (*s==')') - ++f__fmtlen; - return(-1); + for (f__fmtlen = 0; + ((*s != ')') || (--level > 0)) + && (*s != '\0') && (f__fmtlen < 80); ++s, ++f__fmtlen) + { + if (*s == '(') + ++level; } - f__fmtlen = e - s; - return(0); + if (*s == ')') + ++f__fmtlen; + return (-1); + } + f__fmtlen = e - s; + return (0); } + #define STKSZ 10 -int f__cnt[STKSZ],f__ret[STKSZ],f__cp,f__rp; +int f__cnt[STKSZ], f__ret[STKSZ], f__cp, f__rp; flag f__workdone, f__nonl; - static -type_f(int n) +static +type_f (int n) { - switch(n) - { - default: - return(n); - case RET1: - return(RET1); - case REVERT: return(REVERT); - case GOTO: return(GOTO); - case STACK: return(STACK); - case X: - case SLASH: - case APOS: case H: - case T: case TL: case TR: - return(NED); - case F: - case I: - case IM: - case A: case AW: - case O: case OM: - case L: - case E: case EE: case D: - case G: case GE: - case Z: case ZM: - return(ED); - } + switch (n) + { + default: + return (n); + case RET1: + return (RET1); + case REVERT: + return (REVERT); + case GOTO: + return (GOTO); + case STACK: + return (STACK); + case X: + case SLASH: + case APOS: + case H: + case T: + case TL: + case TR: + return (NED); + case F: + case I: + case IM: + case A: + case AW: + case O: + case OM: + case L: + case E: + case EE: + case D: + case G: + case GE: + case Z: + case ZM: + return (ED); + } } -integer do_fio(ftnint *number, char *ptr, ftnlen len) -{ struct syl *p; - int n,i; - for(i=0;i<*number;i++,ptr+=len) - { -loop: switch(type_f((p= &f__syl[f__pc])->op)) +integer +do_fio (ftnint * number, char *ptr, ftnlen len) +{ + struct syl *p; + int n, i; + for (i = 0; i < *number; i++, ptr += len) + { + loop:switch (type_f ((p = &f__syl[f__pc])->op)) { default: - fprintf(stderr,"unknown code in do_fio: %d\n%.*s\n", - p->op,f__fmtlen,f__fmtbuf); - err(f__elist->cierr,100,"do_fio"); + fprintf (stderr, "unknown code in do_fio: %d\n%.*s\n", + p->op, f__fmtlen, f__fmtbuf); + err (f__elist->cierr, 100, "do_fio"); case NED: - if((*f__doned)(p)) - { f__pc++; - goto loop; - } - f__pc++; - continue; + if ((*f__doned) (p)) + { + f__pc++; + goto loop; + } + f__pc++; + continue; case ED: - if(f__cnt[f__cp]<=0) - { f__cp--; - f__pc++; - goto loop; - } - if(ptr==NULL) - return((*f__doend)()); - f__cnt[f__cp]--; - f__workdone=1; - if((n=(*f__doed)(p,ptr,len))>0) - errfl(f__elist->cierr,errno,"fmt"); - if(n<0) - err(f__elist->ciend,(EOF),"fmt"); - continue; + if (f__cnt[f__cp] <= 0) + { + f__cp--; + f__pc++; + goto loop; + } + if (ptr == NULL) + return ((*f__doend) ()); + f__cnt[f__cp]--; + f__workdone = 1; + if ((n = (*f__doed) (p, ptr, len)) > 0) + errfl (f__elist->cierr, errno, "fmt"); + if (n < 0) + err (f__elist->ciend, (EOF), "fmt"); + continue; case STACK: - f__cnt[++f__cp]=p->p1; - f__pc++; - goto loop; + f__cnt[++f__cp] = p->p1; + f__pc++; + goto loop; case RET1: - f__ret[++f__rp]=p->p1; - f__pc++; - goto loop; + f__ret[++f__rp] = p->p1; + f__pc++; + goto loop; case GOTO: - if(--f__cnt[f__cp]<=0) - { f__cp--; - f__rp--; - f__pc++; - goto loop; - } - f__pc=1+f__ret[f__rp--]; - goto loop; + if (--f__cnt[f__cp] <= 0) + { + f__cp--; + f__rp--; + f__pc++; + goto loop; + } + f__pc = 1 + f__ret[f__rp--]; + goto loop; case REVERT: - f__rp=f__cp=0; - f__pc = p->p1; - if(ptr==NULL) - return((*f__doend)()); - if(!f__workdone) return(0); - if((n=(*f__dorevert)()) != 0) return(n); - goto loop; + f__rp = f__cp = 0; + f__pc = p->p1; + if (ptr == NULL) + return ((*f__doend) ()); + if (!f__workdone) + return (0); + if ((n = (*f__dorevert) ()) != 0) + return (n); + goto loop; case COLON: - if(ptr==NULL) - return((*f__doend)()); - f__pc++; - goto loop; + if (ptr == NULL) + return ((*f__doend) ()); + f__pc++; + goto loop; case NONL: - f__nonl = 1; - f__pc++; - goto loop; + f__nonl = 1; + f__pc++; + goto loop; case S: case SS: - f__cplus=0; - f__pc++; - goto loop; + f__cplus = 0; + f__pc++; + goto loop; case SP: - f__cplus = 1; - f__pc++; - goto loop; - case P: f__scale=p->p1; - f__pc++; - goto loop; + f__cplus = 1; + f__pc++; + goto loop; + case P: + f__scale = p->p1; + f__pc++; + goto loop; case BN: - f__cblank=0; - f__pc++; - goto loop; + f__cblank = 0; + f__pc++; + goto loop; case BZ: - f__cblank=1; - f__pc++; - goto loop; - } + f__cblank = 1; + f__pc++; + goto loop; } - return(0); + } + return (0); } -en_fio(void) -{ ftnint one=1; - return(do_fio(&one,(char *)NULL,(ftnint)0)); + +en_fio (void) +{ + ftnint one = 1; + return (do_fio (&one, (char *) NULL, (ftnint) 0)); } + void -fmt_bg(void) +fmt_bg (void) { - f__workdone=f__cp=f__rp=f__pc=f__cursor=0; - f__cnt[0]=f__ret[0]=0; + f__workdone = f__cp = f__rp = f__pc = f__cursor = 0; + f__cnt[0] = f__ret[0] = 0; } diff --git a/libf2c/libI77/fmt.h b/libf2c/libI77/fmt.h index 59b0eac..bcd84ce 100644 --- a/libf2c/libI77/fmt.h +++ b/libf2c/libI77/fmt.h @@ -1,8 +1,14 @@ struct syl -{ int op; - int p1; - union { int i[2]; char *s;} p2; - }; +{ + int op; + int p1; + union + { + int i[2]; + char *s; + } + p2; +}; #define RET1 1 #define REVERT 2 #define GOTO 3 @@ -39,30 +45,34 @@ struct syl #define OM 34 #define Z 35 #define ZM 36 -extern int f__pc,f__parenlvl,f__revloc; +extern int f__pc, f__parenlvl, f__revloc; typedef union -{ real pf; - doublereal pd; -} ufloat; +{ + real pf; + doublereal pd; +} +ufloat; typedef union -{ short is; - signed - char ic; - integer il; +{ + short is; + signed char ic; + integer il; #ifdef Allow_TYQUAD - longint ili; + longint ili; #endif -} Uint; -extern int (*f__doed)(struct syl*, char*, ftnlen),(*f__doned)(struct syl*); -extern int (*f__dorevert)(void); -extern void fmt_bg(void); -extern int pars_f(char*); -extern int rd_ed(struct syl*, char*, ftnlen),rd_ned(struct syl*); -extern int w_ed(struct syl*, char*, ftnlen),w_ned(struct syl*); -extern int wrt_E(ufloat*, int, int, int, ftnlen); -extern int wrt_F(ufloat*, int, int, ftnlen); -extern int wrt_L(Uint*, int, ftnlen); -extern flag f__cblank,f__cplus,f__workdone, f__nonl; +} +Uint; +extern int (*f__doed) (struct syl *, char *, ftnlen), + (*f__doned) (struct syl *); +extern int (*f__dorevert) (void); +extern void fmt_bg (void); +extern int pars_f (char *); +extern int rd_ed (struct syl *, char *, ftnlen), rd_ned (struct syl *); +extern int w_ed (struct syl *, char *, ftnlen), w_ned (struct syl *); +extern int wrt_E (ufloat *, int, int, int, ftnlen); +extern int wrt_F (ufloat *, int, int, ftnlen); +extern int wrt_L (Uint *, int, ftnlen); +extern flag f__cblank, f__cplus, f__workdone, f__nonl; extern char *f__fmtbuf; extern int f__fmtlen; extern int f__scale; @@ -79,4 +89,4 @@ extern int f__cursor; #define TYQUAD 14 #endif -extern char *f__icvt(longint, int*, int*, int); +extern char *f__icvt (longint, int *, int *, int); diff --git a/libf2c/libI77/fmtlib.c b/libf2c/libI77/fmtlib.c index afc8bfd..3d2a299 100644 --- a/libf2c/libI77/fmtlib.c +++ b/libf2c/libI77/fmtlib.c @@ -10,32 +10,37 @@ #define ulongint unsigned long #endif -char *f__icvt(longint value, int *ndigit, int *sign, int base) +char * +f__icvt (longint value, int *ndigit, int *sign, int base) { - static char buf[MAXINTLENGTH+1]; - register int i; - ulongint uvalue; + static char buf[MAXINTLENGTH + 1]; + register int i; + ulongint uvalue; - if(value > 0) { - uvalue = value; - *sign = 0; - } - else if (value < 0) { - uvalue = -value; - *sign = 1; - } - else { - *sign = 0; - *ndigit = 1; - buf[MAXINTLENGTH-1] = '0'; - return &buf[MAXINTLENGTH-1]; - } - i = MAXINTLENGTH; - do { - buf[--i] = (uvalue%base) + '0'; - uvalue /= base; - } - while(uvalue > 0); - *ndigit = MAXINTLENGTH - i; - return &buf[i]; - } + if (value > 0) + { + uvalue = value; + *sign = 0; + } + else if (value < 0) + { + uvalue = -value; + *sign = 1; + } + else + { + *sign = 0; + *ndigit = 1; + buf[MAXINTLENGTH - 1] = '0'; + return &buf[MAXINTLENGTH - 1]; + } + i = MAXINTLENGTH; + do + { + buf[--i] = (uvalue % base) + '0'; + uvalue /= base; + } + while (uvalue > 0); + *ndigit = MAXINTLENGTH - i; + return &buf[i]; +} diff --git a/libf2c/libI77/fp.h b/libf2c/libI77/fp.h index 40743d7..2b78ef9 100644 --- a/libf2c/libI77/fp.h +++ b/libf2c/libI77/fp.h @@ -4,7 +4,7 @@ /* FMAX = max number of nonzero digits passed to atof() */ /* EXPMAX = 10^EXPMAXDIGS - 1 = largest allowed exponent absolute value */ -#ifdef V10 /* Research Tenth-Edition Unix */ +#ifdef V10 /* Research Tenth-Edition Unix */ #include "local.h" #endif diff --git a/libf2c/libI77/ftell_.c b/libf2c/libI77/ftell_.c index 44a5bbc..6315342 100644 --- a/libf2c/libI77/ftell_.c +++ b/libf2c/libI77/ftell_.c @@ -2,34 +2,34 @@ #include "f2c.h" #include "fio.h" - static FILE * -unit_chk(integer Unit, char *who) +static FILE * +unit_chk (integer Unit, char *who) { - if (Unit >= MXUNIT || Unit < 0) - f__fatal(101, who); - return f__units[Unit].ufd; - } + if (Unit >= MXUNIT || Unit < 0) + f__fatal (101, who); + return f__units[Unit].ufd; +} - integer -G77_ftell_0 (integer *Unit) +integer +G77_ftell_0 (integer * Unit) { - FILE *f; - return (f = unit_chk(*Unit, "ftell")) ? (integer) FTELL(f) : -1L; - } + FILE *f; + return (f = unit_chk (*Unit, "ftell")) ? (integer) FTELL (f) : -1L; +} - integer -G77_fseek_0 (integer *Unit, integer *offset, integer *xwhence) +integer +G77_fseek_0 (integer * Unit, integer * offset, integer * xwhence) { - FILE *f; - int w = (int)*xwhence; + FILE *f; + int w = (int) *xwhence; #ifdef SEEK_SET - static int wohin[3] = { SEEK_SET, SEEK_CUR, SEEK_END }; + static int wohin[3] = { SEEK_SET, SEEK_CUR, SEEK_END }; #endif - if (w < 0 || w > 2) - w = 0; + if (w < 0 || w > 2) + w = 0; #ifdef SEEK_SET - w = wohin[w]; + w = wohin[w]; #endif - return !(f = unit_chk(*Unit, "fseek")) - || FSEEK(f, (off_t) *offset, w) ? 1 : 0; - } + return !(f = unit_chk (*Unit, "fseek")) + || FSEEK (f, (off_t) * offset, w) ? 1 : 0; +} diff --git a/libf2c/libI77/iio.c b/libf2c/libI77/iio.c index 6dc03f5..435b4b6 100644 --- a/libf2c/libI77/iio.c +++ b/libf2c/libI77/iio.c @@ -6,133 +6,148 @@ char *f__icend; extern icilist *f__svic; int f__icnum; extern int f__hiwater; -z_getc(void) +z_getc (void) { - if(f__recpos++ < f__svic->icirlen) { - if(f__icptr >= f__icend) err(f__svic->iciend,(EOF),"endfile"); - return(*(unsigned char *)f__icptr++); - } - return '\n'; + if (f__recpos++ < f__svic->icirlen) + { + if (f__icptr >= f__icend) + err (f__svic->iciend, (EOF), "endfile"); + return (*(unsigned char *) f__icptr++); + } + return '\n'; } - void -z_putc(int c) +void +z_putc (int c) { - if (f__icptr < f__icend && f__recpos++ < f__svic->icirlen) - *f__icptr++ = c; + if (f__icptr < f__icend && f__recpos++ < f__svic->icirlen) + *f__icptr++ = c; } -z_rnew(void) +z_rnew (void) { - f__icptr = f__svic->iciunit + (++f__icnum)*f__svic->icirlen; - f__recpos = 0; - f__cursor = 0; - f__hiwater = 0; - return 1; + f__icptr = f__svic->iciunit + (++f__icnum) * f__svic->icirlen; + f__recpos = 0; + f__cursor = 0; + f__hiwater = 0; + return 1; } - static int -z_endp(void) +static int +z_endp (void) { - (*f__donewrec)(); - return 0; - } + (*f__donewrec) (); + return 0; +} -c_si(icilist *a) +c_si (icilist * a) { - if (f__init & 2) - f__fatal (131, "I/O recursion"); - f__init |= 2; - f__elist = (cilist *)a; - f__fmtbuf=a->icifmt; - f__curunit = 0; - f__sequential=f__formatted=1; - f__external=0; - if(pars_f(f__fmtbuf)<0) - err(a->icierr,100,"startint"); - fmt_bg(); - f__cblank=f__cplus=f__scale=0; - f__svic=a; - f__icnum=f__recpos=0; - f__cursor = 0; - f__hiwater = 0; - f__icptr = a->iciunit; - f__icend = f__icptr + a->icirlen*a->icirnum; - f__cf = 0; - return(0); + if (f__init & 2) + f__fatal (131, "I/O recursion"); + f__init |= 2; + f__elist = (cilist *) a; + f__fmtbuf = a->icifmt; + f__curunit = 0; + f__sequential = f__formatted = 1; + f__external = 0; + if (pars_f (f__fmtbuf) < 0) + err (a->icierr, 100, "startint"); + fmt_bg (); + f__cblank = f__cplus = f__scale = 0; + f__svic = a; + f__icnum = f__recpos = 0; + f__cursor = 0; + f__hiwater = 0; + f__icptr = a->iciunit; + f__icend = f__icptr + a->icirlen * a->icirnum; + f__cf = 0; + return (0); } - int -iw_rev(void) +int +iw_rev (void) { - if(f__workdone) - z_endp(); - f__hiwater = f__recpos = f__cursor = 0; - return(f__workdone=0); - } + if (f__workdone) + z_endp (); + f__hiwater = f__recpos = f__cursor = 0; + return (f__workdone = 0); +} -integer s_rsfi(icilist *a) -{ int n; - if(n=c_si(a)) return(n); - f__reading=1; - f__doed=rd_ed; - f__doned=rd_ned; - f__getn=z_getc; - f__dorevert = z_endp; - f__donewrec = z_rnew; - f__doend = z_endp; - return(0); +integer +s_rsfi (icilist * a) +{ + int n; + if (n = c_si (a)) + return (n); + f__reading = 1; + f__doed = rd_ed; + f__doned = rd_ned; + f__getn = z_getc; + f__dorevert = z_endp; + f__donewrec = z_rnew; + f__doend = z_endp; + return (0); } -z_wnew(void) +z_wnew (void) { - if (f__recpos < f__hiwater) { - f__icptr += f__hiwater - f__recpos; - f__recpos = f__hiwater; - } - while(f__recpos++ < f__svic->icirlen) - *f__icptr++ = ' '; - f__recpos = 0; - f__cursor = 0; - f__hiwater = 0; - f__icnum++; - return 1; + if (f__recpos < f__hiwater) + { + f__icptr += f__hiwater - f__recpos; + f__recpos = f__hiwater; + } + while (f__recpos++ < f__svic->icirlen) + *f__icptr++ = ' '; + f__recpos = 0; + f__cursor = 0; + f__hiwater = 0; + f__icnum++; + return 1; } -integer s_wsfi(icilist *a) -{ int n; - if(n=c_si(a)) return(n); - f__reading=0; - f__doed=w_ed; - f__doned=w_ned; - f__putn=z_putc; - f__dorevert = iw_rev; - f__donewrec = z_wnew; - f__doend = z_endp; - return(0); + +integer +s_wsfi (icilist * a) +{ + int n; + if (n = c_si (a)) + return (n); + f__reading = 0; + f__doed = w_ed; + f__doned = w_ned; + f__putn = z_putc; + f__dorevert = iw_rev; + f__donewrec = z_wnew; + f__doend = z_endp; + return (0); } -integer e_rsfi(void) -{ int n; - f__init &= ~2; - n = en_fio(); - f__fmtbuf = NULL; - return(n); + +integer +e_rsfi (void) +{ + int n; + f__init &= ~2; + n = en_fio (); + f__fmtbuf = NULL; + return (n); } -integer e_wsfi(void) + +integer +e_wsfi (void) { - int n; - f__init &= ~2; - n = en_fio(); - f__fmtbuf = NULL; - if(f__svic->icirnum != 1 - && (f__icnum > f__svic->icirnum - || (f__icnum == f__svic->icirnum && (f__recpos | f__hiwater)))) - err(f__svic->icierr,110,"inwrite"); - if (f__recpos < f__hiwater) - f__recpos = f__hiwater; - if (f__recpos >= f__svic->icirlen) - err(f__svic->icierr,110,"recend"); - if (!f__recpos && f__icnum) - return n; - while(f__recpos++ < f__svic->icirlen) - *f__icptr++ = ' '; - return n; + int n; + f__init &= ~2; + n = en_fio (); + f__fmtbuf = NULL; + if (f__svic->icirnum != 1 + && (f__icnum > f__svic->icirnum + || (f__icnum == f__svic->icirnum && (f__recpos | f__hiwater)))) + err (f__svic->icierr, 110, "inwrite"); + if (f__recpos < f__hiwater) + f__recpos = f__hiwater; + if (f__recpos >= f__svic->icirlen) + err (f__svic->icierr, 110, "recend"); + if (!f__recpos && f__icnum) + return n; + while (f__recpos++ < f__svic->icirlen) + *f__icptr++ = ' '; + return n; } diff --git a/libf2c/libI77/ilnw.c b/libf2c/libI77/ilnw.c index bf1fe66..0a92a0c 100644 --- a/libf2c/libI77/ilnw.c +++ b/libf2c/libI77/ilnw.c @@ -6,62 +6,65 @@ extern char *f__icptr; extern char *f__icend; extern icilist *f__svic; extern int f__icnum; -extern void z_putc(int); +extern void z_putc (int); - static int -z_wSL(void) +static int +z_wSL (void) { - while(f__recpos < f__svic->icirlen) - z_putc(' '); - return z_rnew(); - } + while (f__recpos < f__svic->icirlen) + z_putc (' '); + return z_rnew (); +} - static void -c_liw(icilist *a) +static void +c_liw (icilist * a) { - f__reading = 0; - f__external = 0; - f__formatted = 1; - f__putn = z_putc; - L_len = a->icirlen; - f__donewrec = z_wSL; - f__svic = a; - f__icnum = f__recpos = 0; - f__cursor = 0; - f__cf = 0; - f__curunit = 0; - f__icptr = a->iciunit; - f__icend = f__icptr + a->icirlen*a->icirnum; - f__elist = (cilist *)a; - } + f__reading = 0; + f__external = 0; + f__formatted = 1; + f__putn = z_putc; + L_len = a->icirlen; + f__donewrec = z_wSL; + f__svic = a; + f__icnum = f__recpos = 0; + f__cursor = 0; + f__cf = 0; + f__curunit = 0; + f__icptr = a->iciunit; + f__icend = f__icptr + a->icirlen * a->icirnum; + f__elist = (cilist *) a; +} - integer -s_wsni(icilist *a) +integer +s_wsni (icilist * a) { - cilist ca; + cilist ca; - if(f__init != 1) f_init(); - f__init = 3; - c_liw(a); - ca.cifmt = a->icifmt; - x_wsne(&ca); - z_wSL(); - return 0; - } + if (f__init != 1) + f_init (); + f__init = 3; + c_liw (a); + ca.cifmt = a->icifmt; + x_wsne (&ca); + z_wSL (); + return 0; +} - integer -s_wsli(icilist *a) +integer +s_wsli (icilist * a) { - if(f__init != 1) f_init(); - f__init = 3; - f__lioproc = l_write; - c_liw(a); - return(0); - } + if (f__init != 1) + f_init (); + f__init = 3; + f__lioproc = l_write; + c_liw (a); + return (0); +} -integer e_wsli(void) +integer +e_wsli (void) { - f__init = 1; - z_wSL(); - return(0); - } + f__init = 1; + z_wSL (); + return (0); +} diff --git a/libf2c/libI77/inquire.c b/libf2c/libI77/inquire.c index 53cba24..ac13b36 100644 --- a/libf2c/libI77/inquire.c +++ b/libf2c/libI77/inquire.c @@ -8,98 +8,114 @@ #undef max #include "io.h" #endif -integer f_inqu(inlist *a) -{ flag byfile; - int i, n; - unit *p; - char buf[256]; - long x; - if (f__init & 2) - f__fatal (131, "I/O recursion"); - if(a->infile!=NULL) - { byfile=1; - g_char(a->infile,a->infilen,buf); +integer +f_inqu (inlist * a) +{ + flag byfile; + int i, n; + unit *p; + char buf[256]; + long x; + if (f__init & 2) + f__fatal (131, "I/O recursion"); + if (a->infile != NULL) + { + byfile = 1; + g_char (a->infile, a->infilen, buf); #ifdef NON_UNIX_STDIO - x = access(buf,0) ? -1 : 0; - for(i=0,p=NULL;i<MXUNIT;i++) - if(f__units[i].ufd != NULL - && f__units[i].ufnm != NULL - && !strcmp(f__units[i].ufnm,buf)) { - p = &f__units[i]; - break; - } + x = access (buf, 0) ? -1 : 0; + for (i = 0, p = NULL; i < MXUNIT; i++) + if (f__units[i].ufd != NULL + && f__units[i].ufnm != NULL && !strcmp (f__units[i].ufnm, buf)) + { + p = &f__units[i]; + break; + } #else - x=f__inode(buf, &n); - for(i=0,p=NULL;i<MXUNIT;i++) - if(f__units[i].uinode==x - && f__units[i].ufd!=NULL - && f__units[i].udev == n) { - p = &f__units[i]; - break; - } + x = f__inode (buf, &n); + for (i = 0, p = NULL; i < MXUNIT; i++) + if (f__units[i].uinode == x + && f__units[i].ufd != NULL && f__units[i].udev == n) + { + p = &f__units[i]; + break; + } #endif + } + else + { + byfile = 0; + if (a->inunit < MXUNIT && a->inunit >= 0) + { + p = &f__units[a->inunit]; } - else + else { - byfile=0; - if(a->inunit<MXUNIT && a->inunit>=0) - { - p= &f__units[a->inunit]; - } - else - { - p=NULL; - } + p = NULL; } - if(a->inex!=NULL) - if(byfile && x != -1 || !byfile && p!=NULL) - *a->inex=1; - else *a->inex=0; - if(a->inopen!=NULL) - if(byfile) *a->inopen=(p!=NULL); - else *a->inopen=(p!=NULL && p->ufd!=NULL); - if(a->innum!=NULL) *a->innum= p-f__units; - if(a->innamed!=NULL) - if(byfile || p!=NULL && p->ufnm!=NULL) - *a->innamed=1; - else *a->innamed=0; - if(a->inname!=NULL) - if(byfile) - b_char(buf,a->inname,a->innamlen); - else if(p!=NULL && p->ufnm!=NULL) - b_char(p->ufnm,a->inname,a->innamlen); - if(a->inacc!=NULL && p!=NULL && p->ufd!=NULL) - if(p->url) - b_char("DIRECT",a->inacc,a->inacclen); - else b_char("SEQUENTIAL",a->inacc,a->inacclen); - if(a->inseq!=NULL) - if(p!=NULL && p->url) - b_char("NO",a->inseq,a->inseqlen); - else b_char("YES",a->inseq,a->inseqlen); - if(a->indir!=NULL) - if(p==NULL || p->url) - b_char("YES",a->indir,a->indirlen); - else b_char("NO",a->indir,a->indirlen); - if(a->infmt!=NULL) - if(p!=NULL && p->ufmt==0) - b_char("UNFORMATTED",a->infmt,a->infmtlen); - else b_char("FORMATTED",a->infmt,a->infmtlen); - if(a->inform!=NULL) - if(p!=NULL && p->ufmt==0) - b_char("NO",a->inform,a->informlen); - else b_char("YES",a->inform,a->informlen); - if(a->inunf) - if(p!=NULL && p->ufmt==0) - b_char("YES",a->inunf,a->inunflen); - else if (p!=NULL) b_char("NO",a->inunf,a->inunflen); - else b_char("UNKNOWN",a->inunf,a->inunflen); - if(a->inrecl!=NULL && p!=NULL) - *a->inrecl=p->url; - if(a->innrec!=NULL && p!=NULL && p->url>0) - *a->innrec=FTELL(p->ufd)/p->url+1; - if(a->inblank && p!=NULL && p->ufmt) - if(p->ublnk) - b_char("ZERO",a->inblank,a->inblanklen); - else b_char("NULL",a->inblank,a->inblanklen); - return(0); + } + if (a->inex != NULL) + if (byfile && x != -1 || !byfile && p != NULL) + *a->inex = 1; + else + *a->inex = 0; + if (a->inopen != NULL) + if (byfile) + *a->inopen = (p != NULL); + else + *a->inopen = (p != NULL && p->ufd != NULL); + if (a->innum != NULL) + *a->innum = p - f__units; + if (a->innamed != NULL) + if (byfile || p != NULL && p->ufnm != NULL) + *a->innamed = 1; + else + *a->innamed = 0; + if (a->inname != NULL) + if (byfile) + b_char (buf, a->inname, a->innamlen); + else if (p != NULL && p->ufnm != NULL) + b_char (p->ufnm, a->inname, a->innamlen); + if (a->inacc != NULL && p != NULL && p->ufd != NULL) + if (p->url) + b_char ("DIRECT", a->inacc, a->inacclen); + else + b_char ("SEQUENTIAL", a->inacc, a->inacclen); + if (a->inseq != NULL) + if (p != NULL && p->url) + b_char ("NO", a->inseq, a->inseqlen); + else + b_char ("YES", a->inseq, a->inseqlen); + if (a->indir != NULL) + if (p == NULL || p->url) + b_char ("YES", a->indir, a->indirlen); + else + b_char ("NO", a->indir, a->indirlen); + if (a->infmt != NULL) + if (p != NULL && p->ufmt == 0) + b_char ("UNFORMATTED", a->infmt, a->infmtlen); + else + b_char ("FORMATTED", a->infmt, a->infmtlen); + if (a->inform != NULL) + if (p != NULL && p->ufmt == 0) + b_char ("NO", a->inform, a->informlen); + else + b_char ("YES", a->inform, a->informlen); + if (a->inunf) + if (p != NULL && p->ufmt == 0) + b_char ("YES", a->inunf, a->inunflen); + else if (p != NULL) + b_char ("NO", a->inunf, a->inunflen); + else + b_char ("UNKNOWN", a->inunf, a->inunflen); + if (a->inrecl != NULL && p != NULL) + *a->inrecl = p->url; + if (a->innrec != NULL && p != NULL && p->url > 0) + *a->innrec = FTELL (p->ufd) / p->url + 1; + if (a->inblank && p != NULL && p->ufmt) + if (p->ublnk) + b_char ("ZERO", a->inblank, a->inblanklen); + else + b_char ("NULL", a->inblank, a->inblanklen); + return (0); } diff --git a/libf2c/libI77/lio.h b/libf2c/libI77/lio.h index 7663fde..4e17115 100644 --- a/libf2c/libI77/lio.h +++ b/libf2c/libI77/lio.h @@ -43,22 +43,22 @@ typedef union { - signed - char flchar; - short flshort; - ftnint flint; + signed char flchar; + short flshort; + ftnint flint; #ifdef Allow_TYQUAD - longint fllongint; + longint fllongint; #endif - real flreal; - doublereal fldouble; -} flex; + real flreal; + doublereal fldouble; +} +flex; extern int f__scale; -extern int (*f__lioproc)(ftnint*, char*, ftnlen, ftnint); -extern int l_write(ftnint*, char*, ftnlen, ftnint); -extern void x_wsne(cilist*); -extern int c_le(cilist*), (*l_getc)(void), (*l_ungetc)(int,FILE*); -extern int l_read(ftnint*,char*,ftnlen,ftnint); -extern integer e_rsle(void), e_wsle(void), s_wsne(cilist*); -extern int z_rnew(void); +extern int (*f__lioproc) (ftnint *, char *, ftnlen, ftnint); +extern int l_write (ftnint *, char *, ftnlen, ftnint); +extern void x_wsne (cilist *); +extern int c_le (cilist *), (*l_getc) (void), (*l_ungetc) (int, FILE *); +extern int l_read (ftnint *, char *, ftnlen, ftnint); +extern integer e_rsle (void), e_wsle (void), s_wsne (cilist *); +extern int z_rnew (void); extern ftnint L_len; diff --git a/libf2c/libI77/lread.c b/libf2c/libI77/lread.c index bff9d44..3dd4021 100644 --- a/libf2c/libI77/lread.c +++ b/libf2c/libI77/lread.c @@ -25,8 +25,8 @@ static int quad_read; #include "lio.h" #include "fp.h" -int (*f__lioproc)(ftnint*, char*, ftnlen, ftnint), (*l_getc)(void), - (*l_ungetc)(int,FILE*); +int (*f__lioproc) (ftnint *, char *, ftnlen, ftnint), (*l_getc) (void), + (*l_ungetc) (int, FILE *); int l_eof; @@ -42,709 +42,798 @@ int l_eof; #define EX 8 #define SG 16 #define WH 32 -char f__ltab[128+1] = { /* offset one for EOF */ - 0, - 0,0,AX,0,0,0,0,0,0,WH|B,SX|WH,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - SX|B|WH,0,AX,0,0,0,0,AX,0,0,0,SG,SX,SG,0,SX, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,EX,EX,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - AX,0,0,0,EX,EX,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +char f__ltab[128 + 1] = { /* offset one for EOF */ + 0, + 0, 0, AX, 0, 0, 0, 0, 0, 0, WH | B, SX | WH, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + SX | B | WH, 0, AX, 0, 0, 0, 0, AX, 0, 0, 0, SG, SX, SG, 0, SX, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, EX, EX, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + AX, 0, 0, 0, EX, EX, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; #ifdef ungetc - static int -un_getc(int x, FILE *f__cf) -{ return ungetc(x,f__cf); } +static int +un_getc (int x, FILE * f__cf) +{ + return ungetc (x, f__cf); +} #else #define un_getc ungetc -extern int ungetc(int, FILE*); /* for systems with a buggy stdio.h */ +extern int ungetc (int, FILE *); /* for systems with a buggy stdio.h */ #endif -t_getc(void) -{ int ch; - if(f__curunit->uend) return(EOF); - if((ch=getc(f__cf))!=EOF) return(ch); - if(feof(f__cf)) - f__curunit->uend = l_eof = 1; - return(EOF); +t_getc (void) +{ + int ch; + if (f__curunit->uend) + return (EOF); + if ((ch = getc (f__cf)) != EOF) + return (ch); + if (feof (f__cf)) + f__curunit->uend = l_eof = 1; + return (EOF); } -integer e_rsle(void) + +integer +e_rsle (void) { - int ch; - f__init = 1; - if(f__curunit->uend) return(0); - while((ch=t_getc())!='\n') - if (ch == EOF) { - if(feof(f__cf)) - f__curunit->uend = l_eof = 1; - return EOF; - } - return(0); + int ch; + f__init = 1; + if (f__curunit->uend) + return (0); + while ((ch = t_getc ()) != '\n') + if (ch == EOF) + { + if (feof (f__cf)) + f__curunit->uend = l_eof = 1; + return EOF; + } + return (0); } flag f__lquit; -int f__lcount,f__ltype,nml_read; +int f__lcount, f__ltype, nml_read; char *f__lchar; -double f__lx,f__ly; +double f__lx, f__ly; #define ERR(x) if(n=(x)) {f__init &= ~2; return(n);} #define GETC(x) (x=(*l_getc)()) #define Ungetc(x,y) (*l_ungetc)(x,y) - static int -l_R(int poststar, int reqint) +static int +l_R (int poststar, int reqint) { - char s[FMAX+EXPMAXDIGS+4]; - register int ch; - register char *sp, *spe, *sp1; - long e, exp; - int havenum, havestar, se; - - if (!poststar) { - if (f__lcount > 0) - return(0); - f__lcount = 1; - } + char s[FMAX + EXPMAXDIGS + 4]; + register int ch; + register char *sp, *spe, *sp1; + long e, exp; + int havenum, havestar, se; + + if (!poststar) + { + if (f__lcount > 0) + return (0); + f__lcount = 1; + } #ifdef Allow_TYQUAD - f__llx = 0; + f__llx = 0; #endif - f__ltype = 0; - exp = 0; - havestar = 0; + f__ltype = 0; + exp = 0; + havestar = 0; retry: - sp1 = sp = s; - spe = sp + FMAX; - havenum = 0; - - switch(GETC(ch)) { - case '-': *sp++ = ch; sp1++; spe++; - case '+': - GETC(ch); - } - while(ch == '0') { - ++havenum; - GETC(ch); - } - while(isdigit(ch)) { - if (sp < spe) *sp++ = ch; - else ++exp; - GETC(ch); - } - if (ch == '*' && !poststar) { - if (sp == sp1 || exp || *s == '-') { - errfl(f__elist->cierr,112,"bad repetition count"); - } - poststar = havestar = 1; - *sp = 0; - f__lcount = atoi(s); - goto retry; - } - if (ch == '.') { + sp1 = sp = s; + spe = sp + FMAX; + havenum = 0; + + switch (GETC (ch)) + { + case '-': + *sp++ = ch; + sp1++; + spe++; + case '+': + GETC (ch); + } + while (ch == '0') + { + ++havenum; + GETC (ch); + } + while (isdigit (ch)) + { + if (sp < spe) + *sp++ = ch; + else + ++exp; + GETC (ch); + } + if (ch == '*' && !poststar) + { + if (sp == sp1 || exp || *s == '-') + { + errfl (f__elist->cierr, 112, "bad repetition count"); + } + poststar = havestar = 1; + *sp = 0; + f__lcount = atoi (s); + goto retry; + } + if (ch == '.') + { #ifndef ALLOW_FLOAT_IN_INTEGER_LIST_INPUT - if (reqint) - errfl(f__elist->cierr,115,"invalid integer"); + if (reqint) + errfl (f__elist->cierr, 115, "invalid integer"); #endif - GETC(ch); - if (sp == sp1) - while(ch == '0') { - ++havenum; - --exp; - GETC(ch); - } - while(isdigit(ch)) { - if (sp < spe) - { *sp++ = ch; --exp; } - GETC(ch); - } - } - havenum += sp - sp1; - se = 0; - if (issign(ch)) - goto signonly; - if (havenum && isexp(ch)) { + GETC (ch); + if (sp == sp1) + while (ch == '0') + { + ++havenum; + --exp; + GETC (ch); + } + while (isdigit (ch)) + { + if (sp < spe) + { + *sp++ = ch; + --exp; + } + GETC (ch); + } + } + havenum += sp - sp1; + se = 0; + if (issign (ch)) + goto signonly; + if (havenum && isexp (ch)) + { #ifndef ALLOW_FLOAT_IN_INTEGER_LIST_INPUT - if (reqint) - errfl(f__elist->cierr,115,"invalid integer"); + if (reqint) + errfl (f__elist->cierr, 115, "invalid integer"); #endif - GETC(ch); - if (issign(ch)) { -signonly: - if (ch == '-') se = 1; - GETC(ch); - } - if (!isdigit(ch)) { -bad: - errfl(f__elist->cierr,112,"exponent field"); - } - - e = ch - '0'; - while(isdigit(GETC(ch))) { - e = 10*e + ch - '0'; - if (e > EXPMAX) - goto bad; - } - if (se) - exp -= e; - else - exp += e; - } - (void) Ungetc(ch, f__cf); - if (sp > sp1) { - ++havenum; - while(*--sp == '0') - ++exp; - if (exp) - sprintf(sp+1, "e%ld", exp); - else - sp[1] = 0; - f__lx = atof(s); + GETC (ch); + if (issign (ch)) + { + signonly: + if (ch == '-') + se = 1; + GETC (ch); + } + if (!isdigit (ch)) + { + bad: + errfl (f__elist->cierr, 112, "exponent field"); + } + + e = ch - '0'; + while (isdigit (GETC (ch))) + { + e = 10 * e + ch - '0'; + if (e > EXPMAX) + goto bad; + } + if (se) + exp -= e; + else + exp += e; + } + (void) Ungetc (ch, f__cf); + if (sp > sp1) + { + ++havenum; + while (*--sp == '0') + ++exp; + if (exp) + sprintf (sp + 1, "e%ld", exp); + else + sp[1] = 0; + f__lx = atof (s); #ifdef Allow_TYQUAD - if (reqint&2 && (se = sp - sp1 + exp) > 14 && se < 20) { - /* Assuming 64-bit longint and 32-bit long. */ - if (exp < 0) - sp += exp; - if (sp1 <= sp) { - f__llx = *sp1 - '0'; - while(++sp1 <= sp) - f__llx = 10*f__llx + (*sp1 - '0'); - } - while(--exp >= 0) - f__llx *= 10; - if (*s == '-') - f__llx = -f__llx; - } -#endif - } - else - f__lx = 0.; - if (havenum) - f__ltype = TYLONG; - else - switch(ch) { - case ',': - case '/': - break; - default: - if (havestar && ( ch == ' ' - ||ch == '\t' - ||ch == '\n')) - break; - if (nml_read > 1) { - f__lquit = 2; - return 0; - } - errfl(f__elist->cierr,112,"invalid number"); - } - return 0; + if (reqint & 2 && (se = sp - sp1 + exp) > 14 && se < 20) + { + /* Assuming 64-bit longint and 32-bit long. */ + if (exp < 0) + sp += exp; + if (sp1 <= sp) + { + f__llx = *sp1 - '0'; + while (++sp1 <= sp) + f__llx = 10 * f__llx + (*sp1 - '0'); + } + while (--exp >= 0) + f__llx *= 10; + if (*s == '-') + f__llx = -f__llx; } +#endif + } + else + f__lx = 0.; + if (havenum) + f__ltype = TYLONG; + else + switch (ch) + { + case ',': + case '/': + break; + default: + if (havestar && (ch == ' ' || ch == '\t' || ch == '\n')) + break; + if (nml_read > 1) + { + f__lquit = 2; + return 0; + } + errfl (f__elist->cierr, 112, "invalid number"); + } + return 0; +} - static int -rd_count(register int ch) +static int +rd_count (register int ch) { - if (ch < '0' || ch > '9') - return 1; - f__lcount = ch - '0'; - while(GETC(ch) >= '0' && ch <= '9') - f__lcount = 10*f__lcount + ch - '0'; - Ungetc(ch,f__cf); - return f__lcount <= 0; - } + if (ch < '0' || ch > '9') + return 1; + f__lcount = ch - '0'; + while (GETC (ch) >= '0' && ch <= '9') + f__lcount = 10 * f__lcount + ch - '0'; + Ungetc (ch, f__cf); + return f__lcount <= 0; +} - static int -l_C(void) -{ int ch, nml_save; - double lz; - if(f__lcount>0) return(0); - f__ltype=0; - GETC(ch); - if(ch!='(') +static int +l_C (void) +{ + int ch, nml_save; + double lz; + if (f__lcount > 0) + return (0); + f__ltype = 0; + GETC (ch); + if (ch != '(') + { + if (nml_read > 1 && (ch < '0' || ch > '9')) { - if (nml_read > 1 && (ch < '0' || ch > '9')) { - Ungetc(ch,f__cf); - f__lquit = 2; - return 0; - } - if (rd_count(ch)) - if(!f__cf || !feof(f__cf)) - errfl(f__elist->cierr,112,"complex format"); - else - err(f__elist->cierr,(EOF),"lread"); - if(GETC(ch)!='*') - { - if(!f__cf || !feof(f__cf)) - errfl(f__elist->cierr,112,"no star"); - else - err(f__elist->cierr,(EOF),"lread"); - } - if(GETC(ch)!='(') - { Ungetc(ch,f__cf); - return(0); - } + Ungetc (ch, f__cf); + f__lquit = 2; + return 0; } + if (rd_count (ch)) + if (!f__cf || !feof (f__cf)) + errfl (f__elist->cierr, 112, "complex format"); else - f__lcount = 1; - while(iswhit(GETC(ch))); - Ungetc(ch,f__cf); - nml_save = nml_read; - nml_read = 0; - if (ch = l_R(1,0)) - return ch; - if (!f__ltype) - errfl(f__elist->cierr,112,"no real part"); - lz = f__lx; - while(iswhit(GETC(ch))); - if(ch!=',') - { (void) Ungetc(ch,f__cf); - errfl(f__elist->cierr,112,"no comma"); + err (f__elist->cierr, (EOF), "lread"); + if (GETC (ch) != '*') + { + if (!f__cf || !feof (f__cf)) + errfl (f__elist->cierr, 112, "no star"); + else + err (f__elist->cierr, (EOF), "lread"); + } + if (GETC (ch) != '(') + { + Ungetc (ch, f__cf); + return (0); } - while(iswhit(GETC(ch))); - (void) Ungetc(ch,f__cf); - if (ch = l_R(1,0)) - return ch; - if (!f__ltype) - errfl(f__elist->cierr,112,"no imaginary part"); - while(iswhit(GETC(ch))); - if(ch!=')') errfl(f__elist->cierr,112,"no )"); - f__ly = f__lx; - f__lx = lz; + } + else + f__lcount = 1; + while (iswhit (GETC (ch))); + Ungetc (ch, f__cf); + nml_save = nml_read; + nml_read = 0; + if (ch = l_R (1, 0)) + return ch; + if (!f__ltype) + errfl (f__elist->cierr, 112, "no real part"); + lz = f__lx; + while (iswhit (GETC (ch))); + if (ch != ',') + { + (void) Ungetc (ch, f__cf); + errfl (f__elist->cierr, 112, "no comma"); + } + while (iswhit (GETC (ch))); + (void) Ungetc (ch, f__cf); + if (ch = l_R (1, 0)) + return ch; + if (!f__ltype) + errfl (f__elist->cierr, 112, "no imaginary part"); + while (iswhit (GETC (ch))); + if (ch != ')') + errfl (f__elist->cierr, 112, "no )"); + f__ly = f__lx; + f__lx = lz; #ifdef Allow_TYQUAD - f__llx = 0; + f__llx = 0; #endif - nml_read = nml_save; - return(0); + nml_read = nml_save; + return (0); } - static char nmLbuf[256], *nmL_next; - static int (*nmL_getc_save)(void); - static int (*nmL_ungetc_save)(int, FILE*); +static char nmLbuf[256], *nmL_next; +static int (*nmL_getc_save) (void); +static int (*nmL_ungetc_save) (int, FILE *); - static int -nmL_getc(void) +static int +nmL_getc (void) { - int rv; - if (rv = *nmL_next++) - return rv; - l_getc = nmL_getc_save; - l_ungetc = nmL_ungetc_save; - return (*l_getc)(); - } + int rv; + if (rv = *nmL_next++) + return rv; + l_getc = nmL_getc_save; + l_ungetc = nmL_ungetc_save; + return (*l_getc) (); +} - static int -nmL_ungetc(int x, FILE *f) +static int +nmL_ungetc (int x, FILE * f) { - f = f; /* banish non-use warning */ - return *--nmL_next = x; - } + f = f; /* banish non-use warning */ + return *--nmL_next = x; +} - static int -Lfinish(int ch, int dot, int *rvp) +static int +Lfinish (int ch, int dot, int *rvp) { - char *s, *se; - static char what[] = "namelist input"; - - s = nmLbuf + 2; - se = nmLbuf + sizeof(nmLbuf) - 1; - *s++ = ch; - while(!issep(GETC(ch)) && ch!=EOF) { - if (s >= se) { - nmLbuf_ovfl: - return *rvp = err__fl(f__elist->cierr,131,what); - } - *s++ = ch; - if (ch != '=') - continue; - if (dot) - return *rvp = err__fl(f__elist->cierr,112,what); - got_eq: - *s = 0; - nmL_getc_save = l_getc; - l_getc = nmL_getc; - nmL_ungetc_save = l_ungetc; - l_ungetc = nmL_ungetc; - nmLbuf[1] = *(nmL_next = nmLbuf) = ','; - *rvp = f__lcount = 0; - return 1; - } - if (dot) - goto done; - for(;;) { - if (s >= se) - goto nmLbuf_ovfl; - *s++ = ch; - if (!isblnk(ch)) - break; - if (GETC(ch) == EOF) - goto done; - } - if (ch == '=') - goto got_eq; - done: - Ungetc(ch, f__cf); - return 0; + char *s, *se; + static char what[] = "namelist input"; + + s = nmLbuf + 2; + se = nmLbuf + sizeof (nmLbuf) - 1; + *s++ = ch; + while (!issep (GETC (ch)) && ch != EOF) + { + if (s >= se) + { + nmLbuf_ovfl: + return *rvp = err__fl (f__elist->cierr, 131, what); } + *s++ = ch; + if (ch != '=') + continue; + if (dot) + return *rvp = err__fl (f__elist->cierr, 112, what); + got_eq: + *s = 0; + nmL_getc_save = l_getc; + l_getc = nmL_getc; + nmL_ungetc_save = l_ungetc; + l_ungetc = nmL_ungetc; + nmLbuf[1] = *(nmL_next = nmLbuf) = ','; + *rvp = f__lcount = 0; + return 1; + } + if (dot) + goto done; + for (;;) + { + if (s >= se) + goto nmLbuf_ovfl; + *s++ = ch; + if (!isblnk (ch)) + break; + if (GETC (ch) == EOF) + goto done; + } + if (ch == '=') + goto got_eq; +done: + Ungetc (ch, f__cf); + return 0; +} - static int -l_L(void) +static int +l_L (void) { - int ch, rv, sawdot; - if(f__lcount>0) - return(0); - f__lcount = 1; - f__ltype=0; - GETC(ch); - if(isdigit(ch)) + int ch, rv, sawdot; + if (f__lcount > 0) + return (0); + f__lcount = 1; + f__ltype = 0; + GETC (ch); + if (isdigit (ch)) + { + rd_count (ch); + if (GETC (ch) != '*') + if (!f__cf || !feof (f__cf)) + errfl (f__elist->cierr, 112, "no star"); + else + err (f__elist->cierr, (EOF), "lread"); + GETC (ch); + } + sawdot = 0; + if (ch == '.') + { + sawdot = 1; + GETC (ch); + } + switch (ch) + { + case 't': + case 'T': + if (nml_read && Lfinish (ch, sawdot, &rv)) + return rv; + f__lx = 1; + break; + case 'f': + case 'F': + if (nml_read && Lfinish (ch, sawdot, &rv)) + return rv; + f__lx = 0; + break; + default: + if (isblnk (ch) || issep (ch) || ch == EOF) { - rd_count(ch); - if(GETC(ch)!='*') - if(!f__cf || !feof(f__cf)) - errfl(f__elist->cierr,112,"no star"); - else - err(f__elist->cierr,(EOF),"lread"); - GETC(ch); + (void) Ungetc (ch, f__cf); + return (0); } - sawdot = 0; - if(ch == '.') { - sawdot = 1; - GETC(ch); - } - switch(ch) + if (nml_read > 1) { - case 't': - case 'T': - if (nml_read && Lfinish(ch, sawdot, &rv)) - return rv; - f__lx=1; - break; - case 'f': - case 'F': - if (nml_read && Lfinish(ch, sawdot, &rv)) - return rv; - f__lx=0; - break; - default: - if(isblnk(ch) || issep(ch) || ch==EOF) - { (void) Ungetc(ch,f__cf); - return(0); - } - if (nml_read > 1) { - Ungetc(ch,f__cf); - f__lquit = 2; - return 0; - } - errfl(f__elist->cierr,112,"logical"); + Ungetc (ch, f__cf); + f__lquit = 2; + return 0; } - f__ltype=TYLONG; - while(!issep(GETC(ch)) && ch!=EOF); - (void) Ungetc(ch, f__cf); - return(0); + errfl (f__elist->cierr, 112, "logical"); + } + f__ltype = TYLONG; + while (!issep (GETC (ch)) && ch != EOF); + (void) Ungetc (ch, f__cf); + return (0); } #define BUFSIZE 128 - static int -l_CHAR(void) -{ int ch,size,i; - static char rafail[] = "realloc failure"; - char quote,*p; - if(f__lcount>0) return(0); - f__ltype=0; - if(f__lchar!=NULL) free(f__lchar); - size=BUFSIZE; - p=f__lchar = (char *)malloc((unsigned int)size); - if(f__lchar == NULL) - errfl(f__elist->cierr,113,"no space"); - - GETC(ch); - if(isdigit(ch)) { - /* allow Fortran 8x-style unquoted string... */ - /* either find a repetition count or the string */ - f__lcount = ch - '0'; - *p++ = ch; - for(i = 1;;) { - switch(GETC(ch)) { - case '*': - if (f__lcount == 0) { - f__lcount = 1; -#ifndef F8X_NML_ELIDE_QUOTES - if (nml_read) - goto no_quote; -#endif - goto noquote; - } - p = f__lchar; - goto have_lcount; - case ',': - case ' ': - case '\t': - case '\n': - case '/': - Ungetc(ch,f__cf); - /* no break */ - case EOF: - f__lcount = 1; - f__ltype = TYCHAR; - return *p = 0; - } - if (!isdigit(ch)) { - f__lcount = 1; +static int +l_CHAR (void) +{ + int ch, size, i; + static char rafail[] = "realloc failure"; + char quote, *p; + if (f__lcount > 0) + return (0); + f__ltype = 0; + if (f__lchar != NULL) + free (f__lchar); + size = BUFSIZE; + p = f__lchar = (char *) malloc ((unsigned int) size); + if (f__lchar == NULL) + errfl (f__elist->cierr, 113, "no space"); + + GETC (ch); + if (isdigit (ch)) + { + /* allow Fortran 8x-style unquoted string... */ + /* either find a repetition count or the string */ + f__lcount = ch - '0'; + *p++ = ch; + for (i = 1;;) + { + switch (GETC (ch)) + { + case '*': + if (f__lcount == 0) + { + f__lcount = 1; #ifndef F8X_NML_ELIDE_QUOTES - if (nml_read) { - no_quote: - errfl(f__elist->cierr,112, - "undelimited character string"); - } + if (nml_read) + goto no_quote; #endif - goto noquote; - } - *p++ = ch; - f__lcount = 10*f__lcount + ch - '0'; - if (++i == size) { - f__lchar = (char *)realloc(f__lchar, - (unsigned int)(size += BUFSIZE)); - if(f__lchar == NULL) - errfl(f__elist->cierr,113,rafail); - p = f__lchar + i; - } - } - } - else (void) Ungetc(ch,f__cf); - have_lcount: - if(GETC(ch)=='\'' || ch=='"') quote=ch; - else if(isblnk(ch) || (issep(ch) && ch != '\n') || ch==EOF) { - Ungetc(ch,f__cf); - return 0; + goto noquote; } + p = f__lchar; + goto have_lcount; + case ',': + case ' ': + case '\t': + case '\n': + case '/': + Ungetc (ch, f__cf); + /* no break */ + case EOF: + f__lcount = 1; + f__ltype = TYCHAR; + return *p = 0; + } + if (!isdigit (ch)) + { + f__lcount = 1; #ifndef F8X_NML_ELIDE_QUOTES - else if (nml_read > 1) { - Ungetc(ch,f__cf); - f__lquit = 2; - return 0; - } -#endif - else { - /* Fortran 8x-style unquoted string */ - *p++ = ch; - for(i = 1;;) { - switch(GETC(ch)) { - case ',': - case ' ': - case '\t': - case '\n': - case '/': - Ungetc(ch,f__cf); - /* no break */ - case EOF: - f__ltype = TYCHAR; - return *p = 0; - } - noquote: - *p++ = ch; - if (++i == size) { - f__lchar = (char *)realloc(f__lchar, - (unsigned int)(size += BUFSIZE)); - if(f__lchar == NULL) - errfl(f__elist->cierr,113,rafail); - p = f__lchar + i; - } - } - } - f__ltype=TYCHAR; - for(i=0;;) - { while(GETC(ch)!=quote && ch!='\n' - && ch!=EOF && ++i<size) *p++ = ch; - if(i==size) + if (nml_read) { - newone: - f__lchar= (char *)realloc(f__lchar, - (unsigned int)(size += BUFSIZE)); - if(f__lchar == NULL) - errfl(f__elist->cierr,113,rafail); - p=f__lchar+i-1; - *p++ = ch; - } - else if(ch==EOF) return(EOF); - else if(ch=='\n') - { if(*(p-1) != '\\') continue; - i--; - p--; - if(++i<size) *p++ = ch; - else goto newone; - } - else if(GETC(ch)==quote) - { if(++i<size) *p++ = ch; - else goto newone; - } - else - { (void) Ungetc(ch,f__cf); - *p = 0; - return(0); + no_quote: + errfl (f__elist->cierr, 112, + "undelimited character string"); } +#endif + goto noquote; + } + *p++ = ch; + f__lcount = 10 * f__lcount + ch - '0'; + if (++i == size) + { + f__lchar = (char *) realloc (f__lchar, + (unsigned int) (size += BUFSIZE)); + if (f__lchar == NULL) + errfl (f__elist->cierr, 113, rafail); + p = f__lchar + i; + } + } + } + else + (void) Ungetc (ch, f__cf); +have_lcount: + if (GETC (ch) == '\'' || ch == '"') + quote = ch; + else if (isblnk (ch) || (issep (ch) && ch != '\n') || ch == EOF) + { + Ungetc (ch, f__cf); + return 0; + } +#ifndef F8X_NML_ELIDE_QUOTES + else if (nml_read > 1) + { + Ungetc (ch, f__cf); + f__lquit = 2; + return 0; + } +#endif + else + { + /* Fortran 8x-style unquoted string */ + *p++ = ch; + for (i = 1;;) + { + switch (GETC (ch)) + { + case ',': + case ' ': + case '\t': + case '\n': + case '/': + Ungetc (ch, f__cf); + /* no break */ + case EOF: + f__ltype = TYCHAR; + return *p = 0; + } + noquote: + *p++ = ch; + if (++i == size) + { + f__lchar = (char *) realloc (f__lchar, + (unsigned int) (size += BUFSIZE)); + if (f__lchar == NULL) + errfl (f__elist->cierr, 113, rafail); + p = f__lchar + i; + } } + } + f__ltype = TYCHAR; + for (i = 0;;) + { + while (GETC (ch) != quote && ch != '\n' && ch != EOF && ++i < size) + *p++ = ch; + if (i == size) + { + newone: + f__lchar = (char *) realloc (f__lchar, + (unsigned int) (size += BUFSIZE)); + if (f__lchar == NULL) + errfl (f__elist->cierr, 113, rafail); + p = f__lchar + i - 1; + *p++ = ch; + } + else if (ch == EOF) + return (EOF); + else if (ch == '\n') + { + if (*(p - 1) != '\\') + continue; + i--; + p--; + if (++i < size) + *p++ = ch; + else + goto newone; + } + else if (GETC (ch) == quote) + { + if (++i < size) + *p++ = ch; + else + goto newone; + } + else + { + (void) Ungetc (ch, f__cf); + *p = 0; + return (0); + } + } } -c_le(cilist *a) + +c_le (cilist * a) { - if(f__init != 1) f_init(); - f__init = 3; - f__fmtbuf="list io"; - f__curunit = &f__units[a->ciunit]; - f__fmtlen=7; - if(a->ciunit>=MXUNIT || a->ciunit<0) - err(a->cierr,101,"stler"); - f__scale=f__recpos=0; - f__elist=a; - if(f__curunit->ufd==NULL && fk_open(SEQ,FMT,a->ciunit)) - err(a->cierr,102,"lio"); - f__cf=f__curunit->ufd; - if(!f__curunit->ufmt) err(a->cierr,103,"lio"); - return(0); + if (f__init != 1) + f_init (); + f__init = 3; + f__fmtbuf = "list io"; + f__curunit = &f__units[a->ciunit]; + f__fmtlen = 7; + if (a->ciunit >= MXUNIT || a->ciunit < 0) + err (a->cierr, 101, "stler"); + f__scale = f__recpos = 0; + f__elist = a; + if (f__curunit->ufd == NULL && fk_open (SEQ, FMT, a->ciunit)) + err (a->cierr, 102, "lio"); + f__cf = f__curunit->ufd; + if (!f__curunit->ufmt) + err (a->cierr, 103, "lio"); + return (0); } -l_read(ftnint *number, char *ptr, ftnlen len, ftnint type) + +l_read (ftnint * number, char *ptr, ftnlen len, ftnint type) { #define Ptr ((flex *)ptr) - int i,n,ch; - doublereal *yy; - real *xx; - for(i=0;i<*number;i++) + int i, n, ch; + doublereal *yy; + real *xx; + for (i = 0; i < *number; i++) + { + if (f__lquit) + return (0); + if (l_eof) + err (f__elist->ciend, EOF, "list in"); + if (f__lcount == 0) { - if(f__lquit) return(0); - if(l_eof) - err(f__elist->ciend, EOF, "list in"); - if(f__lcount == 0) { - f__ltype = 0; - for(;;) { - GETC(ch); - switch(ch) { - case EOF: - err(f__elist->ciend,(EOF),"list in"); - case ' ': - case '\t': - case '\n': - continue; - case '/': - f__lquit = 1; - goto loopend; - case ',': - f__lcount = 1; - goto loopend; - default: - (void) Ungetc(ch, f__cf); - goto rddata; - } - } - } - rddata: - switch((int)type) + f__ltype = 0; + for (;;) + { + GETC (ch); + switch (ch) { - case TYINT1: - case TYSHORT: - case TYLONG: + case EOF: + err (f__elist->ciend, (EOF), "list in"); + case ' ': + case '\t': + case '\n': + continue; + case '/': + f__lquit = 1; + goto loopend; + case ',': + f__lcount = 1; + goto loopend; + default: + (void) Ungetc (ch, f__cf); + goto rddata; + } + } + } + rddata: + switch ((int) type) + { + case TYINT1: + case TYSHORT: + case TYLONG: #ifndef ALLOW_FLOAT_IN_INTEGER_LIST_INPUT - ERR(l_R(0,1)); - break; + ERR (l_R (0, 1)); + break; #endif - case TYREAL: - case TYDREAL: - ERR(l_R(0,0)); - break; + case TYREAL: + case TYDREAL: + ERR (l_R (0, 0)); + break; #ifdef TYQUAD - case TYQUAD: - n = l_R(0,2); - if (n) - return n; - break; + case TYQUAD: + n = l_R (0, 2); + if (n) + return n; + break; #endif - case TYCOMPLEX: - case TYDCOMPLEX: - ERR(l_C()); - break; - case TYLOGICAL1: - case TYLOGICAL2: - case TYLOGICAL: - ERR(l_L()); - break; - case TYCHAR: - ERR(l_CHAR()); - break; - } - while (GETC(ch) == ' ' || ch == '\t'); - if (ch != ',' || f__lcount > 1) - Ungetc(ch,f__cf); - loopend: - if(f__lquit) return(0); - if(f__cf && ferror(f__cf)) { - clearerr(f__cf); - errfl(f__elist->cierr,errno,"list in"); - } - if(f__ltype==0) goto bump; - switch((int)type) - { - case TYINT1: - case TYLOGICAL1: - Ptr->flchar = (char)f__lx; - break; - case TYLOGICAL2: - case TYSHORT: - Ptr->flshort = (short)f__lx; - break; - case TYLOGICAL: - case TYLONG: - Ptr->flint = (ftnint)f__lx; - break; + case TYCOMPLEX: + case TYDCOMPLEX: + ERR (l_C ()); + break; + case TYLOGICAL1: + case TYLOGICAL2: + case TYLOGICAL: + ERR (l_L ()); + break; + case TYCHAR: + ERR (l_CHAR ()); + break; + } + while (GETC (ch) == ' ' || ch == '\t'); + if (ch != ',' || f__lcount > 1) + Ungetc (ch, f__cf); + loopend: + if (f__lquit) + return (0); + if (f__cf && ferror (f__cf)) + { + clearerr (f__cf); + errfl (f__elist->cierr, errno, "list in"); + } + if (f__ltype == 0) + goto bump; + switch ((int) type) + { + case TYINT1: + case TYLOGICAL1: + Ptr->flchar = (char) f__lx; + break; + case TYLOGICAL2: + case TYSHORT: + Ptr->flshort = (short) f__lx; + break; + case TYLOGICAL: + case TYLONG: + Ptr->flint = (ftnint) f__lx; + break; #ifdef Allow_TYQUAD - case TYQUAD: - if (!(Ptr->fllongint = f__llx)) - Ptr->fllongint = f__lx; - break; + case TYQUAD: + if (!(Ptr->fllongint = f__llx)) + Ptr->fllongint = f__lx; + break; #endif - case TYREAL: - Ptr->flreal=f__lx; - break; - case TYDREAL: - Ptr->fldouble=f__lx; - break; - case TYCOMPLEX: - xx=(real *)ptr; - *xx++ = f__lx; - *xx = f__ly; - break; - case TYDCOMPLEX: - yy=(doublereal *)ptr; - *yy++ = f__lx; - *yy = f__ly; - break; - case TYCHAR: - b_char(f__lchar,ptr,len); - break; - } - bump: - if(f__lcount>0) f__lcount--; - ptr += len; - if (nml_read) - nml_read++; + case TYREAL: + Ptr->flreal = f__lx; + break; + case TYDREAL: + Ptr->fldouble = f__lx; + break; + case TYCOMPLEX: + xx = (real *) ptr; + *xx++ = f__lx; + *xx = f__ly; + break; + case TYDCOMPLEX: + yy = (doublereal *) ptr; + *yy++ = f__lx; + *yy = f__ly; + break; + case TYCHAR: + b_char (f__lchar, ptr, len); + break; } - return(0); + bump: + if (f__lcount > 0) + f__lcount--; + ptr += len; + if (nml_read) + nml_read++; + } + return (0); #undef Ptr } -integer s_rsle(cilist *a) + +integer +s_rsle (cilist * a) { - int n; - - f__reading=1; - f__external=1; - f__formatted=1; - if(n=c_le(a)) return(n); - f__lioproc = l_read; - f__lquit = 0; - f__lcount = 0; - l_eof = 0; - if(f__curunit->uwrt && f__nowreading(f__curunit)) - err(a->cierr,errno,"read start"); - if(f__curunit->uend) - err(f__elist->ciend,(EOF),"read start"); - l_getc = t_getc; - l_ungetc = un_getc; - f__doend = xrd_SL; - return(0); + int n; + + f__reading = 1; + f__external = 1; + f__formatted = 1; + if (n = c_le (a)) + return (n); + f__lioproc = l_read; + f__lquit = 0; + f__lcount = 0; + l_eof = 0; + if (f__curunit->uwrt && f__nowreading (f__curunit)) + err (a->cierr, errno, "read start"); + if (f__curunit->uend) + err (f__elist->ciend, (EOF), "read start"); + l_getc = t_getc; + l_ungetc = un_getc; + f__doend = xrd_SL; + return (0); } diff --git a/libf2c/libI77/lwrite.c b/libf2c/libI77/lwrite.c index f419ff6..c67bffc 100644 --- a/libf2c/libI77/lwrite.c +++ b/libf2c/libI77/lwrite.c @@ -7,260 +7,269 @@ ftnint L_len; int f__Aquote; static void -donewrec(void) +donewrec (void) { - if (f__recpos) - (*f__donewrec)(); - } + if (f__recpos) + (*f__donewrec) (); +} static void -lwrt_I(longint n) +lwrt_I (longint n) { - char *p; - int ndigit, sign; + char *p; + int ndigit, sign; - p = f__icvt(n, &ndigit, &sign, 10); - if(f__recpos + ndigit >= L_len) - donewrec(); - PUT(' '); - if (sign) - PUT('-'); - while(*p) - PUT(*p++); + p = f__icvt (n, &ndigit, &sign, 10); + if (f__recpos + ndigit >= L_len) + donewrec (); + PUT (' '); + if (sign) + PUT ('-'); + while (*p) + PUT (*p++); } static void -lwrt_L(ftnint n, ftnlen len) +lwrt_L (ftnint n, ftnlen len) { - if(f__recpos+LLOGW>=L_len) - donewrec(); - wrt_L((Uint *)&n,LLOGW, len); + if (f__recpos + LLOGW >= L_len) + donewrec (); + wrt_L ((Uint *) & n, LLOGW, len); } static void -lwrt_A(char *p, ftnlen len) +lwrt_A (char *p, ftnlen len) { - int a; - char *p1, *pe; + int a; + char *p1, *pe; - a = 0; - pe = p + len; - if (f__Aquote) { - a = 3; - if (len > 1 && p[len-1] == ' ') { - while(--len > 1 && p[len-1] == ' '); - pe = p + len; - } - p1 = p; - while(p1 < pe) - if (*p1++ == '\'') - a++; - } - if(f__recpos+len+a >= L_len) - donewrec(); - if (a + a = 0; + pe = p + len; + if (f__Aquote) + { + a = 3; + if (len > 1 && p[len - 1] == ' ') + { + while (--len > 1 && p[len - 1] == ' '); + pe = p + len; + } + p1 = p; + while (p1 < pe) + if (*p1++ == '\'') + a++; + } + if (f__recpos + len + a >= L_len) + donewrec (); + if (a #ifndef OMIT_BLANK_CC - || !f__recpos + || !f__recpos #endif - ) - PUT(' '); - if (a) { - PUT('\''); - while(p < pe) { - if (*p == '\'') - PUT('\''); - PUT(*p++); - } - PUT('\''); - } - else - while(p < pe) - PUT(*p++); + ) + PUT (' '); + if (a) + { + PUT ('\''); + while (p < pe) + { + if (*p == '\'') + PUT ('\''); + PUT (*p++); + } + PUT ('\''); + } + else + while (p < pe) + PUT (*p++); } - static int -l_g(char *buf, double n) +static int +l_g (char *buf, double n) { #ifdef Old_list_output - doublereal absn; - char *fmt; + doublereal absn; + char *fmt; - absn = n; - if (absn < 0) - absn = -absn; - fmt = LLOW <= absn && absn < LHIGH ? LFFMT : LEFMT; + absn = n; + if (absn < 0) + absn = -absn; + fmt = LLOW <= absn && absn < LHIGH ? LFFMT : LEFMT; #ifdef USE_STRLEN - sprintf(buf, fmt, n); - return strlen(buf); + sprintf (buf, fmt, n); + return strlen (buf); #else - return sprintf(buf, fmt, n); + return sprintf (buf, fmt, n); #endif #else - register char *b, c, c1; + register char *b, c, c1; - b = buf; - *b++ = ' '; - if (n < 0) { - *b++ = '-'; - n = -n; - } - else - *b++ = ' '; - if (n == 0) { - *b++ = '0'; - *b++ = '.'; - *b = 0; - goto f__ret; - } - sprintf(b, LGFMT, n); - switch(*b) { + b = buf; + *b++ = ' '; + if (n < 0) + { + *b++ = '-'; + n = -n; + } + else + *b++ = ' '; + if (n == 0) + { + *b++ = '0'; + *b++ = '.'; + *b = 0; + goto f__ret; + } + sprintf (b, LGFMT, n); + switch (*b) + { #ifndef WANT_LEAD_0 - case '0': - while(b[0] = b[1]) - b++; - break; + case '0': + while (b[0] = b[1]) + b++; + break; #endif - case 'i': - case 'I': - /* Infinity */ - case 'n': - case 'N': - /* NaN */ - while(*++b); - break; + case 'i': + case 'I': + /* Infinity */ + case 'n': + case 'N': + /* NaN */ + while (*++b); + break; - default: - /* Fortran 77 insists on having a decimal point... */ - for(;; b++) - switch(*b) { - case 0: - *b++ = '.'; - *b = 0; - goto f__ret; - case '.': - while(*++b); - goto f__ret; - case 'E': - for(c1 = '.', c = 'E'; *b = c1; - c1 = c, c = *++b); - goto f__ret; - } - } - f__ret: - return b - buf; + default: + /* Fortran 77 insists on having a decimal point... */ + for (;; b++) + switch (*b) + { + case 0: + *b++ = '.'; + *b = 0; + goto f__ret; + case '.': + while (*++b); + goto f__ret; + case 'E': + for (c1 = '.', c = 'E'; *b = c1; c1 = c, c = *++b); + goto f__ret; + } + } +f__ret: + return b - buf; #endif - } +} static void -l_put(register char *s) +l_put (register char *s) { - register void (*pn)(int) = f__putn; - register int c; + register void (*pn) (int) = f__putn; + register int c; - while(c = *s++) - (*pn)(c); - } + while (c = *s++) + (*pn) (c); +} static void -lwrt_F(double n) +lwrt_F (double n) { - char buf[LEFBL]; + char buf[LEFBL]; - if(f__recpos + l_g(buf,n) >= L_len) - donewrec(); - l_put(buf); + if (f__recpos + l_g (buf, n) >= L_len) + donewrec (); + l_put (buf); } static void -lwrt_C(double a, double b) +lwrt_C (double a, double b) { - char *ba, *bb, bufa[LEFBL], bufb[LEFBL]; - int al, bl; + char *ba, *bb, bufa[LEFBL], bufb[LEFBL]; + int al, bl; - al = l_g(bufa, a); - for(ba = bufa; *ba == ' '; ba++) - --al; - bl = l_g(bufb, b) + 1; /* intentionally high by 1 */ - for(bb = bufb; *bb == ' '; bb++) - --bl; - if(f__recpos + al + bl + 3 >= L_len) - donewrec(); + al = l_g (bufa, a); + for (ba = bufa; *ba == ' '; ba++) + --al; + bl = l_g (bufb, b) + 1; /* intentionally high by 1 */ + for (bb = bufb; *bb == ' '; bb++) + --bl; + if (f__recpos + al + bl + 3 >= L_len) + donewrec (); #ifdef OMIT_BLANK_CC - else + else #endif - PUT(' '); - PUT('('); - l_put(ba); - PUT(','); - if (f__recpos + bl >= L_len) { - (*f__donewrec)(); + PUT (' '); + PUT ('('); + l_put (ba); + PUT (','); + if (f__recpos + bl >= L_len) + { + (*f__donewrec) (); #ifndef OMIT_BLANK_CC - PUT(' '); + PUT (' '); #endif - } - l_put(bb); - PUT(')'); + } + l_put (bb); + PUT (')'); } -l_write(ftnint *number, char *ptr, ftnlen len, ftnint type) +l_write (ftnint * number, char *ptr, ftnlen len, ftnint type) { #define Ptr ((flex *)ptr) - int i; - longint x; - double y,z; - real *xx; - doublereal *yy; - for(i=0;i< *number; i++) + int i; + longint x; + double y, z; + real *xx; + doublereal *yy; + for (i = 0; i < *number; i++) + { + switch ((int) type) { - switch((int)type) - { - default: f__fatal(204,"unknown type in lio"); - case TYINT1: - x = Ptr->flchar; - goto xint; - case TYSHORT: - x=Ptr->flshort; - goto xint; + default: + f__fatal (204, "unknown type in lio"); + case TYINT1: + x = Ptr->flchar; + goto xint; + case TYSHORT: + x = Ptr->flshort; + goto xint; #ifdef Allow_TYQUAD - case TYQUAD: - x = Ptr->fllongint; - goto xint; + case TYQUAD: + x = Ptr->fllongint; + goto xint; #endif - case TYLONG: - x=Ptr->flint; - xint: lwrt_I(x); - break; - case TYREAL: - y=Ptr->flreal; - goto xfloat; - case TYDREAL: - y=Ptr->fldouble; - xfloat: lwrt_F(y); - break; - case TYCOMPLEX: - xx= &Ptr->flreal; - y = *xx++; - z = *xx; - goto xcomplex; - case TYDCOMPLEX: - yy = &Ptr->fldouble; - y= *yy++; - z = *yy; - xcomplex: - lwrt_C(y,z); - break; - case TYLOGICAL1: - x = Ptr->flchar; - goto xlog; - case TYLOGICAL2: - x = Ptr->flshort; - goto xlog; - case TYLOGICAL: - x = Ptr->flint; - xlog: lwrt_L(Ptr->flint, len); - break; - case TYCHAR: - lwrt_A(ptr,len); - break; - } - ptr += len; + case TYLONG: + x = Ptr->flint; + xint:lwrt_I (x); + break; + case TYREAL: + y = Ptr->flreal; + goto xfloat; + case TYDREAL: + y = Ptr->fldouble; + xfloat:lwrt_F (y); + break; + case TYCOMPLEX: + xx = &Ptr->flreal; + y = *xx++; + z = *xx; + goto xcomplex; + case TYDCOMPLEX: + yy = &Ptr->fldouble; + y = *yy++; + z = *yy; + xcomplex: + lwrt_C (y, z); + break; + case TYLOGICAL1: + x = Ptr->flchar; + goto xlog; + case TYLOGICAL2: + x = Ptr->flshort; + goto xlog; + case TYLOGICAL: + x = Ptr->flint; + xlog:lwrt_L (Ptr->flint, len); + break; + case TYCHAR: + lwrt_A (ptr, len); + break; } - return(0); + ptr += len; + } + return (0); } diff --git a/libf2c/libI77/open.c b/libf2c/libI77/open.c index 9e3ce67..b03ec34 100644 --- a/libf2c/libI77/open.c +++ b/libf2c/libI77/open.c @@ -6,7 +6,7 @@ #ifdef MSDOS #include "io.h" #else -#include "unistd.h" /* for access */ +#include "unistd.h" /* for access */ #endif #endif @@ -14,267 +14,287 @@ #undef min #undef max #include <stdlib.h> -extern int f__canseek(FILE*); -extern integer f_clos(cllist*); +extern int f__canseek (FILE *); +extern integer f_clos (cllist *); #ifdef NON_ANSI_RW_MODES -char *f__r_mode[2] = {"r", "r"}; -char *f__w_mode[4] = {"w", "w", "r+w", "r+w"}; +char *f__r_mode[2] = { "r", "r" }; +char *f__w_mode[4] = { "w", "w", "r+w", "r+w" }; #else -char *f__r_mode[2] = {"rb", "r"}; -char *f__w_mode[4] = {"wb", "w", "r+b", "r+"}; +char *f__r_mode[2] = { "rb", "r" }; +char *f__w_mode[4] = { "wb", "w", "r+b", "r+" }; #endif - static char f__buf0[400], *f__buf = f__buf0; - int f__buflen = (int)sizeof(f__buf0); +static char f__buf0[400], *f__buf = f__buf0; +int f__buflen = (int) sizeof (f__buf0); - static void -f__bufadj(int n, int c) +static void +f__bufadj (int n, int c) { - unsigned int len; - char *nbuf, *s, *t, *te; + unsigned int len; + char *nbuf, *s, *t, *te; - if (f__buf == f__buf0) - f__buflen = 1024; - while(f__buflen <= n) - f__buflen <<= 1; - len = (unsigned int)f__buflen; - if (len != f__buflen || !(nbuf = (char*)malloc(len))) - f__fatal(113, "malloc failure"); - s = nbuf; - t = f__buf; - te = t + c; - while(t < te) - *s++ = *t++; - if (f__buf != f__buf0) - free(f__buf); - f__buf = nbuf; - } + if (f__buf == f__buf0) + f__buflen = 1024; + while (f__buflen <= n) + f__buflen <<= 1; + len = (unsigned int) f__buflen; + if (len != f__buflen || !(nbuf = (char *) malloc (len))) + f__fatal (113, "malloc failure"); + s = nbuf; + t = f__buf; + te = t + c; + while (t < te) + *s++ = *t++; + if (f__buf != f__buf0) + free (f__buf); + f__buf = nbuf; +} - int -f__putbuf(int c) +int +f__putbuf (int c) { - char *s, *se; - int n; + char *s, *se; + int n; - if (f__hiwater > f__recpos) - f__recpos = f__hiwater; - n = f__recpos + 1; - if (n >= f__buflen) - f__bufadj(n, f__recpos); - s = f__buf; - se = s + f__recpos; - if (c) - *se++ = c; - *se = 0; - for(;;) { - fputs(s, f__cf); - s += strlen(s); - if (s >= se) - break; /* normally happens the first time */ - putc(*s++, f__cf); - } - return 0; - } + if (f__hiwater > f__recpos) + f__recpos = f__hiwater; + n = f__recpos + 1; + if (n >= f__buflen) + f__bufadj (n, f__recpos); + s = f__buf; + se = s + f__recpos; + if (c) + *se++ = c; + *se = 0; + for (;;) + { + fputs (s, f__cf); + s += strlen (s); + if (s >= se) + break; /* normally happens the first time */ + putc (*s++, f__cf); + } + return 0; +} - void -x_putc(int c) +void +x_putc (int c) { - if (f__recpos >= f__buflen) - f__bufadj(f__recpos, f__buflen); - f__buf[f__recpos++] = c; - } + if (f__recpos >= f__buflen) + f__bufadj (f__recpos, f__buflen); + f__buf[f__recpos++] = c; +} #define opnerr(f,m,s) \ do {if(f) {f__init &= ~2; errno= m;} else opn_err(m,s,a); return(m);} while(0) - static void -opn_err(int m, char *s, olist *a) +static void +opn_err (int m, char *s, olist * a) { - if (a->ofnm) { - /* supply file name to error message */ - if (a->ofnmlen >= f__buflen) - f__bufadj((int)a->ofnmlen, 0); - g_char(a->ofnm, a->ofnmlen, f__curunit->ufnm = f__buf); - } - f__fatal(m, s); - } + if (a->ofnm) + { + /* supply file name to error message */ + if (a->ofnmlen >= f__buflen) + f__bufadj ((int) a->ofnmlen, 0); + g_char (a->ofnm, a->ofnmlen, f__curunit->ufnm = f__buf); + } + f__fatal (m, s); +} -integer f_open(olist *a) -{ unit *b; - integer rv; - char buf[256], *s, *env; - cllist x; - int ufmt; - FILE *tf; - int fd, len; +integer +f_open (olist * a) +{ + unit *b; + integer rv; + char buf[256], *s, *env; + cllist x; + int ufmt; + FILE *tf; + int fd, len; #ifndef NON_UNIX_STDIO - int n; + int n; #endif - if(f__init != 1) f_init(); - f__external = 1; - if(a->ounit>=MXUNIT || a->ounit<0) - err(a->oerr,101,"open"); - f__curunit = b = &f__units[a->ounit]; - if(b->ufd) { - if(a->ofnm==0) - { - same: if (a->oblnk) - b->ublnk = *a->oblnk == 'z' || *a->oblnk == 'Z'; - return(0); - } + if (f__init != 1) + f_init (); + f__external = 1; + if (a->ounit >= MXUNIT || a->ounit < 0) + err (a->oerr, 101, "open"); + f__curunit = b = &f__units[a->ounit]; + if (b->ufd) + { + if (a->ofnm == 0) + { + same:if (a->oblnk) + b->ublnk = *a->oblnk == 'z' || *a->oblnk == 'Z'; + return (0); + } #ifdef NON_UNIX_STDIO - if (b->ufnm - && strlen(b->ufnm) == a->ofnmlen - && !strncmp(b->ufnm, a->ofnm, (unsigned)a->ofnmlen)) - goto same; + if (b->ufnm + && strlen (b->ufnm) == a->ofnmlen + && !strncmp (b->ufnm, a->ofnm, (unsigned) a->ofnmlen)) + goto same; #else - g_char(a->ofnm,a->ofnmlen,buf); - if (f__inode(buf,&n) == b->uinode && n == b->udev) - goto same; + g_char (a->ofnm, a->ofnmlen, buf); + if (f__inode (buf, &n) == b->uinode && n == b->udev) + goto same; #endif - x.cunit=a->ounit; - x.csta=0; - x.cerr=a->oerr; - if ((rv = f_clos(&x)) != 0) - return rv; - } - b->url = (int)a->orl; - b->ublnk = a->oblnk && (*a->oblnk == 'z' || *a->oblnk == 'Z'); - if(a->ofm==0) - { if(b->url>0) b->ufmt=0; - else b->ufmt=1; - } - else if(*a->ofm=='f' || *a->ofm == 'F') b->ufmt=1; - else b->ufmt=0; - ufmt = b->ufmt; + x.cunit = a->ounit; + x.csta = 0; + x.cerr = a->oerr; + if ((rv = f_clos (&x)) != 0) + return rv; + } + b->url = (int) a->orl; + b->ublnk = a->oblnk && (*a->oblnk == 'z' || *a->oblnk == 'Z'); + if (a->ofm == 0) + { + if (b->url > 0) + b->ufmt = 0; + else + b->ufmt = 1; + } + else if (*a->ofm == 'f' || *a->ofm == 'F') + b->ufmt = 1; + else + b->ufmt = 0; + ufmt = b->ufmt; #ifdef url_Adjust - if (b->url && !ufmt) - url_Adjust(b->url); + if (b->url && !ufmt) + url_Adjust (b->url); #endif - if (a->ofnm) { - g_char(a->ofnm,a->ofnmlen,buf); - if (!buf[0]) - opnerr(a->oerr,107,"open"); - } - else - sprintf(buf, "fort.%ld", (long)a->ounit); - b->uscrtch = 0; - b->uend=0; - b->uwrt = 0; - b->ufd = 0; - b->urw = 3; - switch(a->osta ? *a->osta : 'u') - { - case 'o': - case 'O': + if (a->ofnm) + { + g_char (a->ofnm, a->ofnmlen, buf); + if (!buf[0]) + opnerr (a->oerr, 107, "open"); + } + else + sprintf (buf, "fort.%ld", (long) a->ounit); + b->uscrtch = 0; + b->uend = 0; + b->uwrt = 0; + b->ufd = 0; + b->urw = 3; + switch (a->osta ? *a->osta : 'u') + { + case 'o': + case 'O': #ifdef NON_POSIX_STDIO - if (!(tf = fopen(buf,"r"))) - opnerr(a->oerr,errno,"open"); - fclose(tf); + if (!(tf = fopen (buf, "r"))) + opnerr (a->oerr, errno, "open"); + fclose (tf); #else - if (access(buf,0)) - opnerr(a->oerr,errno,"open"); + if (access (buf, 0)) + opnerr (a->oerr, errno, "open"); #endif - break; - case 's': - case 'S': - b->uscrtch=1; -#ifdef HAVE_MKSTEMP /* Allow use of TMPDIR preferentially. */ - env = getenv("TMPDIR"); - if (!env) env = getenv("TEMP"); - if (!env) env = "/tmp"; - len = strlen(env); - if (len > 256 - sizeof "/tmp.FXXXXXX") - err (a->oerr, 132, "open"); - strcpy(buf, env); - strcat(buf, "/tmp.FXXXXXX"); - fd = mkstemp(buf); - if (fd == -1 || close(fd)) - err (a->oerr, 132, "open"); + break; + case 's': + case 'S': + b->uscrtch = 1; +#ifdef HAVE_MKSTEMP /* Allow use of TMPDIR preferentially. */ + env = getenv ("TMPDIR"); + if (!env) + env = getenv ("TEMP"); + if (!env) + env = "/tmp"; + len = strlen (env); + if (len > 256 - sizeof "/tmp.FXXXXXX") + err (a->oerr, 132, "open"); + strcpy (buf, env); + strcat (buf, "/tmp.FXXXXXX"); + fd = mkstemp (buf); + if (fd == -1 || close (fd)) + err (a->oerr, 132, "open"); #else /* ! defined (HAVE_MKSTEMP) */ #ifdef HAVE_TEMPNAM /* Allow use of TMPDIR preferentially. */ - s = tempnam (0, buf); - if (strlen (s) >= sizeof (buf)) - err (a->oerr, 132, "open"); - (void) strcpy (buf, s); - free (s); + s = tempnam (0, buf); + if (strlen (s) >= sizeof (buf)) + err (a->oerr, 132, "open"); + (void) strcpy (buf, s); + free (s); #else /* ! defined (HAVE_TEMPNAM) */ #ifdef HAVE_TMPNAM - tmpnam(buf); + tmpnam (buf); #else - (void) strcpy(buf,"tmp.FXXXXXX"); - (void) mktemp(buf); + (void) strcpy (buf, "tmp.FXXXXXX"); + (void) mktemp (buf); #endif #endif /* ! defined (HAVE_TEMPNAM) */ #endif /* ! defined (HAVE_MKSTEMP) */ - goto replace; - case 'n': - case 'N': + goto replace; + case 'n': + case 'N': #ifdef NON_POSIX_STDIO - if ((tf = fopen(buf,"r")) || (tf = fopen(buf,"a"))) { - fclose(tf); - opnerr(a->oerr,128,"open"); - } + if ((tf = fopen (buf, "r")) || (tf = fopen (buf, "a"))) + { + fclose (tf); + opnerr (a->oerr, 128, "open"); + } #else - if (!access(buf,0)) - opnerr(a->oerr,128,"open"); + if (!access (buf, 0)) + opnerr (a->oerr, 128, "open"); #endif - /* no break */ - case 'r': /* Fortran 90 replace option */ - case 'R': - replace: - if (tf = fopen(buf,f__w_mode[0])) - fclose(tf); - } + /* no break */ + case 'r': /* Fortran 90 replace option */ + case 'R': + replace: + if (tf = fopen (buf, f__w_mode[0])) + fclose (tf); + } - b->ufnm=(char *) malloc((unsigned int)(strlen(buf)+1)); - if(b->ufnm==NULL) opnerr(a->oerr,113,"no space"); - (void) strcpy(b->ufnm,buf); - if ((s = a->oacc) && b->url) - ufmt = 0; - if(!(tf = fopen(buf, f__w_mode[ufmt|2]))) { - if (tf = fopen(buf, f__r_mode[ufmt])) - b->urw = 1; - else if (tf = fopen(buf, f__w_mode[ufmt])) { - b->uwrt = 1; - b->urw = 2; - } - else - err(a->oerr, errno, "open"); - } - b->useek = f__canseek(b->ufd = tf); + b->ufnm = (char *) malloc ((unsigned int) (strlen (buf) + 1)); + if (b->ufnm == NULL) + opnerr (a->oerr, 113, "no space"); + (void) strcpy (b->ufnm, buf); + if ((s = a->oacc) && b->url) + ufmt = 0; + if (!(tf = fopen (buf, f__w_mode[ufmt | 2]))) + { + if (tf = fopen (buf, f__r_mode[ufmt])) + b->urw = 1; + else if (tf = fopen (buf, f__w_mode[ufmt])) + { + b->uwrt = 1; + b->urw = 2; + } + else + err (a->oerr, errno, "open"); + } + b->useek = f__canseek (b->ufd = tf); #ifndef NON_UNIX_STDIO - if((b->uinode = f__inode(buf,&b->udev)) == -1) - opnerr(a->oerr,108,"open"); + if ((b->uinode = f__inode (buf, &b->udev)) == -1) + opnerr (a->oerr, 108, "open"); #endif - if(b->useek) - if (a->orl) - FSEEK(b->ufd, 0, SEEK_SET); - else if ((s = a->oacc) && (*s == 'a' || *s == 'A') - && FSEEK(b->ufd, 0, SEEK_END)) - opnerr(a->oerr,129,"open"); - return(0); + if (b->useek) + if (a->orl) + FSEEK (b->ufd, 0, SEEK_SET); + else if ((s = a->oacc) && (*s == 'a' || *s == 'A') + && FSEEK (b->ufd, 0, SEEK_END)) + opnerr (a->oerr, 129, "open"); + return (0); } -fk_open(int seq, int fmt, ftnint n) -{ char nbuf[10]; - olist a; - int rtn; - int save_init; - (void) sprintf(nbuf,"fort.%ld",(long)n); - a.oerr=1; - a.ounit=n; - a.ofnm=nbuf; - a.ofnmlen=strlen(nbuf); - a.osta=NULL; - a.oacc= seq==SEQ?"s":"d"; - a.ofm = fmt==FMT?"f":"u"; - a.orl = seq==DIR?1:0; - a.oblnk=NULL; - save_init = f__init; - f__init &= ~2; - rtn = f_open(&a); - f__init = save_init | 1; - return rtn; +fk_open (int seq, int fmt, ftnint n) +{ + char nbuf[10]; + olist a; + int rtn; + int save_init; + + (void) sprintf (nbuf, "fort.%ld", (long) n); + a.oerr = 1; + a.ounit = n; + a.ofnm = nbuf; + a.ofnmlen = strlen (nbuf); + a.osta = NULL; + a.oacc = seq == SEQ ? "s" : "d"; + a.ofm = fmt == FMT ? "f" : "u"; + a.orl = seq == DIR ? 1 : 0; + a.oblnk = NULL; + save_init = f__init; + f__init &= ~2; + rtn = f_open (&a); + f__init = save_init | 1; + return rtn; } diff --git a/libf2c/libI77/rdfmt.c b/libf2c/libI77/rdfmt.c index 4da8ed6..f6a9185 100644 --- a/libf2c/libI77/rdfmt.c +++ b/libf2c/libI77/rdfmt.c @@ -12,491 +12,602 @@ extern int f__cursor; #include "fmt.h" #include "fp.h" - static int -rd_Z(Uint *n, int w, ftnlen len) +static int +rd_Z (Uint * n, int w, ftnlen len) { - 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; + 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; - if (!hex['0']) { - s = "0123456789"; - while(ch = *s++) - hex[ch] = ch - '0' + 1; - s = "ABCDEF"; - while(ch = *s++) - hex[ch] = hex[ch + 'a' - 'A'] = ch - 'A' + 11; - } - s = s0 = (char *)x; - s1 = (char *)&x[4]; - se = (char *)&x[8]; - if (len > 4*sizeof(long)) - 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; - } - } - } - if (bad) - return errno = 115; - w = (int)len; - w1 = s - s0; - w2 = w1+1 >> 1; - 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 { - *t = hex[*s0 & 0xff]-1 << 4 | hex[s0[1] & 0xff]-1; - t += i; - s0 += 2; - } - while(--w); - return 0; + if (!hex['0']) + { + s = "0123456789"; + while (ch = *s++) + hex[ch] = ch - '0' + 1; + s = "ABCDEF"; + while (ch = *s++) + hex[ch] = hex[ch + 'a' - 'A'] = ch - 'A' + 11; + } + s = s0 = (char *) x; + s1 = (char *) &x[4]; + se = (char *) &x[8]; + if (len > 4 * sizeof (long)) + 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; + } } + } + if (bad) + return errno = 115; + w = (int) len; + w1 = s - s0; + w2 = w1 + 1 >> 1; + 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 + { + *t = hex[*s0 & 0xff] - 1 << 4 | hex[s0[1] & 0xff] - 1; + t += i; + s0 += 2; + } + while (--w); + return 0; +} - static int -rd_I(Uint *n, int w, ftnlen len, register int base) +static int +rd_I (Uint * n, int w, ftnlen len, register int base) { - int bad, ch, sign; - longint x = 0; + int bad, ch, sign; + longint x = 0; - 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; + 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; #ifdef Allow_TYQUAD - else if (len == sizeof(longint)) - n->ili = x; + else if (len == sizeof (longint)) + n->ili = x; #endif - else - n->is = (short)x; - if (w) { - while(--w) - GET(ch); - return errno = 115; - } - return 0; + else + n->is = (short) x; + if (w) + { + while (--w) + GET (ch); + return errno = 115; + } + return 0; } - static int -rd_L(ftnint *n, int w, ftnlen len) -{ int ch, dot, lv; +static int +rd_L (ftnint * n, int w, ftnlen len) +{ + int ch, dot, lv; - 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; + 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; } - static int -rd_F(ufloat *p, int w, int d, ftnlen len) +static int +rd_F (ufloat * p, int w, int d, ftnlen len) { - char s[FMAX+EXPMAXDIGS+4]; - register int ch; - register char *sp, *spe, *sp1; - double x; - int scale1, se; - long e, exp; + char s[FMAX + EXPMAXDIGS + 4]; + register int ch; + register char *sp, *spe, *sp1; + double x; + int scale1, se; + long e, exp; - sp1 = sp = s; - spe = sp + FMAX; - exp = -d; - x = 0.; + sp1 = sp = s; + spe = sp + FMAX; + exp = -d; + x = 0.; - 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; + 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; - e = ch - '0'; - for(;;) { - if (!w--) - { ch = '\n'; break; } - GET(ch); - if (!isdigit(ch)) { - if (ch == ' ') { - if (f__cblank) - ch = '0'; - else continue; - } - else - break; - } - e = 10*e + ch - '0'; - if (e > EXPMAX && sp > sp1) - goto bad; - } - if (se) - exp -= e; - else - exp += e; - scale1 = 0; + e = ch - '0'; + for (;;) + { + if (!w--) + { + ch = '\n'; + break; + } + GET (ch); + if (!isdigit (ch)) + { + if (ch == ' ') + { + if (f__cblank) + ch = '0'; + else + continue; } - switch(ch) { - case '\n': - case ',': + else break; - default: -bad: - return (errno = 115); - } + } + 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); + } done: - if (sp > sp1) { - while(*--sp == '0') - ++exp; - if (exp -= scale1) - sprintf(sp+1, "e%ld", exp); - else - sp[1] = 0; - x = atof(s); - } + if (sp > sp1) + { + while (*--sp == '0') + ++exp; + if (exp -= scale1) + sprintf (sp + 1, "e%ld", exp); + else + sp[1] = 0; + x = atof (s); + } zero: - if (len == sizeof(real)) - p->pf = x; - else - p->pd = x; - return(0); - } + if (len == sizeof (real)) + p->pf = x; + else + p->pd = x; + return (0); +} - static int -rd_A(char *p, ftnlen len) -{ int i,ch; - for(i=0;i<len;i++) - { GET(ch); - *p++=VAL(ch); - } - return(0); +static int +rd_A (char *p, ftnlen len) +{ + int i, ch; + for (i = 0; i < len; i++) + { + GET (ch); + *p++ = VAL (ch); + } + return (0); } - 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); - } - return(0); - } - for(i=0;i<w;i++) - { GET(ch); - *p++=VAL(ch); +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); } - for(i=0;i<len-w;i++) *p++=' '; - return(0); + return (0); + } + for (i = 0; i < w; i++) + { + GET (ch); + *p++ = VAL (ch); + } + for (i = 0; i < len - w; i++) + *p++ = ' '; + return (0); } - 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); +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); } - 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); +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); } -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) { - 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) + +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) { - 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; + 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; - /* 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. */ + /* 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. */ - 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; + 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; - /* Z and ZM assume 8-bit bytes. */ + /* Z and ZM assume 8-bit bytes. */ - 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); + 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); } -rd_ned(struct syl *p) + +rd_ned (struct syl * p) { - 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); - } + 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); + } } diff --git a/libf2c/libI77/rewind.c b/libf2c/libI77/rewind.c index 39c2dae..d7a9b76 100644 --- a/libf2c/libI77/rewind.c +++ b/libf2c/libI77/rewind.c @@ -1,23 +1,25 @@ #include "config.h" #include "f2c.h" #include "fio.h" -integer f_rew(alist *a) +integer +f_rew (alist * a) { - unit *b; - if (f__init & 2) - f__fatal (131, "I/O recursion"); - if(a->aunit>=MXUNIT || a->aunit<0) - err(a->aerr,101,"rewind"); - b = &f__units[a->aunit]; - if(b->ufd == NULL || b->uwrt == 3) - return(0); - if(!b->useek) - err(a->aerr,106,"rewind"); - if(b->uwrt) { - (void) t_runc(a); - b->uwrt = 3; - } - FSEEK(b->ufd, 0, SEEK_SET); - b->uend=0; - return(0); + unit *b; + if (f__init & 2) + f__fatal (131, "I/O recursion"); + if (a->aunit >= MXUNIT || a->aunit < 0) + err (a->aerr, 101, "rewind"); + b = &f__units[a->aunit]; + if (b->ufd == NULL || b->uwrt == 3) + return (0); + if (!b->useek) + err (a->aerr, 106, "rewind"); + if (b->uwrt) + { + (void) t_runc (a); + b->uwrt = 3; + } + FSEEK (b->ufd, 0, SEEK_SET); + b->uend = 0; + return (0); } diff --git a/libf2c/libI77/rsfe.c b/libf2c/libI77/rsfe.c index 675db1d..fb332a4 100644 --- a/libf2c/libI77/rsfe.c +++ b/libf2c/libI77/rsfe.c @@ -4,74 +4,90 @@ #include "fio.h" #include "fmt.h" -xrd_SL(void) -{ int ch; - if(!f__curunit->uend) - while((ch=getc(f__cf))!='\n') - if (ch == EOF) { - f__curunit->uend = 1; - break; - } - f__cursor=f__recpos=0; - return(1); -} -x_getc(void) -{ int ch; - if(f__curunit->uend) return(EOF); - ch = getc(f__cf); - if(ch!=EOF && ch!='\n') - { f__recpos++; - return(ch); - } - if(ch=='\n') - { (void) ungetc(ch,f__cf); - return(ch); - } - if(f__curunit->uend || feof(f__cf)) - { errno=0; - f__curunit->uend=1; - return(-1); +xrd_SL (void) +{ + int ch; + if (!f__curunit->uend) + while ((ch = getc (f__cf)) != '\n') + if (ch == EOF) + { + f__curunit->uend = 1; + break; } - return(-1); + f__cursor = f__recpos = 0; + return (1); } -x_endp(void) + +x_getc (void) { - xrd_SL(); - return f__curunit->uend == 1 ? EOF : 0; + int ch; + if (f__curunit->uend) + return (EOF); + ch = getc (f__cf); + if (ch != EOF && ch != '\n') + { + f__recpos++; + return (ch); + } + if (ch == '\n') + { + (void) ungetc (ch, f__cf); + return (ch); + } + if (f__curunit->uend || feof (f__cf)) + { + errno = 0; + f__curunit->uend = 1; + return (-1); + } + return (-1); } -x_rev(void) + +x_endp (void) { - (void) xrd_SL(); - return(0); + xrd_SL (); + return f__curunit->uend == 1 ? EOF : 0; } -integer s_rsfe(cilist *a) /* start */ -{ int n; - if(f__init != 1) f_init(); - f__init = 3; - f__reading=1; - f__sequential=1; - f__formatted=1; - f__external=1; - if(n=c_sfe(a)) return(n); - f__elist=a; - f__cursor=f__recpos=0; - f__scale=0; - f__fmtbuf=a->cifmt; - f__curunit= &f__units[a->ciunit]; - f__cf=f__curunit->ufd; - if(pars_f(f__fmtbuf)<0) err(a->cierr,100,"startio"); - f__getn= x_getc; - f__doed= rd_ed; - f__doned= rd_ned; - fmt_bg(); - f__doend=x_endp; - f__donewrec=xrd_SL; - f__dorevert=x_rev; - f__cblank=f__curunit->ublnk; - f__cplus=0; - if(f__curunit->uwrt && f__nowreading(f__curunit)) - err(a->cierr,errno,"read start"); - if(f__curunit->uend) - err(f__elist->ciend,(EOF),"read start"); - return(0); + +x_rev (void) +{ + (void) xrd_SL (); + return (0); +} + +integer +s_rsfe (cilist * a) /* start */ +{ + int n; + if (f__init != 1) + f_init (); + f__init = 3; + f__reading = 1; + f__sequential = 1; + f__formatted = 1; + f__external = 1; + if (n = c_sfe (a)) + return (n); + f__elist = a; + f__cursor = f__recpos = 0; + f__scale = 0; + f__fmtbuf = a->cifmt; + f__curunit = &f__units[a->ciunit]; + f__cf = f__curunit->ufd; + if (pars_f (f__fmtbuf) < 0) + err (a->cierr, 100, "startio"); + f__getn = x_getc; + f__doed = rd_ed; + f__doned = rd_ned; + fmt_bg (); + f__doend = x_endp; + f__donewrec = xrd_SL; + f__dorevert = x_rev; + f__cblank = f__curunit->ublnk; + f__cplus = 0; + if (f__curunit->uwrt && f__nowreading (f__curunit)) + err (a->cierr, errno, "read start"); + if (f__curunit->uend) + err (f__elist->ciend, (EOF), "read start"); + return (0); } diff --git a/libf2c/libI77/rsli.c b/libf2c/libI77/rsli.c index 6648185..a5cd8c5 100644 --- a/libf2c/libI77/rsli.c +++ b/libf2c/libI77/rsli.c @@ -1,7 +1,7 @@ #include "f2c.h" #include "fio.h" #include "lio.h" -#include "fmt.h" /* for f__doend */ +#include "fmt.h" /* for f__doend */ extern flag f__lquit; extern int f__lcount; @@ -10,80 +10,89 @@ extern char *f__icend; extern icilist *f__svic; extern int f__icnum, f__recpos; -static int i_getc(void) +static int +i_getc (void) { - if(f__recpos >= f__svic->icirlen) { - if (f__recpos++ == f__svic->icirlen) - return '\n'; - z_rnew(); - } - f__recpos++; - if(f__icptr >= f__icend) - return EOF; - return(*f__icptr++); - } + if (f__recpos >= f__svic->icirlen) + { + if (f__recpos++ == f__svic->icirlen) + return '\n'; + z_rnew (); + } + f__recpos++; + if (f__icptr >= f__icend) + return EOF; + return (*f__icptr++); +} - static -int i_ungetc(int ch, FILE *f) +static int +i_ungetc (int ch, FILE * f) { - if (--f__recpos == f__svic->icirlen) - return '\n'; - if (f__recpos < -1) - err(f__svic->icierr,110,"recend"); - /* *--icptr == ch, and icptr may point to read-only memory */ - return *--f__icptr /* = ch */; - } + if (--f__recpos == f__svic->icirlen) + return '\n'; + if (f__recpos < -1) + err (f__svic->icierr, 110, "recend"); + /* *--icptr == ch, and icptr may point to read-only memory */ + return *--f__icptr /* = ch */ ; +} - static void -c_lir(icilist *a) +static void +c_lir (icilist * a) { - extern int l_eof; - if(f__init != 1) f_init(); - f__init = 3; - f__reading = 1; - f__external = 0; - f__formatted = 1; - f__svic = a; - L_len = a->icirlen; - f__recpos = -1; - f__icnum = f__recpos = 0; - f__cursor = 0; - l_getc = i_getc; - l_ungetc = i_ungetc; - l_eof = 0; - f__icptr = a->iciunit; - f__icend = f__icptr + a->icirlen*a->icirnum; - f__cf = 0; - f__curunit = 0; - f__elist = (cilist *)a; - } + extern int l_eof; + if (f__init != 1) + f_init (); + f__init = 3; + f__reading = 1; + f__external = 0; + f__formatted = 1; + f__svic = a; + L_len = a->icirlen; + f__recpos = -1; + f__icnum = f__recpos = 0; + f__cursor = 0; + l_getc = i_getc; + l_ungetc = i_ungetc; + l_eof = 0; + f__icptr = a->iciunit; + f__icend = f__icptr + a->icirlen * a->icirnum; + f__cf = 0; + f__curunit = 0; + f__elist = (cilist *) a; +} -integer s_rsli(icilist *a) +integer +s_rsli (icilist * a) { - f__lioproc = l_read; - f__lquit = 0; - f__lcount = 0; - c_lir(a); - f__doend = 0; - return(0); - } + f__lioproc = l_read; + f__lquit = 0; + f__lcount = 0; + c_lir (a); + f__doend = 0; + return (0); +} -integer e_rsli(void) -{ f__init = 1; return 0; } +integer +e_rsli (void) +{ + f__init = 1; + return 0; +} -extern int x_rsne(cilist*); +extern int x_rsne (cilist *); -integer s_rsni(icilist *a) +integer +s_rsni (icilist * a) { - extern int nml_read; - integer rv; - cilist ca; - ca.ciend = a->iciend; - ca.cierr = a->icierr; - ca.cifmt = a->icifmt; - c_lir(a); - rv = x_rsne(&ca); - nml_read = 0; - return rv; - } + extern int nml_read; + integer rv; + cilist ca; + ca.ciend = a->iciend; + ca.cierr = a->icierr; + ca.cifmt = a->icifmt; + c_lir (a); + rv = x_rsne (&ca); + nml_read = 0; + return rv; +} diff --git a/libf2c/libI77/rsne.c b/libf2c/libI77/rsne.c index dbd1b39..9dea279 100644 --- a/libf2c/libI77/rsne.c +++ b/libf2c/libI77/rsne.c @@ -3,41 +3,44 @@ #include "fio.h" #include "lio.h" -#define MAX_NL_CACHE 3 /* maximum number of namelist hash tables to cache */ -#define MAXDIM 20 /* maximum number of subscripts */ +#define MAX_NL_CACHE 3 /* maximum number of namelist hash tables to cache */ +#define MAXDIM 20 /* maximum number of subscripts */ - struct dimen { - ftnlen extent; - ftnlen curval; - ftnlen delta; - ftnlen stride; - }; - typedef struct dimen dimen; +struct dimen +{ + ftnlen extent; + ftnlen curval; + ftnlen delta; + ftnlen stride; +}; +typedef struct dimen dimen; - struct hashentry { - struct hashentry *next; - char *name; - Vardesc *vd; - }; - typedef struct hashentry hashentry; +struct hashentry +{ + struct hashentry *next; + char *name; + Vardesc *vd; +}; +typedef struct hashentry hashentry; - struct hashtab { - struct hashtab *next; - Namelist *nl; - int htsize; - hashentry *tab[1]; - }; - typedef struct hashtab hashtab; +struct hashtab +{ + struct hashtab *next; + Namelist *nl; + int htsize; + hashentry *tab[1]; +}; +typedef struct hashtab hashtab; - static hashtab *nl_cache; - static int n_nlcache; - static hashentry **zot; - static int colonseen; - extern ftnlen f__typesize[]; +static hashtab *nl_cache; +static int n_nlcache; +static hashentry **zot; +static int colonseen; +extern ftnlen f__typesize[]; - extern flag f__lquit; - extern int f__lcount, nml_read; - extern t_getc(void); +extern flag f__lquit; +extern int f__lcount, nml_read; +extern t_getc (void); #undef abs #undef min @@ -46,516 +49,548 @@ #include <string.h> #ifdef ungetc - static int -un_getc(int x, FILE *f__cf) -{ return ungetc(x,f__cf); } +static int +un_getc (int x, FILE * f__cf) +{ + return ungetc (x, f__cf); +} #else #define un_getc ungetc -extern int ungetc(int, FILE*); /* for systems with a buggy stdio.h */ +extern int ungetc (int, FILE *); /* for systems with a buggy stdio.h */ #endif - static Vardesc * -hash(hashtab *ht, register char *s) +static Vardesc * +hash (hashtab * ht, register char *s) { - register int c, x; - register hashentry *h; - char *s0 = s; + register int c, x; + register hashentry *h; + char *s0 = s; - for(x = 0; c = *s++; x = x & 0x4000 ? ((x << 1) & 0x7fff) + 1 : x << 1) - x += c; - for(h = *(zot = ht->tab + x % ht->htsize); h; h = h->next) - if (!strcmp(s0, h->name)) - return h->vd; - return 0; - } + for (x = 0; c = *s++; x = x & 0x4000 ? ((x << 1) & 0x7fff) + 1 : x << 1) + x += c; + for (h = *(zot = ht->tab + x % ht->htsize); h; h = h->next) + if (!strcmp (s0, h->name)) + return h->vd; + return 0; +} - hashtab * -mk_hashtab(Namelist *nl) +hashtab * +mk_hashtab (Namelist * nl) { - int nht, nv; - hashtab *ht; - Vardesc *v, **vd, **vde; - hashentry *he; + int nht, nv; + hashtab *ht; + Vardesc *v, **vd, **vde; + hashentry *he; - hashtab **x, **x0, *y; - for(x = &nl_cache; y = *x; x0 = x, x = &y->next) - if (nl == y->nl) - return y; - if (n_nlcache >= MAX_NL_CACHE) { - /* discard least recently used namelist hash table */ - y = *x0; - free((char *)y->next); - y->next = 0; - } - else - n_nlcache++; - nv = nl->nvars; - if (nv >= 0x4000) - nht = 0x7fff; - else { - for(nht = 1; nht < nv; nht <<= 1); - nht += nht - 1; - } - ht = (hashtab *)malloc(sizeof(hashtab) + (nht-1)*sizeof(hashentry *) - + nv*sizeof(hashentry)); - if (!ht) - return 0; - he = (hashentry *)&ht->tab[nht]; - ht->nl = nl; - ht->htsize = nht; - ht->next = nl_cache; - nl_cache = ht; - memset((char *)ht->tab, 0, nht*sizeof(hashentry *)); - vd = nl->vars; - vde = vd + nv; - while(vd < vde) { - v = *vd++; - if (!hash(ht, v->name)) { - he->next = *zot; - *zot = he; - he->name = v->name; - he->vd = v; - he++; - } - } - return ht; + hashtab **x, **x0, *y; + for (x = &nl_cache; y = *x; x0 = x, x = &y->next) + if (nl == y->nl) + return y; + if (n_nlcache >= MAX_NL_CACHE) + { + /* discard least recently used namelist hash table */ + y = *x0; + free ((char *) y->next); + y->next = 0; + } + else + n_nlcache++; + nv = nl->nvars; + if (nv >= 0x4000) + nht = 0x7fff; + else + { + for (nht = 1; nht < nv; nht <<= 1); + nht += nht - 1; + } + ht = (hashtab *) malloc (sizeof (hashtab) + (nht - 1) * sizeof (hashentry *) + + nv * sizeof (hashentry)); + if (!ht) + return 0; + he = (hashentry *) & ht->tab[nht]; + ht->nl = nl; + ht->htsize = nht; + ht->next = nl_cache; + nl_cache = ht; + memset ((char *) ht->tab, 0, nht * sizeof (hashentry *)); + vd = nl->vars; + vde = vd + nv; + while (vd < vde) + { + v = *vd++; + if (!hash (ht, v->name)) + { + he->next = *zot; + *zot = he; + he->name = v->name; + he->vd = v; + he++; } + } + return ht; +} static char Alpha[256], Alphanum[256]; static void -nl_init(void) { - register char *s; - register int c; +nl_init (void) +{ + register char *s; + register int c; - for(s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; c = *s++; ) - Alpha[c] - = Alphanum[c] - = Alpha[c + 'a' - 'A'] - = Alphanum[c + 'a' - 'A'] - = c; - for(s = "0123456789_"; c = *s++; ) - Alphanum[c] = c; - } + for (s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; c = *s++;) + Alpha[c] + = Alphanum[c] = Alpha[c + 'a' - 'A'] = Alphanum[c + 'a' - 'A'] = c; + for (s = "0123456789_"; c = *s++;) + Alphanum[c] = c; +} #define GETC(x) (x=(*l_getc)()) #define Ungetc(x,y) (*l_ungetc)(x,y) - static int -getname(register char *s, int slen) +static int +getname (register char *s, int slen) { - register char *se = s + slen - 1; - register int ch; + register char *se = s + slen - 1; + register int ch; - GETC(ch); - if (!(*s++ = Alpha[ch & 0xff])) { - if (ch != EOF) - ch = 115; - errfl(f__elist->cierr, ch, "namelist read"); - } - while(*s = Alphanum[GETC(ch) & 0xff]) - if (s < se) - s++; - if (ch == EOF) - err(f__elist->cierr, EOF, "namelist read"); - if (ch > ' ') - Ungetc(ch,f__cf); - return *s = 0; - } + GETC (ch); + if (!(*s++ = Alpha[ch & 0xff])) + { + if (ch != EOF) + ch = 115; + errfl (f__elist->cierr, ch, "namelist read"); + } + while (*s = Alphanum[GETC (ch) & 0xff]) + if (s < se) + s++; + if (ch == EOF) + err (f__elist->cierr, EOF, "namelist read"); + if (ch > ' ') + Ungetc (ch, f__cf); + return *s = 0; +} - static int -getnum(int *chp, ftnlen *val) +static int +getnum (int *chp, ftnlen * val) { - register int ch, sign; - register ftnlen x; + register int ch, sign; + register ftnlen x; - while(GETC(ch) <= ' ' && ch >= 0); - if (ch == '-') { - sign = 1; - GETC(ch); - } - else { - sign = 0; - if (ch == '+') - GETC(ch); - } - x = ch - '0'; - if (x < 0 || x > 9) - return 115; - while(GETC(ch) >= '0' && ch <= '9') - x = 10*x + ch - '0'; - while(ch <= ' ' && ch >= 0) - GETC(ch); - if (ch == EOF) - return EOF; - *val = sign ? -x : x; - *chp = ch; - return 0; - } + while (GETC (ch) <= ' ' && ch >= 0); + if (ch == '-') + { + sign = 1; + GETC (ch); + } + else + { + sign = 0; + if (ch == '+') + GETC (ch); + } + x = ch - '0'; + if (x < 0 || x > 9) + return 115; + while (GETC (ch) >= '0' && ch <= '9') + x = 10 * x + ch - '0'; + while (ch <= ' ' && ch >= 0) + GETC (ch); + if (ch == EOF) + return EOF; + *val = sign ? -x : x; + *chp = ch; + return 0; +} - static int -getdimen(int *chp, dimen *d, ftnlen delta, ftnlen extent, ftnlen *x1) +static int +getdimen (int *chp, dimen * d, ftnlen delta, ftnlen extent, ftnlen * x1) { - register int k; - ftnlen x2, x3; + register int k; + ftnlen x2, x3; - if (k = getnum(chp, x1)) - return k; - x3 = 1; - if (*chp == ':') { - if (k = getnum(chp, &x2)) - return k; - x2 -= *x1; - if (*chp == ':') { - if (k = getnum(chp, &x3)) - return k; - if (!x3) - return 123; - x2 /= x3; - colonseen = 1; - } - if (x2 < 0 || x2 >= extent) - return 123; - d->extent = x2 + 1; - } - else - d->extent = 1; - d->curval = 0; - d->delta = delta; - d->stride = x3; - return 0; + if (k = getnum (chp, x1)) + return k; + x3 = 1; + if (*chp == ':') + { + if (k = getnum (chp, &x2)) + return k; + x2 -= *x1; + if (*chp == ':') + { + if (k = getnum (chp, &x3)) + return k; + if (!x3) + return 123; + x2 /= x3; + colonseen = 1; } + if (x2 < 0 || x2 >= extent) + return 123; + d->extent = x2 + 1; + } + else + d->extent = 1; + d->curval = 0; + d->delta = delta; + d->stride = x3; + return 0; +} #ifndef No_Namelist_Questions static void -print_ne(cilist *a) +print_ne (cilist * a) { - flag intext = f__external; - int rpsave = f__recpos; - FILE *cfsave = f__cf; - unit *usave = f__curunit; - cilist t; - t = *a; - t.ciunit = 6; - s_wsne(&t); - fflush(f__cf); - f__external = intext; - f__reading = 1; - f__recpos = rpsave; - f__cf = cfsave; - f__curunit = usave; - f__elist = a; - } + flag intext = f__external; + int rpsave = f__recpos; + FILE *cfsave = f__cf; + unit *usave = f__curunit; + cilist t; + t = *a; + t.ciunit = 6; + s_wsne (&t); + fflush (f__cf); + f__external = intext; + f__reading = 1; + f__recpos = rpsave; + f__cf = cfsave; + f__curunit = usave; + f__elist = a; +} #endif - static char where0[] = "namelist read start "; +static char where0[] = "namelist read start "; -x_rsne(cilist *a) +x_rsne (cilist * a) { - int ch, got1, k, n, nd, quote, readall; - Namelist *nl; - static char where[] = "namelist read"; - char buf[64]; - hashtab *ht; - Vardesc *v; - dimen *dn, *dn0, *dn1; - ftnlen *dims, *dims1; - ftnlen b, b0, b1, ex, no, nomax, size, span; - ftnint no1, type; - char *vaddr; - long iva, ivae; - dimen dimens[MAXDIM], substr; + int ch, got1, k, n, nd, quote, readall; + Namelist *nl; + static char where[] = "namelist read"; + char buf[64]; + hashtab *ht; + Vardesc *v; + dimen *dn, *dn0, *dn1; + ftnlen *dims, *dims1; + ftnlen b, b0, b1, ex, no, nomax, size, span; + ftnint no1, type; + char *vaddr; + long iva, ivae; + dimen dimens[MAXDIM], substr; - if (!Alpha['a']) - nl_init(); - f__reading=1; - f__formatted=1; - got1 = 0; - top: - for(;;) switch(GETC(ch)) { - case EOF: - eof: - err(a->ciend,(EOF),where0); - case '&': - case '$': - goto have_amp; + if (!Alpha['a']) + nl_init (); + f__reading = 1; + f__formatted = 1; + got1 = 0; +top: + for (;;) + switch (GETC (ch)) + { + case EOF: + eof: + err (a->ciend, (EOF), where0); + case '&': + case '$': + goto have_amp; #ifndef No_Namelist_Questions - case '?': - print_ne(a); - continue; + case '?': + print_ne (a); + continue; #endif - default: - if (ch <= ' ' && ch >= 0) - continue; + default: + if (ch <= ' ' && ch >= 0) + continue; #ifndef No_Namelist_Comments - while(GETC(ch) != '\n') - if (ch == EOF) - goto eof; + while (GETC (ch) != '\n') + if (ch == EOF) + goto eof; #else - errfl(a->cierr, 115, where0); + errfl (a->cierr, 115, where0); #endif - } - have_amp: - if (ch = getname(buf,sizeof(buf))) - return ch; - nl = (Namelist *)a->cifmt; - if (strcmp(buf, nl->name)) + } +have_amp: + if (ch = getname (buf, sizeof (buf))) + return ch; + nl = (Namelist *) a->cifmt; + if (strcmp (buf, nl->name)) #ifdef No_Bad_Namelist_Skip - errfl(a->cierr, 118, where0); + errfl (a->cierr, 118, where0); #else + { + fprintf (stderr, + "Skipping namelist \"%s\": seeking namelist \"%s\".\n", + buf, nl->name); + fflush (stderr); + for (;;) + switch (GETC (ch)) + { + case EOF: + err (a->ciend, EOF, where0); + case '/': + case '&': + case '$': + if (f__external) + e_rsle (); + else + z_rnew (); + goto top; + case '"': + case '\'': + quote = ch; + more_quoted: + while (GETC (ch) != quote) + if (ch == EOF) + err (a->ciend, EOF, where0); + if (GETC (ch) == quote) + goto more_quoted; + Ungetc (ch, f__cf); + default: + continue; + } + } +#endif + ht = mk_hashtab (nl); + if (!ht) + errfl (f__elist->cierr, 113, where0); + for (;;) + { + for (;;) + switch (GETC (ch)) + { + case EOF: + if (got1) + return 0; + err (a->ciend, EOF, where0); + case '/': + case '$': + case '&': + return 0; + default: + if (ch <= ' ' && ch >= 0 || ch == ',') + continue; + Ungetc (ch, f__cf); + if (ch = getname (buf, sizeof (buf))) + return ch; + goto havename; + } + havename: + v = hash (ht, buf); + if (!v) + errfl (a->cierr, 119, where); + while (GETC (ch) <= ' ' && ch >= 0); + vaddr = v->addr; + type = v->type; + if (type < 0) + { + size = -type; + type = TYCHAR; + } + else + size = f__typesize[type]; + ivae = size; + iva = readall = 0; + if (ch == '(' /*) */ ) { - fprintf(stderr, - "Skipping namelist \"%s\": seeking namelist \"%s\".\n", - buf, nl->name); - fflush(stderr); - for(;;) switch(GETC(ch)) { - case EOF: - err(a->ciend, EOF, where0); - case '/': - case '&': - case '$': - if (f__external) - e_rsle(); - else - z_rnew(); - goto top; - case '"': - case '\'': - quote = ch; - more_quoted: - while(GETC(ch) != quote) - if (ch == EOF) - err(a->ciend, EOF, where0); - if (GETC(ch) == quote) - goto more_quoted; - Ungetc(ch,f__cf); - default: - continue; - } + dn = dimens; + if (!(dims = v->dims)) + { + if (type != TYCHAR) + errfl (a->cierr, 122, where); + if (k = getdimen (&ch, dn, (ftnlen) size, (ftnlen) size, &b)) + errfl (a->cierr, k, where); + if (ch != ')') + errfl (a->cierr, 115, where); + b1 = dn->extent; + if (--b < 0 || b + b1 > size) + return 124; + iva += b; + size = b1; + while (GETC (ch) <= ' ' && ch >= 0); + goto scalar; + } + nd = (int) dims[0]; + nomax = span = dims[1]; + ivae = iva + size * nomax; + colonseen = 0; + if (k = getdimen (&ch, dn, size, nomax, &b)) + errfl (a->cierr, k, where); + no = dn->extent; + b0 = dims[2]; + dims1 = dims += 3; + ex = 1; + for (n = 1; n++ < nd; dims++) + { + if (ch != ',') + errfl (a->cierr, 115, where); + dn1 = dn + 1; + span /= *dims; + if (k = getdimen (&ch, dn1, dn->delta ** dims, span, &b1)) + errfl (a->cierr, k, where); + ex *= *dims; + b += b1 * ex; + no *= dn1->extent; + dn = dn1; + } + if (ch != ')') + errfl (a->cierr, 115, where); + readall = 1 - colonseen; + b -= b0; + if (b < 0 || b >= nomax) + errfl (a->cierr, 125, where); + iva += size * b; + dims = dims1; + while (GETC (ch) <= ' ' && ch >= 0); + no1 = 1; + dn0 = dimens; + if (type == TYCHAR && ch == '(' /*) */ ) + { + if (k = getdimen (&ch, &substr, size, size, &b)) + errfl (a->cierr, k, where); + if (ch != ')') + errfl (a->cierr, 115, where); + b1 = substr.extent; + if (--b < 0 || b + b1 > size) + return 124; + iva += b; + b0 = size; + size = b1; + while (GETC (ch) <= ' ' && ch >= 0); + if (b1 < b0) + goto delta_adj; + } + if (readall) + goto delta_adj; + for (; dn0 < dn; dn0++) + { + if (dn0->extent != *dims++ || dn0->stride != 1) + break; + no1 *= dn0->extent; + } + if (dn0 == dimens && dimens[0].stride == 1) + { + no1 = dimens[0].extent; + dn0++; + } + delta_adj: + ex = 0; + for (dn1 = dn0; dn1 <= dn; dn1++) + ex += (dn1->extent - 1) * (dn1->delta *= dn1->stride); + for (dn1 = dn; dn1 > dn0; dn1--) + { + ex -= (dn1->extent - 1) * dn1->delta; + dn1->delta -= ex; + } + } + else if (dims = v->dims) + { + no = no1 = dims[1]; + ivae = iva + no * size; + } + else + scalar: + no = no1 = 1; + if (ch != '=') + errfl (a->cierr, 115, where); + got1 = nml_read = 1; + f__lcount = 0; + readloop: + for (;;) + { + if (iva >= ivae || iva < 0) + { + f__lquit = 1; + goto mustend; + } + else if (iva + no1 * size > ivae) + no1 = (ivae - iva) / size; + f__lquit = 0; + if (k = l_read (&no1, vaddr + iva, size, type)) + return k; + if (f__lquit == 1) + return 0; + if (readall) + { + iva += dn0->delta; + if (f__lcount > 0) + { + no1 = (ivae - iva) / size; + if (no1 > f__lcount) + no1 = f__lcount; + if (k = l_read (&no1, vaddr + iva, size, type)) + return k; + iva += no1 * dn0->delta; } -#endif - ht = mk_hashtab(nl); - if (!ht) - errfl(f__elist->cierr, 113, where0); - for(;;) { - for(;;) switch(GETC(ch)) { - case EOF: - if (got1) - return 0; - err(a->ciend, EOF, where0); - case '/': - case '$': - case '&': - return 0; - default: - if (ch <= ' ' && ch >= 0 || ch == ',') - continue; - Ungetc(ch,f__cf); - if (ch = getname(buf,sizeof(buf))) - return ch; - goto havename; - } - havename: - v = hash(ht,buf); - if (!v) - errfl(a->cierr, 119, where); - while(GETC(ch) <= ' ' && ch >= 0); - vaddr = v->addr; - type = v->type; - if (type < 0) { - size = -type; - type = TYCHAR; - } - else - size = f__typesize[type]; - ivae = size; - iva = readall = 0; - if (ch == '(' /*)*/ ) { - dn = dimens; - if (!(dims = v->dims)) { - if (type != TYCHAR) - errfl(a->cierr, 122, where); - if (k = getdimen(&ch, dn, (ftnlen)size, - (ftnlen)size, &b)) - errfl(a->cierr, k, where); - if (ch != ')') - errfl(a->cierr, 115, where); - b1 = dn->extent; - if (--b < 0 || b + b1 > size) - return 124; - iva += b; - size = b1; - while(GETC(ch) <= ' ' && ch >= 0); - goto scalar; - } - nd = (int)dims[0]; - nomax = span = dims[1]; - ivae = iva + size*nomax; - colonseen = 0; - if (k = getdimen(&ch, dn, size, nomax, &b)) - errfl(a->cierr, k, where); - no = dn->extent; - b0 = dims[2]; - dims1 = dims += 3; - ex = 1; - for(n = 1; n++ < nd; dims++) { - if (ch != ',') - errfl(a->cierr, 115, where); - dn1 = dn + 1; - span /= *dims; - if (k = getdimen(&ch, dn1, dn->delta**dims, - span, &b1)) - errfl(a->cierr, k, where); - ex *= *dims; - b += b1*ex; - no *= dn1->extent; - dn = dn1; - } - if (ch != ')') - errfl(a->cierr, 115, where); - readall = 1 - colonseen; - b -= b0; - if (b < 0 || b >= nomax) - errfl(a->cierr, 125, where); - iva += size * b; - dims = dims1; - while(GETC(ch) <= ' ' && ch >= 0); - no1 = 1; - dn0 = dimens; - if (type == TYCHAR && ch == '(' /*)*/) { - if (k = getdimen(&ch, &substr, size, size, &b)) - errfl(a->cierr, k, where); - if (ch != ')') - errfl(a->cierr, 115, where); - b1 = substr.extent; - if (--b < 0 || b + b1 > size) - return 124; - iva += b; - b0 = size; - size = b1; - while(GETC(ch) <= ' ' && ch >= 0); - if (b1 < b0) - goto delta_adj; - } - if (readall) - goto delta_adj; - for(; dn0 < dn; dn0++) { - if (dn0->extent != *dims++ || dn0->stride != 1) - break; - no1 *= dn0->extent; - } - if (dn0 == dimens && dimens[0].stride == 1) { - no1 = dimens[0].extent; - dn0++; - } - delta_adj: - ex = 0; - for(dn1 = dn0; dn1 <= dn; dn1++) - ex += (dn1->extent-1) - * (dn1->delta *= dn1->stride); - for(dn1 = dn; dn1 > dn0; dn1--) { - ex -= (dn1->extent - 1) * dn1->delta; - dn1->delta -= ex; - } - } - else if (dims = v->dims) { - no = no1 = dims[1]; - ivae = iva + no*size; - } - else - scalar: - no = no1 = 1; - if (ch != '=') - errfl(a->cierr, 115, where); - got1 = nml_read = 1; - f__lcount = 0; - readloop: - for(;;) { - if (iva >= ivae || iva < 0) { - f__lquit = 1; - goto mustend; - } - else if (iva + no1*size > ivae) - no1 = (ivae - iva)/size; - f__lquit = 0; - if (k = l_read(&no1, vaddr + iva, size, type)) - return k; - if (f__lquit == 1) - return 0; - if (readall) { - iva += dn0->delta; - if (f__lcount > 0) { - no1 = (ivae - iva)/size; - if (no1 > f__lcount) - no1 = f__lcount; - if (k = l_read(&no1, vaddr + iva, - size, type)) - return k; - iva += no1 * dn0->delta; - } - } - mustend: - GETC(ch); - if (readall) - if (iva >= ivae) - readall = 0; - else for(;;) { - switch(ch) { - case ' ': - case '\t': - case '\n': - GETC(ch); - continue; - } - break; - } - if (ch == '/' || ch == '$' || ch == '&') { - f__lquit = 1; - return 0; - } - else if (f__lquit) { - while(ch <= ' ' && ch >= 0) - GETC(ch); - Ungetc(ch,f__cf); - if (!Alpha[ch & 0xff] && ch >= 0) - errfl(a->cierr, 125, where); - break; - } - Ungetc(ch,f__cf); - if (readall && !Alpha[ch & 0xff]) - goto readloop; - if ((no -= no1) <= 0) - break; - for(dn1 = dn0; dn1 <= dn; dn1++) { - if (++dn1->curval < dn1->extent) { - iva += dn1->delta; - goto readloop; - } - dn1->curval = 0; - } - break; - } + } + mustend: + GETC (ch); + if (readall) + if (iva >= ivae) + readall = 0; + else + for (;;) + { + switch (ch) + { + case ' ': + case '\t': + case '\n': + GETC (ch); + continue; + } + break; + } + if (ch == '/' || ch == '$' || ch == '&') + { + f__lquit = 1; + return 0; + } + else if (f__lquit) + { + while (ch <= ' ' && ch >= 0) + GETC (ch); + Ungetc (ch, f__cf); + if (!Alpha[ch & 0xff] && ch >= 0) + errfl (a->cierr, 125, where); + break; + } + Ungetc (ch, f__cf); + if (readall && !Alpha[ch & 0xff]) + goto readloop; + if ((no -= no1) <= 0) + break; + for (dn1 = dn0; dn1 <= dn; dn1++) + { + if (++dn1->curval < dn1->extent) + { + iva += dn1->delta; + goto readloop; } + dn1->curval = 0; + } + break; } + } +} - integer -s_rsne(cilist *a) +integer +s_rsne (cilist * a) { - extern int l_eof; - int n; + extern int l_eof; + int n; - f__external=1; - l_eof = 0; - if(n = c_le(a)) - return n; - if(f__curunit->uwrt && f__nowreading(f__curunit)) - err(a->cierr,errno,where0); - l_getc = t_getc; - l_ungetc = un_getc; - f__doend = xrd_SL; - n = x_rsne(a); - nml_read = 0; - if (n) - return n; - return e_rsle(); - } + f__external = 1; + l_eof = 0; + if (n = c_le (a)) + return n; + if (f__curunit->uwrt && f__nowreading (f__curunit)) + err (a->cierr, errno, where0); + l_getc = t_getc; + l_ungetc = un_getc; + f__doend = xrd_SL; + n = x_rsne (a); + nml_read = 0; + if (n) + return n; + return e_rsle (); +} diff --git a/libf2c/libI77/sfe.c b/libf2c/libI77/sfe.c index c4be0d7..9b52122 100644 --- a/libf2c/libI77/sfe.c +++ b/libf2c/libI77/sfe.c @@ -5,31 +5,39 @@ extern char *f__fmtbuf; -integer e_rsfe(void) -{ int n; - f__init = 1; - n=en_fio(); - f__fmtbuf=NULL; - return(n); +integer +e_rsfe (void) +{ + int n; + f__init = 1; + n = en_fio (); + f__fmtbuf = NULL; + return (n); } -c_sfe(cilist *a) /* check */ -{ unit *p; - if(a->ciunit >= MXUNIT || a->ciunit<0) - err(a->cierr,101,"startio"); - p = &f__units[a->ciunit]; - if(p->ufd==NULL && fk_open(SEQ,FMT,a->ciunit)) err(a->cierr,114,"sfe"); - if(!p->ufmt) err(a->cierr,102,"sfe"); - return(0); + +c_sfe (cilist * a) /* check */ +{ + unit *p; + if (a->ciunit >= MXUNIT || a->ciunit < 0) + err (a->cierr, 101, "startio"); + p = &f__units[a->ciunit]; + if (p->ufd == NULL && fk_open (SEQ, FMT, a->ciunit)) + err (a->cierr, 114, "sfe"); + if (!p->ufmt) + err (a->cierr, 102, "sfe"); + return (0); } -integer e_wsfe(void) + +integer +e_wsfe (void) { - int n; - f__init = 1; - n = en_fio(); - f__fmtbuf=NULL; + int n; + f__init = 1; + n = en_fio (); + f__fmtbuf = NULL; #ifdef ALWAYS_FLUSH - if (!n && fflush(f__cf)) - err(f__elist->cierr, errno, "write end"); + if (!n && fflush (f__cf)) + err (f__elist->cierr, errno, "write end"); #endif - return n; + return n; } diff --git a/libf2c/libI77/sue.c b/libf2c/libI77/sue.c index 9c3aa45..70cff92 100644 --- a/libf2c/libI77/sue.c +++ b/libf2c/libI77/sue.c @@ -4,73 +4,89 @@ extern uiolen f__reclen; off_t f__recloc; -c_sue(cilist *a) +c_sue (cilist * a) { - f__external=f__sequential=1; - f__formatted=0; - f__curunit = &f__units[a->ciunit]; - if(a->ciunit >= MXUNIT || a->ciunit < 0) - err(a->cierr,101,"startio"); - f__elist=a; - if(f__curunit->ufd==NULL && fk_open(SEQ,UNF,a->ciunit)) - err(a->cierr,114,"sue"); - f__cf=f__curunit->ufd; - if(f__curunit->ufmt) err(a->cierr,103,"sue"); - if(!f__curunit->useek) err(a->cierr,103,"sue"); - return(0); + f__external = f__sequential = 1; + f__formatted = 0; + f__curunit = &f__units[a->ciunit]; + if (a->ciunit >= MXUNIT || a->ciunit < 0) + err (a->cierr, 101, "startio"); + f__elist = a; + if (f__curunit->ufd == NULL && fk_open (SEQ, UNF, a->ciunit)) + err (a->cierr, 114, "sue"); + f__cf = f__curunit->ufd; + if (f__curunit->ufmt) + err (a->cierr, 103, "sue"); + if (!f__curunit->useek) + err (a->cierr, 103, "sue"); + return (0); } -integer s_rsue(cilist *a) + +integer +s_rsue (cilist * a) { - int n; - if(f__init != 1) f_init(); - f__init = 3; - f__reading=1; - if(n=c_sue(a)) return(n); - f__recpos=0; - if(f__curunit->uwrt && f__nowreading(f__curunit)) - err(a->cierr, errno, "read start"); - if(fread((char *)&f__reclen,sizeof(uiolen),1,f__cf) - != 1) - { if(feof(f__cf)) - { f__curunit->uend = 1; - err(a->ciend, EOF, "start"); - } - clearerr(f__cf); - err(a->cierr, errno, "start"); + int n; + if (f__init != 1) + f_init (); + f__init = 3; + f__reading = 1; + if (n = c_sue (a)) + return (n); + f__recpos = 0; + if (f__curunit->uwrt && f__nowreading (f__curunit)) + err (a->cierr, errno, "read start"); + if (fread ((char *) &f__reclen, sizeof (uiolen), 1, f__cf) != 1) + { + if (feof (f__cf)) + { + f__curunit->uend = 1; + err (a->ciend, EOF, "start"); } - return(0); + clearerr (f__cf); + err (a->cierr, errno, "start"); + } + return (0); } -integer s_wsue(cilist *a) + +integer +s_wsue (cilist * a) { - int n; - if(f__init != 1) f_init(); - f__init = 3; - if(n=c_sue(a)) return(n); - f__reading=0; - f__reclen=0; - if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) - err(a->cierr, errno, "write start"); - f__recloc=FTELL(f__cf); - FSEEK(f__cf,(off_t)sizeof(uiolen),SEEK_CUR); - return(0); + int n; + if (f__init != 1) + f_init (); + f__init = 3; + if (n = c_sue (a)) + return (n); + f__reading = 0; + f__reclen = 0; + if (f__curunit->uwrt != 1 && f__nowwriting (f__curunit)) + err (a->cierr, errno, "write start"); + f__recloc = FTELL (f__cf); + FSEEK (f__cf, (off_t) sizeof (uiolen), SEEK_CUR); + return (0); } -integer e_wsue(void) -{ off_t loc; - f__init = 1; - fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf); + +integer +e_wsue (void) +{ + off_t loc; + f__init = 1; + fwrite ((char *) &f__reclen, sizeof (uiolen), 1, f__cf); #ifdef ALWAYS_FLUSH - if (fflush(f__cf)) - err(f__elist->cierr, errno, "write end"); + if (fflush (f__cf)) + err (f__elist->cierr, errno, "write end"); #endif - loc=FTELL(f__cf); - FSEEK(f__cf,f__recloc,SEEK_SET); - fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf); - FSEEK(f__cf,loc,SEEK_SET); - return(0); + loc = FTELL (f__cf); + FSEEK (f__cf, f__recloc, SEEK_SET); + fwrite ((char *) &f__reclen, sizeof (uiolen), 1, f__cf); + FSEEK (f__cf, loc, SEEK_SET); + return (0); } -integer e_rsue(void) + +integer +e_rsue (void) { - f__init = 1; - FSEEK(f__cf,(off_t)(f__reclen-f__recpos+sizeof(uiolen)),SEEK_CUR); - return(0); + f__init = 1; + FSEEK (f__cf, (off_t) (f__reclen - f__recpos + sizeof (uiolen)), SEEK_CUR); + return (0); } diff --git a/libf2c/libI77/typesize.c b/libf2c/libI77/typesize.c index 7f42aa1..8e2a74a 100644 --- a/libf2c/libI77/typesize.c +++ b/libf2c/libI77/typesize.c @@ -1,13 +1,14 @@ #include "config.h" #include "f2c.h" -ftnlen f__typesize[] = { 0, 0, sizeof(shortint), sizeof(integer), - sizeof(real), sizeof(doublereal), - sizeof(complex), sizeof(doublecomplex), - sizeof(logical), sizeof(char), - 0, sizeof(integer1), - sizeof(logical1), sizeof(shortlogical), +ftnlen f__typesize[] = { 0, 0, sizeof (shortint), sizeof (integer), + sizeof (real), sizeof (doublereal), + sizeof (complex), sizeof (doublecomplex), + sizeof (logical), sizeof (char), + 0, sizeof (integer1), + sizeof (logical1), sizeof (shortlogical), #ifdef Allow_TYQUAD - sizeof(longint), + sizeof (longint), #endif - 0}; + 0 +}; diff --git a/libf2c/libI77/uio.c b/libf2c/libI77/uio.c index d282ee4..d22e5a3 100644 --- a/libf2c/libI77/uio.c +++ b/libf2c/libI77/uio.c @@ -3,51 +3,56 @@ #include <sys/types.h> uiolen f__reclen; -do_us(ftnint *number, char *ptr, ftnlen len) +do_us (ftnint * number, char *ptr, ftnlen len) { - if(f__reading) - { - f__recpos += (int)(*number * len); - if(f__recpos>f__reclen) - err(f__elist->cierr, 110, "do_us"); - if (fread(ptr,(size_t)len,(size_t)(*number),f__cf) != *number) - err(f__elist->ciend, EOF, "do_us"); - return(0); - } - else - { - f__reclen += *number * len; - (void) fwrite(ptr,(size_t)len,(size_t)(*number),f__cf); - return(0); - } + if (f__reading) + { + f__recpos += (int) (*number * len); + if (f__recpos > f__reclen) + err (f__elist->cierr, 110, "do_us"); + if (fread (ptr, (size_t) len, (size_t) (*number), f__cf) != *number) + err (f__elist->ciend, EOF, "do_us"); + return (0); + } + else + { + f__reclen += *number * len; + (void) fwrite (ptr, (size_t) len, (size_t) (*number), f__cf); + return (0); + } } -integer do_ud(ftnint *number, char *ptr, ftnlen len) +integer +do_ud (ftnint * number, char *ptr, ftnlen len) { - f__recpos += (int)(*number * len); - if(f__recpos > f__curunit->url && f__curunit->url!=1) - err(f__elist->cierr,110,"do_ud"); - if(f__reading) - { + f__recpos += (int) (*number * len); + if (f__recpos > f__curunit->url && f__curunit->url != 1) + err (f__elist->cierr, 110, "do_ud"); + if (f__reading) + { #ifdef Pad_UDread - size_t i; - if (!(i = fread(ptr,(size_t)len,(size_t)(*number),f__cf)) - && !(f__recpos - *number*len)) - err(f__elist->cierr,EOF,"do_ud"); - if (i < *number) - memset(ptr + i*len, 0, (*number - i)*len); - return 0; + size_t i; + if (!(i = fread (ptr, (size_t) len, (size_t) (*number), f__cf)) + && !(f__recpos - *number * len)) + err (f__elist->cierr, EOF, "do_ud"); + if (i < *number) + memset (ptr + i * len, 0, (*number - i) * len); + return 0; #else - if(fread(ptr,(size_t)len,(size_t)(*number),f__cf) != *number) - err(f__elist->cierr,EOF,"do_ud"); - else return(0); + if (fread (ptr, (size_t) len, (size_t) (*number), f__cf) != *number) + err (f__elist->cierr, EOF, "do_ud"); + else + return (0); #endif - } - (void) fwrite(ptr,(size_t)len,(size_t)(*number),f__cf); - return(0); + } + (void) fwrite (ptr, (size_t) len, (size_t) (*number), f__cf); + return (0); } -integer do_uio(ftnint *number, char *ptr, ftnlen len) + +integer +do_uio (ftnint * number, char *ptr, ftnlen len) { - if(f__sequential) - return(do_us(number,ptr,len)); - else return(do_ud(number,ptr,len)); + if (f__sequential) + return (do_us (number, ptr, len)); + else + return (do_ud (number, ptr, len)); } diff --git a/libf2c/libI77/util.c b/libf2c/libI77/util.c index 9e8f6bd..6e7c52b 100644 --- a/libf2c/libI77/util.c +++ b/libf2c/libI77/util.c @@ -9,34 +9,44 @@ #include "fio.h" void -g_char(char *a, ftnlen alen, char *b) +g_char (char *a, ftnlen alen, char *b) { - char *x = a + alen, *y = b + alen; + char *x = a + alen, *y = b + alen; - for(;; y--) { - if (x <= a) { - *b = 0; - return; - } - if (*--x != ' ') - break; - } - *y-- = 0; - do *y-- = *x; - while(x-- > a); + for (;; y--) + { + if (x <= a) + { + *b = 0; + return; } + if (*--x != ' ') + break; + } + *y-- = 0; + do + *y-- = *x; + while (x-- > a); +} void -b_char(char *a, char *b, ftnlen blen) -{ int i; - for(i=0;i<blen && *a!=0;i++) *b++= *a++; - for(;i<blen;i++) *b++=' '; +b_char (char *a, char *b, ftnlen blen) +{ + int i; + for (i = 0; i < blen && *a != 0; i++) + *b++ = *a++; + for (; i < blen; i++) + *b++ = ' '; } + #ifndef NON_UNIX_STDIO -long f__inode(char *a, int *dev) -{ struct stat x; - if(stat(a,&x)<0) return(-1); - *dev = x.st_dev; - return(x.st_ino); +long +f__inode (char *a, int *dev) +{ + struct stat x; + if (stat (a, &x) < 0) + return (-1); + *dev = x.st_dev; + return (x.st_ino); } #endif diff --git a/libf2c/libI77/wref.c b/libf2c/libI77/wref.c index 677364c..c2600a1 100644 --- a/libf2c/libI77/wref.c +++ b/libf2c/libI77/wref.c @@ -13,254 +13,290 @@ #include "fmt.h" #include "fp.h" -wrt_E(ufloat *p, int w, int d, int e, ftnlen len) +wrt_E (ufloat * p, int w, int d, int e, ftnlen len) { - char buf[FMAX+EXPMAXDIGS+4], *s, *se; - int d1, delta, e1, i, sign, signspace; - double dd; + char buf[FMAX + EXPMAXDIGS + 4], *s, *se; + int d1, delta, e1, i, sign, signspace; + double dd; #ifdef WANT_LEAD_0 - int insert0 = 0; + int insert0 = 0; #endif #ifndef VAX - int e0 = e; + int e0 = e; #endif - if(e <= 0) - e = 2; - if(f__scale) { - if(f__scale >= d + 2 || f__scale <= -d) - goto nogood; - } - if(f__scale <= 0) - --d; - if (len == sizeof(real)) - dd = p->pf; - else - dd = p->pd; - if (dd < 0.) { - signspace = sign = 1; - dd = -dd; - } - else { - sign = 0; - signspace = (int)f__cplus; + if (e <= 0) + e = 2; + if (f__scale) + { + if (f__scale >= d + 2 || f__scale <= -d) + goto nogood; + } + if (f__scale <= 0) + --d; + if (len == sizeof (real)) + dd = p->pf; + else + dd = p->pd; + if (dd < 0.) + { + signspace = sign = 1; + dd = -dd; + } + else + { + sign = 0; + signspace = (int) f__cplus; #ifndef VAX - if (!dd) - dd = 0.; /* avoid -0 */ + if (!dd) + dd = 0.; /* avoid -0 */ #endif - } - delta = w - (2 /* for the . and the d adjustment above */ - + 2 /* for the E+ */ + signspace + d + e); + } + delta = w - (2 /* for the . and the d adjustment above */ + + 2 /* for the E+ */ + signspace + d + e); #ifdef WANT_LEAD_0 - if (f__scale <= 0 && delta > 0) { - delta--; - insert0 = 1; - } - else + if (f__scale <= 0 && delta > 0) + { + delta--; + insert0 = 1; + } + else #endif - if (delta < 0) { -nogood: - while(--w >= 0) - PUT('*'); - return(0); - } - if (f__scale < 0) - d += f__scale; - if (d > FMAX) { - d1 = d - FMAX; - d = FMAX; - } - else - d1 = 0; - sprintf(buf,"%#.*E", d, dd); + if (delta < 0) + { + nogood: + while (--w >= 0) + PUT ('*'); + return (0); + } + if (f__scale < 0) + d += f__scale; + if (d > FMAX) + { + d1 = d - FMAX; + d = FMAX; + } + else + d1 = 0; + sprintf (buf, "%#.*E", d, dd); #ifndef VAX - /* check for NaN, Infinity */ - if (!isdigit(buf[0])) { - switch(buf[0]) { - case 'n': - case 'N': - signspace = 0; /* no sign for NaNs */ - } - delta = w - strlen(buf) - signspace; - if (delta < 0) - goto nogood; - while(--delta >= 0) - PUT(' '); - if (signspace) - PUT(sign ? '-' : '+'); - for(s = buf; *s; s++) - PUT(*s); - return 0; - } + /* check for NaN, Infinity */ + if (!isdigit (buf[0])) + { + switch (buf[0]) + { + case 'n': + case 'N': + signspace = 0; /* no sign for NaNs */ + } + delta = w - strlen (buf) - signspace; + if (delta < 0) + goto nogood; + while (--delta >= 0) + PUT (' '); + if (signspace) + PUT (sign ? '-' : '+'); + for (s = buf; *s; s++) + PUT (*s); + return 0; + } #endif - se = buf + d + 3; -#ifdef GOOD_SPRINTF_EXPONENT /* When possible, exponent has 2 digits. */ - if (f__scale != 1 && dd) - sprintf(se, "%+.2d", atoi(se) + 1 - f__scale); + se = buf + d + 3; +#ifdef GOOD_SPRINTF_EXPONENT /* When possible, exponent has 2 digits. */ + if (f__scale != 1 && dd) + sprintf (se, "%+.2d", atoi (se) + 1 - f__scale); #else - if (dd) - sprintf(se, "%+.2d", atoi(se) + 1 - f__scale); - else - strcpy(se, "+00"); + if (dd) + sprintf (se, "%+.2d", atoi (se) + 1 - f__scale); + else + strcpy (se, "+00"); #endif - s = ++se; - if (e < 2) { - if (*s != '0') - goto nogood; - } + s = ++se; + if (e < 2) + { + if (*s != '0') + goto nogood; + } #ifndef VAX - /* accommodate 3 significant digits in exponent */ - if (s[2]) { + /* accommodate 3 significant digits in exponent */ + if (s[2]) + { #ifdef Pedantic - if (!e0 && !s[3]) - for(s -= 2, e1 = 2; s[0] = s[1]; s++); + if (!e0 && !s[3]) + for (s -= 2, e1 = 2; s[0] = s[1]; s++); - /* Pedantic gives the behavior that Fortran 77 specifies, */ - /* i.e., requires that E be specified for exponent fields */ - /* of more than 3 digits. With Pedantic undefined, we get */ - /* the behavior that Cray displays -- you get a bigger */ - /* exponent field if it fits. */ + /* Pedantic gives the behavior that Fortran 77 specifies, */ + /* i.e., requires that E be specified for exponent fields */ + /* of more than 3 digits. With Pedantic undefined, we get */ + /* the behavior that Cray displays -- you get a bigger */ + /* exponent field if it fits. */ #else - if (!e0) { - for(s -= 2, e1 = 2; s[0] = s[1]; s++) + if (!e0) + { + for (s -= 2, e1 = 2; s[0] = s[1]; s++) #ifdef CRAY - delta--; - if ((delta += 4) < 0) - goto nogood + delta--; + if ((delta += 4) < 0) + goto nogood #endif - ; - } + ; + } #endif - else if (e0 >= 0) - goto shift; - else - e1 = e; - } - else - shift: + else if (e0 >= 0) + goto shift; + else + e1 = e; + } + else + shift: #endif - for(s += 2, e1 = 2; *s; ++e1, ++s) - if (e1 >= e) - goto nogood; - while(--delta >= 0) - PUT(' '); - if (signspace) - PUT(sign ? '-' : '+'); - s = buf; - i = f__scale; - if (f__scale <= 0) { + for (s += 2, e1 = 2; *s; ++e1, ++s) + if (e1 >= e) + goto nogood; + while (--delta >= 0) + PUT (' '); + if (signspace) + PUT (sign ? '-' : '+'); + s = buf; + i = f__scale; + if (f__scale <= 0) + { #ifdef WANT_LEAD_0 - if (insert0) - PUT('0'); + if (insert0) + PUT ('0'); #endif - PUT('.'); - for(; i < 0; ++i) - PUT('0'); - PUT(*s); - s += 2; - } - else if (f__scale > 1) { - PUT(*s); - s += 2; - while(--i > 0) - PUT(*s++); - PUT('.'); - } - if (d1) { - se -= 2; - while(s < se) PUT(*s++); - se += 2; - do PUT('0'); while(--d1 > 0); - } - while(s < se) - PUT(*s++); - if (e < 2) - PUT(s[1]); - else { - while(++e1 <= e) - PUT('0'); - while(*s) - PUT(*s++); - } - return 0; - } + PUT ('.'); + for (; i < 0; ++i) + PUT ('0'); + PUT (*s); + s += 2; + } + else if (f__scale > 1) + { + PUT (*s); + s += 2; + while (--i > 0) + PUT (*s++); + PUT ('.'); + } + if (d1) + { + se -= 2; + while (s < se) + PUT (*s++); + se += 2; + do + PUT ('0'); + while (--d1 > 0); + } + while (s < se) + PUT (*s++); + if (e < 2) + PUT (s[1]); + else + { + while (++e1 <= e) + PUT ('0'); + while (*s) + PUT (*s++); + } + return 0; +} -wrt_F(ufloat *p, int w, int d, ftnlen len) +wrt_F (ufloat * p, int w, int d, ftnlen len) { - int d1, sign, n; - double x; - char *b, buf[MAXINTDIGS+MAXFRACDIGS+4], *s; + int d1, sign, n; + double x; + char *b, buf[MAXINTDIGS + MAXFRACDIGS + 4], *s; - x= (len==sizeof(real)?p->pf:p->pd); - if (d < MAXFRACDIGS) - d1 = 0; - else { - d1 = d - MAXFRACDIGS; - d = MAXFRACDIGS; - } - if (x < 0.) - { x = -x; sign = 1; } - else { - sign = 0; + x = (len == sizeof (real) ? p->pf : p->pd); + if (d < MAXFRACDIGS) + d1 = 0; + else + { + d1 = d - MAXFRACDIGS; + d = MAXFRACDIGS; + } + if (x < 0.) + { + x = -x; + sign = 1; + } + else + { + sign = 0; #ifndef VAX - if (!x) - x = 0.; + if (!x) + x = 0.; #endif - } + } - if (n = f__scale) - if (n > 0) - do x *= 10.; while(--n > 0); - else - do x *= 0.1; while(++n < 0); + if (n = f__scale) + if (n > 0) + do + x *= 10.; + while (--n > 0); + else + do + x *= 0.1; + while (++n < 0); #ifdef USE_STRLEN - sprintf(b = buf, "%#.*f", d, x); - n = strlen(b) + d1; + sprintf (b = buf, "%#.*f", d, x); + n = strlen (b) + d1; #else - n = sprintf(b = buf, "%#.*f", d, x) + d1; + n = sprintf (b = buf, "%#.*f", d, x) + d1; #endif #ifndef WANT_LEAD_0 - if (buf[0] == '0' && d) - { ++b; --n; } + if (buf[0] == '0' && d) + { + ++b; + --n; + } #endif - if (sign) { - /* check for all zeros */ - for(s = b;;) { - while(*s == '0') s++; - switch(*s) { - case '.': - s++; continue; - case 0: - sign = 0; - } - break; - } - } - if (sign || f__cplus) - ++n; - if (n > w) { + if (sign) + { + /* check for all zeros */ + for (s = b;;) + { + while (*s == '0') + s++; + switch (*s) + { + case '.': + s++; + continue; + case 0: + sign = 0; + } + break; + } + } + if (sign || f__cplus) + ++n; + if (n > w) + { #ifdef WANT_LEAD_0 - if (buf[0] == '0' && --n == w) - ++b; - else + if (buf[0] == '0' && --n == w) + ++b; + else #endif - { - while(--w >= 0) - PUT('*'); - return 0; - } - } - for(w -= n; --w >= 0; ) - PUT(' '); - if (sign) - PUT('-'); - else if (f__cplus) - PUT('+'); - while(n = *b++) - PUT(n); - while(--d1 >= 0) - PUT('0'); - return 0; + { + while (--w >= 0) + PUT ('*'); + return 0; } + } + for (w -= n; --w >= 0;) + PUT (' '); + if (sign) + PUT ('-'); + else if (f__cplus) + PUT ('+'); + while (n = *b++) + PUT (n); + while (--d1 >= 0) + PUT ('0'); + return 0; +} diff --git a/libf2c/libI77/wrtfmt.c b/libf2c/libI77/wrtfmt.c index 12c770c..c2a440f 100644 --- a/libf2c/libI77/wrtfmt.c +++ b/libf2c/libI77/wrtfmt.c @@ -6,317 +6,393 @@ extern icilist *f__svic; extern char *f__icptr; - static int -mv_cur(void) /* shouldn't use fseek because it insists on calling fflush */ +static int +mv_cur (void) /* shouldn't use fseek because it insists on calling fflush */ /* instead we know too much about stdio */ { - int cursor = f__cursor; - f__cursor = 0; - if(f__external == 0) { - if(cursor < 0) { - if(f__hiwater < f__recpos) - f__hiwater = f__recpos; - f__recpos += cursor; - f__icptr += cursor; - if(f__recpos < 0) - err(f__elist->cierr, 110, "left off"); - } - else if(cursor > 0) { - if(f__recpos + cursor >= f__svic->icirlen) - err(f__elist->cierr, 110, "recend"); - if(f__hiwater <= f__recpos) - for(; cursor > 0; cursor--) - (*f__putn)(' '); - else if(f__hiwater <= f__recpos + cursor) { - cursor -= f__hiwater - f__recpos; - f__icptr += f__hiwater - f__recpos; - f__recpos = f__hiwater; - for(; cursor > 0; cursor--) - (*f__putn)(' '); - } - else { - f__icptr += cursor; - f__recpos += cursor; - } - } - return(0); + int cursor = f__cursor; + f__cursor = 0; + if (f__external == 0) + { + if (cursor < 0) + { + if (f__hiwater < f__recpos) + f__hiwater = f__recpos; + f__recpos += cursor; + f__icptr += cursor; + if (f__recpos < 0) + err (f__elist->cierr, 110, "left off"); + } + else if (cursor > 0) + { + if (f__recpos + cursor >= f__svic->icirlen) + err (f__elist->cierr, 110, "recend"); + if (f__hiwater <= f__recpos) + for (; cursor > 0; cursor--) + (*f__putn) (' '); + else if (f__hiwater <= f__recpos + cursor) + { + cursor -= f__hiwater - f__recpos; + f__icptr += f__hiwater - f__recpos; + f__recpos = f__hiwater; + for (; cursor > 0; cursor--) + (*f__putn) (' '); + } + else + { + f__icptr += cursor; + f__recpos += cursor; + } } - if (cursor > 0) { - if(f__hiwater <= f__recpos) - for(;cursor>0;cursor--) (*f__putn)(' '); - else if(f__hiwater <= f__recpos + cursor) { - cursor -= f__hiwater - f__recpos; - f__recpos = f__hiwater; - for(; cursor > 0; cursor--) - (*f__putn)(' '); - } - else { - f__recpos += cursor; - } + return (0); + } + if (cursor > 0) + { + if (f__hiwater <= f__recpos) + for (; cursor > 0; cursor--) + (*f__putn) (' '); + else if (f__hiwater <= f__recpos + cursor) + { + cursor -= f__hiwater - f__recpos; + f__recpos = f__hiwater; + for (; cursor > 0; cursor--) + (*f__putn) (' '); } - else if (cursor < 0) + else { - if(cursor + f__recpos < 0) - err(f__elist->cierr,110,"left off"); - if(f__hiwater < f__recpos) - f__hiwater = f__recpos; - f__recpos += cursor; + f__recpos += cursor; } - return(0); + } + else if (cursor < 0) + { + if (cursor + f__recpos < 0) + err (f__elist->cierr, 110, "left off"); + if (f__hiwater < f__recpos) + f__hiwater = f__recpos; + f__recpos += cursor; + } + return (0); } - static int -wrt_Z(Uint *n, int w, int minlen, ftnlen len) +static int +wrt_Z (Uint * n, int w, int minlen, ftnlen len) { - register char *s, *se; - register int i, w1; - static int one = 1; - static char hex[] = "0123456789ABCDEF"; - s = (char *)n; - --len; - if (*(char *)&one) { - /* little endian */ - se = s; - s += len; - i = -1; - } - else { - se = s + len; - i = 1; - } - for(;; s += i) - if (s == se || *s) - break; - w1 = (i*(se-s) << 1) + 1; - if (*s & 0xf0) - w1++; - if (w1 > w) - for(i = 0; i < w; i++) - (*f__putn)('*'); - else { - if ((minlen -= w1) > 0) - w1 += minlen; - while(--w >= w1) - (*f__putn)(' '); - while(--minlen >= 0) - (*f__putn)('0'); - if (!(*s & 0xf0)) { - (*f__putn)(hex[*s & 0xf]); - if (s == se) - return 0; - s += i; - } - for(;; s += i) { - (*f__putn)(hex[*s >> 4 & 0xf]); - (*f__putn)(hex[*s & 0xf]); - if (s == se) - break; - } - } - return 0; + register char *s, *se; + register int i, w1; + static int one = 1; + static char hex[] = "0123456789ABCDEF"; + s = (char *) n; + --len; + if (*(char *) &one) + { + /* little endian */ + se = s; + s += len; + i = -1; + } + else + { + se = s + len; + i = 1; + } + for (;; s += i) + if (s == se || *s) + break; + w1 = (i * (se - s) << 1) + 1; + if (*s & 0xf0) + w1++; + if (w1 > w) + for (i = 0; i < w; i++) + (*f__putn) ('*'); + else + { + if ((minlen -= w1) > 0) + w1 += minlen; + while (--w >= w1) + (*f__putn) (' '); + while (--minlen >= 0) + (*f__putn) ('0'); + if (!(*s & 0xf0)) + { + (*f__putn) (hex[*s & 0xf]); + if (s == se) + return 0; + s += i; + } + for (;; s += i) + { + (*f__putn) (hex[*s >> 4 & 0xf]); + (*f__putn) (hex[*s & 0xf]); + if (s == se) + break; } + } + return 0; +} - static int -wrt_I(Uint *n, int w, ftnlen len, register int base) -{ int ndigit,sign,spare,i; - longint x; - char *ans; - if(len==sizeof(integer)) x=n->il; - else if(len == sizeof(char)) x = n->ic; +static int +wrt_I (Uint * n, int w, ftnlen len, register int base) +{ + int ndigit, sign, spare, i; + longint x; + char *ans; + if (len == sizeof (integer)) + x = n->il; + else if (len == sizeof (char)) + x = n->ic; #ifdef Allow_TYQUAD - else if (len == sizeof(longint)) x = n->ili; + else if (len == sizeof (longint)) + x = n->ili; #endif - else x=n->is; - ans=f__icvt(x,&ndigit,&sign, base); - spare=w-ndigit; - if(sign || f__cplus) spare--; - if(spare<0) - for(i=0;i<w;i++) (*f__putn)('*'); - else - { for(i=0;i<spare;i++) (*f__putn)(' '); - if(sign) (*f__putn)('-'); - else if(f__cplus) (*f__putn)('+'); - for(i=0;i<ndigit;i++) (*f__putn)(*ans++); - } - return(0); + else + x = n->is; + ans = f__icvt (x, &ndigit, &sign, base); + spare = w - ndigit; + if (sign || f__cplus) + spare--; + if (spare < 0) + for (i = 0; i < w; i++) + (*f__putn) ('*'); + else + { + for (i = 0; i < spare; i++) + (*f__putn) (' '); + if (sign) + (*f__putn) ('-'); + else if (f__cplus) + (*f__putn) ('+'); + for (i = 0; i < ndigit; i++) + (*f__putn) (*ans++); + } + return (0); } - static int -wrt_IM(Uint *n, int w, int m, ftnlen len, int base) -{ int ndigit,sign,spare,i,xsign; - longint x; - char *ans; - if(sizeof(integer)==len) x=n->il; - else if(len == sizeof(char)) x = n->ic; +static int +wrt_IM (Uint * n, int w, int m, ftnlen len, int base) +{ + int ndigit, sign, spare, i, xsign; + longint x; + char *ans; + if (sizeof (integer) == len) + x = n->il; + else if (len == sizeof (char)) + x = n->ic; #ifdef Allow_TYQUAD - else if (len == sizeof(longint)) x = n->ili; + else if (len == sizeof (longint)) + x = n->ili; #endif - else x=n->is; - ans=f__icvt(x,&ndigit,&sign, base); - if(sign || f__cplus) xsign=1; - else xsign=0; - if(ndigit+xsign>w || m+xsign>w) - { for(i=0;i<w;i++) (*f__putn)('*'); - return(0); - } - if(x==0 && m==0) - { for(i=0;i<w;i++) (*f__putn)(' '); - return(0); - } - if(ndigit>=m) - spare=w-ndigit-xsign; - else - spare=w-m-xsign; - for(i=0;i<spare;i++) (*f__putn)(' '); - if(sign) (*f__putn)('-'); - else if(f__cplus) (*f__putn)('+'); - for(i=0;i<m-ndigit;i++) (*f__putn)('0'); - for(i=0;i<ndigit;i++) (*f__putn)(*ans++); - return(0); + else + x = n->is; + ans = f__icvt (x, &ndigit, &sign, base); + if (sign || f__cplus) + xsign = 1; + else + xsign = 0; + if (ndigit + xsign > w || m + xsign > w) + { + for (i = 0; i < w; i++) + (*f__putn) ('*'); + return (0); + } + if (x == 0 && m == 0) + { + for (i = 0; i < w; i++) + (*f__putn) (' '); + return (0); + } + if (ndigit >= m) + spare = w - ndigit - xsign; + else + spare = w - m - xsign; + for (i = 0; i < spare; i++) + (*f__putn) (' '); + if (sign) + (*f__putn) ('-'); + else if (f__cplus) + (*f__putn) ('+'); + for (i = 0; i < m - ndigit; i++) + (*f__putn) ('0'); + for (i = 0; i < ndigit; i++) + (*f__putn) (*ans++); + return (0); } - static int -wrt_AP(char *s) -{ char quote; - int i; +static int +wrt_AP (char *s) +{ + char quote; + int i; - if(f__cursor && (i = mv_cur())) - return i; - quote = *s++; - for(;*s;s++) - { if(*s!=quote) (*f__putn)(*s); - else if(*++s==quote) (*f__putn)(*s); - else return(1); - } - return(1); + if (f__cursor && (i = mv_cur ())) + return i; + quote = *s++; + for (; *s; s++) + { + if (*s != quote) + (*f__putn) (*s); + else if (*++s == quote) + (*f__putn) (*s); + else + return (1); + } + return (1); } - static int -wrt_H(int a, char *s) +static int +wrt_H (int a, char *s) { - int i; + int i; - if(f__cursor && (i = mv_cur())) - return i; - while(a--) (*f__putn)(*s++); - return(1); + if (f__cursor && (i = mv_cur ())) + return i; + while (a--) + (*f__putn) (*s++); + return (1); } -wrt_L(Uint *n, int len, ftnlen sz) -{ int i; - long x; - if(sizeof(long)==sz) x=n->il; - else if(sz == sizeof(char)) x = n->ic; - else x=n->is; - for(i=0;i<len-1;i++) - (*f__putn)(' '); - if(x) (*f__putn)('T'); - else (*f__putn)('F'); - return(0); + +wrt_L (Uint * n, int len, ftnlen sz) +{ + int i; + long x; + if (sizeof (long) == sz) + x = n->il; + else if (sz == sizeof (char)) + x = n->ic; + else + x = n->is; + for (i = 0; i < len - 1; i++) + (*f__putn) (' '); + if (x) + (*f__putn) ('T'); + else + (*f__putn) ('F'); + return (0); } - static int -wrt_A(char *p, ftnlen len) +static int +wrt_A (char *p, ftnlen len) { - while(len-- > 0) (*f__putn)(*p++); - return(0); + while (len-- > 0) + (*f__putn) (*p++); + return (0); } - static int -wrt_AW(char * p, int w, ftnlen len) +static int +wrt_AW (char *p, int w, ftnlen len) { - while(w>len) - { w--; - (*f__putn)(' '); - } - while(w-- > 0) - (*f__putn)(*p++); - return(0); + while (w > len) + { + w--; + (*f__putn) (' '); + } + while (w-- > 0) + (*f__putn) (*p++); + return (0); } - static int -wrt_G(ufloat *p, int w, int d, int e, ftnlen len) -{ double up = 1,x; - int i=0,oldscale,n,j; - x = len==sizeof(real)?p->pf:p->pd; - if(x < 0 ) x = -x; - if(x<.1) { - if (x != 0.) - return(wrt_E(p,w,d,e,len)); - i = 1; - goto have_i; - } - for(;i<=d;i++,up*=10) - { if(x>=up) continue; - have_i: - oldscale = f__scale; - f__scale = 0; - if(e==0) n=4; - else n=e+2; - i=wrt_F(p,w-n,d-i,len); - for(j=0;j<n;j++) (*f__putn)(' '); - f__scale=oldscale; - return(i); - } - return(wrt_E(p,w,d,e,len)); +static int +wrt_G (ufloat * p, int w, int d, int e, ftnlen len) +{ + double up = 1, x; + int i = 0, oldscale, n, j; + x = len == sizeof (real) ? p->pf : p->pd; + if (x < 0) + x = -x; + if (x < .1) + { + if (x != 0.) + return (wrt_E (p, w, d, e, len)); + i = 1; + goto have_i; + } + for (; i <= d; i++, up *= 10) + { + if (x >= up) + continue; + have_i: + oldscale = f__scale; + f__scale = 0; + if (e == 0) + n = 4; + else + n = e + 2; + i = wrt_F (p, w - n, d - i, len); + for (j = 0; j < n; j++) + (*f__putn) (' '); + f__scale = oldscale; + return (i); + } + return (wrt_E (p, w, d, e, len)); } -w_ed(struct syl *p, char *ptr, ftnlen len) + +w_ed (struct syl * p, char *ptr, ftnlen len) { - int i; + int i; - if(f__cursor && (i = mv_cur())) - return i; - switch(p->op) - { - default: - fprintf(stderr,"w_ed, unexpected code: %d\n", p->op); - sig_die(f__fmtbuf, 1); - case I: return(wrt_I((Uint *)ptr,p->p1,len, 10)); - case IM: - return(wrt_IM((Uint *)ptr,p->p1,p->p2.i[0],len,10)); + if (f__cursor && (i = mv_cur ())) + return i; + switch (p->op) + { + default: + fprintf (stderr, "w_ed, unexpected code: %d\n", p->op); + sig_die (f__fmtbuf, 1); + case I: + return (wrt_I ((Uint *) ptr, p->p1, len, 10)); + case IM: + return (wrt_IM ((Uint *) ptr, p->p1, p->p2.i[0], len, 10)); - /* 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. */ + /* 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. */ - case O: return(wrt_I((Uint *)ptr, p->p1, len, 8)); - case OM: - return(wrt_IM((Uint *)ptr,p->p1,p->p2.i[0],len,8)); - case L: return(wrt_L((Uint *)ptr,p->p1, len)); - case A: return(wrt_A(ptr,len)); - case AW: - return(wrt_AW(ptr,p->p1,len)); - case D: - case E: - case EE: - return(wrt_E((ufloat *)ptr,p->p1,p->p2.i[0],p->p2.i[1],len)); - case G: - case GE: - return(wrt_G((ufloat *)ptr,p->p1,p->p2.i[0],p->p2.i[1],len)); - case F: return(wrt_F((ufloat *)ptr,p->p1,p->p2.i[0],len)); + case O: + return (wrt_I ((Uint *) ptr, p->p1, len, 8)); + case OM: + return (wrt_IM ((Uint *) ptr, p->p1, p->p2.i[0], len, 8)); + case L: + return (wrt_L ((Uint *) ptr, p->p1, len)); + case A: + return (wrt_A (ptr, len)); + case AW: + return (wrt_AW (ptr, p->p1, len)); + case D: + case E: + case EE: + return (wrt_E ((ufloat *) ptr, p->p1, p->p2.i[0], p->p2.i[1], len)); + case G: + case GE: + return (wrt_G ((ufloat *) ptr, p->p1, p->p2.i[0], p->p2.i[1], len)); + case F: + return (wrt_F ((ufloat *) ptr, p->p1, p->p2.i[0], len)); - /* Z and ZM assume 8-bit bytes. */ + /* Z and ZM assume 8-bit bytes. */ - case Z: return(wrt_Z((Uint *)ptr,p->p1,0,len)); - case ZM: - return(wrt_Z((Uint *)ptr,p->p1,p->p2.i[0],len)); - } + case Z: + return (wrt_Z ((Uint *) ptr, p->p1, 0, len)); + case ZM: + return (wrt_Z ((Uint *) ptr, p->p1, p->p2.i[0], len)); + } } -w_ned(struct syl *p) + +w_ned (struct syl * p) { - switch(p->op) - { - default: fprintf(stderr,"w_ned, unexpected code: %d\n", p->op); - sig_die(f__fmtbuf, 1); - case SLASH: - return((*f__donewrec)()); - 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); - case TR: - case X: - f__cursor += p->p1; - return(1); - case APOS: - return(wrt_AP(p->p2.s)); - case H: - return(wrt_H(p->p1,p->p2.s)); - } + switch (p->op) + { + default: + fprintf (stderr, "w_ned, unexpected code: %d\n", p->op); + sig_die (f__fmtbuf, 1); + case SLASH: + return ((*f__donewrec) ()); + 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); + case TR: + case X: + f__cursor += p->p1; + return (1); + case APOS: + return (wrt_AP (p->p2.s)); + case H: + return (wrt_H (p->p1, p->p2.s)); + } } diff --git a/libf2c/libI77/wsfe.c b/libf2c/libI77/wsfe.c index 292b2ac..2c71957 100644 --- a/libf2c/libI77/wsfe.c +++ b/libf2c/libI77/wsfe.c @@ -5,68 +5,75 @@ #include "fmt.h" extern int f__hiwater; - int -x_wSL(void) +int +x_wSL (void) { - int n = f__putbuf('\n'); - f__hiwater = f__recpos = f__cursor = 0; - return(n == 0); + int n = f__putbuf ('\n'); + f__hiwater = f__recpos = f__cursor = 0; + return (n == 0); } - static int -xw_end(void) +static int +xw_end (void) { - int n; + int n; - if(f__nonl) { - f__putbuf(n = 0); - fflush(f__cf); - } - else - n = f__putbuf('\n'); - f__hiwater = f__recpos = f__cursor = 0; - return n; + if (f__nonl) + { + f__putbuf (n = 0); + fflush (f__cf); + } + else + n = f__putbuf ('\n'); + f__hiwater = f__recpos = f__cursor = 0; + return n; } - static int -xw_rev(void) +static int +xw_rev (void) { - int n = 0; - if(f__workdone) { - n = f__putbuf('\n'); - f__workdone = 0; - } - f__hiwater = f__recpos = f__cursor = 0; - return n; + int n = 0; + if (f__workdone) + { + n = f__putbuf ('\n'); + f__workdone = 0; + } + f__hiwater = f__recpos = f__cursor = 0; + return n; } -integer s_wsfe(cilist *a) /*start*/ -{ int n; - if(f__init != 1) f_init(); - f__init = 3; - f__reading=0; - f__sequential=1; - f__formatted=1; - f__external=1; - if(n=c_sfe(a)) return(n); - f__elist=a; - f__hiwater = f__cursor=f__recpos=0; - f__nonl = 0; - f__scale=0; - f__fmtbuf=a->cifmt; - f__curunit = &f__units[a->ciunit]; - f__cf=f__curunit->ufd; - if(pars_f(f__fmtbuf)<0) err(a->cierr,100,"startio"); - f__putn= x_putc; - f__doed= w_ed; - f__doned= w_ned; - f__doend=xw_end; - f__dorevert=xw_rev; - f__donewrec=x_wSL; - fmt_bg(); - f__cplus=0; - f__cblank=f__curunit->ublnk; - if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) - err(a->cierr,errno,"write start"); - return(0); +integer +s_wsfe (cilist * a) /*start */ +{ + int n; + if (f__init != 1) + f_init (); + f__init = 3; + f__reading = 0; + f__sequential = 1; + f__formatted = 1; + f__external = 1; + if (n = c_sfe (a)) + return (n); + f__elist = a; + f__hiwater = f__cursor = f__recpos = 0; + f__nonl = 0; + f__scale = 0; + f__fmtbuf = a->cifmt; + f__curunit = &f__units[a->ciunit]; + f__cf = f__curunit->ufd; + if (pars_f (f__fmtbuf) < 0) + err (a->cierr, 100, "startio"); + f__putn = x_putc; + f__doed = w_ed; + f__doned = w_ned; + f__doend = xw_end; + f__dorevert = xw_rev; + f__donewrec = x_wSL; + fmt_bg (); + f__cplus = 0; + f__cblank = f__curunit->ublnk; + if (f__curunit->uwrt != 1 && f__nowwriting (f__curunit)) + err (a->cierr, errno, "write start"); + return (0); } diff --git a/libf2c/libI77/wsle.c b/libf2c/libI77/wsle.c index 5e17481..b418707 100644 --- a/libf2c/libI77/wsle.c +++ b/libf2c/libI77/wsle.c @@ -5,31 +5,34 @@ #include "lio.h" #include "string.h" -integer s_wsle(cilist *a) +integer +s_wsle (cilist * a) { - int n; - if(n=c_le(a)) return(n); - f__reading=0; - f__external=1; - f__formatted=1; - f__putn = x_putc; - f__lioproc = l_write; - L_len = LINE; - f__donewrec = x_wSL; - if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) - err(a->cierr, errno, "list output start"); - return(0); - } + int n; + if (n = c_le (a)) + return (n); + f__reading = 0; + f__external = 1; + f__formatted = 1; + f__putn = x_putc; + f__lioproc = l_write; + L_len = LINE; + f__donewrec = x_wSL; + if (f__curunit->uwrt != 1 && f__nowwriting (f__curunit)) + err (a->cierr, errno, "list output start"); + return (0); +} -integer e_wsle(void) +integer +e_wsle (void) { - int n; - f__init = 1; - n = f__putbuf('\n'); - f__recpos=0; + int n; + f__init = 1; + n = f__putbuf ('\n'); + f__recpos = 0; #ifdef ALWAYS_FLUSH - if (!n && fflush(f__cf)) - err(f__elist->cierr, errno, "write end"); + if (!n && fflush (f__cf)) + err (f__elist->cierr, errno, "write end"); #endif - return(n); - } + return (n); +} diff --git a/libf2c/libI77/wsne.c b/libf2c/libI77/wsne.c index 7c08925..8211ca7 100644 --- a/libf2c/libI77/wsne.c +++ b/libf2c/libI77/wsne.c @@ -2,21 +2,21 @@ #include "fio.h" #include "lio.h" - integer -s_wsne(cilist *a) +integer +s_wsne (cilist * a) { - int n; + int n; - if(n=c_le(a)) - return(n); - f__reading=0; - f__external=1; - f__formatted=1; - f__putn = x_putc; - L_len = LINE; - f__donewrec = x_wSL; - if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) - err(a->cierr, errno, "namelist output start"); - x_wsne(a); - return e_wsle(); - } + if (n = c_le (a)) + return (n); + f__reading = 0; + f__external = 1; + f__formatted = 1; + f__putn = x_putc; + L_len = LINE; + f__donewrec = x_wSL; + if (f__curunit->uwrt != 1 && f__nowwriting (f__curunit)) + err (a->cierr, errno, "namelist output start"); + x_wsne (a); + return e_wsle (); +} diff --git a/libf2c/libI77/xwsne.c b/libf2c/libI77/xwsne.c index c5a8556..68b606c 100644 --- a/libf2c/libI77/xwsne.c +++ b/libf2c/libI77/xwsne.c @@ -7,62 +7,65 @@ extern int f__Aquote; static void -nl_donewrec(void) +nl_donewrec (void) { - (*f__donewrec)(); - PUT(' '); - } + (*f__donewrec) (); + PUT (' '); +} #include <string.h> void -x_wsne(cilist *a) +x_wsne (cilist * a) { - Namelist *nl; - char *s; - Vardesc *v, **vd, **vde; - ftnint number, type; - ftnlen *dims; - ftnlen size; - extern ftnlen f__typesize[]; + Namelist *nl; + char *s; + Vardesc *v, **vd, **vde; + ftnint number, type; + ftnlen *dims; + ftnlen size; + extern ftnlen f__typesize[]; - nl = (Namelist *)a->cifmt; - PUT('&'); - for(s = nl->name; *s; s++) - PUT(*s); - PUT(' '); - f__Aquote = 1; - vd = nl->vars; - vde = vd + nl->nvars; - while(vd < vde) { - v = *vd++; - s = v->name; + nl = (Namelist *) a->cifmt; + PUT ('&'); + for (s = nl->name; *s; s++) + PUT (*s); + PUT (' '); + f__Aquote = 1; + vd = nl->vars; + vde = vd + nl->nvars; + while (vd < vde) + { + v = *vd++; + s = v->name; #ifdef No_Extra_Namelist_Newlines - if (f__recpos+strlen(s)+2 >= L_len) + if (f__recpos + strlen (s) + 2 >= L_len) #endif - nl_donewrec(); - while(*s) - PUT(*s++); - PUT(' '); - PUT('='); - number = (dims = v->dims) ? dims[1] : 1; - type = v->type; - if (type < 0) { - size = -type; - type = TYCHAR; - } - else - size = f__typesize[type]; - l_write(&number, v->addr, size, type); - if (vd < vde) { - if (f__recpos+2 >= L_len) - nl_donewrec(); - PUT(','); - PUT(' '); - } - else if (f__recpos+1 >= L_len) - nl_donewrec(); - } - f__Aquote = 0; - PUT('/'); + nl_donewrec (); + while (*s) + PUT (*s++); + PUT (' '); + PUT ('='); + number = (dims = v->dims) ? dims[1] : 1; + type = v->type; + if (type < 0) + { + size = -type; + type = TYCHAR; + } + else + size = f__typesize[type]; + l_write (&number, v->addr, size, type); + if (vd < vde) + { + if (f__recpos + 2 >= L_len) + nl_donewrec (); + PUT (','); + PUT (' '); } + else if (f__recpos + 1 >= L_len) + nl_donewrec (); + } + f__Aquote = 0; + PUT ('/'); +} diff --git a/libf2c/libU77/access_.c b/libf2c/libU77/access_.c index a2439e8..02dcd51 100644 --- a/libf2c/libU77/access_.c +++ b/libf2c/libU77/access_.c @@ -45,27 +45,40 @@ Boston, MA 02111-1307, USA. */ # define F_OK 0 #endif -void g_char(const char *a, ftnlen alen, char *b); +void g_char (const char *a, ftnlen alen, char *b); -integer G77_access_0 (const char *name, const char *mode, ftnlen Lname, ftnlen Lmode) +integer +G77_access_0 (const char *name, const char *mode, ftnlen Lname, ftnlen Lmode) { char *buff; char *bp, *blast; int amode, i; - buff = malloc (Lname+1); - if (!buff) return -1; + buff = malloc (Lname + 1); + if (!buff) + return -1; g_char (name, Lname, buff); amode = 0; - for (i=0;i<Lmode;i++) { - switch (mode[i]) { - case 'r': amode |= R_OK; break; - case 'w': amode |= W_OK; break; - case 'x': amode |= X_OK; break; - case ' ': amode |= F_OK; break; /* as per Sun, at least */ - default: return EINVAL; + for (i = 0; i < Lmode; i++) + { + switch (mode[i]) + { + case 'r': + amode |= R_OK; + break; + case 'w': + amode |= W_OK; + break; + case 'x': + amode |= X_OK; + break; + case ' ': + amode |= F_OK; + break; /* as per Sun, at least */ + default: + return EINVAL; + } } - } i = access (buff, amode); free (buff); return i; diff --git a/libf2c/libU77/alarm_.c b/libf2c/libU77/alarm_.c index fd3842a..d2c9382 100644 --- a/libf2c/libU77/alarm_.c +++ b/libf2c/libU77/alarm_.c @@ -31,20 +31,21 @@ Boston, MA 02111-1307, USA. */ /* we shouldn't rely on this... */ #define RETSIGTYPE void #endif -typedef RETSIGTYPE (*sig_type)(); +typedef RETSIGTYPE (*sig_type) (); #include <signal.h> -typedef int (*sig_proc)(int); +typedef int (*sig_proc) (int); #ifndef SIG_ERR #define SIG_ERR ((sig_type) -1) #endif -integer G77_alarm_0 (integer *seconds, sig_proc proc) +integer +G77_alarm_0 (integer * seconds, sig_proc proc) { int status; #if defined (HAVE_ALARM) && defined (SIGALRM) - if (signal(SIGALRM, (sig_type)proc) == SIG_ERR) + if (signal (SIGALRM, (sig_type) proc) == SIG_ERR) status = -1; else status = alarm (*seconds); diff --git a/libf2c/libU77/bes.c b/libf2c/libU77/bes.c index 442337f..73373fd 100644 --- a/libf2c/libU77/bes.c +++ b/libf2c/libU77/bes.c @@ -16,31 +16,43 @@ License along with GNU Fortran; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#if 0 /* Don't include these unless necessary -- jcb. */ +#if 0 /* Don't include these unless necessary -- jcb. */ #include "f2c.h" #include <math.h> -double G77_besj0_0 (const real *x) { - return j0 (*x); +double +G77_besj0_0 (const real * x) +{ + return j0 (*x); } -double G77_besj1_0 (const real *x) { - return j1 (*x); +double +G77_besj1_0 (const real * x) +{ + return j1 (*x); } -double G77_besjn_0 (const integer *n, real *x) { - return jn (*n, *x); - } +double +G77_besjn_0 (const integer * n, real * x) +{ + return jn (*n, *x); +} -double G77_besy0_0 (const real *x) { - return y0 (*x); +double +G77_besy0_0 (const real * x) +{ + return y0 (*x); } -double G77_besy1_0 (const real *x) { - return y1 (*x); +double +G77_besy1_0 (const real * x) +{ + return y1 (*x); } -double G77_besyn_0 (const integer *n, real *x) { - return yn (*n, *x); +double +G77_besyn_0 (const integer * n, real * x) +{ + return yn (*n, *x); } #endif diff --git a/libf2c/libU77/chdir_.c b/libf2c/libU77/chdir_.c index a071a6d..d9afb57 100644 --- a/libf2c/libU77/chdir_.c +++ b/libf2c/libU77/chdir_.c @@ -32,16 +32,18 @@ Boston, MA 02111-1307, USA. */ #include "f2c.h" -void g_char(const char *a, ftnlen alen, char *b); +void g_char (const char *a, ftnlen alen, char *b); -integer G77_chdir_0 (const char *name, const ftnlen Lname) +integer +G77_chdir_0 (const char *name, const ftnlen Lname) { char *buff; char *bp, *blast; int i; - buff = malloc (Lname+1); - if (!buff) return -1; + buff = malloc (Lname + 1); + if (!buff) + return -1; g_char (name, Lname, buff); i = chdir (buff); free (buff); diff --git a/libf2c/libU77/chmod_.c b/libf2c/libU77/chmod_.c index dfe0d36..554d259 100644 --- a/libf2c/libU77/chmod_.c +++ b/libf2c/libU77/chmod_.c @@ -41,10 +41,13 @@ Boston, MA 02111-1307, USA. */ #define CHMOD_PATH "/bin/chmod" #endif -extern void s_cat(char *lp, char *rpp[], ftnlen rnp[], ftnlen *np, ftnlen ll); -void g_char(const char *a, ftnlen alen, char *b); +extern void s_cat (char *lp, char *rpp[], ftnlen rnp[], ftnlen * np, + ftnlen ll); +void g_char (const char *a, ftnlen alen, char *b); -integer G77_chmod_0 (/* const */ char *name, /* const */ char *mode, const ftnlen Lname, const ftnlen Lmode) +integer +G77_chmod_0 ( /* const */ char *name, /* const */ char *mode, + const ftnlen Lname, const ftnlen Lmode) { char *buff; char *bp, *blast; @@ -53,20 +56,27 @@ integer G77_chmod_0 (/* const */ char *name, /* const */ char *mode, const ftnle ftnlen six = 6; address a[6]; ftnlen ii[6]; - char chmod_path [] = CHMOD_PATH; + char chmod_path[] = CHMOD_PATH; l = strlen (chmod_path); - buff = malloc (Lname+Lmode+l+3+13+1); - if (!buff) return -1; - ii[0] = l; a[0] = chmod_path; - ii[1] = 1; a[1] = " "; - ii[2] = Lmode; a[2] = mode; - ii[3] = 2; a[3] = " '"; - for (l2=Lname; (l2 > 1) && (name[l2-1] == ' '); ) + buff = malloc (Lname + Lmode + l + 3 + 13 + 1); + if (!buff) + return -1; + ii[0] = l; + a[0] = chmod_path; + ii[1] = 1; + a[1] = " "; + ii[2] = Lmode; + a[2] = mode; + ii[3] = 2; + a[3] = " '"; + for (l2 = Lname; (l2 > 1) && (name[l2 - 1] == ' ');) l2--; - ii[4] = l2; a[4] = name; - ii[5] = 13; a[5] = "' 2>/dev/null"; - s_cat (buff, a, ii, &six, Lname+Lmode+l+3+13); - buff[Lname+Lmode+l+3+13] = '\0'; + ii[4] = l2; + a[4] = name; + ii[5] = 13; + a[5] = "' 2>/dev/null"; + s_cat (buff, a, ii, &six, Lname + Lmode + l + 3 + 13); + buff[Lname + Lmode + l + 3 + 13] = '\0'; i = system (buff); free (buff); return i; diff --git a/libf2c/libU77/ctime_.c b/libf2c/libU77/ctime_.c index c80f6f68..34e6d7c 100644 --- a/libf2c/libU77/ctime_.c +++ b/libf2c/libU77/ctime_.c @@ -39,7 +39,8 @@ Boston, MA 02111-1307, USA. */ /* may need sys/time.h & long arg for stime (bsd, svr1-3) */ -/* Character */ void G77_ctime_0 (char *chtime, const ftnlen Lchtime, longint * xstime) +/* Character */ void +G77_ctime_0 (char *chtime, const ftnlen Lchtime, longint * xstime) { int i, l; int s_copy (); diff --git a/libf2c/libU77/date_.c b/libf2c/libU77/date_.c index ca94797..fffbe20 100644 --- a/libf2c/libU77/date_.c +++ b/libf2c/libU77/date_.c @@ -9,47 +9,47 @@ static integer c__5 = 5; -/* Subroutine */ int G77_date_y2kbug_0 (char *buf, ftnlen buf_len) +/* Subroutine */ int +G77_date_y2kbug_0 (char *buf, ftnlen buf_len) { - /* System generated locals */ - address a__1[5]; - longint i__1; - integer i__2[5]; - char ch__1[24]; - - /* Builtin functions */ - /* Subroutine */ int s_copy(), s_cat(); - - /* Local variables */ - static char cbuf[24]; - extern longint G77_time_0 (); - extern /* Character */ void G77_ctime_0 (); - - i__1 = G77_time_0 (); - G77_ctime_0 (ch__1, 24L, &i__1); - s_copy(cbuf, ch__1, 24L, 24L); + /* System generated locals */ + address a__1[5]; + longint i__1; + integer i__2[5]; + char ch__1[24]; + + /* Builtin functions */ + /* Subroutine */ int s_copy (), s_cat (); + + /* Local variables */ + static char cbuf[24]; + extern longint G77_time_0 (); + extern /* Character */ void G77_ctime_0 (); + + i__1 = G77_time_0 (); + G77_ctime_0 (ch__1, 24L, &i__1); + s_copy (cbuf, ch__1, 24L, 24L); /* Writing concatenation */ - i__2[0] = 2, a__1[0] = cbuf + 8; - i__2[1] = 1, a__1[1] = "-"; - i__2[2] = 3, a__1[2] = cbuf + 4; - i__2[3] = 1, a__1[3] = "-"; - i__2[4] = 2, a__1[4] = cbuf + 22; - s_cat(buf, a__1, i__2, &c__5, buf_len); - return 0; -} /* date_ */ + i__2[0] = 2, a__1[0] = cbuf + 8; + i__2[1] = 1, a__1[1] = "-"; + i__2[2] = 3, a__1[2] = cbuf + 4; + i__2[3] = 1, a__1[3] = "-"; + i__2[4] = 2, a__1[4] = cbuf + 22; + s_cat (buf, a__1, i__2, &c__5, buf_len); + return 0; +} /* date_ */ #ifdef PIC # include <stdio.h> const char *G77_Non_Y2K_Compliance_Message = - "Call to non Y2K compliant subroutine detected."; + "Call to non Y2K compliant subroutine detected."; -int G77_date_y2kbuggy_0 (char *buf, ftnlen buf_len) +int +G77_date_y2kbuggy_0 (char *buf, ftnlen buf_len) { - extern int G77_abort_0(); + extern int G77_abort_0 (); fprintf (stderr, "%s\n", G77_Non_Y2K_Compliance_Message); - G77_abort_0(); + G77_abort_0 (); } #endif - - diff --git a/libf2c/libU77/datetime_.c b/libf2c/libU77/datetime_.c index 68fe411..40786ed 100644 --- a/libf2c/libU77/datetime_.c +++ b/libf2c/libU77/datetime_.c @@ -33,14 +33,15 @@ Boston, MA 02111-1307, USA. */ #endif #include "f2c.h" -void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb); +void s_copy (register char *a, register char *b, ftnlen la, ftnlen lb); -int G77_date_and_time_0 (char *date, char *fftime, char *zone, - integer *values, ftnlen date_len, - ftnlen fftime_len, ftnlen zone_len) +int +G77_date_and_time_0 (char *date, char *fftime, char *zone, + integer * values, ftnlen date_len, + ftnlen fftime_len, ftnlen zone_len) { - time_t lt=time(<); - struct tm ltime = *localtime(<), gtime = *gmtime(<); + time_t lt = time (<); + struct tm ltime = *localtime (<), gtime = *gmtime (<); char dat[9], zon[6], ftim[11]; int i, vals[8]; @@ -49,18 +50,18 @@ int G77_date_and_time_0 (char *date, char *fftime, char *zone, vals[2] = ltime.tm_mday; /* fixme: year boundaries */ vals[3] = (ltime.tm_min - gtime.tm_min + - 60*(ltime.tm_hour - gtime.tm_hour + - 24*(ltime.tm_yday -gtime.tm_yday))); + 60 * (ltime.tm_hour - gtime.tm_hour + + 24 * (ltime.tm_yday - gtime.tm_yday))); vals[4] = ltime.tm_hour; vals[5] = ltime.tm_min; vals[6] = ltime.tm_sec; - vals[7] = 0; /* no STDC/POSIX way to get this */ + vals[7] = 0; /* no STDC/POSIX way to get this */ /* GNUish way; maybe use `ftime' on other systems. */ #if HAVE_GETTIMEOFDAY { struct timeval tp; # if GETTIMEOFDAY_ONE_ARGUMENT - if (! gettimeofday (&tp)) + if (!gettimeofday (&tp)) # else # if HAVE_STRUCT_TIMEZONE struct timezone tzp; @@ -70,26 +71,28 @@ int G77_date_and_time_0 (char *date, char *fftime, char *zone, HPUX. Configure checks if gettimeofday actually fails with a non-NULL arg and pretends that struct timezone is missing if it does fail. */ - if (! gettimeofday (&tp, &tzp)) + if (!gettimeofday (&tp, &tzp)) # else - if (! gettimeofday (&tp, (void *) 0)) + if (!gettimeofday (&tp, (void *) 0)) # endif /* HAVE_STRUCT_TIMEZONE */ # endif /* GETTIMEOFDAY_ONE_ARGUMENT */ - vals[7] = tp.tv_usec/1000; + vals[7] = tp.tv_usec / 1000; } #endif /* HAVE_GETTIMEOFDAY */ if (values) /* null pointer for missing optional */ - for (i=0; i<=7; i++) + for (i = 0; i <= 7; i++) values[i] = vals[i]; sprintf (dat, "%04d%02d%02d", vals[0], vals[1], vals[2]); - s_copy(date, dat, date_len, 8); - if (zone) { - sprintf(zon, "%+03d%02d", vals[3] / 60, abs(vals[3] % 60)); - s_copy(zone, zon, zone_len, 5); - } - if (fftime) { - sprintf (ftim, "%02d%02d%02d.%03d", vals[4], vals[5], vals[6], vals[7]); - s_copy(fftime, ftim, fftime_len, 10); - } + s_copy (date, dat, date_len, 8); + if (zone) + { + sprintf (zon, "%+03d%02d", vals[3] / 60, abs (vals[3] % 60)); + s_copy (zone, zon, zone_len, 5); + } + if (fftime) + { + sprintf (ftim, "%02d%02d%02d.%03d", vals[4], vals[5], vals[6], vals[7]); + s_copy (fftime, ftim, fftime_len, 10); + } return 0; } diff --git a/libf2c/libU77/dbes.c b/libf2c/libU77/dbes.c index 1ef5978..8a31746 100644 --- a/libf2c/libU77/dbes.c +++ b/libf2c/libU77/dbes.c @@ -16,31 +16,43 @@ License along with GNU Fortran; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#if 0 /* Don't include these unless necessary -- dnp. */ +#if 0 /* Don't include these unless necessary -- dnp. */ #include "f2c.h" #include <math.h> -double G77_dbesj0_0 (const double *x) { - return j0 (*x); +double +G77_dbesj0_0 (const double *x) +{ + return j0 (*x); } -double G77_dbesj1_0 (const double *x) { - return j1 (*x); +double +G77_dbesj1_0 (const double *x) +{ + return j1 (*x); } -double G77_dbesjn_0 (const integer *n, double *x) { - return jn (*n, *x); - } +double +G77_dbesjn_0 (const integer * n, double *x) +{ + return jn (*n, *x); +} -double G77_dbesy0_0 (const double *x) { - return y0 (*x); +double +G77_dbesy0_0 (const double *x) +{ + return y0 (*x); } -double G77_dbesy1_0 (const double *x) { - return y1 (*x); +double +G77_dbesy1_0 (const double *x) +{ + return y1 (*x); } -double G77_dbesyn_0 (const integer *n, double *x) { - return yn (*n, *x); +double +G77_dbesyn_0 (const integer * n, double *x) +{ + return yn (*n, *x); } #endif diff --git a/libf2c/libU77/dtime_.c b/libf2c/libU77/dtime_.c index ab821d7..cc3961b 100644 --- a/libf2c/libU77/dtime_.c +++ b/libf2c/libU77/dtime_.c @@ -51,7 +51,8 @@ Boston, MA 02111-1307, USA. */ different to all others. */ static long clk_tck = 0; -double G77_dtime_0 (real tarray[2]) +double +G77_dtime_0 (real tarray[2]) { #if defined (_WIN32) static int win32_platform = -1; @@ -63,7 +64,7 @@ double G77_dtime_0 (real tarray[2]) GetVersionEx (&osv); win32_platform = osv.dwPlatformId; } - + /* We need to use this hack on non-NT platforms, where the first call returns 0.0 and subsequent ones return the correct value. */ if (win32_platform != VER_PLATFORM_WIN32_NT) @@ -77,7 +78,7 @@ double G77_dtime_0 (real tarray[2]) if (clock_freq == 0) { LARGE_INTEGER freq; - if (! QueryPerformanceFrequency (&freq)) + if (!QueryPerformanceFrequency (&freq)) { errno = ENOSYS; return 0.0; @@ -85,15 +86,15 @@ double G77_dtime_0 (real tarray[2]) else { clock_freq = ((unsigned long long) freq.HighPart << 32) - + ((unsigned) freq.LowPart); + + ((unsigned) freq.LowPart); } } - if (! QueryPerformanceCounter (&counter_val)) + if (!QueryPerformanceCounter (&counter_val)) return -1.0; count = ((unsigned long long) counter_val.HighPart << 32) - + (unsigned) counter_val.LowPart; + + (unsigned) counter_val.LowPart; delta = ((double) (count - old_count)) / clock_freq; tarray[0] = (float) delta; tarray[1] = 0.0; @@ -107,10 +108,10 @@ double G77_dtime_0 (real tarray[2]) GetProcessTimes (GetCurrentProcess (), &creation_time, &exit_time, &kernel_time, &user_time); - utime = ((unsigned long long) user_time.dwHighDateTime << 32) - + (unsigned) user_time.dwLowDateTime; - stime = ((unsigned long long) kernel_time.dwHighDateTime << 32) - + (unsigned) kernel_time.dwLowDateTime; + utime = ((unsigned long long) user_time.dwHighDateTime << 32) + + (unsigned) user_time.dwLowDateTime; + stime = ((unsigned long long) kernel_time.dwHighDateTime << 32) + + (unsigned) kernel_time.dwLowDateTime; tarray[0] = (utime - old_utime) / 1.0e7; tarray[1] = (stime - old_stime) / 1.0e7; @@ -126,15 +127,15 @@ double G77_dtime_0 (real tarray[2]) static float old_utime = 0.0, old_stime = 0.0; struct rusage rbuff; - if (getrusage (RUSAGE_SELF, &rbuff) != 0) - abort (); - utime = (float) (rbuff.ru_utime).tv_sec + - (float) (rbuff.ru_utime).tv_usec/1000000.0; - tarray[0] = utime - (float) old_utime; - stime = (float) (rbuff.ru_stime).tv_sec + - (float) (rbuff.ru_stime).tv_usec/1000000.0; + if (getrusage (RUSAGE_SELF, &rbuff) != 0) + abort (); + utime = (float) (rbuff.ru_utime).tv_sec + + (float) (rbuff.ru_utime).tv_usec / 1000000.0; + tarray[0] = utime - (float) old_utime; + stime = (float) (rbuff.ru_stime).tv_sec + + (float) (rbuff.ru_stime).tv_usec / 1000000.0; tarray[1] = stime - old_stime; -#else /* HAVE_GETRUSAGE */ +#else /* HAVE_GETRUSAGE */ time_t utime, stime; static time_t old_utime = 0, old_stime = 0; struct tms buffer; @@ -142,24 +143,31 @@ double G77_dtime_0 (real tarray[2]) /* NeXTStep seems to define _SC_CLK_TCK but not to have sysconf; fixme: does using _POSIX_VERSION help? */ # if defined _SC_CLK_TCK && defined _POSIX_VERSION - if (! clk_tck) clk_tck = sysconf(_SC_CLK_TCK); + if (!clk_tck) + clk_tck = sysconf (_SC_CLK_TCK); # elif defined CLOCKS_PER_SECOND - if (! clk_tck) clk_tck = CLOCKS_PER_SECOND; + if (!clk_tck) + clk_tck = CLOCKS_PER_SECOND; # elif defined CLK_TCK - if (! clk_tck) clk_tck = CLK_TCK; + if (!clk_tck) + clk_tck = CLK_TCK; # elif defined HZ - if (! clk_tck) clk_tck = HZ; + if (!clk_tck) + clk_tck = HZ; # elif defined HAVE_GETRUSAGE # else - #error Dont know clock tick length +#error Dont know clock tick length # endif - if (times(&buffer) == (clock_t)-1) return -1.0; - utime = buffer.tms_utime; stime = buffer.tms_stime; - tarray[0] = ((float)(utime - old_utime)) / (float)clk_tck; - tarray[1] = ((float)(stime - old_stime)) / (float)clk_tck; + if (times (&buffer) == (clock_t) - 1) + return -1.0; + utime = buffer.tms_utime; + stime = buffer.tms_stime; + tarray[0] = ((float) (utime - old_utime)) / (float) clk_tck; + tarray[1] = ((float) (stime - old_stime)) / (float) clk_tck; #endif /* HAVE_GETRUSAGE */ - old_utime = utime; old_stime = stime; - return (tarray[0]+tarray[1]); + old_utime = utime; + old_stime = stime; + return (tarray[0] + tarray[1]); #else /* ! HAVE_GETRUSAGE && ! HAVE_TIMES */ errno = ENOSYS; return 0.0; diff --git a/libf2c/libU77/etime_.c b/libf2c/libU77/etime_.c index b613e89..f942ea8 100644 --- a/libf2c/libU77/etime_.c +++ b/libf2c/libU77/etime_.c @@ -51,7 +51,8 @@ Boston, MA 02111-1307, USA. */ different to all others. */ static long clk_tck = 0; -double G77_etime_0 (real tarray[2]) +double +G77_etime_0 (real tarray[2]) { #if defined (_WIN32) static int win32_platform = -1; @@ -64,7 +65,7 @@ double G77_etime_0 (real tarray[2]) GetVersionEx (&osv); win32_platform = osv.dwPlatformId; } - + /* non-NT platforms don't have a clue as to how long a process has been running, so simply return the uptime. Bad judgement call? */ if (win32_platform != VER_PLATFORM_WIN32_NT) @@ -77,7 +78,7 @@ double G77_etime_0 (real tarray[2]) if (clock_freq == 0) { LARGE_INTEGER freq; - if (! QueryPerformanceFrequency (&freq)) + if (!QueryPerformanceFrequency (&freq)) { errno = ENOSYS; return 0.0; @@ -85,19 +86,19 @@ double G77_etime_0 (real tarray[2]) else { clock_freq = ((unsigned long long) freq.HighPart << 32) - + ((unsigned) freq.LowPart); - if (! QueryPerformanceCounter (&counter_val)) + + ((unsigned) freq.LowPart); + if (!QueryPerformanceCounter (&counter_val)) return -1.0; old_count = ((unsigned long long) counter_val.HighPart << 32) - + (unsigned) counter_val.LowPart; + + (unsigned) counter_val.LowPart; } } - if (! QueryPerformanceCounter (&counter_val)) + if (!QueryPerformanceCounter (&counter_val)) return -1.0; count = ((unsigned long long) counter_val.HighPart << 32) - + (unsigned) counter_val.LowPart; + + (unsigned) counter_val.LowPart; tarray[0] = usertime = (double) (count - old_count) / clock_freq; tarray[1] = systime = 0.0; } @@ -109,13 +110,13 @@ double G77_etime_0 (real tarray[2]) GetProcessTimes (GetCurrentProcess (), &creation_time, &exit_time, &kernel_time, &user_time); utime = ((unsigned long long) user_time.dwHighDateTime << 32) - + (unsigned) user_time.dwLowDateTime; + + (unsigned) user_time.dwLowDateTime; stime = ((unsigned long long) kernel_time.dwHighDateTime << 32) - + (unsigned) kernel_time.dwLowDateTime; + + (unsigned) kernel_time.dwLowDateTime; tarray[0] = usertime = utime / 1.0e7; tarray[1] = systime = stime / 1.0e7; - } + } return usertime + systime; #elif defined (HAVE_GETRUSAGE) || defined (HAVE_TIMES) @@ -123,34 +124,39 @@ double G77_etime_0 (real tarray[2]) #ifdef HAVE_GETRUSAGE struct rusage rbuff; - if (getrusage (RUSAGE_SELF, &rbuff) != 0) - abort (); - tarray[0] = ((float) (rbuff.ru_utime).tv_sec + - (float) (rbuff.ru_utime).tv_usec/1000000.0); - tarray[1] = ((float) (rbuff.ru_stime).tv_sec + - (float) (rbuff.ru_stime).tv_usec/1000000.0); -#else /* HAVE_GETRUSAGE */ + if (getrusage (RUSAGE_SELF, &rbuff) != 0) + abort (); + tarray[0] = ((float) (rbuff.ru_utime).tv_sec + + (float) (rbuff.ru_utime).tv_usec / 1000000.0); + tarray[1] = ((float) (rbuff.ru_stime).tv_sec + + (float) (rbuff.ru_stime).tv_usec / 1000000.0); +#else /* HAVE_GETRUSAGE */ struct tms buffer; /* NeXTStep seems to define _SC_CLK_TCK but not to have sysconf; fixme: does using _POSIX_VERSION help? */ # if defined _SC_CLK_TCK && defined _POSIX_VERSION - if (! clk_tck) clk_tck = sysconf(_SC_CLK_TCK); + if (!clk_tck) + clk_tck = sysconf (_SC_CLK_TCK); # elif defined CLOCKS_PER_SECOND - if (! clk_tck) clk_tck = CLOCKS_PER_SECOND; + if (!clk_tck) + clk_tck = CLOCKS_PER_SECOND; # elif defined CLK_TCK - if (! clk_tck) clk_tck = CLK_TCK; + if (!clk_tck) + clk_tck = CLK_TCK; # elif defined HZ - if (! clk_tck) clk_tck = HZ; + if (!clk_tck) + clk_tck = HZ; # elif defined HAVE_GETRUSAGE # else - #error Dont know clock tick length +#error Dont know clock tick length # endif - if (times(&buffer) == (clock_t)-1) return -1.0; - tarray[0] = (float) buffer.tms_utime / (float)clk_tck; - tarray[1] = (float) buffer.tms_stime / (float)clk_tck; + if (times (&buffer) == (clock_t) - 1) + return -1.0; + tarray[0] = (float) buffer.tms_utime / (float) clk_tck; + tarray[1] = (float) buffer.tms_stime / (float) clk_tck; #endif /* HAVE_GETRUSAGE */ - return (tarray[0]+tarray[1]); + return (tarray[0] + tarray[1]); #else /* ! HAVE_GETRUSAGE && ! HAVE_TIMES */ errno = ENOSYS; return 0.0; diff --git a/libf2c/libU77/fdate_.c b/libf2c/libU77/fdate_.c index a0bc983..d710a5c 100644 --- a/libf2c/libU77/fdate_.c +++ b/libf2c/libU77/fdate_.c @@ -43,12 +43,13 @@ Boston, MA 02111-1307, USA. */ also a subroutine version. Of course, the calling convention is essentially the same for both. */ -/* Character *24 */ void G77_fdate_0 (char *ret_val, ftnlen ret_val_len) +/* Character *24 */ void +G77_fdate_0 (char *ret_val, ftnlen ret_val_len) { - int s_copy (); - time_t tloc; - tloc = time (NULL); - /* Allow a length other than 24 for compatibility with what other - systems do, despite it being documented as 24. */ - s_copy (ret_val, ctime ((time_t *) &tloc), ret_val_len, 24); + int s_copy (); + time_t tloc; + tloc = time (NULL); + /* Allow a length other than 24 for compatibility with what other + systems do, despite it being documented as 24. */ + s_copy (ret_val, ctime ((time_t *) & tloc), ret_val_len, 24); } diff --git a/libf2c/libU77/fgetc_.c b/libf2c/libU77/fgetc_.c index 66a3e2d..ec94829 100644 --- a/libf2c/libU77/fgetc_.c +++ b/libf2c/libU77/fgetc_.c @@ -26,30 +26,36 @@ Boston, MA 02111-1307, USA. */ #include "f2c.h" #include "fio.h" -integer G77_fgetc_0 (const integer *lunit, char *c, ftnlen Lc) +integer +G77_fgetc_0 (const integer * lunit, char *c, ftnlen Lc) { int err; FILE *f = f__units[*lunit].ufd; - if (*lunit>=MXUNIT || *lunit<0) + if (*lunit >= MXUNIT || *lunit < 0) return 101; /* bad unit error */ err = getc (f); - if (err == EOF) { - if (feof (f)) - return -1; - else - return ferror (f); } - else { - if (Lc == 0) + if (err == EOF) + { + if (feof (f)) + return -1; + else + return ferror (f); + } + else + { + if (Lc == 0) + return 0; + + c[0] = err; + while (--Lc) + *++c = ' '; return 0; - - c[0] = err; - while (--Lc) - *++c = ' '; - return 0; } + } } -integer G77_fget_0 (char *c, const ftnlen Lc) +integer +G77_fget_0 (char *c, const ftnlen Lc) { integer five = 5; diff --git a/libf2c/libU77/flush1_.c b/libf2c/libU77/flush1_.c index 71b09c7..7327593 100644 --- a/libf2c/libU77/flush1_.c +++ b/libf2c/libU77/flush1_.c @@ -27,13 +27,14 @@ Boston, MA 02111-1307, USA. */ extern integer G77_fnum_0 (integer *); -/* Subroutine */ int G77_flush1_0 (const integer *lunit) +/* Subroutine */ int +G77_flush1_0 (const integer * lunit) { - if (*lunit>=MXUNIT || *lunit<0) - err(1,101,"flush"); + if (*lunit >= MXUNIT || *lunit < 0) + err (1, 101, "flush"); /* f__units is a table of descriptions for the unit numbers (defined in io.h) with file descriptors rather than streams */ if (f__units[*lunit].ufd != NULL && f__units[*lunit].uwrt) - fflush(f__units[*lunit].ufd); + fflush (f__units[*lunit].ufd); return 0; } diff --git a/libf2c/libU77/fnum_.c b/libf2c/libU77/fnum_.c index cdd3399..daf8f3d 100644 --- a/libf2c/libU77/fnum_.c +++ b/libf2c/libU77/fnum_.c @@ -22,12 +22,13 @@ Boston, MA 02111-1307, USA. */ #include "f2c.h" #include "fio.h" -integer G77_fnum_0 (integer *lunit) +integer +G77_fnum_0 (integer * lunit) { - if (*lunit>=MXUNIT || *lunit<0) - err(1,101,"fnum"); + if (*lunit >= MXUNIT || *lunit < 0) + err (1, 101, "fnum"); /* f__units is a table of descriptions for the unit numbers (defined in io.h). Use file descriptor (ufd) and fileno rather than udev field since udev is unix specific */ - return fileno(f__units[*lunit].ufd); + return fileno (f__units[*lunit].ufd); } diff --git a/libf2c/libU77/fputc_.c b/libf2c/libU77/fputc_.c index fe527e5..0a878bd 100644 --- a/libf2c/libU77/fputc_.c +++ b/libf2c/libU77/fputc_.c @@ -26,25 +26,28 @@ Boston, MA 02111-1307, USA. */ #include "f2c.h" #include "fio.h" -integer G77_fputc_0 (const integer *lunit, const char *c, const ftnlen Lc) +integer +G77_fputc_0 (const integer * lunit, const char *c, const ftnlen Lc) { int err; FILE *f = f__units[*lunit].ufd; - if (*lunit>=MXUNIT || *lunit<0) + if (*lunit >= MXUNIT || *lunit < 0) return 101; /* bad unit error */ err = putc (c[0], f); - if (err == EOF) { - if (feof (f)) - return -1; - else - return ferror (f); - } + if (err == EOF) + { + if (feof (f)) + return -1; + else + return ferror (f); + } else return 0; } -integer G77_fput_0 (const char *c, const ftnlen Lc) +integer +G77_fput_0 (const char *c, const ftnlen Lc) { integer six = 6; diff --git a/libf2c/libU77/fstat_.c b/libf2c/libU77/fstat_.c index cf64d4e..e978c6a 100644 --- a/libf2c/libU77/fstat_.c +++ b/libf2c/libU77/fstat_.c @@ -28,7 +28,8 @@ Boston, MA 02111-1307, USA. */ extern integer G77_fnum_0 (const integer *); -integer G77_fstat_0 (const integer *lunit, integer statb[13]) +integer +G77_fstat_0 (const integer * lunit, integer statb[13]) { int err; struct stat buf; diff --git a/libf2c/libU77/gerror_.c b/libf2c/libU77/gerror_.c index 61c0052..252440d 100644 --- a/libf2c/libU77/gerror_.c +++ b/libf2c/libU77/gerror_.c @@ -29,15 +29,16 @@ Boston, MA 02111-1307, USA. */ #include "f2c.h" #ifndef HAVE_STRERROR - extern char *sys_errlist []; +extern char *sys_errlist[]; # define strerror(i) (sys_errlist[i]) #endif -extern void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb); -/* Subroutine */ int G77_gerror_0 (char *str, ftnlen Lstr) +extern void s_copy (register char *a, register char *b, ftnlen la, ftnlen lb); +/* Subroutine */ int +G77_gerror_0 (char *str, ftnlen Lstr) { - char * s; + char *s; - s = strerror(errno); + s = strerror (errno); s_copy (str, s, Lstr, strlen (s)); return 0; } diff --git a/libf2c/libU77/getcwd_.c b/libf2c/libU77/getcwd_.c index 4b1c8a9..75277af 100644 --- a/libf2c/libU77/getcwd_.c +++ b/libf2c/libU77/getcwd_.c @@ -34,20 +34,22 @@ Boston, MA 02111-1307, USA. */ #ifdef HAVE_UNISTD_H # include <unistd.h> #else - extern char *getcwd (); +extern char *getcwd (); #endif -extern void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb); -integer G77_getcwd_0 (char *str, const ftnlen Lstr) +extern void s_copy (register char *a, register char *b, ftnlen la, ftnlen lb); +integer +G77_getcwd_0 (char *str, const ftnlen Lstr) { - int i; - char *ret; + int i; + char *ret; - ret = getcwd (str, Lstr); - if (ret == NULL) return errno; - for (i=strlen(str); i<Lstr; i++) - str[i] = ' '; - return 0; + ret = getcwd (str, Lstr); + if (ret == NULL) + return errno; + for (i = strlen (str); i < Lstr; i++) + str[i] = ' '; + return 0; } #elif HAVE_GETWD /* HAVE_GETCWD */ @@ -55,25 +57,30 @@ integer G77_getcwd_0 (char *str, const ftnlen Lstr) /* getwd usage taken from SunOS4 man */ # include <sys/param.h> - extern char *getwd (); -extern void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb); -integer G77_getcwd_0 (char *str, const ftnlen Lstr) +extern char *getwd (); +extern void s_copy (register char *a, register char *b, ftnlen la, ftnlen lb); +integer +G77_getcwd_0 (char *str, const ftnlen Lstr) { char pathname[MAXPATHLEN]; size_t l; - if (getwd (pathname) == NULL) { - return errno; - } else { - s_copy (str, pathname, Lstr, strlen (str)); - return 0; - } + if (getwd (pathname) == NULL) + { + return errno; + } + else + { + s_copy (str, pathname, Lstr, strlen (str)); + return 0; + } } -#else /* !HAVE_GETWD && !HAVE_GETCWD */ +#else /* !HAVE_GETWD && !HAVE_GETCWD */ -extern void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb); -integer G77_getcwd_0 (char *str, const ftnlen Lstr) +extern void s_copy (register char *a, register char *b, ftnlen la, ftnlen lb); +integer +G77_getcwd_0 (char *str, const ftnlen Lstr) { return errno = ENOSYS; } diff --git a/libf2c/libU77/getgid_.c b/libf2c/libU77/getgid_.c index b831fc2..7dcbdf8 100644 --- a/libf2c/libU77/getgid_.c +++ b/libf2c/libU77/getgid_.c @@ -26,7 +26,8 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> /* for ENOSYS */ #include "f2c.h" -integer G77_getgid_0 (void) +integer +G77_getgid_0 (void) { #if defined (HAVE_GETGID) return getgid (); diff --git a/libf2c/libU77/getlog_.c b/libf2c/libU77/getlog_.c index 9831014..94c5f41 100644 --- a/libf2c/libU77/getlog_.c +++ b/libf2c/libU77/getlog_.c @@ -41,8 +41,9 @@ Boston, MA 02111-1307, USA. */ /* SGI also has character*(*) function getlog() */ -extern void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb); -/* Subroutine */ int G77_getlog_0 (char *str, const ftnlen Lstr) +extern void s_copy (register char *a, register char *b, ftnlen la, ftnlen lb); +/* Subroutine */ int +G77_getlog_0 (char *str, const ftnlen Lstr) { size_t i; char *p; @@ -50,12 +51,15 @@ extern void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb); #if defined (HAVE_GETLOGIN) p = getlogin (); - if (p != NULL) { - i = strlen (p); - s_copy (str, p, Lstr, i); - } else { - s_copy (str, " ", Lstr, 1); - } + if (p != NULL) + { + i = strlen (p); + s_copy (str, p, Lstr, i); + } + else + { + s_copy (str, " ", Lstr, 1); + } status = 0; #else errno = ENOSYS; diff --git a/libf2c/libU77/getpid_.c b/libf2c/libU77/getpid_.c index c31cc04..6f1d8d7 100644 --- a/libf2c/libU77/getpid_.c +++ b/libf2c/libU77/getpid_.c @@ -25,7 +25,8 @@ Boston, MA 02111-1307, USA. */ #include <sys/types.h> #include "f2c.h" -integer G77_getpid_0 (void) +integer +G77_getpid_0 (void) { return getpid (); } diff --git a/libf2c/libU77/getuid_.c b/libf2c/libU77/getuid_.c index 7db9c59..d88b8e2 100644 --- a/libf2c/libU77/getuid_.c +++ b/libf2c/libU77/getuid_.c @@ -26,7 +26,8 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> /* for ENOSYS */ #include "f2c.h" -integer G77_getuid_0 (void) +integer +G77_getuid_0 (void) { #if defined (HAVE_GETUID) return getuid (); diff --git a/libf2c/libU77/gmtime_.c b/libf2c/libU77/gmtime_.c index 0c4e6a9..9de3c5a 100644 --- a/libf2c/libU77/gmtime_.c +++ b/libf2c/libU77/gmtime_.c @@ -33,7 +33,8 @@ Boston, MA 02111-1307, USA. */ #endif #include "f2c.h" -/* Subroutine */ int G77_gmtime_0 (const integer * xstime, integer tarray[9]) +/* Subroutine */ int +G77_gmtime_0 (const integer * xstime, integer tarray[9]) { struct tm *lt; time_t stime = *xstime; diff --git a/libf2c/libU77/hostnm_.c b/libf2c/libU77/hostnm_.c index fd717b9..7f511f4 100644 --- a/libf2c/libU77/hostnm_.c +++ b/libf2c/libU77/hostnm_.c @@ -30,20 +30,22 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> /* for ENOSYS */ #include "f2c.h" -integer G77_hostnm_0 (char *name, ftnlen Lname) +integer +G77_hostnm_0 (char *name, ftnlen Lname) { - int ret, i; + int ret, i; #if HAVE_GETHOSTNAME - ret = gethostname (name, Lname); - if (ret==0) { - /* Pad with blanks (assuming gethostname will make an error - return if it can't fit in the null). */ - for (i=strlen(name); i<Lname; i++) - name[i] = ' '; + ret = gethostname (name, Lname); + if (ret == 0) + { + /* Pad with blanks (assuming gethostname will make an error + return if it can't fit in the null). */ + for (i = strlen (name); i < Lname; i++) + name[i] = ' '; } - return ret; + return ret; #else - return errno = ENOSYS; + return errno = ENOSYS; #endif } diff --git a/libf2c/libU77/idate_.c b/libf2c/libU77/idate_.c index b4c29f2..f2bea12 100644 --- a/libf2c/libU77/idate_.c +++ b/libf2c/libU77/idate_.c @@ -37,12 +37,13 @@ Boston, MA 02111-1307, USA. */ /* libU77 one: */ -/* Subroutine */ int G77_idate_0 (int iarray[3]) +/* Subroutine */ int +G77_idate_0 (int iarray[3]) { struct tm *lt; time_t tim; - tim = time(NULL); - lt = localtime(&tim); + tim = time (NULL); + lt = localtime (&tim); iarray[0] = lt->tm_mday; iarray[1] = lt->tm_mon + 1; /* in range 1-12 in SunOS (experimentally) */ /* The `+1900' is consistent with SunOS and Irix, but they don't say diff --git a/libf2c/libU77/ierrno_.c b/libf2c/libU77/ierrno_.c index ed7d4e7..0dc76b0 100644 --- a/libf2c/libU77/ierrno_.c +++ b/libf2c/libU77/ierrno_.c @@ -22,7 +22,8 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> #include "f2c.h" -integer G77_ierrno_0 (void) +integer +G77_ierrno_0 (void) { return errno; } diff --git a/libf2c/libU77/irand_.c b/libf2c/libU77/irand_.c index 8349689..a905431 100644 --- a/libf2c/libU77/irand_.c +++ b/libf2c/libU77/irand_.c @@ -31,22 +31,18 @@ Boston, MA 02111-1307, USA. */ /* Note this is per SunOS -- other s may have no arg. */ -integer G77_irand_0 (integer *flag) +integer +G77_irand_0 (integer * flag) { - switch (*flag) { - case 0: - break; - case 1: - srand (0); /* Arbitrary choice of initialiser. */ - break; - default: - srand (*flag); - } + switch (*flag) + { + case 0: + break; + case 1: + srand (0); /* Arbitrary choice of initialiser. */ + break; + default: + srand (*flag); + } return rand (); } - - - - - - diff --git a/libf2c/libU77/isatty_.c b/libf2c/libU77/isatty_.c index 3d803b3..fa2f56d 100644 --- a/libf2c/libU77/isatty_.c +++ b/libf2c/libU77/isatty_.c @@ -27,11 +27,12 @@ Boston, MA 02111-1307, USA. */ extern integer G77_fnum_0 (integer *); -logical G77_isatty_0 (integer *lunit) +logical +G77_isatty_0 (integer * lunit) { - if (*lunit>=MXUNIT || *lunit<0) - err(1,101,"isatty"); + if (*lunit >= MXUNIT || *lunit < 0) + err (1, 101, "isatty"); /* f__units is a table of descriptions for the unit numbers (defined in io.h) with file descriptors rather than streams */ - return (isatty(G77_fnum_0 (lunit)) ? TRUE_ : FALSE_); + return (isatty (G77_fnum_0 (lunit)) ? TRUE_ : FALSE_); } diff --git a/libf2c/libU77/itime_.c b/libf2c/libU77/itime_.c index 8fbfcc3..12a7864 100644 --- a/libf2c/libU77/itime_.c +++ b/libf2c/libU77/itime_.c @@ -33,13 +33,14 @@ Boston, MA 02111-1307, USA. */ #endif #include "f2c.h" -/* Subroutine */ int G77_itime_0 (integer tarray[3]) +/* Subroutine */ int +G77_itime_0 (integer tarray[3]) { struct tm *lt; time_t tim; - tim = time(NULL); - lt = localtime(&tim); + tim = time (NULL); + lt = localtime (&tim); tarray[0] = lt->tm_hour; tarray[1] = lt->tm_min; tarray[2] = lt->tm_sec; diff --git a/libf2c/libU77/kill_.c b/libf2c/libU77/kill_.c index d133fa5..41eab15 100644 --- a/libf2c/libU77/kill_.c +++ b/libf2c/libU77/kill_.c @@ -26,10 +26,11 @@ Boston, MA 02111-1307, USA. */ /* fixme: bsd, svr1-3 use int, not pid_t */ -integer G77_kill_0 (const integer *pid, const integer *signum) +integer +G77_kill_0 (const integer * pid, const integer * signum) { #if defined (HAVE_KILL) - return kill ((pid_t) *pid, *signum) ? errno : 0; + return kill ((pid_t) * pid, *signum) ? errno : 0; #else errno = ENOSYS; return -1; diff --git a/libf2c/libU77/link_.c b/libf2c/libU77/link_.c index 1f46e2e..88c110f 100644 --- a/libf2c/libU77/link_.c +++ b/libf2c/libU77/link_.c @@ -34,23 +34,28 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> /* for ENOSYS */ #include "f2c.h" -void g_char(const char *a, ftnlen alen, char *b); +void g_char (const char *a, ftnlen alen, char *b); -integer G77_link_0 (const char *path1, const char *path2, const ftnlen Lpath1, const ftnlen Lpath2) +integer +G77_link_0 (const char *path1, const char *path2, const ftnlen Lpath1, + const ftnlen Lpath2) { #if defined (HAVE_LINK) char *buff1, *buff2; char *bp, *blast; int i; - buff1 = malloc (Lpath1+1); - if (buff1 == NULL) return -1; + buff1 = malloc (Lpath1 + 1); + if (buff1 == NULL) + return -1; g_char (path1, Lpath1, buff1); - buff2 = malloc (Lpath2+1); - if (buff2 == NULL) return -1; + buff2 = malloc (Lpath2 + 1); + if (buff2 == NULL) + return -1; g_char (path2, Lpath2, buff2); i = link (buff1, buff2); - free (buff1); free (buff2); + free (buff1); + free (buff2); return i ? errno : 0; #else /* ! HAVE_LINK */ errno = ENOSYS; diff --git a/libf2c/libU77/lnblnk_.c b/libf2c/libU77/lnblnk_.c index 806eca2..f21ac42 100644 --- a/libf2c/libU77/lnblnk_.c +++ b/libf2c/libU77/lnblnk_.c @@ -21,15 +21,18 @@ Boston, MA 02111-1307, USA. */ #include "f2c.h" -integer G77_lnblnk_0 (char *str, ftnlen str_len) +integer +G77_lnblnk_0 (char *str, ftnlen str_len) { - integer ret_val; - integer i_len(); - - for (ret_val = str_len; ret_val >= 1; --ret_val) { - if (*(unsigned char *)&str[ret_val - 1] != ' ') { - return ret_val; + integer ret_val; + integer i_len (); + + for (ret_val = str_len; ret_val >= 1; --ret_val) + { + if (*(unsigned char *) &str[ret_val - 1] != ' ') + { + return ret_val; } } - return ret_val; + return ret_val; } diff --git a/libf2c/libU77/lstat_.c b/libf2c/libU77/lstat_.c index 5a1831b..0d5a830 100644 --- a/libf2c/libU77/lstat_.c +++ b/libf2c/libU77/lstat_.c @@ -30,9 +30,10 @@ Boston, MA 02111-1307, USA. */ /* lstat isn't posix */ -void g_char(const char *a, ftnlen alen, char *b); +void g_char (const char *a, ftnlen alen, char *b); -integer G77_lstat_0 (const char *name, integer statb[13], const ftnlen Lname) +integer +G77_lstat_0 (const char *name, integer statb[13], const ftnlen Lname) { #if HAVE_LSTAT char *buff; @@ -40,8 +41,9 @@ integer G77_lstat_0 (const char *name, integer statb[13], const ftnlen Lname) int err; struct stat buf; - buff = malloc (Lname+1); - if (buff == NULL) return -1; + buff = malloc (Lname + 1); + if (buff == NULL) + return -1; g_char (name, Lname, buff); err = lstat (buff, &buf); free (buff); @@ -71,7 +73,7 @@ integer G77_lstat_0 (const char *name, integer statb[13], const ftnlen Lname) statb[12] = -1; #endif return err; -#else /* !HAVE_LSTAT */ +#else /* !HAVE_LSTAT */ return errno = ENOSYS; -#endif /* !HAVE_LSTAT */ +#endif /* !HAVE_LSTAT */ } diff --git a/libf2c/libU77/ltime_.c b/libf2c/libU77/ltime_.c index ea5b1b9..008df1d 100644 --- a/libf2c/libU77/ltime_.c +++ b/libf2c/libU77/ltime_.c @@ -33,7 +33,8 @@ Boston, MA 02111-1307, USA. */ #endif #include "f2c.h" -/* Subroutine */ int G77_ltime_0 (const integer * xstime, integer tarray[9]) +/* Subroutine */ int +G77_ltime_0 (const integer * xstime, integer tarray[9]) { struct tm *lt; time_t stime = *xstime; diff --git a/libf2c/libU77/mclock_.c b/libf2c/libU77/mclock_.c index cf6abb4..686c490 100644 --- a/libf2c/libU77/mclock_.c +++ b/libf2c/libU77/mclock_.c @@ -33,7 +33,8 @@ Boston, MA 02111-1307, USA. */ /* Reported by wd42ej@sgi83.wwb.noaa.gov (Russ Jones AUTO-Sun3) on AIX. */ -longint G77_mclock_0 (void) +longint +G77_mclock_0 (void) { #if HAVE_CLOCK return clock (); diff --git a/libf2c/libU77/perror_.c b/libf2c/libU77/perror_.c index 1d3c3f2..6fe96aa 100644 --- a/libf2c/libU77/perror_.c +++ b/libf2c/libU77/perror_.c @@ -28,14 +28,15 @@ Boston, MA 02111-1307, USA. */ #endif #include "f2c.h" -/* Subroutine */ int G77_perror_0 (const char *str, const ftnlen Lstr) +/* Subroutine */ int +G77_perror_0 (const char *str, const ftnlen Lstr) { char buff[1000]; char *bp, *blast; /* same technique as `system' -- what's wrong with malloc? */ blast = buff + (Lstr < 1000 ? Lstr : 1000); - for (bp = buff ; bp<blast && *str!='\0' ; ) + for (bp = buff; bp < blast && *str != '\0';) *bp++ = *str++; *bp = '\0'; perror (buff); diff --git a/libf2c/libU77/rand_.c b/libf2c/libU77/rand_.c index 5560461..1592dc5 100644 --- a/libf2c/libU77/rand_.c +++ b/libf2c/libU77/rand_.c @@ -34,16 +34,18 @@ Boston, MA 02111-1307, USA. */ /* Note this is per SunOS -- other s may have no arg. */ -double G77_rand_0 (integer *flag) +double +G77_rand_0 (integer * flag) { - switch (*flag) { - case 0: - break; - case 1: - srand (0); /* Arbitrary choice of initialiser. */ - break; - default: - srand (*flag); - } + switch (*flag) + { + case 0: + break; + case 1: + srand (0); /* Arbitrary choice of initialiser. */ + break; + default: + srand (*flag); + } return (float) rand () / RAND_MAX; } diff --git a/libf2c/libU77/rename_.c b/libf2c/libU77/rename_.c index 335b592..bef384b 100644 --- a/libf2c/libU77/rename_.c +++ b/libf2c/libU77/rename_.c @@ -29,21 +29,26 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> #include "f2c.h" -void g_char(const char *a, ftnlen alen, char *b); +void g_char (const char *a, ftnlen alen, char *b); -integer G77_rename_0 (const char *path1, const char *path2, const ftnlen Lpath1, const ftnlen Lpath2) +integer +G77_rename_0 (const char *path1, const char *path2, const ftnlen Lpath1, + const ftnlen Lpath2) { char *buff1, *buff2; char *bp, *blast; int i; - buff1 = malloc (Lpath1+1); - if (buff1 == NULL) return -1; + buff1 = malloc (Lpath1 + 1); + if (buff1 == NULL) + return -1; g_char (path1, Lpath1, buff1); - buff2 = malloc (Lpath2+1); - if (buff2 == NULL) return -1; + buff2 = malloc (Lpath2 + 1); + if (buff2 == NULL) + return -1; g_char (path2, Lpath2, buff2); i = rename (buff1, buff2); - free (buff1); free (buff2); + free (buff1); + free (buff2); return i ? errno : 0; } diff --git a/libf2c/libU77/secnds_.c b/libf2c/libU77/secnds_.c index 1942528..1d661a9 100644 --- a/libf2c/libU77/secnds_.c +++ b/libf2c/libU77/secnds_.c @@ -36,16 +36,16 @@ Boston, MA 02111-1307, USA. */ /* This is a VMS intrinsic. */ -double G77_secnds_0 (real *r) +double +G77_secnds_0 (real * r) { - struct tm *lt; - time_t clock; - float f; - - clock = time (NULL); - lt = localtime (&clock); - f= (3600.0*((real)lt->tm_hour) + 60.0*((real)lt->tm_min) + - (real)lt->tm_sec - *r); - return f; + struct tm *lt; + time_t clock; + float f; + + clock = time (NULL); + lt = localtime (&clock); + f = (3600.0 * ((real) lt->tm_hour) + 60.0 * ((real) lt->tm_min) + + (real) lt->tm_sec - *r); + return f; } - diff --git a/libf2c/libU77/second_.c b/libf2c/libU77/second_.c index 41bb5a9..b40474a 100644 --- a/libf2c/libU77/second_.c +++ b/libf2c/libU77/second_.c @@ -18,7 +18,9 @@ Boston, MA 02111-1307, USA. */ #include "f2c.h" -double G77_second_0 () { +double +G77_second_0 () +{ extern double G77_etime_0 (); real tarray[2]; diff --git a/libf2c/libU77/sleep_.c b/libf2c/libU77/sleep_.c index 081bc5b..fcf112a 100644 --- a/libf2c/libU77/sleep_.c +++ b/libf2c/libU77/sleep_.c @@ -25,7 +25,8 @@ Boston, MA 02111-1307, USA. */ #include "f2c.h" /* Subroutine */ -int G77_sleep_0 (const integer *seconds) +int +G77_sleep_0 (const integer * seconds) { (void) sleep ((unsigned int) *seconds); return 0; diff --git a/libf2c/libU77/srand_.c b/libf2c/libU77/srand_.c index 1228018..822d980 100644 --- a/libf2c/libU77/srand_.c +++ b/libf2c/libU77/srand_.c @@ -24,8 +24,9 @@ Boston, MA 02111-1307, USA. */ #endif #include "f2c.h" -/* Subroutine */ -int G77_srand_0 (const integer *seed) +/* Subroutine */ +int +G77_srand_0 (const integer * seed) { srand ((unsigned int) *seed); return 0; diff --git a/libf2c/libU77/stat_.c b/libf2c/libU77/stat_.c index 4c89248..b864da2 100644 --- a/libf2c/libU77/stat_.c +++ b/libf2c/libU77/stat_.c @@ -27,17 +27,19 @@ Boston, MA 02111-1307, USA. */ #include <sys/stat.h> #include "f2c.h" -void g_char(const char *a, ftnlen alen, char *b); +void g_char (const char *a, ftnlen alen, char *b); -integer G77_stat_0 (const char *name, integer statb[13], const ftnlen Lname) +integer +G77_stat_0 (const char *name, integer statb[13], const ftnlen Lname) { char *buff; char *bp, *blast; int err; struct stat buf; - buff = malloc (Lname+1); - if (buff == NULL) return -1; + buff = malloc (Lname + 1); + if (buff == NULL) + return -1; g_char (name, Lname, buff); err = stat (buff, &buf); free (buff); diff --git a/libf2c/libU77/symlnk_.c b/libf2c/libU77/symlnk_.c index 6f24841..f51739a 100644 --- a/libf2c/libU77/symlnk_.c +++ b/libf2c/libU77/symlnk_.c @@ -33,25 +33,30 @@ Boston, MA 02111-1307, USA. */ #endif #include "f2c.h" -void g_char(const char *a, ftnlen alen, char *b); +void g_char (const char *a, ftnlen alen, char *b); -integer G77_symlnk_0 (const char *path1, const char *path2, const ftnlen Lpath1, const ftnlen Lpath2) +integer +G77_symlnk_0 (const char *path1, const char *path2, const ftnlen Lpath1, + const ftnlen Lpath2) { #if HAVE_SYMLINK char *buff1, *buff2; char *bp, *blast; int i; - buff1 = (char *) malloc (Lpath1+1); - if (buff1 == NULL) return -1; + buff1 = (char *) malloc (Lpath1 + 1); + if (buff1 == NULL) + return -1; g_char (path1, Lpath1, buff1); - buff2 = (char *) malloc (Lpath2+1); - if (buff2 == NULL) return -1; + buff2 = (char *) malloc (Lpath2 + 1); + if (buff2 == NULL) + return -1; g_char (path2, Lpath2, buff2); i = symlink (buff1, buff2); - free (buff1); free (buff2); + free (buff1); + free (buff2); return i ? errno : 0; -#else /* !HAVE_SYMLINK */ +#else /* !HAVE_SYMLINK */ return errno = ENOSYS; -#endif /* !HAVE_SYMLINK */ +#endif /* !HAVE_SYMLINK */ } diff --git a/libf2c/libU77/sys_clock_.c b/libf2c/libU77/sys_clock_.c index d35faad..ea39eea 100644 --- a/libf2c/libU77/sys_clock_.c +++ b/libf2c/libU77/sys_clock_.c @@ -43,26 +43,29 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> /* for ENOSYS */ #include "f2c.h" -int G77_system_clock_0 (integer *count, integer *count_rate, integer *count_max) +int +G77_system_clock_0 (integer * count, integer * count_rate, + integer * count_max) { #if defined (HAVE_TIMES) struct tms buffer; unsigned long cnt; - if (count_rate) { + if (count_rate) + { #ifdef _SC_CLK_TCK - *count_rate = sysconf(_SC_CLK_TCK); + *count_rate = sysconf (_SC_CLK_TCK); #elif defined CLOCKS_PER_SECOND - *count_rate = CLOCKS_PER_SECOND; + *count_rate = CLOCKS_PER_SECOND; #elif defined CLK_TCK - *count_rate = CLK_TCK; + *count_rate = CLK_TCK; #elif defined HZ - *count_rate = HZ; + *count_rate = HZ; #else #error Dont know clock tick length #endif - } + } if (count_max) /* optional arg present? */ - *count_max = INT_MAX; /* dubious */ + *count_max = INT_MAX; /* dubious */ cnt = times (&buffer); if (cnt > (unsigned long) (INT_MAX)) *count = INT_MAX; /* also dubious */ diff --git a/libf2c/libU77/time_.c b/libf2c/libU77/time_.c index 621da3a..2eb8a41 100644 --- a/libf2c/libU77/time_.c +++ b/libf2c/libU77/time_.c @@ -35,7 +35,8 @@ Boston, MA 02111-1307, USA. */ /* As well as this external function some compilers have an intrinsic subroutine which fills a character argument (which is the VMS way) -- caveat emptor. */ -longint G77_time_0 (void) +longint +G77_time_0 (void) { /* There are potential problems with the cast of the time_t here. */ return time (NULL); diff --git a/libf2c/libU77/ttynam_.c b/libf2c/libU77/ttynam_.c index 3175f05..ffdf5bf 100644 --- a/libf2c/libU77/ttynam_.c +++ b/libf2c/libU77/ttynam_.c @@ -35,21 +35,25 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> /* for ENOSYS */ #include "f2c.h" -extern integer G77_fnum_0 (integer *lunit); -extern void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb); -/* Character */ void G77_ttynam_0 (char *ret_val, ftnlen ret_val_len, integer *lunit) +extern integer G77_fnum_0 (integer * lunit); +extern void s_copy (register char *a, register char *b, ftnlen la, ftnlen lb); +/* Character */ void +G77_ttynam_0 (char *ret_val, ftnlen ret_val_len, integer * lunit) { #if defined (HAVE_TTYNAME) size_t i; char *p; p = ttyname (G77_fnum_0 (lunit)); - if (p != NULL) { - i = strlen (p); - s_copy (ret_val, p, ret_val_len, i); - } else { - s_copy (ret_val, " ", ret_val_len, 1); - } + if (p != NULL) + { + i = strlen (p); + s_copy (ret_val, p, ret_val_len, i); + } + else + { + s_copy (ret_val, " ", ret_val_len, 1); + } #else errno = ENOSYS; s_copy (ret_val, " ", ret_val_len, 1); diff --git a/libf2c/libU77/umask_.c b/libf2c/libU77/umask_.c index 347da2d..5c4546a 100644 --- a/libf2c/libU77/umask_.c +++ b/libf2c/libU77/umask_.c @@ -23,7 +23,8 @@ Boston, MA 02111-1307, USA. */ #include <sys/stat.h> #include "f2c.h" -integer G77_umask_0 (integer *mask) +integer +G77_umask_0 (integer * mask) { - return umask ((mode_t) *mask); + return umask ((mode_t) * mask); } diff --git a/libf2c/libU77/unlink_.c b/libf2c/libU77/unlink_.c index 004002e..2d8fbcb 100644 --- a/libf2c/libU77/unlink_.c +++ b/libf2c/libU77/unlink_.c @@ -33,16 +33,18 @@ Boston, MA 02111-1307, USA. */ #endif #include "f2c.h" -void g_char(const char *a, ftnlen alen, char *b); +void g_char (const char *a, ftnlen alen, char *b); -integer G77_unlink_0 (const char *str, const ftnlen Lstr) +integer +G77_unlink_0 (const char *str, const ftnlen Lstr) { char *buff; char *bp, *blast; int i; - buff = malloc (Lstr+1); - if (buff == NULL) return -1; + buff = malloc (Lstr + 1); + if (buff == NULL) + return -1; g_char (str, Lstr, buff); i = unlink (buff); free (buff); diff --git a/libf2c/libU77/vxtidate_.c b/libf2c/libU77/vxtidate_.c index 6211f13..7bf0ec9 100644 --- a/libf2c/libU77/vxtidate_.c +++ b/libf2c/libU77/vxtidate_.c @@ -38,24 +38,26 @@ Boston, MA 02111-1307, USA. */ /* VMS style: */ /* Subroutine */ -int G77_vxtidate_y2kbug_0 (integer *m, integer *d, integer *y) +int +G77_vxtidate_y2kbug_0 (integer * m, integer * d, integer * y) { struct tm *lt; time_t tim; - tim = time(NULL); - lt = localtime(&tim); + tim = time (NULL); + lt = localtime (&tim); *y = lt->tm_year % 100; - *m = lt->tm_mon+1; + *m = lt->tm_mon + 1; *d = lt->tm_mday; return 0; } #ifdef PIC extern const char *G77_Non_Y2K_Compliance_Message; -int G77_vxtidate_y2kbuggy_0 (integer *m, integer *d, integer *y) +int +G77_vxtidate_y2kbuggy_0 (integer * m, integer * d, integer * y) { - extern int G77_abort_0(); + extern int G77_abort_0 (); fprintf (stderr, "%s\n", G77_Non_Y2K_Compliance_Message); - G77_abort_0(); + G77_abort_0 (); } #endif diff --git a/libf2c/libU77/vxttime_.c b/libf2c/libU77/vxttime_.c index 99d3f50..c283aac 100644 --- a/libf2c/libU77/vxttime_.c +++ b/libf2c/libU77/vxttime_.c @@ -39,11 +39,12 @@ Boston, MA 02111-1307, USA. */ #include "f2c.h" /* Subroutine */ -void G77_vxttime_0 (char chtime[8], const ftnlen Lchtime) +void +G77_vxttime_0 (char chtime[8], const ftnlen Lchtime) { time_t tim; char *ctim; - tim = time(NULL); + tim = time (NULL); ctim = ctime (&tim); - strncpy (chtime, ctim+11, 8); + strncpy (chtime, ctim + 11, 8); } |