diff options
author | jmz <jmz@FreeBSD.org> | 1997-04-13 01:16:58 +0000 |
---|---|---|
committer | jmz <jmz@FreeBSD.org> | 1997-04-13 01:16:58 +0000 |
commit | 438bdd8a9c9d390f13a4b05980c19b18e974d16c (patch) | |
tree | e809113557ae09d5ce13e9239ae81534708bd955 /lib/libI77 | |
parent | 5d93c9d5fb208d10eacf608b44ee02d3cd5b4a16 (diff) | |
download | FreeBSD-src-438bdd8a9c9d390f13a4b05980c19b18e974d16c.zip FreeBSD-src-438bdd8a9c9d390f13a4b05980c19b18e974d16c.tar.gz |
Upgrade to the 1997/02/26 version.
Diffstat (limited to 'lib/libI77')
-rw-r--r-- | lib/libI77/Notice | 2 | ||||
-rw-r--r-- | lib/libI77/README | 37 | ||||
-rw-r--r-- | lib/libI77/Version.c | 24 | ||||
-rw-r--r-- | lib/libI77/dfe.c | 23 | ||||
-rw-r--r-- | lib/libI77/due.c | 11 | ||||
-rw-r--r-- | lib/libI77/endfile.c | 4 | ||||
-rw-r--r-- | lib/libI77/err.c | 19 | ||||
-rw-r--r-- | lib/libI77/f2ch.add | 2 | ||||
-rw-r--r-- | lib/libI77/fio.h | 6 | ||||
-rw-r--r-- | lib/libI77/fmt.c | 22 | ||||
-rw-r--r-- | lib/libI77/fmt.h | 5 | ||||
-rw-r--r-- | lib/libI77/fmtlib.c | 18 | ||||
-rw-r--r-- | lib/libI77/iio.c | 17 | ||||
-rw-r--r-- | lib/libI77/inquire.c | 5 | ||||
-rw-r--r-- | lib/libI77/libI77.xsum | 41 | ||||
-rw-r--r-- | lib/libI77/lread.c | 45 | ||||
-rw-r--r-- | lib/libI77/lwrite.c | 14 | ||||
-rw-r--r-- | lib/libI77/makefile | 96 | ||||
-rw-r--r-- | lib/libI77/open.c | 15 | ||||
-rw-r--r-- | lib/libI77/rawio.h | 14 | ||||
-rw-r--r-- | lib/libI77/rdfmt.c | 19 | ||||
-rw-r--r-- | lib/libI77/rsfe.c | 13 | ||||
-rw-r--r-- | lib/libI77/rsli.c | 3 | ||||
-rw-r--r-- | lib/libI77/rsne.c | 50 | ||||
-rw-r--r-- | lib/libI77/sfe.c | 4 | ||||
-rw-r--r-- | lib/libI77/sue.c | 8 | ||||
-rw-r--r-- | lib/libI77/uio.c | 5 | ||||
-rw-r--r-- | lib/libI77/wref.c | 16 | ||||
-rw-r--r-- | lib/libI77/wrtfmt.c | 94 | ||||
-rw-r--r-- | lib/libI77/wsfe.c | 12 | ||||
-rw-r--r-- | lib/libI77/wsle.c | 2 | ||||
-rw-r--r-- | lib/libI77/wsne.c | 2 |
32 files changed, 269 insertions, 379 deletions
diff --git a/lib/libI77/Notice b/lib/libI77/Notice index 9715a19..8db1d7b 100644 --- a/lib/libI77/Notice +++ b/lib/libI77/Notice @@ -1,5 +1,5 @@ /**************************************************************** -Copyright 1990 - 1995 by AT&T Bell Laboratories and Bellcore. +Copyright 1990 - 1997 by AT&T Bell Laboratories and Bellcore. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby diff --git a/lib/libI77/README b/lib/libI77/README index 6b0558d..30dd5b5 100644 --- a/lib/libI77/README +++ b/lib/libI77/README @@ -32,6 +32,9 @@ number of characters transmitted -- then insert the line at the end of fmt.h . This is necessary with at least some versions of Sun and DEC software. +In particular, if you get a warning about an improper +pointer/integer combination in compiling wref.c, then +you need to compile with -DUSE_STRLEN . If your system's fopen does not like the ANSI binary reading and writing modes "rb" and "wb", then you should @@ -117,7 +120,7 @@ To check for transmission errors, issue the command This assumes you have the xsum program whose source, xsum.c, is distributed as part of "all from f2c/src". If you do not have xsum, you can obtain xsum.c by sending the following E-mail -message to netlib@research.att.com +message to netlib@netlib.bell-labs.com send xsum.c from f2c/src The makefile assumes you have installed f2c.h in a standard @@ -134,6 +137,10 @@ not specify a file name (and does not specify STATUS='SCRATCH') assumes FILE='fort.n' . You can change this by editing open.c and endfile.c suitably. +Unless you adjust the "#define MXUNIT" line in fio.h, Fortran units +0, 1, ..., 99 are available, i.e., the highest allowed unit number +is MXUNIT - 1. + Lines protected from compilation by #ifdef Allow_TYQUAD are for a possible extension to 64-bit integers in which integer = int = 32 bits and longint = long = 64 bits. @@ -188,3 +195,31 @@ formatted writes of floating-point numbers of absolute value < 1 have a zero before the decimal point. By default, libI77 omits such superfluous zeros, but you can cause them to appear by compiling lwrite.c, wref.c, and wrtfmt.c with -DWANT_LEAD_0 . + +If your system lacks a ranlib command, you don't need it. +Either comment out the makefile's ranlib invocation, or install +a harmless "ranlib" command somewhere in your PATH, such as the +one-line shell script + + exit 0 + +or (on some systems) + + exec /usr/bin/ar lts $1 >/dev/null + +Most of the routines in libI77 are support routines for Fortran +I/O. There are a few exceptions, summarized below -- I/O related +functions and subroutines that appear to your program as ordinary +external Fortran routines. + +1. CALL FLUSH flushes all buffers. + +2. FTELL(i) is an INTEGER function that returns the current + offset of Fortran unit i (or -1 if unit i is not open). + +3. CALL FSEEK(i, offset, whence, *errlab) attemps to move + Fortran unit i to the specified offset: absolute offset + if whence = 0; relative to the current offset if whence = 1; + relative to the end of the file if whence = 2. It branches + to label errlab if unit i is not open or if the call + otherwise fails. diff --git a/lib/libI77/Version.c b/lib/libI77/Version.c index ebd3f0b..b73ae67 100644 --- a/lib/libI77/Version.c +++ b/lib/libI77/Version.c @@ -1,4 +1,4 @@ -static char junk[] = "\n@(#) LIBI77 VERSION pjw,dmg-mods 19950907\n"; +static char junk[] = "\n@(#) LIBI77 VERSION pjw,dmg-mods 19970226\n"; /* 2.01 $ format added @@ -95,7 +95,7 @@ wrtfmt.c: /* 17 Oct. 1991: change type of length field in sequential unformatted records from int to long (for systems where sizeof(int) can vary, depending on the compiler or compiler options). */ -/* 14 Nov. 1991: change uint to Uint in fmt.h, rdfmt.c, wrtfmt.c. +/* 14 Nov. 1991: change uint to Uint in fmt.h, rdfmt.c, wrtfmt.c. */ /* 25 Nov. 1991: change uint to Uint in lwrite.c; change sizeof(int) to sizeof(uioint) in fseeks in sue.c (missed on 17 Oct.). */ /* 1 Dec. 1991: uio.c: add test for read failure (seq. unformatted reads); @@ -222,3 +222,23 @@ wrtfmt.c: namelist read statements invoke f_init if needed. */ /* 7 Sept. 1995: Fix some bugs with -DAllow_TYQUAD (for integer*8). Add -DNo_Namelist_Comments lines to rsne.c. */ +/* 5 Oct. 1995: wrtfmt.c: fix bug with t editing (f__cursor was not + always zeroed in mv_cur). */ +/* 11 Oct. 1995: move defs of f__hiwater, f__svic, f__icptr from wrtfmt.c + to err.c */ +/* 15 Mar. 1996: lread.c, rsfe.c: honor END= in READ stmt with empty iolist */ + +/* 13 May 1996: add ftell_.c and fseek_.c */ +/* 9 June 1996: Adjust rsli.c and lread.c so internal list input with + too few items in the input string will honor end= . */ +/* 12 Sept. 1995:fmtlib.c: fix glitch in printing the most negative integer. */ +/* 25 Sept. 1995:fmt.h: for formatted writes of negative integer*1 values, + make ic signed on ANSI systems. If formatted writes of + integer*1 values trouble you when using a K&R C compiler, + switch to an ANSI compiler or use a compiler flag that + makes characters signed. */ +/* 9 Dec. 1996: d[fu]e.c, err.c: complain about non-positive rec= + in direct read and write statements. + ftell_.c: change param "unit" to "Unit" for -DKR_headers. */ +/* 26 Feb. 1997: ftell_.c: on systems that define SEEK_SET, etc., use + SEEK_SET, SEEK_CUR, SEEK_END for *whence = 0, 1, 2. */ diff --git a/lib/libI77/dfe.c b/lib/libI77/dfe.c index 1135ffd..51023d5 100644 --- a/lib/libI77/dfe.c +++ b/lib/libI77/dfe.c @@ -2,7 +2,6 @@ #include "fio.h" #include "fmt.h" -int y_rsk(Void) { if(f__curunit->uend || f__curunit->url <= f__recpos @@ -12,8 +11,6 @@ y_rsk(Void) } while(++f__recpos < f__curunit->url); return 0; } - -int y_getc(Void) { int ch; @@ -33,10 +30,7 @@ y_getc(Void) return(-1); } err(f__elist->cierr,errno,"readingd"); - return 0; } - -int #ifdef KR_headers y_putc(c) #else @@ -50,8 +44,6 @@ y_putc(int c) err(f__elist->cierr,110,"dout"); return(0); } - -int y_rev(Void) { /*what about work done?*/ if(f__curunit->url==1 || f__recpos==f__curunit->url) @@ -61,17 +53,11 @@ y_rev(Void) f__recpos=0; return(0); } - -int y_err(Void) { err(f__elist->cierr, 110, "dfe"); -#ifdef __cplusplus - return 0; -#endif } -int y_newrec(Void) { if(f__curunit->url == 1 || f__recpos == f__curunit->url) { @@ -85,7 +71,6 @@ y_newrec(Void) return(1); } -int #ifdef KR_headers c_dfe(a) cilist *a; #else @@ -105,7 +90,9 @@ c_dfe(cilist *a) if(!f__curunit->ufmt) err(a->cierr,102,"dfe") if(!f__curunit->useek) err(a->cierr,104,"dfe") f__fmtbuf=a->cifmt; - (void) fseek(f__cf,(long)f__curunit->url * (a->cirec-1),SEEK_SET); + if(a->cirec <= 0) + err(a->cierr,130,"dfe") + fseek(f__cf,(long)f__curunit->url * (a->cirec-1),SEEK_SET); f__curunit->uend = 0; return(0); } @@ -117,8 +104,8 @@ integer s_rdfe(cilist *a) { int n; if(!f__init) f_init(); - if( (n=c_dfe(a)) )return(n); 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; @@ -139,8 +126,8 @@ integer s_wdfe(cilist *a) { int n; if(!f__init) f_init(); - if( (n=c_dfe(a)) ) return(n); 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 = y_putc; diff --git a/lib/libI77/due.c b/lib/libI77/due.c index ff9ce55..670b0f1 100644 --- a/lib/libI77/due.c +++ b/lib/libI77/due.c @@ -1,7 +1,6 @@ #include "f2c.h" #include "fio.h" -int #ifdef KR_headers c_due(a) cilist *a; #else @@ -20,7 +19,9 @@ c_due(cilist *a) 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") - (void) fseek(f__cf,(long)(a->cirec-1)*f__curunit->url,SEEK_SET); + if(a->cirec <= 0) + err(a->cierr,130,"due") + fseek(f__cf,(long)(a->cirec-1)*f__curunit->url,SEEK_SET); f__curunit->uend = 0; return(0); } @@ -31,8 +32,8 @@ integer s_rdue(cilist *a) #endif { int n; - if( (n=c_due(a)) ) return(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); @@ -44,8 +45,8 @@ integer s_wdue(cilist *a) #endif { int n; - if( (n=c_due(a)) ) return(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); @@ -54,7 +55,7 @@ integer e_rdue(Void) { if(f__curunit->url==1 || f__recpos==f__curunit->url) return(0); - (void) fseek(f__cf,(long)(f__curunit->url-f__recpos),SEEK_CUR); + fseek(f__cf,(long)(f__curunit->url-f__recpos),SEEK_CUR); if(ftell(f__cf)%f__curunit->url) err(f__elist->cierr,200,"syserr"); return(0); diff --git a/lib/libI77/endfile.c b/lib/libI77/endfile.c index 8425a29..f5990e3 100644 --- a/lib/libI77/endfile.c +++ b/lib/libI77/endfile.c @@ -43,7 +43,7 @@ integer f_end(alist *a) (void) sprintf(nbuf,"fort.%ld",a->aunit); #ifdef NON_UNIX_STDIO { FILE *tf; - if ( (tf = fopen(nbuf, f__w_mode[0])) ) + if (tf = fopen(nbuf, f__w_mode[0])) fclose(tf); } #else @@ -63,7 +63,7 @@ copy(from, len, to) char *from, *to; register long len; copy(FILE *from, register long len, FILE *to) #endif { - int len1; + int k, len1; char buf[BUFSIZ]; while(fread(buf, len1 = len > BUFSIZ ? BUFSIZ : (int)len, 1, from)) { diff --git a/lib/libI77/err.c b/lib/libI77/err.c index 923a667..29747ff 100644 --- a/lib/libI77/err.c +++ b/lib/libI77/err.c @@ -21,6 +21,7 @@ extern char *malloc(); unit f__units[MXUNIT]; /*unit table*/ flag f__init; /*0 on entry, 1 after initializations*/ 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; @@ -39,7 +40,8 @@ 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__scale; +int f__cursor, f__hiwater, f__scale; +char *f__icptr; /*error messages*/ char *F_err[] = @@ -73,14 +75,15 @@ char *F_err[] = "can't read file", /* 126 */ "can't write file", /* 127 */ "'new' file exists", /* 128 */ - "can't append to file" /* 129 */ + "can't append to file", /* 129 */ + "non-positive record number" /* 130 */ }; #define MAXERR (sizeof(F_err)/sizeof(char *)+100) #ifdef KR_headers -int f__canseek(f) FILE *f; /*SYSDEP*/ +f__canseek(f) FILE *f; /*SYSDEP*/ #else -int f__canseek(FILE *f) /*SYSDEP*/ +f__canseek(FILE *f) /*SYSDEP*/ #endif { #ifdef NON_UNIX_STDIO @@ -187,9 +190,9 @@ f_init(Void) p->uwrt=1; } #ifdef KR_headers -int f__nowreading(x) unit *x; +f__nowreading(x) unit *x; #else -int f__nowreading(unit *x) +f__nowreading(unit *x) #endif { long loc; @@ -210,9 +213,9 @@ int f__nowreading(unit *x) return(0); } #ifdef KR_headers -int f__nowwriting(x) unit *x; +f__nowwriting(x) unit *x; #else -int f__nowwriting(unit *x) +f__nowwriting(unit *x) #endif { long loc; diff --git a/lib/libI77/f2ch.add b/lib/libI77/f2ch.add index 4ab0d80..a2acc17 100644 --- a/lib/libI77/f2ch.add +++ b/lib/libI77/f2ch.add @@ -150,7 +150,7 @@ extern integer s_wsni(icilist *); extern integer s_wsue(cilist *); extern void sig_die(char *, int); extern integer signal_(integer *, void (*)(int)); -extern int system_(char *, ftnlen); +extern integer system_(char *, ftnlen); extern double z_abs(doublecomplex *); extern void z_cos(doublecomplex *, doublecomplex *); extern void z_div(doublecomplex *, doublecomplex *, doublecomplex *); diff --git a/lib/libI77/fio.h b/lib/libI77/fio.h index 17e5593..e8c693b 100644 --- a/lib/libI77/fio.h +++ b/lib/libI77/fio.h @@ -80,8 +80,8 @@ 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) {if( (f) ) errno=(m); else f__fatal((m),(s)); return((m));} -#define errfl(f,m,s) return err__fl((int)(f),(m),(s)) +#define err(f,m,s) {if(f) errno= m; else f__fatal(m,s); return(m);} +#define errfl(f,m,s) return err__fl((int)f,m,s) /*Table sizes*/ #define MXUNIT 100 @@ -99,4 +99,4 @@ extern int f__hiwater; /* so TL doesn't confuse us */ #define EXT 7 #define INT 8 -#define buf_end(x) ((x)->_flag & _IONBF ? (x)->_ptr : (x)->_base + BUFSIZ) +#define buf_end(x) (x->_flag & _IONBF ? x->_ptr : x->_base + BUFSIZ) diff --git a/lib/libI77/fmt.c b/lib/libI77/fmt.c index 8689ef5..12792fc 100644 --- a/lib/libI77/fmt.c +++ b/lib/libI77/fmt.c @@ -40,9 +40,9 @@ char *ap_end(char *s) /*NOTREACHED*/ return 0; } #ifdef KR_headers -int op_gen(a,b,c,d) +op_gen(a,b,c,d) #else -int op_gen(int a, int b, int c, int d) +op_gen(int a, int b, int c, int d) #endif { struct syl *p= &f__syl[f__pc]; if(f__pc>=SYLMX) @@ -99,9 +99,9 @@ char *f_s(char *s, int curloc) return(s); } #ifdef KR_headers -int ne_d(s,p) char *s,**p; +ne_d(s,p) char *s,**p; #else -int ne_d(char *s, char **p) +ne_d(char *s, char **p) #endif { int n,x,sign=0; struct syl *sp; @@ -185,9 +185,9 @@ int ne_d(char *s, char **p) return(1); } #ifdef KR_headers -int e_d(s,p) char *s,**p; +e_d(s,p) char *s,**p; #else -int e_d(char *s, char **p) +e_d(char *s, char **p) #endif { int i,im,n,w,d,e,found=0,x=0; char *sv=s; @@ -333,9 +333,9 @@ char *f_list(char *s) } #ifdef KR_headers -int pars_f(s) char *s; +pars_f(s) char *s; #else -int pars_f(char *s) +pars_f(char *s) #endif { f__parenlvl=f__revloc=f__pc=0; @@ -350,9 +350,9 @@ int f__cnt[STKSZ],f__ret[STKSZ],f__cp,f__rp; flag f__workdone, f__nonl; #ifdef KR_headers -int type_f(n) +type_f(n) #else -int type_f(int n) +type_f(int n) #endif { switch(n) @@ -476,8 +476,6 @@ loop: switch(type_f((p= &f__syl[f__pc])->op)) } return(0); } - -int en_fio(Void) { ftnint one=1; return(do_fio(&one,(char *)NULL,(ftnint)0)); diff --git a/lib/libI77/fmt.h b/lib/libI77/fmt.h index e94bc1c..509746e 100644 --- a/lib/libI77/fmt.h +++ b/lib/libI77/fmt.h @@ -45,7 +45,10 @@ typedef union } ufloat; typedef union { short is; - char ic; +#ifndef KR_headers + signed +#endif + char ic; integer il; #ifdef Allow_TYQUAD longint ili; diff --git a/lib/libI77/fmtlib.c b/lib/libI77/fmtlib.c index 1c6801e..91483fc 100644 --- a/lib/libI77/fmtlib.c +++ b/lib/libI77/fmtlib.c @@ -5,6 +5,8 @@ #ifndef Allow_TYQUAD #undef longint #define longint long +#undef ulongint +#define ulongint unsigned long #endif #ifdef KR_headers @@ -13,13 +15,17 @@ char *f__icvt(value,ndigit,sign, base) longint value; int *ndigit,*sign; #else char *f__icvt(longint value, int *ndigit, int *sign, int base) #endif -{ static char buf[MAXINTLENGTH+1]; +{ + static char buf[MAXINTLENGTH+1]; register int i; + ulongint uvalue; - if(value > 0) + if(value > 0) { + uvalue = value; *sign = 0; + } else if (value < 0) { - value = -value; + uvalue = -value; *sign = 1; } else { @@ -30,10 +36,10 @@ char *f__icvt(longint value, int *ndigit, int *sign, int base) } i = MAXINTLENGTH; do { - buf[--i] = (value%base) + '0'; - value /= base; + buf[--i] = (uvalue%base) + '0'; + uvalue /= base; } - while(value > 0); + while(uvalue > 0); *ndigit = MAXINTLENGTH - i; return &buf[i]; } diff --git a/lib/libI77/iio.c b/lib/libI77/iio.c index dff9e3f..4c8eb9d 100644 --- a/lib/libI77/iio.c +++ b/lib/libI77/iio.c @@ -6,8 +6,6 @@ char *f__icend; extern icilist *f__svic; int f__icnum; extern int f__hiwater; - -int z_getc(Void) { if(f__recpos++ < f__svic->icirlen) { @@ -17,9 +15,9 @@ z_getc(Void) return '\n'; } #ifdef KR_headers -int z_putc(c) +z_putc(c) #else -int z_putc(int c) +z_putc(int c) #endif { if(f__icptr >= f__icend) err(f__svic->icierr,110,"inwrite"); @@ -28,8 +26,6 @@ int z_putc(int c) else err(f__svic->icierr,110,"recend"); return 0; } - -int z_rnew(Void) { f__icptr = f__svic->iciunit + (++f__icnum)*f__svic->icirlen; @@ -47,9 +43,9 @@ z_endp(Void) } #ifdef KR_headers -int c_si(a) icilist *a; +c_si(a) icilist *a; #else -int c_si(icilist *a) +c_si(icilist *a) #endif { f__elist = (cilist *)a; @@ -86,7 +82,7 @@ integer s_rsfi(a) icilist *a; integer s_rsfi(icilist *a) #endif { int n; - if( (n=c_si(a)) ) return(n); + if(n=c_si(a)) return(n); f__reading=1; f__doed=rd_ed; f__doned=rd_ned; @@ -97,7 +93,6 @@ integer s_rsfi(icilist *a) return(0); } -int z_wnew(Void) { if (f__recpos < f__hiwater) { @@ -118,7 +113,7 @@ integer s_wsfi(a) icilist *a; integer s_wsfi(icilist *a) #endif { int n; - if( (n=c_si(a)) ) return(n); + if(n=c_si(a)) return(n); f__reading=0; f__doed=w_ed; f__doned=w_ned; diff --git a/lib/libI77/inquire.c b/lib/libI77/inquire.c index c28e367..ec98b22 100644 --- a/lib/libI77/inquire.c +++ b/lib/libI77/inquire.c @@ -1,4 +1,3 @@ -#include <unistd.h> #include "f2c.h" #include "fio.h" #ifdef KR_headers @@ -54,7 +53,7 @@ integer f_inqu(inlist *a) } } if(a->inex!=NULL) - if((byfile && x != -1) || (!byfile && p!=NULL)) + if(byfile && x != -1 || !byfile && p!=NULL) *a->inex=1; else *a->inex=0; if(a->inopen!=NULL) @@ -62,7 +61,7 @@ integer f_inqu(inlist *a) 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)) + if(byfile || p!=NULL && p->ufnm!=NULL) *a->innamed=1; else *a->innamed=0; if(a->inname!=NULL) diff --git a/lib/libI77/libI77.xsum b/lib/libI77/libI77.xsum deleted file mode 100644 index c93a190..0000000 --- a/lib/libI77/libI77.xsum +++ /dev/null @@ -1,41 +0,0 @@ -Notice fd29c05f 1184 -README ef678ce5 8578 -Version.c 367e2b0 11141 -backspace.c e29c7ec1 1794 -close.c 175acd02 1336 -dfe.c 16facc04 2891 -dolio.c 17595b24 404 -due.c f05f7fa6 1519 -endfile.c 12d875dc 3400 -err.c fccb27de 6084 -f2ch.add fed3bb7b 6056 -fio.h e7e8a21c 2315 -fmt.c e37e7c2a 7857 -fmt.h 7686340 1835 -fmtlib.c f79c9df4 704 -fp.h 100fb355 665 -iio.c fedbf0b5 2374 -ilnw.c fa459169 1049 -inquire.c e1059667 2536 -lio.h a087b39 1564 -lread.c 4dfc73b 12130 -lwrite.c 19137b45 4565 -makefile e8266f12 1972 -open.c 1ef408ec 4512 -rawio.h b9d538d 688 -rdfmt.c 55975ac 8347 -rewind.c 87b080b 408 -rsfe.c 1d79e4a1 1415 -rsli.c 1259dfec 1748 -rsne.c f2e2cad1 11466 -sfe.c 45a6968 793 -sue.c ec169681 1803 -typesize.c e5660590 319 -uio.c fe44d524 1547 -util.c f17978be 824 -wref.c fbed7e10 4507 -wrtfmt.c 7a73318 8090 -wsfe.c 250d1ef 1658 -wsle.c f74ea563 684 -wsne.c ea4dac25 412 -xwsne.c 16641f3c 1135 diff --git a/lib/libI77/lread.c b/lib/libI77/lread.c index 74f6f49..27f0269 100644 --- a/lib/libI77/lread.c +++ b/lib/libI77/lread.c @@ -67,7 +67,6 @@ extern int ungetc(int, FILE*); /* for systems with a buggy stdio.h */ #endif #endif -int t_getc(Void) { int ch; if(f__curunit->uend) return(EOF); @@ -80,7 +79,12 @@ integer e_rsle(Void) { int ch; if(f__curunit->uend) return(0); - while((ch=t_getc())!='\n' && ch!=EOF); + while((ch=t_getc())!='\n') + if (ch == EOF) { + if(feof(f__cf)) + f__curunit->uend = l_eof = 1; + return EOF; + } return(0); } @@ -88,14 +92,14 @@ flag f__lquit; int f__lcount,f__ltype,nml_read; char *f__lchar; double f__lx,f__ly; -#define ERR(x) if( (n=(x)) ) return(n) +#define ERR(x) if(n=(x)) return(n) #define GETC(x) (x=(*l_getc)()) #define Ungetc(x,y) (*l_ungetc)(x,y) #ifdef KR_headers -int l_R(poststar) int poststar; +l_R(poststar) int poststar; #else -int l_R(int poststar) +l_R(int poststar) #endif { char s[FMAX+EXPMAXDIGS+4]; @@ -250,7 +254,6 @@ rd_count(register int ch) return f__lcount <= 0; } -int l_C(Void) { int ch, nml_save; double lz; @@ -287,7 +290,7 @@ l_C(Void) Ungetc(ch,f__cf); nml_save = nml_read; nml_read = 0; - if ( (ch = l_R(1)) ) + if (ch = l_R(1)) return ch; if (!f__ltype) errfl(f__elist->cierr,112,"no real part"); @@ -299,7 +302,7 @@ l_C(Void) } while(iswhit(GETC(ch))); (void) Ungetc(ch,f__cf); - if ( (ch = l_R(1)) ) + if (ch = l_R(1)) return ch; if (!f__ltype) errfl(f__elist->cierr,112,"no imaginary part"); @@ -313,8 +316,6 @@ l_C(Void) nml_read = nml_save; return(0); } - -int l_L(Void) { int ch; @@ -361,8 +362,6 @@ l_L(Void) return(0); } #define BUFSIZE 128 - -int l_CHAR(Void) { int ch,size,i; static char rafail[] = "realloc failure"; @@ -485,9 +484,9 @@ l_CHAR(Void) } } #ifdef KR_headers -int c_le(a) cilist *a; +c_le(a) cilist *a; #else -int c_le(cilist *a) +c_le(cilist *a) #endif { if(!f__init) @@ -505,9 +504,9 @@ int c_le(cilist *a) return(0); } #ifdef KR_headers -int l_read(number,ptr,len,type) ftnint *number,type; char *ptr; ftnlen len; +l_read(number,ptr,len,type) ftnint *number,type; char *ptr; ftnlen len; #else -int l_read(ftnint *number, char *ptr, ftnlen len, ftnint type) +l_read(ftnint *number, char *ptr, ftnlen len, ftnint type) #endif { #define Ptr ((flex *)ptr) @@ -525,7 +524,7 @@ int l_read(ftnint *number, char *ptr, ftnlen len, ftnint type) GETC(ch); switch(ch) { case EOF: - goto loopend; + err(f__elist->ciend,(EOF),"list in") case ' ': case '\t': case '\n': @@ -579,13 +578,9 @@ int l_read(ftnint *number, char *ptr, ftnlen len, ftnint type) Ungetc(ch,f__cf); loopend: if(f__lquit) return(0); - if(f__cf) { - if (feof(f__cf)) - err(f__elist->ciend,(EOF),"list in") - else if(ferror(f__cf)) { - clearerr(f__cf); - errfl(f__elist->cierr,errno,"list in"); - } + 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) @@ -645,7 +640,7 @@ integer s_rsle(cilist *a) { int n; - if( (n=c_le(a)) ) return(n); + if(n=c_le(a)) return(n); f__reading=1; f__external=1; f__formatted=1; diff --git a/lib/libI77/lwrite.c b/lib/libI77/lwrite.c index 0d323ec..5da7dfb 100644 --- a/lib/libI77/lwrite.c +++ b/lib/libI77/lwrite.c @@ -14,9 +14,9 @@ donewrec(Void) } #ifdef KR_headers -int t_putc(c) +t_putc(c) #else -int t_putc(int c) +t_putc(int c) #endif { f__recpos++; @@ -141,7 +141,7 @@ l_g(char *buf, double n) switch(*b) { #ifndef WANT_LEAD_0 case '0': - while( (b[0] = b[1]) ) + while(b[0] = b[1]) b++; break; #endif @@ -166,7 +166,7 @@ l_g(char *buf, double n) while(*++b); goto f__ret; case 'E': - for(c1 = '.', c = 'E'; (*b = c1); + for(c1 = '.', c = 'E'; *b = c1; c1 = c, c = *++b); goto f__ret; } @@ -188,7 +188,7 @@ l_put(register char *s) #else register int c, (*pn)(int) = f__putn; #endif - while( (c = *s++) ) + while(c = *s++) (*pn)(c); } @@ -240,9 +240,9 @@ lwrt_C(double a, double b) PUT(')'); } #ifdef KR_headers -int l_write(number,ptr,len,type) ftnint *number,type; char *ptr; ftnlen len; +l_write(number,ptr,len,type) ftnint *number,type; char *ptr; ftnlen len; #else -int l_write(ftnint *number, char *ptr, ftnlen len, ftnint type) +l_write(ftnint *number, char *ptr, ftnlen len, ftnint type) #endif { #define Ptr ((flex *)ptr) diff --git a/lib/libI77/makefile b/lib/libI77/makefile deleted file mode 100644 index db250d2..0000000 --- a/lib/libI77/makefile +++ /dev/null @@ -1,96 +0,0 @@ -.SUFFIXES: .c .o -CC = cc -CFLAGS = -O -SHELL = /bin/sh - -# compile, then strip unnecessary symbols -.c.o: - $(CC) -c -DSkip_f2c_Undefs $(CFLAGS) $*.c - ld -r -x -o $*.xxx $*.o - mv $*.xxx $*.o - -OBJ = Version.o backspace.o close.o dfe.o dolio.o due.o endfile.o err.o \ - fmt.o fmtlib.o iio.o ilnw.o inquire.o lread.o lwrite.o open.o \ - rdfmt.o rewind.o rsfe.o rsli.o rsne.o sfe.o sue.o typesize.o uio.o \ - util.o wref.o wrtfmt.o wsfe.o wsle.o wsne.o xwsne.o -libI77.a: $(OBJ) - ar r libI77.a $? - ranlib libI77.a -install: libI77.a - cp libI77.a /usr/lib/libI77.a - ranlib /usr/lib/libI77.a - -Version.o: Version.c - $(CC) -c Version.c - -# To compile with C++, first "make f2c.h" -f2c.h: f2ch.add - cat /usr/include/f2c.h f2ch.add >f2c.h - - -clean: - rm -f $(OBJ) libI77.a - -clobber: clean - rm -f libI77.a - -backspace.o: fio.h -close.o: fio.h -dfe.o: fio.h -dfe.o: fmt.h -due.o: fio.h -endfile.o: fio.h rawio.h -err.o: fio.h rawio.h -fmt.o: fio.h -fmt.o: fmt.h -iio.o: fio.h -iio.o: fmt.h -ilnw.o: fio.h -ilnw.o: lio.h -inquire.o: fio.h -lread.o: fio.h -lread.o: fmt.h -lread.o: lio.h -lread.o: fp.h -lwrite.o: fio.h -lwrite.o: fmt.h -lwrite.o: lio.h -open.o: fio.h rawio.h -rdfmt.o: fio.h -rdfmt.o: fmt.h -rdfmt.o: fp.h -rewind.o: fio.h -rsfe.o: fio.h -rsfe.o: fmt.h -rsli.o: fio.h -rsli.o: lio.h -rsne.o: fio.h -rsne.o: lio.h -sfe.o: fio.h -sue.o: fio.h -uio.o: fio.h -util.o: fio.h -wref.o: fio.h -wref.o: fmt.h -wref.o: fp.h -wrtfmt.o: fio.h -wrtfmt.o: fmt.h -wsfe.o: fio.h -wsfe.o: fmt.h -wsle.o: fio.h -wsle.o: fmt.h -wsle.o: lio.h -wsne.o: fio.h -wsne.o: lio.h -xwsne.o: fio.h -xwsne.o: lio.h -xwsne.o: fmt.h - -check: - xsum Notice README Version.c backspace.c close.c dfe.c dolio.c \ - due.c endfile.c err.c f2ch.add fio.h fmt.c fmt.h fmtlib.c fp.h \ - iio.c ilnw.c inquire.c lio.h lread.c lwrite.c makefile open.c \ - rawio.h rdfmt.c rewind.c rsfe.c rsli.c rsne.c sfe.c sue.c \ - typesize.c uio.c util.c wref.c wrtfmt.c wsfe.c wsle.c wsne.c \ - xwsne.c >zap - cmp zap libI77.xsum && rm zap || diff libI77.xsum zap diff --git a/lib/libI77/open.c b/lib/libI77/open.c index beb525e..75386b9 100644 --- a/lib/libI77/open.c +++ b/lib/libI77/open.c @@ -1,4 +1,3 @@ -#include <unistd.h> #ifndef NON_UNIX_STDIO #include "sys/types.h" #include "sys/stat.h" @@ -29,9 +28,9 @@ char *f__w_mode[4] = {"wb", "w", "r+b", "r+"}; #endif #ifdef KR_headers -int f__isdev(s) char *s; +f__isdev(s) char *s; #else -int f__isdev(char *s) +f__isdev(char *s) #endif { #ifdef NON_UNIX_STDIO @@ -165,7 +164,7 @@ integer f_open(olist *a) case 'R': replace: #ifdef NON_UNIX_STDIO - if ( (tf = fopen(buf,f__w_mode[0])) ) + if (tf = fopen(buf,f__w_mode[0])) fclose(tf); #else (void) close(creat(buf, 0666)); @@ -188,9 +187,9 @@ integer f_open(olist *a) else { if(!(b->ufd = fopen(buf, f__r_mode[ufmt]))) { #ifdef NON_UNIX_STDIO - if ( (b->ufd = fopen(buf, f__w_mode[ufmt|2])) ) + if (b->ufd = fopen(buf, f__w_mode[ufmt|2])) b->uwrt = 2; - else if ( (b->ufd = fopen(buf, f__w_mode[ufmt])) ) + else if (b->ufd = fopen(buf, f__w_mode[ufmt])) b->uwrt = 1; else #else @@ -220,9 +219,9 @@ integer f_open(olist *a) return(0); } #ifdef KR_headers -int fk_open(seq,fmt,n) ftnint n; +fk_open(seq,fmt,n) ftnint n; #else -int fk_open(int seq, int fmt, ftnint n) +fk_open(int seq, int fmt, ftnint n) #endif { char nbuf[10]; olist a; diff --git a/lib/libI77/rawio.h b/lib/libI77/rawio.h index 3e2c750..4cbd847 100644 --- a/lib/libI77/rawio.h +++ b/lib/libI77/rawio.h @@ -1,38 +1,32 @@ #ifdef KR_headers -#ifndef __FreeBSD__ extern FILE *fdopen(); -#endif #else #ifdef MSDOS #include "io.h" +#ifndef WATCOM #define close _close #define creat _creat #define open _open #define read _read #define write _write -#endif +#endif /*WATCOM*/ +#endif /*MSDOS*/ #ifdef __cplusplus extern "C" { #endif #ifndef MSDOS #ifdef OPEN_DECL -#ifndef __FreeBSD__ extern int creat(const char*,int), open(const char*,int); #endif -#endif -#ifndef __FreeBSD__ extern int close(int); extern int read(int,void*,size_t), write(int,void*,size_t); extern int unlink(const char*); -#endif #ifndef _POSIX_SOURCE #ifndef NON_UNIX_STDIO -#ifndef __FreeBSD__ extern FILE *fdopen(int, const char*); #endif #endif -#endif -#endif +#endif /*KR_HEADERS*/ extern char *mktemp(char*); diff --git a/lib/libI77/rdfmt.c b/lib/libI77/rdfmt.c index 3878dd9..03b325e 100644 --- a/lib/libI77/rdfmt.c +++ b/lib/libI77/rdfmt.c @@ -2,6 +2,7 @@ #include "fio.h" #include "fmt.h" #include "fp.h" +#include "ctype.h" extern int f__cursor; #ifdef KR_headers @@ -29,10 +30,10 @@ rd_Z(Uint *n, int w, ftnlen len) if (!hex['0']) { s = "0123456789"; - while( (ch = *s++) ) + while(ch = *s++) hex[ch] = ch - '0' + 1; s = "ABCDEF"; - while( (ch = *s++) ) + while(ch = *s++) hex[ch] = hex[ch + 'a' - 'A'] = ch - 'A' + 11; } s = s0 = (char *)x; @@ -61,7 +62,7 @@ rd_Z(Uint *n, int w, ftnlen len) return errno = 115; w = (int)len; w1 = s - s0; - w2 = (w1+1) >> 1; + w2 = w1+1 >> 1; t = (char *)n; if (*(char *)&one) { /* little endian */ @@ -83,7 +84,7 @@ rd_Z(Uint *n, int w, ftnlen len) t += i; } do { - *t = ((hex[*s0 & 0xff]-1) << 4) | (hex[s0[1] & 0xff]-1); + *t = hex[*s0 & 0xff]-1 << 4 | hex[s0[1] & 0xff]-1; t += i; s0 += 2; } @@ -154,8 +155,6 @@ rd_L(ftnint *n, int w, ftnlen len) return 0; } -#include "ctype.h" - static int #ifdef KR_headers rd_F(p, w, d, len) ufloat *p; ftnlen len; @@ -387,9 +386,9 @@ rd_POS(char *s) return(1); } #ifdef KR_headers -int rd_ed(p,ptr,len) struct syl *p; char *ptr; ftnlen len; +rd_ed(p,ptr,len) struct syl *p; char *ptr; ftnlen len; #else -int rd_ed(struct syl *p, char *ptr, ftnlen len) +rd_ed(struct syl *p, char *ptr, ftnlen len) #endif { int ch; for(;f__cursor>0;f__cursor--) if((ch=(*f__getn)())<0) return(ch); @@ -450,9 +449,9 @@ int rd_ed(struct syl *p, char *ptr, ftnlen len) return(errno); } #ifdef KR_headers -int rd_ned(p) struct syl *p; +rd_ned(p) struct syl *p; #else -int rd_ned(struct syl *p) +rd_ned(struct syl *p) #endif { switch(p->op) diff --git a/lib/libI77/rsfe.c b/lib/libI77/rsfe.c index 24ecafc..41ff257 100644 --- a/lib/libI77/rsfe.c +++ b/lib/libI77/rsfe.c @@ -3,7 +3,6 @@ #include "fio.h" #include "fmt.h" -int xrd_SL(Void) { int ch; if(!f__curunit->uend) @@ -15,8 +14,6 @@ xrd_SL(Void) f__cursor=f__recpos=0; return(1); } - -int x_getc(Void) { int ch; if(f__curunit->uend) return(EOF); @@ -36,15 +33,11 @@ x_getc(Void) } return(-1); } - -int x_endp(Void) { - (void) xrd_SL(); - return(0); + xrd_SL(); + return f__curunit->uend == 1 ? EOF : 0; } - -int x_rev(Void) { (void) xrd_SL(); @@ -57,7 +50,7 @@ integer s_rsfe(cilist *a) /* start */ #endif { int n; if(!f__init) f_init(); - if( (n=c_sfe(a)) ) return(n); + if(n=c_sfe(a)) return(n); f__reading=1; f__sequential=1; f__formatted=1; diff --git a/lib/libI77/rsli.c b/lib/libI77/rsli.c index 999b0d4..a081cd5 100644 --- a/lib/libI77/rsli.c +++ b/lib/libI77/rsli.c @@ -18,7 +18,8 @@ static int i_getc(Void) z_rnew(); } f__recpos++; - if(f__icptr >= f__icend) err(f__svic->iciend,(EOF),"internal read"); + if(f__icptr >= f__icend) + return EOF; return(*f__icptr++); } diff --git a/lib/libI77/rsne.c b/lib/libI77/rsne.c index 9378717..cc679c7 100644 --- a/lib/libI77/rsne.c +++ b/lib/libI77/rsne.c @@ -29,7 +29,7 @@ typedef struct hashtab hashtab; static hashtab *nl_cache; - static n_nlcache; + static int n_nlcache; static hashentry **zot; static int colonseen; extern ftnlen f__typesize[]; @@ -78,7 +78,7 @@ hash(hashtab *ht, register char *s) register hashentry *h; char *s0 = s; - for(x = 0; (c = *s++); x = x & 0x4000 ? ((x << 1) & 0x7fff) + 1 : x << 1) + 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)) @@ -99,7 +99,7 @@ mk_hashtab(Namelist *nl) hashentry *he; hashtab **x, **x0, *y; - for(x = &nl_cache; (y = *x); x0 = x, x = &y->next) + for(x = &nl_cache; y = *x; x0 = x, x = &y->next) if (nl == y->nl) return y; if (n_nlcache >= MAX_NL_CACHE) { @@ -151,13 +151,13 @@ nl_init(Void) { if(!f__init) f_init(); - for(s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; (c = *s++); ) + for(s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; c = *s++; ) Alpha[c] = Alphanum[c] = Alpha[c + 'a' - 'A'] = Alphanum[c + 'a' - 'A'] = c; - for(s = "0123456789_"; (c = *s++); ) + for(s = "0123456789_"; c = *s++; ) Alphanum[c] = c; } @@ -180,7 +180,7 @@ getname(register char *s, int slen) ch = 115; errfl(f__elist->cierr, ch, "namelist read"); } - while( (*s = Alphanum[GETC(ch) & 0xff]) ) + while(*s = Alphanum[GETC(ch) & 0xff]) if (s < se) s++; if (ch == EOF) @@ -235,15 +235,15 @@ getdimen(int *chp, dimen *d, ftnlen delta, ftnlen extent, ftnlen *x1) register int k; ftnlen x2, x3; - if ( (k = getnum(chp, x1)) ) + if (k = getnum(chp, x1)) return k; x3 = 1; if (*chp == ':') { - if ( (k = getnum(chp, &x2)) ) + if (k = getnum(chp, &x2)) return k; x2 -= *x1; if (*chp == ':') { - if ( (k = getnum(chp, &x3)) ) + if (k = getnum(chp, &x3)) return k; if (!x3) return 123; @@ -291,9 +291,9 @@ print_ne(cilist *a) static char where0[] = "namelist read start "; #ifdef KR_headers -int x_rsne(a) cilist *a; +x_rsne(a) cilist *a; #else -int x_rsne(cilist *a) +x_rsne(cilist *a) #endif { int ch, got1, k, n, nd, quote, readall; @@ -340,7 +340,7 @@ int x_rsne(cilist *a) #endif } have_amp: - if ( (ch = getname(buf,sizeof(buf))) ) + if (ch = getname(buf,sizeof(buf))) return ch; nl = (Namelist *)a->cifmt; if (strcmp(buf, nl->name)) @@ -392,10 +392,10 @@ int x_rsne(cilist *a) case '&': return 0; default: - if ((ch <= ' ' && ch >= 0) || (ch == ',')) + if (ch <= ' ' && ch >= 0 || ch == ',') continue; Ungetc(ch,f__cf); - if ( (ch = getname(buf,sizeof(buf))) ) + if (ch = getname(buf,sizeof(buf))) return ch; goto havename; } @@ -419,8 +419,8 @@ int x_rsne(cilist *a) if (!(dims = v->dims)) { if (type != TYCHAR) errfl(a->cierr, 122, where); - if ( (k = getdimen(&ch, dn, (ftnlen)size, - (ftnlen)size, &b)) ) + if (k = getdimen(&ch, dn, (ftnlen)size, + (ftnlen)size, &b)) errfl(a->cierr, k, where); if (ch != ')') errfl(a->cierr, 115, where); @@ -436,7 +436,7 @@ int x_rsne(cilist *a) nomax = span = dims[1]; ivae = iva + size*nomax; colonseen = 0; - if ( (k = getdimen(&ch, dn, size, nomax, &b)) ) + if (k = getdimen(&ch, dn, size, nomax, &b)) errfl(a->cierr, k, where); no = dn->extent; b0 = dims[2]; @@ -447,8 +447,8 @@ int x_rsne(cilist *a) errfl(a->cierr, 115, where); dn1 = dn + 1; span /= *dims; - if ( (k = getdimen(&ch, dn1, dn->delta**dims, - span, &b1)) ) + if (k = getdimen(&ch, dn1, dn->delta**dims, + span, &b1)) errfl(a->cierr, k, where); ex *= *dims; b += b1*ex; @@ -467,7 +467,7 @@ int x_rsne(cilist *a) no1 = 1; dn0 = dimens; if (type == TYCHAR && ch == '(' /*)*/) { - if ( (k = getdimen(&ch, &substr, size, size, &b)) ) + if (k = getdimen(&ch, &substr, size, size, &b)) errfl(a->cierr, k, where); if (ch != ')') errfl(a->cierr, 115, where); @@ -502,7 +502,7 @@ int x_rsne(cilist *a) dn1->delta -= ex; } } - else if ( (dims = v->dims) ) { + else if (dims = v->dims) { no = no1 = dims[1]; ivae = iva + no*size; } @@ -522,7 +522,7 @@ int x_rsne(cilist *a) else if (iva + no1*size > ivae) no1 = (ivae - iva)/size; f__lquit = 0; - if ( (k = l_read(&no1, vaddr + iva, size, type)) ) + if (k = l_read(&no1, vaddr + iva, size, type)) return k; if (f__lquit == 1) return 0; @@ -533,8 +533,8 @@ int x_rsne(cilist *a) if (no1 > f__lcount) no1 = f__lcount; iva += no1 * dn0->delta; - if ( (k = l_read(&no1, vaddr + iva, - size, type)) ) + if (k = l_read(&no1, vaddr + iva, + size, type)) return k; } } @@ -594,7 +594,7 @@ s_rsne(cilist *a) f__external=1; l_eof = 0; - if( (n = c_le(a)) ) + if(n = c_le(a)) return n; if(f__curunit->uwrt && f__nowreading(f__curunit)) err(a->cierr,errno,where0); diff --git a/lib/libI77/sfe.c b/lib/libI77/sfe.c index 6fe9aa0..eea9078 100644 --- a/lib/libI77/sfe.c +++ b/lib/libI77/sfe.c @@ -15,9 +15,9 @@ integer e_rsfe(Void) return(n); } #ifdef KR_headers -int c_sfe(a) cilist *a; /* check */ +c_sfe(a) cilist *a; /* check */ #else -int c_sfe(cilist *a) /* check */ +c_sfe(cilist *a) /* check */ #endif { unit *p; if(a->ciunit >= MXUNIT || a->ciunit<0) diff --git a/lib/libI77/sue.c b/lib/libI77/sue.c index a179169..b1b8bc3 100644 --- a/lib/libI77/sue.c +++ b/lib/libI77/sue.c @@ -4,9 +4,9 @@ extern uiolen f__reclen; long f__recloc; #ifdef KR_headers -int c_sue(a) cilist *a; +c_sue(a) cilist *a; #else -int c_sue(cilist *a) +c_sue(cilist *a) #endif { if(a->ciunit >= MXUNIT || a->ciunit < 0) @@ -31,7 +31,7 @@ integer s_rsue(cilist *a) int n; if(!f__init) f_init(); f__reading=1; - if( (n=c_sue(a)) ) return(n); + if(n=c_sue(a)) return(n); f__recpos=0; if(f__curunit->uwrt && f__nowreading(f__curunit)) err(a->cierr, errno, "read start"); @@ -54,7 +54,7 @@ integer s_wsue(cilist *a) { int n; if(!f__init) f_init(); - if( (n=c_sue(a)) ) return(n); + if(n=c_sue(a)) return(n); f__reading=0; f__reclen=0; if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) diff --git a/lib/libI77/uio.c b/lib/libI77/uio.c index 6bceb27..e40875e 100644 --- a/lib/libI77/uio.c +++ b/lib/libI77/uio.c @@ -3,9 +3,9 @@ uiolen f__reclen; #ifdef KR_headers -int do_us(number,ptr,len) ftnint *number; char *ptr; ftnlen len; +do_us(number,ptr,len) ftnint *number; char *ptr; ftnlen len; #else -int do_us(ftnint *number, char *ptr, ftnlen len) +do_us(ftnint *number, char *ptr, ftnlen len) #endif { if(f__reading) @@ -23,7 +23,6 @@ int do_us(ftnint *number, char *ptr, ftnlen len) (void) fwrite(ptr,(int)len,(int)(*number),f__cf); return(0); } - return (0); } #ifdef KR_headers integer do_ud(number,ptr,len) ftnint *number; char *ptr; ftnlen len; diff --git a/lib/libI77/wref.c b/lib/libI77/wref.c index 0adcccc..5e4871d 100644 --- a/lib/libI77/wref.c +++ b/lib/libI77/wref.c @@ -15,9 +15,9 @@ #endif #ifdef KR_headers -int wrt_E(p,w,d,e,len) ufloat *p; ftnlen len; +wrt_E(p,w,d,e,len) ufloat *p; ftnlen len; #else -int wrt_E(ufloat *p, int w, int d, int e, ftnlen len) +wrt_E(ufloat *p, int w, int d, int e, ftnlen len) #endif { char buf[FMAX+EXPMAXDIGS+4], *s, *se; @@ -118,7 +118,7 @@ nogood: if (s[2]) { #ifdef Pedantic if (!e0 && !s[3]) - e1 = 2; /* for(s -= 2, e1 = 2; s[0] = s[1]; s++); */ + e1 = 2;/* 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 */ @@ -127,7 +127,7 @@ nogood: /* exponent field if it fits. */ #else if (!e0) { - for(s -= 2, e1 = 2; (s[0] = s[1]); s++) + for(s -= 2, e1 = 2; s[0] = s[1]; s++) #ifdef CRAY delta--; if ((delta += 4) < 0) @@ -191,9 +191,9 @@ nogood: } #ifdef KR_headers -int wrt_F(p,w,d,len) ufloat *p; ftnlen len; +wrt_F(p,w,d,len) ufloat *p; ftnlen len; #else -int wrt_F(ufloat *p, int w, int d, ftnlen len) +wrt_F(ufloat *p, int w, int d, ftnlen len) #endif { int d1, sign, n; @@ -217,7 +217,7 @@ int wrt_F(ufloat *p, int w, int d, ftnlen len) #endif } - if ( (n = f__scale) ) + if (n = f__scale) if (n > 0) do x *= 10.; while(--n > 0); else @@ -267,7 +267,7 @@ int wrt_F(ufloat *p, int w, int d, ftnlen len) PUT('-'); else if (f__cplus) PUT('+'); - while( (n = *b++) ) + while(n = *b++) PUT(n); while(--d1 >= 0) PUT('0'); diff --git a/lib/libI77/wrtfmt.c b/lib/libI77/wrtfmt.c index 077db71..f261ec3 100644 --- a/lib/libI77/wrtfmt.c +++ b/lib/libI77/wrtfmt.c @@ -2,87 +2,84 @@ #include "fio.h" #include "fmt.h" -extern int f__cursor; -int f__hiwater; -icilist *f__svic; -char *f__icptr; +extern icilist *f__svic; +extern char *f__icptr; -int + 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(f__cursor < 0) { + if(cursor < 0) { if(f__hiwater < f__recpos) f__hiwater = f__recpos; - f__recpos += f__cursor; - f__icptr += f__cursor; - f__cursor = 0; + f__recpos += cursor; + f__icptr += cursor; if(f__recpos < 0) err(f__elist->cierr, 110, "left off"); } - else if(f__cursor > 0) { - if(f__recpos + f__cursor >= f__svic->icirlen) + else if(cursor > 0) { + if(f__recpos + cursor >= f__svic->icirlen) err(f__elist->cierr, 110, "recend"); if(f__hiwater <= f__recpos) - for(; f__cursor > 0; f__cursor--) + for(; cursor > 0; cursor--) (*f__putn)(' '); - else if(f__hiwater <= f__recpos + f__cursor) { - f__cursor -= f__hiwater - f__recpos; + else if(f__hiwater <= f__recpos + cursor) { + cursor -= f__hiwater - f__recpos; f__icptr += f__hiwater - f__recpos; f__recpos = f__hiwater; - for(; f__cursor > 0; f__cursor--) + for(; cursor > 0; cursor--) (*f__putn)(' '); } else { - f__icptr += f__cursor; - f__recpos += f__cursor; + f__icptr += cursor; + f__recpos += cursor; } - f__cursor = 0; } return(0); } - if(f__cursor > 0) { + if(cursor > 0) { if(f__hiwater <= f__recpos) - for(;f__cursor>0;f__cursor--) (*f__putn)(' '); - else if(f__hiwater <= f__recpos + f__cursor) { + for(;cursor>0;cursor--) (*f__putn)(' '); + else if(f__hiwater <= f__recpos + cursor) { #ifndef NON_UNIX_STDIO if(f__cf->_ptr + f__hiwater - f__recpos < buf_end(f__cf)) f__cf->_ptr += f__hiwater - f__recpos; else #endif (void) fseek(f__cf, (long) (f__hiwater - f__recpos), SEEK_CUR); - f__cursor -= f__hiwater - f__recpos; + cursor -= f__hiwater - f__recpos; f__recpos = f__hiwater; - for(; f__cursor > 0; f__cursor--) + for(; cursor > 0; cursor--) (*f__putn)(' '); } else { #ifndef NON_UNIX_STDIO - if(f__cf->_ptr + f__cursor < buf_end(f__cf)) - f__cf->_ptr += f__cursor; + if(f__cf->_ptr + cursor < buf_end(f__cf)) + f__cf->_ptr += cursor; else #endif - (void) fseek(f__cf, (long)f__cursor, SEEK_CUR); - f__recpos += f__cursor; + (void) fseek(f__cf, (long)cursor, SEEK_CUR); + f__recpos += cursor; } } - if(f__cursor<0) + if(cursor<0) { - if(f__cursor+f__recpos<0) err(f__elist->cierr,110,"left off"); + if(cursor+f__recpos<0) err(f__elist->cierr,110,"left off"); #ifndef NON_UNIX_STDIO - if(f__cf->_ptr + f__cursor >= f__cf->_base) - f__cf->_ptr += f__cursor; + if(f__cf->_ptr + cursor >= f__cf->_base) + f__cf->_ptr += cursor; else #endif if(f__curunit && f__curunit->useek) - (void) fseek(f__cf,(long)f__cursor,SEEK_CUR); + (void) fseek(f__cf,(long)cursor,SEEK_CUR); else err(f__elist->cierr,106,"fmt"); if(f__hiwater < f__recpos) f__hiwater = f__recpos; - f__recpos += f__cursor; - f__cursor=0; + f__recpos += cursor; } return(0); } @@ -95,7 +92,7 @@ wrt_Z(Uint *n, int w, int minlen, ftnlen len) #endif { register char *s, *se; - register i, w1; + register int i, w1; static int one = 1; static char hex[] = "0123456789ABCDEF"; s = (char *)n; @@ -214,7 +211,10 @@ wrt_AP(s) char *s; wrt_AP(char *s) #endif { char quote; - if(f__cursor && mv_cur()) return(mv_cur()); + int i; + + if(f__cursor && (i = mv_cur())) + return i; quote = *s++; for(;*s;s++) { if(*s!=quote) (*f__putn)(*s); @@ -230,14 +230,17 @@ wrt_H(a,s) char *s; wrt_H(int a, char *s) #endif { - if(f__cursor && mv_cur()) return(mv_cur()); + int i; + + if(f__cursor && (i = mv_cur())) + return i; while(a--) (*f__putn)(*s++); return(1); } #ifdef KR_headers -int wrt_L(n,len, sz) Uint *n; ftnlen sz; +wrt_L(n,len, sz) Uint *n; ftnlen sz; #else -int wrt_L(Uint *n, int len, ftnlen sz) +wrt_L(Uint *n, int len, ftnlen sz) #endif { int i; long x; @@ -309,12 +312,15 @@ wrt_G(ufloat *p, int w, int d, int e, ftnlen len) return(wrt_E(p,w,d,e,len)); } #ifdef KR_headers -int w_ed(p,ptr,len) struct syl *p; char *ptr; ftnlen len; +w_ed(p,ptr,len) struct syl *p; char *ptr; ftnlen len; #else -int w_ed(struct syl *p, char *ptr, ftnlen len) +w_ed(struct syl *p, char *ptr, ftnlen len) #endif { - if(f__cursor && mv_cur()) return(mv_cur()); + int i; + + if(f__cursor && (i = mv_cur())) + return i; switch(p->op) { default: @@ -352,9 +358,9 @@ int w_ed(struct syl *p, char *ptr, ftnlen len) } } #ifdef KR_headers -int w_ned(p) struct syl *p; +w_ned(p) struct syl *p; #else -int w_ned(struct syl *p) +w_ned(struct syl *p) #endif { switch(p->op) diff --git a/lib/libI77/wsfe.c b/lib/libI77/wsfe.c index d69f9af..7c7f014 100644 --- a/lib/libI77/wsfe.c +++ b/lib/libI77/wsfe.c @@ -5,9 +5,9 @@ extern int f__hiwater; #ifdef KR_headers -int x_putc(c) +x_putc(c) #else -int x_putc(int c) +x_putc(int c) #endif { /* this uses \n as an indicator of record-end */ @@ -27,8 +27,6 @@ int x_putc(int c) #endif return putc(c,f__cf); } - -int x_wSL(Void) { (*f__putn)('\n'); @@ -37,8 +35,6 @@ x_wSL(Void) f__hiwater = 0; return(1); } - -int xw_end(Void) { if(f__nonl == 0) @@ -46,8 +42,6 @@ xw_end(Void) f__hiwater = f__recpos = f__cursor = 0; return(0); } - -int xw_rev(Void) { if(f__workdone) (*f__putn)('\n'); @@ -62,7 +56,7 @@ integer s_wsfe(cilist *a) /*start*/ #endif { int n; if(!f__init) f_init(); - if( (n=c_sfe(a)) ) return(n); + if(n=c_sfe(a)) return(n); f__reading=0; f__sequential=1; f__formatted=1; diff --git a/lib/libI77/wsle.c b/lib/libI77/wsle.c index 1e47d5d..44b6972 100644 --- a/lib/libI77/wsle.c +++ b/lib/libI77/wsle.c @@ -10,7 +10,7 @@ integer s_wsle(cilist *a) #endif { int n; - if( (n=c_le(a)) ) return(n); + if(n=c_le(a)) return(n); f__reading=0; f__external=1; f__formatted=1; diff --git a/lib/libI77/wsne.c b/lib/libI77/wsne.c index 9b7f9b6..0febd52 100644 --- a/lib/libI77/wsne.c +++ b/lib/libI77/wsne.c @@ -11,7 +11,7 @@ s_wsne(cilist *a) { int n; - if( (n=c_le(a)) ) + if(n=c_le(a)) return(n); f__reading=0; f__external=1; |