00001 char 00002 _libi77_version_f2c[] = "\n@(#) LIBI77 VERSION (f2c) pjw,dmg-mods 20030321\n"; 00003 00004 /* 00005 2.01 $ format added 00006 2.02 Coding bug in open.c repaired 00007 2.03 fixed bugs in lread.c (read * with negative f-format) and lio.c 00008 and lio.h (e-format conforming to spec) 00009 2.04 changed open.c and err.c (fopen and freopen respectively) to 00010 update to new c-library (append mode) 00011 2.05 added namelist capability 00012 2.06 allow internal list and namelist I/O 00013 */ 00014 00015 /* 00016 close.c: 00017 allow upper-case STATUS= values 00018 endfile.c 00019 create fort.nnn if unit nnn not open; 00020 else if (file length == 0) use creat() rather than copy; 00021 use local copy() rather than forking /bin/cp; 00022 rewind, fseek to clear buffer (for no reading past EOF) 00023 err.c 00024 use neither setbuf nor setvbuf; make stderr buffered 00025 fio.h 00026 #define _bufend 00027 inquire.c 00028 upper case responses; 00029 omit byfile test from SEQUENTIAL= 00030 answer "YES" to DIRECT= for unopened file (open to debate) 00031 lio.c 00032 flush stderr, stdout at end of each stmt 00033 space before character strings in list output only at line start 00034 lio.h 00035 adjust LEW, LED consistent with old libI77 00036 lread.c 00037 use atof() 00038 allow "nnn*," when reading complex constants 00039 open.c 00040 try opening for writing when open for read fails, with 00041 special uwrt value (2) delaying creat() to first write; 00042 set curunit so error messages don't drop core; 00043 no file name ==> fort.nnn except for STATUS='SCRATCH' 00044 rdfmt.c 00045 use atof(); trust EOF == end-of-file (so don't read past 00046 end-of-file after endfile stmt) 00047 sfe.c 00048 flush stderr, stdout at end of each stmt 00049 wrtfmt.c: 00050 use upper case 00051 put wrt_E and wrt_F into wref.c, use sprintf() 00052 rather than ecvt() and fcvt() [more accurate on VAX] 00053 */ 00054 00055 /* 16 Oct. 1988: uwrt = 3 after write, rewind, so close won't zap the file. */ 00056 00057 /* 10 July 1989: change _bufend to buf_end in fio.h, wsfe.c, wrtfmt.c */ 00058 00059 /* 28 Nov. 1989: corrections for IEEE and Cray arithmetic */ 00060 /* 29 Nov. 1989: change various int return types to long for f2c */ 00061 /* 30 Nov. 1989: various types from f2c.h */ 00062 /* 6 Dec. 1989: types corrected various places */ 00063 /* 19 Dec. 1989: make iostat= work right for internal I/O */ 00064 /* 8 Jan. 1990: add rsne, wsne -- routines for handling NAMELIST */ 00065 /* 28 Jan. 1990: have NAMELIST read treat $ as &, general white 00066 space as blank */ 00067 /* 27 Mar. 1990: change an = to == in rd_L(rdfmt.c) so formatted reads 00068 of logical values reject letters other than fFtT; 00069 have nowwriting reset cf */ 00070 /* 14 Aug. 1990: adjust lread.c to treat tabs as spaces in list input */ 00071 /* 17 Aug. 1990: adjust open.c to recognize blank='Z...' as well as 00072 blank='z...' when reopening an open file */ 00073 /* 30 Aug. 1990: prevent embedded blanks in list output of complex values; 00074 omit exponent field in list output of values of 00075 magnitude between 10 and 1e8; prevent writing stdin 00076 and reading stdout or stderr; don't close stdin, stdout, 00077 or stderr when reopening units 5, 6, 0. */ 00078 /* 18 Sep. 1990: add component udev to unit and consider old == new file 00079 iff uinode and udev values agree; use stat rather than 00080 access to check existence of file (when STATUS='OLD')*/ 00081 /* 2 Oct. 1990: adjust rewind.c so two successive rewinds after a write 00082 don't clobber the file. */ 00083 /* 9 Oct. 1990: add #include "fcntl.h" to endfile.c, err.c, open.c; 00084 adjust g_char in util.c for segmented memories. */ 00085 /* 17 Oct. 1990: replace abort() and _cleanup() with calls on 00086 sig_die(...,1) (defined in main.c). */ 00087 /* 5 Nov. 1990: changes to open.c: complain if new= is specified and the 00088 file already exists; allow file= to be omitted in open stmts 00089 and allow status='replace' (Fortran 90 extensions). */ 00090 /* 11 Dec. 1990: adjustments for POSIX. */ 00091 /* 15 Jan. 1991: tweak i_ungetc in rsli.c to allow reading from 00092 strings in read-only memory. */ 00093 /* 25 Apr. 1991: adjust namelist stuff to work with f2c -i2 */ 00094 /* 26 Apr. 1991: fix some bugs with NAMELIST read of multi-dim. arrays */ 00095 /* 16 May 1991: increase LEFBL in lio.h to bypass NeXT bug */ 00096 /* 17 Oct. 1991: change type of length field in sequential unformatted 00097 records from int to long (for systems where sizeof(int) 00098 can vary, depending on the compiler or compiler options). */ 00099 /* 14 Nov. 1991: change uint to Uint in fmt.h, rdfmt.c, wrtfmt.c. */ 00100 /* 25 Nov. 1991: change uint to Uint in lwrite.c; change sizeof(int) to 00101 sizeof(uioint) in fseeks in sue.c (missed on 17 Oct.). */ 00102 /* 1 Dec. 1991: uio.c: add test for read failure (seq. unformatted reads); 00103 adjust an error return from EOF to off end of record */ 00104 /* 12 Dec. 1991: rsli.c: fix bug with internal list input that caused 00105 the last character of each record to be ignored. 00106 iio.c: adjust error message in internal formatted 00107 input from "end-of-file" to "off end of record" if 00108 the format specifies more characters than the 00109 record contains. */ 00110 /* 17 Jan. 1992: lread.c, rsne.c: in list and namelist input, 00111 treat "r* ," and "r*," alike (where r is a 00112 positive integer constant), and fix a bug in 00113 handling null values following items with repeat 00114 counts (e.g., 2*1,,3); for namelist reading 00115 of a numeric array, allow a new name-value subsequence 00116 to terminate the current one (as though the current 00117 one ended with the right number of null values). 00118 lio.h, lwrite.c: omit insignificant zeros in 00119 list and namelist output. To get the old 00120 behavior, compile with -DOld_list_output . */ 00121 /* 18 Jan. 1992: make list output consistent with F format by 00122 printing .1 rather than 0.1 (introduced yesterday). */ 00123 /* 3 Feb. 1992: rsne.c: fix namelist read bug that caused the 00124 character following a comma to be ignored. */ 00125 /* 19 May 1992: adjust iio.c, ilnw.c, rdfmt.c and rsli.c to make err= 00126 work with internal list and formatted I/O. */ 00127 /* 18 July 1992: adjust rsne.c to allow namelist input to stop at 00128 an & (e.g. &end). */ 00129 /* 23 July 1992: switch to ANSI prototypes unless KR_headers is #defined ; 00130 recognize Z format (assuming 8-bit bytes). */ 00131 /* 14 Aug. 1992: tweak wrt_E in wref.c to avoid -NaN */ 00132 /* 23 Oct. 1992: Supply missing l_eof = 0 assignment to s_rsne() in rsne.c 00133 (so end-of-file on other files won't confuse namelist 00134 reads of external files). Prepend f__ to external 00135 names that are only of internal interest to lib[FI]77. */ 00136 /* 1 Feb. 1993: backspace.c: fix bug that bit when last char of 2nd 00137 buffer == '\n'. 00138 endfile.c: guard against tiny L_tmpnam; close and reopen 00139 files in t_runc(). 00140 lio.h: lengthen LINTW (buffer size in lwrite.c). 00141 err.c, open.c: more prepending of f__ (to [rw]_mode). */ 00142 /* 5 Feb. 1993: tweaks to NAMELIST: rsne.c: ? prints the namelist being 00143 sought; namelists of the wrong name are skipped (after 00144 an error message; xwsne.c: namelist writes have a 00145 newline before each new variable. 00146 open.c: ACCESS='APPEND' positions sequential files 00147 at EOF (nonstandard extension -- that doesn't require 00148 changing data structures). */ 00149 /* 9 Feb. 1993: Change some #ifdef MSDOS lines to #ifdef NON_UNIX_STDIO. 00150 err.c: under NON_UNIX_STDIO, avoid close(creat(name,0666)) 00151 when the unit has another file descriptor for name. */ 00152 /* 4 March 1993: err.c, open.c: take declaration of fdopen from rawio.h; 00153 open.c: always give f__w_mode[] 4 elements for use 00154 in t_runc (in endfile.c -- for change of 1 Feb. 1993). */ 00155 /* 6 March 1993: uio.c: adjust off-end-of-record test for sequential 00156 unformatted reads to respond to err= rather than end=. */ 00157 /* 12 March 1993: various tweaks for C++ */ 00158 /* 6 April 1993: adjust error returns for formatted inputs to flush 00159 the current input line when err=label is specified. 00160 To restore the old behavior (input left mid-line), 00161 either adjust the #definition of errfl in fio.h or 00162 omit the invocation of f__doend in err__fl (in err.c). */ 00163 /* 23 June 1993: iio.c: fix bug in format reversions for internal writes. */ 00164 /* 5 Aug. 1993: lread.c: fix bug in handling repetition counts for 00165 logical data (during list or namelist input). 00166 Change struct f__syl to struct syl (for buggy compilers). */ 00167 /* 7 Aug. 1993: lread.c: fix bug in namelist reading of incomplete 00168 logical arrays. */ 00169 /* 9 Aug. 1993: lread.c: fix bug in namelist reading of an incomplete 00170 array of numeric data followed by another namelist 00171 item whose name starts with 'd', 'D', 'e', or 'E'. */ 00172 /* 8 Sept. 1993: open.c: protect #include "sys/..." with 00173 #ifndef NON_UNIX_STDIO; Version date not changed. */ 00174 /* 10 Nov. 1993: backspace.c: add nonsense for #ifdef MSDOS */ 00175 /* 8 Dec. 1993: iio.c: adjust internal formatted reads to treat 00176 short records as though padded with blanks 00177 (rather than causing an "off end of record" error). */ 00178 /* 22 Feb. 1994: lread.c: check that realloc did not return NULL. */ 00179 /* 6 June 1994: Under NON_UNIX_STDIO, use binary mode for direct 00180 formatted files (avoiding any confusion regarding \n). */ 00181 /* 5 July 1994: Fix bug (introduced 6 June 1994?) in reopening files 00182 under NON_UNIX_STDIO. */ 00183 /* 6 July 1994: wref.c: protect with #ifdef GOOD_SPRINTF_EXPONENT an 00184 optimization that requires exponents to have 2 digits 00185 when 2 digits suffice. 00186 lwrite.c wsfe.c (list and formatted external output): 00187 omit ' ' carriage-control when compiled with 00188 -DOMIT_BLANK_CC . Off-by-one bug fixed in character 00189 count for list output of character strings. 00190 Omit '.' in list-directed printing of Nan, Infinity. */ 00191 /* 12 July 1994: wrtfmt.c: under G11.4, write 0. as " .0000 " rather 00192 than " .0000E+00". */ 00193 /* 3 Aug. 1994: lwrite.c: do not insert a newline when appending an 00194 oversize item to an empty line. */ 00195 /* 12 Aug. 1994: rsli.c rsne.c: fix glitch (reset nml_read) that kept 00196 ERR= (in list- or format-directed input) from working 00197 after a NAMELIST READ. */ 00198 /* 7 Sept. 1994: typesize.c: adjust to allow types LOGICAL*1, LOGICAL*2, 00199 INTEGER*1, and (under -DAllow_TYQUAD) INTEGER*8 00200 in NAMELISTs. */ 00201 /* 6 Oct. 1994: util.c: omit f__mvgbt, as it is never used. */ 00202 /* 2 Nov. 1994: add #ifdef ALWAYS_FLUSH logic. */ 00203 /* 26 Jan. 1995: wref.c: fix glitch in printing the exponent of 0 when 00204 GOOD_SPRINTF_EXPONENT is not #defined. */ 00205 /* 24 Feb. 1995: iio.c: z_getc: insert (unsigned char *) to allow 00206 internal reading of characters with high-bit set 00207 (on machines that sign-extend characters). */ 00208 /* 14 March 1995:lread.c and rsfe.c: adjust s_rsle and s_rsfe to 00209 check for end-of-file (to prevent infinite loops 00210 with empty read statements). */ 00211 /* 26 May 1995: iio.c: z_wnew: fix bug in handling T format items 00212 in internal writes whose last item is written to 00213 an earlier position than some previous item. */ 00214 /* 29 Aug. 1995: backspace.c: adjust MSDOS logic. */ 00215 /* 6 Sept. 1995: Adjust namelist input to treat a subscripted name 00216 whose subscripts do not involve colons similarly 00217 to the name without a subscript: accept several 00218 values, stored in successive elements starting at 00219 the indicated subscript. Adjust namelist output 00220 to quote character strings (avoiding confusion with 00221 arrays of character strings). Adjust f_init calls 00222 for people who don't use libF77's main(); now open and 00223 namelist read statements invoke f_init if needed. */ 00224 /* 7 Sept. 1995: Fix some bugs with -DAllow_TYQUAD (for integer*8). 00225 Add -DNo_Namelist_Comments lines to rsne.c. */ 00226 /* 5 Oct. 1995: wrtfmt.c: fix bug with t editing (f__cursor was not 00227 always zeroed in mv_cur). */ 00228 /* 11 Oct. 1995: move defs of f__hiwater, f__svic, f__icptr from wrtfmt.c 00229 to err.c */ 00230 /* 15 Mar. 1996: lread.c, rsfe.c: honor END= in READ stmt with empty iolist */ 00231 00232 /* 13 May 1996: add ftell_.c and fseek_.c */ 00233 /* 9 June 1996: Adjust rsli.c and lread.c so internal list input with 00234 too few items in the input string will honor end= . */ 00235 /* 12 Sept. 1995:fmtlib.c: fix glitch in printing the most negative integer. */ 00236 /* 25 Sept. 1995:fmt.h: for formatted writes of negative integer*1 values, 00237 make ic signed on ANSI systems. If formatted writes of 00238 integer*1 values trouble you when using a K&R C compiler, 00239 switch to an ANSI compiler or use a compiler flag that 00240 makes characters signed. */ 00241 /* 9 Dec. 1996: d[fu]e.c, err.c: complain about non-positive rec= 00242 in direct read and write statements. 00243 ftell_.c: change param "unit" to "Unit" for -DKR_headers. */ 00244 /* 26 Feb. 1997: ftell_.c: on systems that define SEEK_SET, etc., use 00245 SEEK_SET, SEEK_CUR, SEEK_END for *whence = 0, 1, 2. */ 00246 /* 7 Apr. 1997: fmt.c: adjust to complain at missing numbers in formats 00247 (but still treat missing ".nnn" as ".0"). */ 00248 /* 11 Apr. 1997: err.c: attempt to make stderr line buffered rather 00249 than fully buffered. (Buffering is needed for format 00250 items T and TR.) */ 00251 /* 27 May 1997: ftell_.c: fix typo (that caused the third argument to be 00252 treated as 2 on some systems). */ 00253 /* 5 Aug. 1997: lread.c: adjust to accord with a change to the Fortran 8X 00254 draft (in 1990 or 1991) that rescinded permission to elide 00255 quote marks in namelist input of character data; compile 00256 with -DF8X_NML_ELIDE_QUOTES to get the old behavior. 00257 wrtfmt.o: wrt_G: tweak to print the right number of 0's 00258 for zero under G format. */ 00259 /* 16 Aug. 1997: iio.c: fix bug in internal writes to an array of character 00260 strings that sometimes caused one more array element than 00261 required by the format to be blank-filled. Example: 00262 format(1x). */ 00263 /* 16 Sept. 1997:fmt.[ch] rdfmt.c wrtfmt.c: tweak struct syl for machines 00264 with 64-bit pointers and 32-bit ints that did not 64-bit 00265 align struct syl (e.g., Linux on the DEC Alpha). */ 00266 /* 19 Jan. 1998: backspace.c: for b->ufmt==0, change sizeof(int) to 00267 sizeof(uiolen). On machines where this would make a 00268 difference, it is best for portability to compile libI77 with 00269 -DUIOLEN_int (which will render the change invisible). */ 00270 /* 4 March 1998: open.c: fix glitch in comparing file names under 00271 -DNON_UNIX_STDIO */ 00272 /* 17 March 1998: endfile.c, open.c: acquire temporary files from tmpfile(), 00273 unless compiled with -DNON_ANSI_STDIO, which uses mktemp(). 00274 New buffering scheme independent of NON_UNIX_STDIO for 00275 handling T format items. Now -DNON_UNIX_STDIO is no 00276 longer be necessary for Linux, and libf2c no longer 00277 causes stderr to be buffered -- the former setbuf or 00278 setvbuf call for stderr was to make T format items work. 00279 open.c: use the Posix access() function to check existence 00280 or nonexistence of files, except under -DNON_POSIX_STDIO, 00281 where trial fopen calls are used. */ 00282 /* 5 April 1998: wsfe.c: make $ format item work: this was lost in the 00283 changes of 17 March 1998. */ 00284 /* 28 May 1998: backspace.c dfe.c due.c iio.c lread.c rsfe.c sue.c wsfe.c: 00285 set f__curunit sooner so various error messages will 00286 correctly identify the I/O unit involved. */ 00287 /* 17 June 1998: lread.c: unless compiled with 00288 ALLOW_FLOAT_IN_INTEGER_LIST_INPUT #defined, treat 00289 floating-point numbers (containing either a decimal point 00290 or an exponent field) as errors when they appear as list 00291 input for integer data. */ 00292 /* 7 Sept. 1998: move e_wdfe from sfe.c to dfe.c, where it was originally. 00293 Why did it ever move to sfe.c? */ 00294 /* 2 May 1999: open.c: set f__external (to get "external" versus "internal" 00295 right in the error message if we cannot open the file). 00296 err.c: cast a pointer difference to (int) for %d. 00297 rdfmt.c: omit fixed-length buffer that could be overwritten 00298 by formats Inn or Lnn with nn > 83. */ 00299 /* 3 May 1999: open.c: insert two casts for machines with 64-bit longs. */ 00300 /* 18 June 1999: backspace.c: allow for b->ufd changing in t_runc */ 00301 /* 27 June 1999: rsne.c: fix bug in namelist input: a misplaced increment */ 00302 /* could cause wrong array elements to be assigned; e.g., */ 00303 /* "&input k(5)=10*1 &end" assigned k(5) and k(15..23) */ 00304 /* 15 Nov. 1999: endfile.c: set state to writing (b->uwrt = 1) when an */ 00305 /* endfile statement requires copying the file. */ 00306 /* (Otherwise an immediately following rewind statement */ 00307 /* could make the file appear empty.) Also, supply a */ 00308 /* missing (long) cast in the sprintf call. */ 00309 /* sfe.c: add #ifdef ALWAYS_FLUSH logic, for formatted I/O: */ 00310 /* Compiling libf2c with -DALWAYS_FLUSH should prevent losing */ 00311 /* any data in buffers should the program fault. It also */ 00312 /* makes the program run more slowly. */ 00313 /* 20 April 2000: rsne.c, xwsne.c: tweaks that only matter if ftnint and */ 00314 /* ftnlen are of different fundamental types (different numbers */ 00315 /* of bits). Since these files will not compile when this */ 00316 /* change matters, the above VERSION string remains unchanged. */ 00317 /* 4 July 2000: adjustments to permit compilation by C++ compilers; */ 00318 /* VERSION string remains unchanged. */ 00319 /* 5 Dec. 2000: lread.c: under namelist input, when reading a logical array, */ 00320 /* treat Tstuff= and Fstuff= as new assignments rather than as */ 00321 /* logical constants. */ 00322 /* 22 Feb. 2001: endfile.c: adjust to use truncate() unless compiled with */ 00323 /* -DNO_TRUNCATE (or with -DMSDOS). */ 00324 /* 1 March 2001: endfile.c: switch to ftruncate (absent -DNO_TRUNCATE), */ 00325 /* thus permitting truncation of scratch files on true Unix */ 00326 /* systems, where scratch files have no name. Add an fflush() */ 00327 /* (surprisingly) needed on some Linux systems. */ 00328 /* 11 Oct. 2001: backspac.c dfe.c due.c endfile.c err.c fio.h fmt.c fmt.h */ 00329 /* inquire.c open.c rdfmt.c sue.c util.c: change fseek and */ 00330 /* ftell to FSEEK and FTELL (#defined to be fseek and ftell, */ 00331 /* respectively, in fio.h unless otherwise #defined), and use */ 00332 /* type OFF_T (#defined to be long unless otherwise #defined) */ 00333 /* to permit handling files over 2GB long where possible, */ 00334 /* with suitable -D options, provided for some systems in new */ 00335 /* header file sysdep1.h (copied from sysdep1.h0 by default). */ 00336 /* 15 Nov. 2001: endfile.c: add FSEEK after FTRUNCATE. */ 00337 /* 28 Nov. 2001: fmt.h lwrite.c wref.c and (new) signbit.c: on IEEE systems, */ 00338 /* print -0 as -0 when compiled with -DSIGNED_ZEROS. See */ 00339 /* comments in makefile or (better) libf2c/makefile.* . */ 00340 /* 6 Sept. 2002: rsne.c: fix bug with multiple repeat counts in reading */ 00341 /* namelists, e.g., &nl a(2) = 3*1.0, 2*2.0, 3*3.0 / */ 00342 /* 21 March 2003: err.c: before writing to a file after reading from it, */ 00343 /* f_seek(file, 0, SEEK_CUR) to make writing legal in ANSI C. */