From 7b704871fdac058719f34a1e6b9de71ee76c5be4 Mon Sep 17 00:00:00 2001 From: kan Date: Fri, 11 Jul 2003 03:42:19 +0000 Subject: Gcc 3.3.1-pre 2003-07-11 libf2c bits. --- contrib/libf2c/libI77/Makefile.in | 4 +- contrib/libf2c/libI77/Version.c | 18 +- contrib/libf2c/libI77/backspace.c | 139 ++-- contrib/libf2c/libI77/close.c | 159 ++-- contrib/libf2c/libI77/configure | 231 +++--- contrib/libf2c/libI77/configure.in | 44 +- contrib/libf2c/libI77/dfe.c | 243 ++++--- contrib/libf2c/libI77/dolio.c | 19 +- contrib/libf2c/libI77/due.c | 124 ++-- contrib/libf2c/libI77/endfile.c | 198 +++-- contrib/libf2c/libI77/err.c | 461 ++++++------ contrib/libf2c/libI77/f2ch.add | 315 ++++---- contrib/libf2c/libI77/fio.h | 99 ++- contrib/libf2c/libI77/fmt.c | 990 +++++++++++++------------ contrib/libf2c/libI77/fmt.h | 79 +- contrib/libf2c/libI77/fmtlib.c | 64 +- contrib/libf2c/libI77/fp.h | 2 +- contrib/libf2c/libI77/ftell_.c | 56 +- contrib/libf2c/libI77/iio.c | 249 +++---- contrib/libf2c/libI77/ilnw.c | 115 ++- contrib/libf2c/libI77/inquire.c | 218 +++--- contrib/libf2c/libI77/lio.h | 40 +- contrib/libf2c/libI77/lread.c | 1405 +++++++++++++++++++----------------- contrib/libf2c/libI77/lwrite.c | 469 ++++++------ contrib/libf2c/libI77/open.c | 494 ++++++------- contrib/libf2c/libI77/rdfmt.c | 1061 ++++++++++++++------------- contrib/libf2c/libI77/rewind.c | 42 +- contrib/libf2c/libI77/rsfe.c | 152 ++-- contrib/libf2c/libI77/rsli.c | 158 ++-- contrib/libf2c/libI77/rsne.c | 1073 ++++++++++++++------------- contrib/libf2c/libI77/sfe.c | 57 +- contrib/libf2c/libI77/sue.c | 145 ++-- contrib/libf2c/libI77/typesize.c | 17 +- contrib/libf2c/libI77/uio.c | 101 ++- contrib/libf2c/libI77/util.c | 70 +- contrib/libf2c/libI77/wref.c | 472 ++++++------ contrib/libf2c/libI77/wrtfmt.c | 675 +++++++++-------- contrib/libf2c/libI77/wsfe.c | 119 +-- contrib/libf2c/libI77/wsle.c | 53 +- contrib/libf2c/libI77/wsne.c | 36 +- contrib/libf2c/libI77/xwsne.c | 109 ++- 41 files changed, 5374 insertions(+), 5201 deletions(-) (limited to 'contrib/libf2c/libI77') diff --git a/contrib/libf2c/libI77/Makefile.in b/contrib/libf2c/libI77/Makefile.in index ff0d8e1..d6abf70 100644 --- a/contrib/libf2c/libI77/Makefile.in +++ b/contrib/libf2c/libI77/Makefile.in @@ -38,12 +38,12 @@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ @SET_MAKE@ -SHELL = /bin/sh +SHELL = @SHELL@ #### End of system configuration section. #### ALL_CFLAGS = -I. -I$(srcdir) -I$(G2C_H_DIR) -I$(F2C_H_DIR) $(CPPFLAGS) \ - $(DEFS) $(CFLAGS) + $(DEFS) $(WARN_CFLAGS) $(CFLAGS) .SUFFIXES: .SUFFIXES: .c .lo diff --git a/contrib/libf2c/libI77/Version.c b/contrib/libf2c/libI77/Version.c index 06177cf..f6b3d5d 100644 --- a/contrib/libf2c/libI77/Version.c +++ b/contrib/libf2c/libI77/Version.c @@ -1,9 +1,4 @@ -static char junk[] = "\n@(#) LIBI77 VERSION pjw,dmg-mods 20001205\n"; - -/* -*/ - -char __G77_LIBI77_VERSION__[] = "3.2.2 20030205 (release)"; +const char __LIBI77_VERSION__[] = "@(#) LIBI77 VERSION pjw,dmg-mods 20001205\n"; /* 2.01 $ format added @@ -324,17 +319,6 @@ wrtfmt.c: /* treat Tstuff= and Fstuff= as new assignments rather than as */ /* logical constants. */ - - /* Changes for GNU Fortran (g77) version of libf2c: */ /* 17 June 1997: detect recursive I/O and call f__fatal explaining it. */ - -#include - -void -g77__ivers__ () -{ - fprintf (stderr, "__G77_LIBI77_VERSION__: %s", __G77_LIBI77_VERSION__); - fputs (junk, stderr); -} diff --git a/contrib/libf2c/libI77/backspace.c b/contrib/libf2c/libI77/backspace.c index 8489239..c31e711 100644 --- a/contrib/libf2c/libI77/backspace.c +++ b/contrib/libf2c/libI77/backspace.c @@ -2,73 +2,80 @@ #include #include "f2c.h" #include "fio.h" -#ifdef KR_headers -integer f_back(a) alist *a; -#else -integer f_back(alist *a) -#endif -{ 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/contrib/libf2c/libI77/close.c b/contrib/libf2c/libI77/close.c index 79a3493..769c569 100644 --- a/contrib/libf2c/libI77/close.c +++ b/contrib/libf2c/libI77/close.c @@ -1,9 +1,7 @@ #include "config.h" #include "f2c.h" #include "fio.h" -#ifdef KR_headers -integer f_clos(a) cllist *a; -#else + #undef abs #undef min #undef max @@ -16,91 +14,88 @@ integer f_clos(a) cllist *a; #if defined (MSDOS) && !defined (GO32) #include "io.h" #else -#ifdef __cplusplus -extern "C" int unlink(const char*); -#else -extern int unlink(const char*); -#endif +extern int unlink (const char *); #endif #endif -integer f_clos(cllist *a) -#endif -{ 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 -#ifdef KR_headers -f_exit() -#else -f_exit(void) -#endif -{ 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;iufd); + if (b->ufnm) + { + unlink (b->ufnm); + /*SYSDEP*/ free (b->ufnm); } + } + b->ufd = NULL; +done: + b->uend = 0; + b->ufnm = NULL; + return (0); } - int -#ifdef KR_headers -G77_flush_0 () -#else + +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) -#endif -{ int i; - for(i=0;i> confdefs.h <<\EOF -#define _XOPEN_SOURCE 500L -EOF - -# The following is needed by irix6.2 so that struct timeval is declared. -cat >> confdefs.h <<\EOF -#define _XOPEN_SOURCE_EXTENDED 1 -EOF - -# The following is needed by Solaris2.5.1 so that struct timeval is declared. -cat >> confdefs.h <<\EOF -#define __EXTENSIONS__ 1 -EOF - -cat >> confdefs.h <<\EOF -#define _FILE_OFFSET_BITS 64 -EOF - -cat >> confdefs.h <<\EOF -#define _LARGEFILE_SOURCE 1 -EOF - - - # For g77 we'll set CC to point at the built gcc, but this will get it into @@ -556,7 +541,7 @@ EOF # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:560: checking for $ac_word" >&5 +echo "configure:545: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -586,7 +571,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:590: checking for $ac_word" >&5 +echo "configure:575: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -637,7 +622,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:641: checking for $ac_word" >&5 +echo "configure:626: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -670,7 +655,7 @@ fi echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:674: checking whether we are using GNU C" >&5 +echo "configure:659: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -679,7 +664,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:683: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:668: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -698,7 +683,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:702: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:687: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -730,13 +715,64 @@ else fi +# These defines are necessary to get 64-bit file size support. +# NetBSD 1.4 header files does not support XOPEN_SOURCE == 600, but it +# handles 64-bit file sizes without needing these defines. +echo $ac_n "checking whether _XOPEN_SOURCE may be defined""... $ac_c" 1>&6 +echo "configure:723: checking whether _XOPEN_SOURCE may be defined" >&5 +cat > conftest.$ac_ext < +int main() { + +; return 0; } +EOF +if { (eval echo configure:733: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + may_use_xopen_source=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + may_use_xopen_source=no +fi +rm -f conftest* +echo "$ac_t""$may_use_xopen_source" 1>&6 +if test $may_use_xopen_source = yes; then + cat >> confdefs.h <<\EOF +#define _XOPEN_SOURCE 600L +EOF + + # The following is needed by irix6.2 so that struct timeval is declared. + cat >> confdefs.h <<\EOF +#define _XOPEN_SOURCE_EXTENDED 1 +EOF + + # The following is needed by Solaris2.5.1 so that struct timeval is declared. + cat >> confdefs.h <<\EOF +#define __EXTENSIONS__ 1 +EOF + + cat >> confdefs.h <<\EOF +#define _FILE_OFFSET_BITS 64 +EOF + + cat >> confdefs.h <<\EOF +#define _LARGEFILE_SOURCE 1 +EOF + +fi + + LIBTOOL='$(SHELL) ../libtool' test "$AR" || AR=ar echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:740: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:776: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -766,7 +802,7 @@ fi # Sanity check for the cross-compilation case: echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:770: checking how to run the C preprocessor" >&5 +echo "configure:806: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -781,13 +817,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:791: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:827: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -798,13 +834,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:808: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:844: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -815,13 +851,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:825: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:861: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -847,17 +883,17 @@ echo "$ac_t""$CPP" 1>&6 ac_safe=`echo "stdio.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for stdio.h""... $ac_c" 1>&6 -echo "configure:851: checking for stdio.h" >&5 +echo "configure:887: checking for stdio.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:861: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:897: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -885,12 +921,12 @@ fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:889: checking for ANSI C header files" >&5 +echo "configure:925: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -898,7 +934,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:902: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:938: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -915,7 +951,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -933,7 +969,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -954,7 +990,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -965,7 +1001,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:969: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1005: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -988,14 +1024,13 @@ EOF fi - echo $ac_n "checking for posix""... $ac_c" 1>&6 -echo "configure:994: checking for posix" >&5 +echo "configure:1029: checking for posix" >&5 if eval "test \"`echo '$''{'g77_cv_header_posix'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1021,12 +1056,12 @@ echo "$ac_t""$g77_cv_header_posix" 1>&6 # We can rely on the GNU library being posix-ish. I guess checking the # header isn't actually like checking the functions, though... echo $ac_n "checking for GNU library""... $ac_c" 1>&6 -echo "configure:1025: checking for GNU library" >&5 +echo "configure:1060: checking for GNU library" >&5 if eval "test \"`echo '$''{'g77_cv_lib_gnu'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #ifdef __GNU_LIBRARY__ @@ -1050,12 +1085,12 @@ echo "$ac_t""$g77_cv_lib_gnu" 1>&6 # Apparently cygwin needs to be special-cased. echo $ac_n "checking for cyg\`win'32""... $ac_c" 1>&6 -echo "configure:1054: checking for cyg\`win'32" >&5 +echo "configure:1089: checking for cyg\`win'32" >&5 if eval "test \"`echo '$''{'g77_cv_sys_cygwin32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 # ditto for mingw32. echo $ac_n "checking for mingw32""... $ac_c" 1>&6 -echo "configure:1082: checking for mingw32" >&5 +echo "configure:1117: checking for mingw32" >&5 if eval "test \"`echo '$''{'g77_cv_sys_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1110: checking for working const" >&5 +echo "configure:1145: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1199: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1181,12 +1216,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:1185: checking for size_t" >&5 +echo "configure:1220: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1219,12 +1254,12 @@ fi # Apparently positive result on cygwin loses re. NON_UNIX_STDIO # (as of cygwin b18). Likewise on mingw. echo $ac_n "checking for fstat""... $ac_c" 1>&6 -echo "configure:1223: checking for fstat" >&5 +echo "configure:1258: checking for fstat" >&5 if eval "test \"`echo '$''{'ac_cv_func_fstat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1286: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_fstat=yes" else @@ -1267,7 +1302,7 @@ else fi echo $ac_n "checking need for NON_UNIX_STDIO""... $ac_c" 1>&6 -echo "configure:1271: checking need for NON_UNIX_STDIO" >&5 +echo "configure:1306: checking need for NON_UNIX_STDIO" >&5 if test $g77_cv_sys_cygwin32 = yes \ || test $g77_cv_sys_mingw32 = yes \ || test $ac_cv_func_fstat = no; then @@ -1283,12 +1318,12 @@ fi for ac_func in fseeko do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1287: checking for $ac_func" >&5 +echo "configure:1322: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1350: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1338,12 +1373,12 @@ done for ac_func in ftello do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1342: checking for $ac_func" >&5 +echo "configure:1377: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1393,12 +1428,12 @@ done for ac_func in ftruncate do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1397: checking for $ac_func" >&5 +echo "configure:1432: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1460: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1448,12 +1483,12 @@ done for ac_func in mkstemp do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1452: checking for $ac_func" >&5 +echo "configure:1487: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1503,12 +1538,12 @@ done for ac_func in tempnam do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1507: checking for $ac_func" >&5 +echo "configure:1542: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1570: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1558,12 +1593,12 @@ done for ac_func in tmpnam do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1562: checking for $ac_func" >&5 +echo "configure:1597: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1616,19 +1651,19 @@ done # However, on my sunos4/gcc setup unistd.h leads us wrongly to believe # we're posix-conformant, so always do the test. echo $ac_n "checking for ansi/posix sprintf result""... $ac_c" 1>&6 -echo "configure:1620: checking for ansi/posix sprintf result" >&5 +echo "configure:1655: checking for ansi/posix sprintf result" >&5 if test "$cross_compiling" = yes; then g77_cv_sys_sprintf_ansi=no else cat > conftest.$ac_ext < /* does sprintf return the number of chars transferred? */ main () {char foo[2]; (sprintf(foo, "1") == 1) ? exit(0) : exit(1);} EOF -if { (eval echo configure:1632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1667: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then g77_cv_sys_sprintf_ansi=yes else @@ -1659,9 +1694,9 @@ fi # define NON_ANSI_RW_MODES on unix (can't hurt) echo $ac_n "checking NON_ANSI_RW_MODES""... $ac_c" 1>&6 -echo "configure:1663: checking NON_ANSI_RW_MODES" >&5 +echo "configure:1698: checking NON_ANSI_RW_MODES" >&5 cat > conftest.$ac_ext <&6 -echo "configure:1710: checking for off_t" >&5 +echo "configure:1745: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS diff --git a/contrib/libf2c/libI77/configure.in b/contrib/libf2c/libI77/configure.in index 988a8e5..83f98fb 100644 --- a/contrib/libf2c/libI77/configure.in +++ b/contrib/libf2c/libI77/configure.in @@ -23,18 +23,6 @@ AC_PREREQ(2.12.1) AC_INIT(ftell_.c) AC_CONFIG_HEADER(config.h) -# These defines are necessary to get 64-bit file size support. - -AC_DEFINE(_XOPEN_SOURCE, 500L, [Get Single Unix Specification semantics]) -# The following is needed by irix6.2 so that struct timeval is declared. -AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Get Single Unix Specification semantics]) -# The following is needed by Solaris2.5.1 so that struct timeval is declared. -AC_DEFINE(__EXTENSIONS__, 1, [Solaris extensions]) -AC_DEFINE(_FILE_OFFSET_BITS, 64, [Get 64-bit file size support]) -AC_DEFINE(_LARGEFILE_SOURCE, 1, [Define for HP-UX ftello and fseeko extension.]) - -dnl Checks for programs. - dnl FIXME AC_PROG_CC wants CC to be able to link things, but it may dnl not be able to. define([AC_PROG_CC_WORKS],[]) @@ -43,6 +31,27 @@ define([AC_PROG_CC_WORKS],[]) # the makefiles AC_PROG_CC +# These defines are necessary to get 64-bit file size support. +# NetBSD 1.4 header files does not support XOPEN_SOURCE == 600, but it +# handles 64-bit file sizes without needing these defines. +AC_MSG_CHECKING(whether _XOPEN_SOURCE may be defined) +AC_TRY_COMPILE([#define _XOPEN_SOURCE 600L +#include ],, +may_use_xopen_source=yes, +may_use_xopen_source=no) +AC_MSG_RESULT($may_use_xopen_source) +if test $may_use_xopen_source = yes; then + AC_DEFINE(_XOPEN_SOURCE, 600L, [Get Single Unix Specification semantics]) + # The following is needed by irix6.2 so that struct timeval is declared. + AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Get Single Unix Specification semantics]) + # The following is needed by Solaris2.5.1 so that struct timeval is declared. + AC_DEFINE(__EXTENSIONS__, 1, [Solaris extensions]) + AC_DEFINE(_FILE_OFFSET_BITS, 64, [Get 64-bit file size support]) + AC_DEFINE(_LARGEFILE_SOURCE, 1, [Define for HP-UX ftello and fseeko extension.]) +fi + +dnl Checks for programs. + LIBTOOL='$(SHELL) ../libtool' AC_SUBST(LIBTOOL) @@ -62,17 +71,6 @@ the G77 runtime system. If necessary, install gcc now with \`LANGUAGES=c', then the target library, then build with \`LANGUAGES=f77'.])]) AC_HEADER_STDC -dnl We could do this if we didn't know we were using gcc -dnl AC_MSG_CHECKING(for prototype-savvy compiler) -dnl AC_CACHE_VAL(g77_cv_sys_proto, -dnl [AC_TRY_LINK(, -dnl dnl looks screwy because TRY_LINK expects a function body -dnl [return 0;} int foo (int * bar) {], -dnl g77_cv_sys_proto=yes, -dnl [g77_cv_sys_proto=no -dnl AC_DEFINE(KR_headers)])]) -dnl AC_MSG_RESULT($g77_cv_sys_proto) - AC_MSG_CHECKING(for posix) AC_CACHE_VAL(g77_cv_header_posix, AC_EGREP_CPP(yes, diff --git a/contrib/libf2c/libI77/dfe.c b/contrib/libf2c/libI77/dfe.c index 18edabc..5ce0b4c 100644 --- a/contrib/libf2c/libI77/dfe.c +++ b/contrib/libf2c/libI77/dfe.c @@ -3,145 +3,154 @@ #include "fio.h" #include "fmt.h" -y_rsk(Void) +int +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) + +int +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); } -#ifdef KR_headers -c_dfe(a) cilist *a; -#else -c_dfe(cilist *a) -#endif +int +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); } -#ifdef KR_headers -integer s_rdfe(a) cilist *a; -#else -integer s_rdfe(cilist *a) -#endif + +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); } -#ifdef KR_headers -integer s_wdfe(a) cilist *a; -#else -integer s_wdfe(cilist *a) -#endif + +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/contrib/libf2c/libI77/dolio.c b/contrib/libf2c/libI77/dolio.c index 1e0c377..e50e900 100644 --- a/contrib/libf2c/libI77/dolio.c +++ b/contrib/libf2c/libI77/dolio.c @@ -1,21 +1,10 @@ #include "config.h" #include "f2c.h" -#ifdef __cplusplus -extern "C" { -#endif -#ifdef KR_headers -extern int (*f__lioproc)(); +extern int (*f__lioproc) (ftnint *, char *, ftnlen, ftnint); -integer do_lio(type,number,ptr,len) ftnint *number,*type; char *ptr; ftnlen len; -#else -extern int (*f__lioproc)(ftnint*, char*, ftnlen, ftnint); - -integer do_lio(ftnint *type, ftnint *number, char *ptr, ftnlen len) -#endif +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)); } -#ifdef __cplusplus - } -#endif diff --git a/contrib/libf2c/libI77/due.c b/contrib/libf2c/libI77/due.c index f7d6941..7c6a801 100644 --- a/contrib/libf2c/libI77/due.c +++ b/contrib/libf2c/libI77/due.c @@ -2,75 +2,79 @@ #include "f2c.h" #include "fio.h" -#ifdef KR_headers -c_due(a) cilist *a; -#else -c_due(cilist *a) -#endif +int +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); } -#ifdef KR_headers -integer s_rdue(a) cilist *a; -#else -integer s_rdue(cilist *a) -#endif + +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); } -#ifdef KR_headers -integer s_wdue(a) cilist *a; -#else -integer s_wdue(cilist *a) -#endif + +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/contrib/libf2c/libI77/endfile.c b/contrib/libf2c/libI77/endfile.c index 4c5a9dd..513f210 100644 --- a/contrib/libf2c/libI77/endfile.c +++ b/contrib/libf2c/libI77/endfile.c @@ -5,136 +5,126 @@ #include #include -#ifdef KR_headers -extern char *strcpy(); -extern FILE *tmpfile(); -#else #undef abs #undef min #undef max #include #include -#endif extern char *f__r_mode[], *f__w_mode[]; -#ifdef KR_headers -integer f_end(a) alist *a; -#else -integer f_end(alist *a) -#endif +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 -#ifdef KR_headers -copy(from, len, to) FILE *from, *to; register long len; -#else -copy(FILE *from, register long len, FILE *to) -#endif +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 -#ifdef KR_headers -t_runc(a) alist *a; -#else -t_runc(alist *a) -#endif +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/contrib/libf2c/libI77/err.c b/contrib/libf2c/libI77/err.c index 1c21f19..1a204e8 100644 --- a/contrib/libf2c/libI77/err.c +++ b/contrib/libf2c/libI77/err.c @@ -6,285 +6,274 @@ #include #endif #include "f2c.h" -#ifdef KR_headers -extern char *malloc(); -#else #undef abs #undef min #undef max #include -#endif #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 */ -#ifdef KR_headers -int (*f__doed)(),(*f__doned)(); -int (*f__doend)(),(*f__donewrec)(),(*f__dorevert)(); -int (*f__getn)(); /* for formatted input */ -void (*f__putn)(); /* for formatted output */ -#else -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); -#endif -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) -#ifdef KR_headers -f__canseek(f) FILE *f; /*SYSDEP*/ -#else -f__canseek(FILE *f) /*SYSDEP*/ -#endif +int +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 -#ifdef KR_headers -f__fatal(n,s) char *s; -#else -f__fatal(int n, char *s) -#endif +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); + 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); } - 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); - } - 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; +void +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; } -#ifdef KR_headers -f__nowreading(x) unit *x; -#else -f__nowreading(unit *x) -#endif + +int +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; } -#ifdef KR_headers -f__nowwriting(x) unit *x; -#else -f__nowwriting(unit *x) -#endif + +int +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 -#ifdef KR_headers -err__fl(f, m, s) int f, m; char *s; -#else -err__fl(int f, int m, char *s) -#endif +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/contrib/libf2c/libI77/f2ch.add b/contrib/libf2c/libI77/f2ch.add index a2acc17..04b13e8 100644 --- a/contrib/libf2c/libI77/f2ch.add +++ b/contrib/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/contrib/libf2c/libI77/fio.h b/contrib/libf2c/libI77/fio.h index 8c6d274..7734f0c 100644 --- a/contrib/libf2c/libI77/fio.h +++ b/contrib/libf2c/libI77/fio.h @@ -39,65 +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; -#undef Void -#ifdef KR_headers -#define Void /*void*/ -extern int (*f__getn)(); /* for formatted input */ -extern void (*f__putn)(); /* for formatted output */ -extern void x_putc(); -extern long f__inode(); -extern VOID sig_die(); -extern int (*f__donewrec)(), t_putc(), x_wSL(); -extern int c_sfe(), err__fl(), xrd_SL(), f__putbuf(); -#else -#define Void void -#ifdef __cplusplus -extern "C" { -#endif -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); -#ifdef __cplusplus - } -#endif -#endif -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) @@ -105,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/contrib/libf2c/libI77/fmt.c b/contrib/libf2c/libI77/fmt.c index 793dceb..fa9b73c 100644 --- a/contrib/libf2c/libI77/fmt.c +++ b/contrib/libf2c/libI77/fmt.c @@ -17,528 +17,586 @@ #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 -#ifdef KR_headers -char *ap_end(s) char *s; -#else -char *ap_end(char *s) -#endif -{ 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 -#ifdef KR_headers -op_gen(a,b,c,d) -#else -op_gen(int a, int b, int c, int d) -#endif -{ 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 int +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++); } -#ifdef KR_headers -static char *f_list(); -static char *gt_num(s,n,n1) char *s; int *n, n1; -#else -static char *f_list(char*); -static char *gt_num(char *s, int *n, int n1) -#endif -{ 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 -#ifdef KR_headers -char *f_s(s,curloc) char *s; -#else -char *f_s(char *s, int curloc) -#endif +static char * +f_s (char *s, int curloc) { - skip(s); - if(*s++!='(') + 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 int +ne_d (char *s, char **p) +{ + 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 -#ifdef KR_headers -ne_d(s,p) char *s,**p; -#else -ne_d(char *s, char **p) -#endif -{ 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 -#ifdef KR_headers -e_d(s,p) char *s,**p; -#else -e_d(char *s, char **p) -#endif -{ 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 int +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))) { - 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; + bad: + *p = 0; + return 1; } - if(found==0) - { f__pc--; /*unSTACK*/ - *p=sv; - return(0); + if (w == 0) + break; + if (*s == '.') + { + if (!(s = gt_num (s + 1, &d, 0))) + goto bad; } - *p=s; - return(1); + 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 (found == 0) + { + f__pc--; /*unSTACK */ + *p = sv; + return (0); + } + *p = s; + return (1); } - static -#ifdef KR_headers -char *i_tem(s) char *s; -#else -char *i_tem(char *s) -#endif -{ 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 -#ifdef KR_headers -char *f_list(s) char *s; -#else -char *f_list(char *s) -#endif +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); } -#ifdef KR_headers -pars_f(s) char *s; -#else -pars_f(char *s) -#endif +int +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 -#ifdef KR_headers -type_f(n) -#else -type_f(int n) -#endif +static int +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); + } } -#ifdef KR_headers -integer do_fio(number,ptr,len) ftnint *number; ftnlen len; char *ptr; -#else -integer do_fio(ftnint *number, char *ptr, ftnlen len) -#endif -{ 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)); + +int +en_fio (void) +{ + ftnint one = 1; + return (do_fio (&one, (char *) NULL, (ftnint) 0)); } - VOID -fmt_bg(Void) + +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/contrib/libf2c/libI77/fmt.h b/contrib/libf2c/libI77/fmt.h index 6197e76..bcd84cee 100644 --- a/contrib/libf2c/libI77/fmt.h +++ b/contrib/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,45 +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; -#ifndef KR_headers - signed -#endif - char ic; - integer il; +{ + short is; + signed char ic; + integer il; #ifdef Allow_TYQUAD - longint ili; -#endif -} Uint; -#ifdef KR_headers -extern int (*f__doed)(),(*f__doned)(); -extern int (*f__dorevert)(); -extern int rd_ed(),rd_ned(); -extern int w_ed(),w_ned(); -#else -#ifdef __cplusplus -extern "C" { -#endif -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); -#ifdef __cplusplus - } + longint ili; #endif -#endif -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; @@ -94,8 +89,4 @@ extern int f__cursor; #define TYQUAD 14 #endif -#ifdef KR_headers -extern char *f__icvt(); -#else -extern char *f__icvt(longint, int*, int*, int); -#endif +extern char *f__icvt (longint, int *, int *, int); diff --git a/contrib/libf2c/libI77/fmtlib.c b/contrib/libf2c/libI77/fmtlib.c index 69c0d9b..3d2a299 100644 --- a/contrib/libf2c/libI77/fmtlib.c +++ b/contrib/libf2c/libI77/fmtlib.c @@ -10,37 +10,37 @@ #define ulongint unsigned long #endif -#ifdef KR_headers -char *f__icvt(value,ndigit,sign, base) longint value; int *ndigit,*sign; - register int base; -#else -char *f__icvt(longint value, int *ndigit, int *sign, int base) -#endif +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/contrib/libf2c/libI77/fp.h b/contrib/libf2c/libI77/fp.h index 40743d7..2b78ef9 100644 --- a/contrib/libf2c/libI77/fp.h +++ b/contrib/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/contrib/libf2c/libI77/ftell_.c b/contrib/libf2c/libI77/ftell_.c index 250a0cc..6315342 100644 --- a/contrib/libf2c/libI77/ftell_.c +++ b/contrib/libf2c/libI77/ftell_.c @@ -2,46 +2,34 @@ #include "f2c.h" #include "fio.h" - static FILE * -#ifdef KR_headers -unit_chk(Unit, who) integer Unit; char *who; -#else -unit_chk(integer Unit, char *who) -#endif +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 -#ifdef KR_headers -G77_ftell_0 (Unit) integer *Unit; -#else -G77_ftell_0 (integer *Unit) -#endif +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 -#ifdef KR_headers -G77_fseek_0 (Unit, offset, xwhence) integer *Unit, *offset, *xwhence; -#else -G77_fseek_0 (integer *Unit, integer *offset, integer *xwhence) -#endif +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/contrib/libf2c/libI77/iio.c b/contrib/libf2c/libI77/iio.c index 931f15a..940cbf8 100644 --- a/contrib/libf2c/libI77/iio.c +++ b/contrib/libf2c/libI77/iio.c @@ -6,149 +6,152 @@ char *f__icend; extern icilist *f__svic; int f__icnum; extern int f__hiwater; -z_getc(Void) +int +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 -#ifdef KR_headers -z_putc(c) -#else -z_putc(int c) -#endif +void +z_putc (int c) { - if (f__icptr < f__icend && f__recpos++ < f__svic->icirlen) - *f__icptr++ = c; + if (f__recpos++ < f__svic->icirlen && f__icptr < f__icend) + *f__icptr++ = c; } -z_rnew(Void) +int +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; +} -#ifdef KR_headers -c_si(a) icilist *a; -#else -c_si(icilist *a) -#endif +int +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); +} -#ifdef KR_headers -integer s_rsfi(a) icilist *a; -#else -integer s_rsfi(icilist *a) -#endif -{ 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) +int +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; } -#ifdef KR_headers -integer s_wsfi(a) icilist *a; -#else -integer s_wsfi(icilist *a) -#endif -{ 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/contrib/libf2c/libI77/ilnw.c b/contrib/libf2c/libI77/ilnw.c index 58fca0d..0a92a0c 100644 --- a/contrib/libf2c/libI77/ilnw.c +++ b/contrib/libf2c/libI77/ilnw.c @@ -6,78 +6,65 @@ extern char *f__icptr; extern char *f__icend; extern icilist *f__svic; extern int f__icnum; -#ifdef KR_headers -extern void z_putc(); -#else -extern void z_putc(int); -#endif +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 -#ifdef KR_headers -c_liw(a) icilist *a; -#else -c_liw(icilist *a) -#endif +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 -#ifdef KR_headers -s_wsni(a) icilist *a; -#else -s_wsni(icilist *a) -#endif +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 -#ifdef KR_headers -s_wsli(a) icilist *a; -#else -s_wsli(icilist *a) -#endif +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/contrib/libf2c/libI77/inquire.c b/contrib/libf2c/libI77/inquire.c index 5c5575a..dae869c 100644 --- a/contrib/libf2c/libI77/inquire.c +++ b/contrib/libf2c/libI77/inquire.c @@ -2,108 +2,142 @@ #include "f2c.h" #include "fio.h" #include -#ifdef KR_headers -integer f_inqu(a) inlist *a; -#else #if defined (MSDOS) && !defined (GO32) #undef abs #undef min #undef max #include "io.h" #endif -integer f_inqu(inlist *a) -#endif -{ 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;iinunit < MXUNIT && a->inunit >= 0) + { + p = &f__units[a->inunit]; } - else + else { - byfile=0; - if(a->inunitinunit>=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/contrib/libf2c/libI77/lio.h b/contrib/libf2c/libI77/lio.h index 0123172..4e17115 100644 --- a/contrib/libf2c/libI77/lio.h +++ b/contrib/libf2c/libI77/lio.h @@ -43,32 +43,22 @@ typedef union { - 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; -#ifdef KR_headers -extern int (*f__lioproc)(), (*l_getc)(), (*l_ungetc)(); -extern int l_read(), l_write(); -#else -#ifdef __cplusplus -extern "C" { -#endif -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); -#ifdef __cplusplus - } -#endif -#endif +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/contrib/libf2c/libI77/lread.c b/contrib/libf2c/libI77/lread.c index d546efc..b926367 100644 --- a/contrib/libf2c/libI77/lread.c +++ b/contrib/libf2c/libI77/lread.c @@ -13,28 +13,19 @@ extern int f__fmtlen; #ifdef Allow_TYQUAD static longint f__llx; -static int quad_read; #endif -#ifdef KR_headers -extern double atof(); -extern char *malloc(), *realloc(); -int (*f__lioproc)(), (*l_getc)(), (*l_ungetc)(); -#else #undef abs #undef min #undef max #include -#endif #include "fmt.h" #include "lio.h" #include "fp.h" -#ifndef KR_headers -int (*f__lioproc)(ftnint*, char*, ftnlen, ftnint), (*l_getc)(void), - (*l_ungetc)(int,FILE*); -#endif +int (*f__lioproc) (ftnint *, char *, ftnlen, ftnint), (*l_getc) (void), + (*l_ungetc) (int, FILE *); int l_eof; @@ -50,749 +41,805 @@ 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 -#ifdef KR_headers -un_getc(x,f__cf) int x; FILE *f__cf; -#else -un_getc(int x, FILE *f__cf) -#endif -{ return ungetc(x,f__cf); } +static int +un_getc (int x, FILE * f__cf) +{ + return ungetc (x, f__cf); +} #else #define un_getc ungetc -#ifdef KR_headers - extern int ungetc(); -#else -extern int ungetc(int, FILE*); /* for systems with a buggy stdio.h */ -#endif +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); +int +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; -#define ERR(x) if(n=(x)) {f__init &= ~2; return(n);} +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 -#ifdef KR_headers -l_R(poststar, reqint) int poststar, reqint; -#else -l_R(int poststar, int reqint) -#endif +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); -#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; + GETC (ch); + if (issign (ch)) + { + signonly: + if (ch == '-') + se = 1; + GETC (ch); + } + if (!isdigit (ch)) + { + bad: + errfl (f__elist->cierr, 112, "exponent field"); } - static int -#ifdef KR_headers -rd_count(ch) register int ch; -#else -rd_count(register int ch) + 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; +} + +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; } - 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"); + 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"); } - 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; + if (GETC (ch) != '(') + { + Ungetc (ch, f__cf); + return (0); + } + } + 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); -#ifdef KR_headers - static int (*nmL_ungetc_save)(/* int, FILE* */); -#else - static int (*nmL_ungetc_save)(int, FILE*); -#endif +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 -#ifdef KR_headers -nmL_ungetc(x, f) int x; FILE *f; -#else -nmL_ungetc(int x, FILE *f) -#endif +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 -#ifdef KR_headers -Lfinish(ch, dot, rvp) int ch, dot, *rvp; -#else -Lfinish(int ch, int dot, int *rvp) -#endif +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 && ++icierr,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(++icierr, 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; + } } -} -#ifdef KR_headers -c_le(a) cilist *a; -#else -c_le(cilist *a) + } + 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); + } + } +} + +int +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); } -#ifdef KR_headers -l_read(number,ptr,len,type) ftnint *number,type; char *ptr; ftnlen len; -#else -l_read(ftnint *number, char *ptr, ftnlen len, ftnint type) -#endif + +int +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 } -#ifdef KR_headers -integer s_rsle(a) cilist *a; -#else -integer s_rsle(cilist *a) -#endif + +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/contrib/libf2c/libI77/lwrite.c b/contrib/libf2c/libI77/lwrite.c index bf209f4..b910ab1 100644 --- a/contrib/libf2c/libI77/lwrite.c +++ b/contrib/libf2c/libI77/lwrite.c @@ -6,297 +6,272 @@ ftnint L_len; int f__Aquote; - static VOID -donewrec(Void) +static void +donewrec (void) { - if (f__recpos) - (*f__donewrec)(); - } + if (f__recpos) + (*f__donewrec) (); +} - static VOID -#ifdef KR_headers -lwrt_I(n) longint n; -#else -lwrt_I(longint n) -#endif +static void +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 -#ifdef KR_headers -lwrt_L(n, len) ftnint n; ftnlen len; -#else -lwrt_L(ftnint n, ftnlen len) -#endif +static void +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 -#ifdef KR_headers -lwrt_A(p,len) char *p; ftnlen len; -#else -lwrt_A(char *p, ftnlen len) -#endif +static void +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 -#ifdef KR_headers -l_g(buf, n) char *buf; double n; -#else -l_g(char *buf, double n) -#endif +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 -#ifdef KR_headers -l_put(s) register char *s; -#else -l_put(register char *s) -#endif +static void +l_put (register char *s) { -#ifdef KR_headers - register void (*pn)() = f__putn; -#else - register void (*pn)(int) = f__putn; -#endif - register int c; + register void (*pn) (int) = f__putn; + register int c; - while(c = *s++) - (*pn)(c); - } + while ((c = *s++)) + (*pn) (c); +} - static VOID -#ifdef KR_headers -lwrt_F(n) double n; -#else -lwrt_F(double n) -#endif +static void +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 -#ifdef KR_headers -lwrt_C(a,b) double a,b; -#else -lwrt_C(double a, double b) -#endif +static void +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 (')'); } -#ifdef KR_headers -l_write(number,ptr,len,type) ftnint *number,type; char *ptr; ftnlen len; -#else -l_write(ftnint *number, char *ptr, ftnlen len, ftnint type) -#endif + +int +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/contrib/libf2c/libI77/open.c b/contrib/libf2c/libI77/open.c index 9457ccc..ac1e00e 100644 --- a/contrib/libf2c/libI77/open.c +++ b/contrib/libf2c/libI77/open.c @@ -1,6 +1,3 @@ -/* Define _XOPEN_SOURCE to get tempnam prototype with glibc et al -- - more general than _INCLUDE_XOPEN_SOURCE used elsewhere `for HP-UX'. */ -#define _XOPEN_SOURCE 1 #include "config.h" #include "f2c.h" #include "fio.h" @@ -9,307 +6,296 @@ #ifdef MSDOS #include "io.h" #else -#include "unistd.h" /* for access */ +#include "unistd.h" /* for access */ #endif #endif -#ifdef KR_headers -extern char *malloc(); -#ifdef NON_ANSI_STDIO -extern char *mktemp(); -#endif -extern integer f_clos(); -#else #undef abs #undef min #undef max #include -extern int f__canseek(FILE*); -extern integer f_clos(cllist*); -#endif +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 -#ifdef KR_headers -f__bufadj(n, c) int n, c; -#else -f__bufadj(int n, int c) -#endif +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 -#ifdef KR_headers -f__putbuf(c) int c; -#else -f__putbuf(int c) -#endif +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 -#ifdef KR_headers -x_putc(c) -#else -x_putc(int c) -#endif +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 -#ifdef KR_headers -opn_err(m, s, a) int m; char *s; olist *a; -#else -opn_err(int m, char *s, olist *a) -#endif +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); +} -#ifdef KR_headers -integer f_open(a) olist *a; -#else -integer f_open(olist *a) -#endif -{ 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 ((a->oacc) && (*a->oacc == 'D' || *a->oacc == 'd')) + 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 - (int) 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); } -#ifdef KR_headers -fk_open(seq,fmt,n) ftnint n; -#else -fk_open(int seq, int fmt, ftnint n) -#endif -{ 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; +int +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/contrib/libf2c/libI77/rdfmt.c b/contrib/libf2c/libI77/rdfmt.c index 81426ae..8a8818a 100644 --- a/contrib/libf2c/libI77/rdfmt.c +++ b/contrib/libf2c/libI77/rdfmt.c @@ -4,543 +4,612 @@ #include "fio.h" extern int f__cursor; -#ifdef KR_headers -extern double atof(); -#else #undef abs #undef min #undef max #include -#endif #include "fmt.h" #include "fp.h" - static int -#ifdef KR_headers -rd_Z(n,w,len) Uint *n; ftnlen len; -#else -rd_Z(Uint *n, int w, ftnlen len) -#endif +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 * (ftnlen) 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 -#ifdef KR_headers -rd_I(n,w,len, base) Uint *n; int w; ftnlen len; register int base; -#else -rd_I(Uint *n, int w, ftnlen len, register int base) -#endif +static int +rd_I (Uint * n, int w, ftnlen len, register int base) { - int bad, ch, sign; - longint x = 0; + int 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 -#ifdef KR_headers -rd_L(n,w,len) ftnint *n; ftnlen len; -#else -rd_L(ftnint *n, int w, ftnlen len) -#endif -{ 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 -#ifdef KR_headers -rd_F(p, w, d, len) ufloat *p; ftnlen len; -#else -rd_F(ufloat *p, int w, int d, ftnlen len) -#endif +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 -#ifdef KR_headers -rd_A(p,len) char *p; ftnlen len; -#else -rd_A(char *p, ftnlen len) -#endif -{ int i,ch; - for(i=0;i=len) - { for(i=0;i= len) + { + for (i = 0; i < w - len; i++) + GET (ch); + for (i = 0; i < len; i++) + { + GET (ch); + *p++ = VAL (ch); } - for(i=0;i0;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) + +int +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); } -#ifdef KR_headers -rd_ned(p) struct syl *p; -#else -rd_ned(struct syl *p) -#endif + +int +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/contrib/libf2c/libI77/rewind.c b/contrib/libf2c/libI77/rewind.c index 0691519..d7a9b76 100644 --- a/contrib/libf2c/libI77/rewind.c +++ b/contrib/libf2c/libI77/rewind.c @@ -1,27 +1,25 @@ #include "config.h" #include "f2c.h" #include "fio.h" -#ifdef KR_headers -integer f_rew(a) alist *a; -#else -integer f_rew(alist *a) -#endif +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/contrib/libf2c/libI77/rsfe.c b/contrib/libf2c/libI77/rsfe.c index 1be4531..0dcda39 100644 --- a/contrib/libf2c/libI77/rsfe.c +++ b/contrib/libf2c/libI77/rsfe.c @@ -4,78 +4,94 @@ #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); +int +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) + +int +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) + +int +x_endp (void) { - (void) xrd_SL(); - return(0); + xrd_SL (); + return f__curunit->uend == 1 ? EOF : 0; } -#ifdef KR_headers -integer s_rsfe(a) cilist *a; /* start */ -#else -integer s_rsfe(cilist *a) /* start */ -#endif -{ 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); + +int +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/contrib/libf2c/libI77/rsli.c b/contrib/libf2c/libI77/rsli.c index baf2ba5..c07632a 100644 --- a/contrib/libf2c/libI77/rsli.c +++ b/contrib/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,96 +10,90 @@ 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 -#ifdef KR_headers -int i_ungetc(ch, f) int ch; FILE *f; -#else -int i_ungetc(int ch, FILE *f) -#endif +static int +i_ungetc (int ch __attribute__ ((__unused__)), + FILE * f __attribute__ ((__unused__))) { - 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 -#ifdef KR_headers -c_lir(a) icilist *a; -#else -c_lir(icilist *a) -#endif +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; +} -#ifdef KR_headers -integer s_rsli(a) icilist *a; -#else -integer s_rsli(icilist *a) -#endif +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; +} -#ifdef KR_headers -integer s_rsni(a) icilist *a; -#else -extern int x_rsne(cilist*); +extern int x_rsne (cilist *); -integer s_rsni(icilist *a) -#endif +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/contrib/libf2c/libI77/rsne.c b/contrib/libf2c/libI77/rsne.c index a0d0bfe..f233a4a 100644 --- a/contrib/libf2c/libI77/rsne.c +++ b/contrib/libf2c/libI77/rsne.c @@ -3,55 +3,45 @@ #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 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 dimen +{ + ftnlen extent; + ftnlen curval; + ftnlen delta; + ftnlen stride; +}; +typedef struct dimen dimen; - static hashtab *nl_cache; - static int n_nlcache; - static hashentry **zot; - static int colonseen; - extern ftnlen f__typesize[]; +struct hashentry +{ + struct hashentry *next; + char *name; + Vardesc *vd; +}; +typedef struct hashentry hashentry; - extern flag f__lquit; - extern int f__lcount, nml_read; - extern t_getc(Void); +struct hashtab +{ + struct hashtab *next; + Namelist *nl; + int htsize; + hashentry *tab[1]; +}; +typedef struct hashtab hashtab; -#ifdef KR_headers - extern char *malloc(), *memset(); +static hashtab *nl_cache; +static int n_nlcache; +static hashentry **zot; +static int colonseen; +extern ftnlen f__typesize[]; -#ifdef ungetc - static int -un_getc(x,f__cf) int x; FILE *f__cf; -{ return ungetc(x,f__cf); } -#else -#define un_getc ungetc - extern int ungetc(); -#endif +extern flag f__lquit; +extern int f__lcount, nml_read; +extern int t_getc (void); -#else #undef abs #undef min #undef max @@ -59,550 +49,551 @@ un_getc(x,f__cf) int x; FILE *f__cf; #include #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 */ -#endif +extern int ungetc (int, FILE *); /* for systems with a buggy stdio.h */ #endif - static Vardesc * -#ifdef KR_headers -hash(ht, s) hashtab *ht; register char *s; -#else -hash(hashtab *ht, register char *s) -#endif +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 * -#ifdef KR_headers -mk_hashtab(nl) Namelist *nl; -#else -mk_hashtab(Namelist *nl) -#endif +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; +static void +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 -#ifdef KR_headers -getname(s, slen) register char *s; int slen; -#else -getname(register char *s, int slen) -#endif +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 -#ifdef KR_headers -getnum(chp, val) int *chp; ftnlen *val; -#else -getnum(int *chp, ftnlen *val) -#endif +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 -#ifdef KR_headers -getdimen(chp, d, delta, extent, x1) - int *chp; dimen *d; ftnlen delta, extent, *x1; -#else -getdimen(int *chp, dimen *d, ftnlen delta, ftnlen extent, ftnlen *x1) -#endif +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 -#ifdef KR_headers -print_ne(a) cilist *a; -#else -print_ne(cilist *a) -#endif +static void +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 "; -#ifdef KR_headers -x_rsne(a) cilist *a; -#else -x_rsne(cilist *a) -#endif +int +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) + { + ftnint no2 = (ivae - iva) / size; + if (no2 > f__lcount) + no2 = f__lcount; + if ((k = l_read (&no2, vaddr + iva, size, type))) + return k; + iva += no2 * 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 -#ifdef KR_headers -s_rsne(a) cilist *a; -#else -s_rsne(cilist *a) -#endif +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/contrib/libf2c/libI77/sfe.c b/contrib/libf2c/libI77/sfe.c index b67d823..8f05e48 100644 --- a/contrib/libf2c/libI77/sfe.c +++ b/contrib/libf2c/libI77/sfe.c @@ -5,35 +5,40 @@ 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); } -#ifdef KR_headers -c_sfe(a) cilist *a; /* check */ -#else -c_sfe(cilist *a) /* check */ -#endif -{ 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); + +int +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/contrib/libf2c/libI77/sue.c b/contrib/libf2c/libI77/sue.c index 8865054..a20df66 100644 --- a/contrib/libf2c/libI77/sue.c +++ b/contrib/libf2c/libI77/sue.c @@ -4,85 +4,90 @@ extern uiolen f__reclen; off_t f__recloc; -#ifdef KR_headers -c_sue(a) cilist *a; -#else -c_sue(cilist *a) -#endif +int +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); } -#ifdef KR_headers -integer s_rsue(a) cilist *a; -#else -integer s_rsue(cilist *a) -#endif + +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); } -#ifdef KR_headers -integer s_wsue(a) cilist *a; -#else -integer s_wsue(cilist *a) -#endif + +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/contrib/libf2c/libI77/typesize.c b/contrib/libf2c/libI77/typesize.c index 7f42aa1..8e2a74a 100644 --- a/contrib/libf2c/libI77/typesize.c +++ b/contrib/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/contrib/libf2c/libI77/uio.c b/contrib/libf2c/libI77/uio.c index ea733ce..706b5dd 100644 --- a/contrib/libf2c/libI77/uio.c +++ b/contrib/libf2c/libI77/uio.c @@ -1,69 +1,60 @@ +#include "config.h" #include "f2c.h" #include "fio.h" #include uiolen f__reclen; -#ifdef KR_headers -do_us(number,ptr,len) ftnint *number; char *ptr; ftnlen len; -#else -do_us(ftnint *number, char *ptr, ftnlen len) -#endif +int +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) != (size_t) *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); + } } -#ifdef KR_headers -integer do_ud(number,ptr,len) ftnint *number; char *ptr; ftnlen len; -#else -integer do_ud(ftnint *number, char *ptr, ftnlen len) -#endif +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 -#ifdef KR_headers - int i; + 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 < (size_t) *number) + memset (ptr + i * len, 0, (*number - i) * len); + return 0; #else - size_t i; + if (fread (ptr, (size_t) len, (size_t) (*number), f__cf) != *number) + err (f__elist->cierr, EOF, "do_ud"); + else + return (0); #endif - 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); -#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); } -#ifdef KR_headers -integer do_uio(number,ptr,len) ftnint *number; char *ptr; ftnlen len; -#else -integer do_uio(ftnint *number, char *ptr, ftnlen len) -#endif + +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/contrib/libf2c/libI77/util.c b/contrib/libf2c/libI77/util.c index 8280ac0..6e7c52b 100644 --- a/contrib/libf2c/libI77/util.c +++ b/contrib/libf2c/libI77/util.c @@ -8,47 +8,45 @@ #include "f2c.h" #include "fio.h" - VOID -#ifdef KR_headers -g_char(a,alen,b) char *a,*b; ftnlen alen; -#else -g_char(char *a, ftnlen alen, char *b) -#endif +void +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 -#ifdef KR_headers -b_char(a,b,blen) char *a,*b; ftnlen blen; -#else -b_char(char *a, char *b, ftnlen blen) -#endif -{ int i; - for(i=0;i #endif -#ifndef KR_headers #undef abs #undef min #undef max #include #include -#endif #include "fmt.h" #include "fp.h" -#ifdef KR_headers -wrt_E(p,w,d,e,len) ufloat *p; ftnlen len; -#else -wrt_E(ufloat *p, int w, int d, int e, ftnlen len) -#endif +int +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 ((unsigned char) 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; +} -#ifdef KR_headers -wrt_F(p,w,d,len) ufloat *p; ftnlen len; -#else -wrt_F(ufloat *p, int w, int d, ftnlen len) -#endif +int +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/contrib/libf2c/libI77/wrtfmt.c b/contrib/libf2c/libI77/wrtfmt.c index 37006ba..0190f71 100644 --- a/contrib/libf2c/libI77/wrtfmt.c +++ b/contrib/libf2c/libI77/wrtfmt.c @@ -6,361 +6,396 @@ 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"); } - 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; - } + 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; + } } - else if (cursor < 0) + return (0); + } + if (cursor > 0) + { + if (f__hiwater <= f__recpos) + for (; cursor > 0; cursor--) + (*f__putn) (' '); + else if (f__hiwater <= f__recpos + cursor) { - if(cursor + f__recpos < 0) - err(f__elist->cierr,110,"left off"); - if(f__hiwater < f__recpos) - f__hiwater = f__recpos; - f__recpos += cursor; + cursor -= f__hiwater - f__recpos; + f__recpos = f__hiwater; + for (; cursor > 0; cursor--) + (*f__putn) (' '); } - return(0); + else + { + f__recpos += cursor; + } + } + 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 -#ifdef KR_headers -wrt_Z(n,w,minlen,len) Uint *n; int w, minlen; ftnlen len; -#else -wrt_Z(Uint *n, int w, int minlen, ftnlen len) -#endif +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 -#ifdef KR_headers -wrt_I(n,w,len, base) Uint *n; ftnlen len; register int base; -#else -wrt_I(Uint *n, int w, ftnlen len, register int base) -#endif -{ 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;iis; + 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 -#ifdef KR_headers -wrt_IM(n,w,m,len,base) Uint *n; ftnlen len; int base; -#else -wrt_IM(Uint *n, int w, int m, ftnlen len, int base) -#endif -{ 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=m) - spare=w-ndigit-xsign; - else - spare=w-m-xsign; - for(i=0;iis; + 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 -#ifdef KR_headers -wrt_AP(s) char *s; -#else -wrt_AP(char *s) -#endif -{ 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 -#ifdef KR_headers -wrt_H(a,s) char *s; -#else -wrt_H(int a, char *s) -#endif +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); } -#ifdef KR_headers -wrt_L(n,len, sz) Uint *n; ftnlen sz; -#else -wrt_L(Uint *n, int len, ftnlen sz) -#endif -{ 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;iil; + 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 -#ifdef KR_headers -wrt_A(p,len) char *p; ftnlen len; -#else -wrt_A(char *p, ftnlen len) -#endif +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 -#ifdef KR_headers -wrt_AW(p,w,len) char * p; ftnlen len; -#else -wrt_AW(char * p, int w, ftnlen len) -#endif +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 -#ifdef KR_headers -wrt_G(p,w,d,e,len) ufloat *p; ftnlen len; -#else -wrt_G(ufloat *p, int w, int d, int e, ftnlen len) -#endif -{ 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;jpf : 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)); } -#ifdef KR_headers -w_ed(p,ptr,len) struct syl *p; char *ptr; ftnlen len; -#else -w_ed(struct syl *p, char *ptr, ftnlen len) -#endif + +int +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)); + } } -#ifdef KR_headers -w_ned(p) struct syl *p; -#else -w_ned(struct syl *p) -#endif + +int +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/contrib/libf2c/libI77/wsfe.c b/contrib/libf2c/libI77/wsfe.c index 490231a..46f7a8f 100644 --- a/contrib/libf2c/libI77/wsfe.c +++ b/contrib/libf2c/libI77/wsfe.c @@ -5,72 +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; } -#ifdef KR_headers -integer s_wsfe(a) cilist *a; /*start*/ -#else -integer s_wsfe(cilist *a) /*start*/ -#endif -{ 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/contrib/libf2c/libI77/wsle.c b/contrib/libf2c/libI77/wsle.c index 386e867..e9ef172 100644 --- a/contrib/libf2c/libI77/wsle.c +++ b/contrib/libf2c/libI77/wsle.c @@ -5,35 +5,34 @@ #include "lio.h" #include "string.h" -#ifdef KR_headers -integer s_wsle(a) cilist *a; -#else -integer s_wsle(cilist *a) -#endif +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/contrib/libf2c/libI77/wsne.c b/contrib/libf2c/libI77/wsne.c index ae3f817..bcf0826 100644 --- a/contrib/libf2c/libI77/wsne.c +++ b/contrib/libf2c/libI77/wsne.c @@ -2,25 +2,21 @@ #include "fio.h" #include "lio.h" - integer -#ifdef KR_headers -s_wsne(a) cilist *a; -#else -s_wsne(cilist *a) -#endif +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/contrib/libf2c/libI77/xwsne.c b/contrib/libf2c/libI77/xwsne.c index 96fdd02..68b606c 100644 --- a/contrib/libf2c/libI77/xwsne.c +++ b/contrib/libf2c/libI77/xwsne.c @@ -6,67 +6,66 @@ extern int f__Aquote; - static VOID -nl_donewrec(Void) +static void +nl_donewrec (void) { - (*f__donewrec)(); - PUT(' '); - } + (*f__donewrec) (); + PUT (' '); +} -#ifdef KR_headers -x_wsne(a) cilist *a; -#else #include - VOID -x_wsne(cilist *a) -#endif +void +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 ('/'); +} -- cgit v1.1