⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pread.c

📁 把fortran语言编的程序转为c语言编的程序, 运行环境linux
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************Copyright 1990, 1992, 1993, 1994 by AT&T Bell Laboratories and Bellcore.Permission to use, copy, modify, and distribute this softwareand its documentation for any purpose and without fee is herebygranted, provided that the above copyright notice appear in allcopies and that both that the copyright notice and thispermission notice and warranty disclaimer appear in supportingdocumentation, and that the names of AT&T Bell Laboratories orBellcore or any of their entities not be used in advertising orpublicity pertaining to distribution of the software withoutspecific, written prior permission.AT&T and Bellcore disclaim all warranties with regard to thissoftware, including all implied warranties of merchantabilityand fitness.  In no event shall AT&T or Bellcore be liable forany special, indirect or consequential damages or any damageswhatsoever resulting from loss of use, data or profits, whetherin an action of contract, negligence or other tortious action,arising out of or in connection with the use or performance ofthis software.****************************************************************/#include "defs.h" static char Ptok[128], Pct[Table_size]; static char *Pfname; static long Plineno; static int Pbad; static int *tfirst, *tlast, *tnext, tmax;#define P_space	1#define P_anum	2#define P_delim	3#define P_slash	4#define TGULP	100 static voidtrealloc(Void){	int k = tmax;	tfirst = (int *)realloc((char *)tfirst,		(tmax += TGULP)*sizeof(int));	if (!tfirst) {		fprintf(stderr,		"Pfile: realloc failure!\n");		exit(2);		}	tlast = tfirst + tmax;	tnext = tfirst + k;	} static void#ifdef KR_headersbadchar(c)	int c;#elsebadchar(int c)#endif{	fprintf(stderr,		"unexpected character 0x%.2x = '%c' on line %ld of %s\n",		c, c, Plineno, Pfname);	exit(2);	} static voidbad_type(Void){	fprintf(stderr,		"unexpected type \"%s\" on line %ld of %s\n",		Ptok, Plineno, Pfname);	exit(2);	} static void#ifdef KR_headersbadflag(tname, option)	char *tname;	char *option;#elsebadflag(char *tname, char *option)#endif{	fprintf(stderr, "%s type from `f2c -%s` on line %ld of %s\n",		tname, option, Plineno, Pfname);	Pbad++;	} static void#ifdef KR_headersdetected(msg)	char *msg;#elsedetected(char *msg)#endif{	fprintf(stderr,	"%sdetected on line %ld of %s\n", msg, Plineno, Pfname);	Pbad++;	}#if 0 static void#ifdef KR_headerschecklogical(k)	int k;#elsechecklogical(int k)#endif{	static int lastmsg = 0;	static int seen[2] = {0,0};	seen[k] = 1;	if (seen[1-k]) {		if (lastmsg < 3) {			lastmsg = 3;			detected(	"Illegal combination of LOGICAL types -- mixing -I4 with -I2 or -i2\n\t");			}		return;		}	if (k) {		if (tylogical == TYLONG || lastmsg >= 2)			return;		if (!lastmsg) {			lastmsg = 2;			badflag("LOGICAL", "I4");			}		}	else {		if (tylogical == TYSHORT || lastmsg & 1)			return;		if (!lastmsg) {			lastmsg = 1;			badflag("LOGICAL", "i2` or `f2c -I2");			}		}	}#else#define checklogical(n) /* */#endif static void#ifdef KR_headerscheckreal(k)	int k;#elsecheckreal(int k)#endif{	static int warned = 0;	static int seen[2] = {0,0};	seen[k] = 1;	if (seen[1-k]) {		if (warned < 2)			detected("Illegal mixture of -R and -!R ");		warned = 2;		return;		}	if (k == forcedouble || warned)		return;	warned = 1;	badflag("REAL return", k ? "!R" : "R");	} static void#ifdef KR_headersPnotboth(e)	Extsym *e;#elsePnotboth(Extsym *e)#endif{	if (e->curno)		return;	Pbad++;	e->curno = 1;	fprintf(stderr,	"%s cannot be both a procedure and a common block (line %ld of %s)\n",		e->fextname, Plineno, Pfname);	} static int#ifdef KR_headersnumread(pf, n)	register FILE *pf;	int *n;#elsenumread(register FILE *pf, int *n)#endif{	register int c, k;	if ((c = getc(pf)) < '0' || c > '9')		return c;	k = c - '0';	for(;;) {		if ((c = getc(pf)) == ' ') {			*n = k;			return c;			}		if (c < '0' || c > '9')			break;		k = 10*k + c - '0';		}	return c;	} static void argverify Argdcl((int, Extsym*)); static void Pbadret Argdcl((int ftype, Extsym *p)); static int#ifdef KR_headersreadref(pf, e, ftype)	register FILE *pf;	Extsym *e;	int ftype;#elsereadref(register FILE *pf, Extsym *e, int ftype)#endif{	register int c, *t;	int i, nargs, type;	Argtypes *at;	Atype *a, *ae;	if (ftype > TYSUBR)		return 0;	if ((c = numread(pf, &nargs)) != ' ') {		if (c != ':')			return c == EOF;		/* just a typed external */		if (e->extstg == STGUNKNOWN) {			at = 0;			goto justsym;			}		if (e->extstg == STGEXT) {			if (e->extype != ftype)				Pbadret(ftype, e);			}		else			Pnotboth(e);		return 0;		}	tnext = tfirst;	for(i = 0; i < nargs; i++) {		if ((c = numread(pf, &type)) != ' '		|| type >= 500		|| type != TYFTNLEN + 100 && type % 100 > TYSUBR)			return c == EOF;		if (tnext >= tlast)			trealloc();		*tnext++ = type;		}	if (e->extstg == STGUNKNOWN) { save_at:		at = (Argtypes *)			gmem(sizeof(Argtypes) + (nargs-1)*sizeof(Atype), 1);		at->dnargs = at->nargs = nargs;		at->changes = 0;		t = tfirst;		a = at->atypes;		for(ae = a + nargs; a < ae; a++) {			a->type = *t++;			a->cp = 0;			} justsym:		e->extstg = STGEXT;		e->extype = ftype;		e->arginfo = at;		}	else if (e->extstg != STGEXT) {		Pnotboth(e);		}	else if (!e->arginfo) {		if (e->extype != ftype)			Pbadret(ftype, e);		else			goto save_at;		}	else		argverify(ftype, e);	return 0;	} static int#ifdef KR_headerscomlen(pf)	register FILE *pf;#elsecomlen(register FILE *pf)#endif{	register int c;	register char *s, *se;	char buf[128], cbuf[128];	int refread;	long L;	Extsym *e;	if ((c = getc(pf)) == EOF)		return 1;	if (c == ' ') {		refread = 0;		s = "comlen ";		}	else if (c == ':') {		refread = 1;		s = "ref: ";		}	else { ret0:		if (c == '*')			ungetc(c,pf);		return 0;		}	while(*s) {		if ((c = getc(pf)) == EOF)			return 1;		if (c != *s++)			goto ret0;		}	s = buf;	se = buf + sizeof(buf) - 1;	for(;;) {		if ((c = getc(pf)) == EOF)			return 1;		if (c == ' ')			break;		if (s >= se || Pct[c] != P_anum)			goto ret0;		*s++ = c;		}	*s-- = 0;	if (s <= buf || *s != '_')		return 0;	strcpy(cbuf,buf);	*s-- = 0;	if (*s == '_') {		*s-- = 0;		if (s <= buf)			return 0;		}	for(L = 0;;) {		if ((c = getc(pf)) == EOF)			return 1;		if (c == ' ')			break;		if (c < '0' && c > '9')			goto ret0;		L = 10*L + c - '0';		}	if (!L && !refread)		return 0;	e = mkext1(buf, cbuf);	if (refread)		return readref(pf, e, (int)L);	if (e->extstg == STGUNKNOWN) {		e->extstg = STGCOMMON;		e->maxleng = L;		}	else if (e->extstg != STGCOMMON)		Pnotboth(e);	else if (e->maxleng != L) {		fprintf(stderr,	"incompatible lengths for common block %s (line %ld of %s)\n",				    buf, Plineno, Pfname);		if (e->maxleng < L)			e->maxleng = L;		}	return 0;	} static int#ifdef KR_headersPtoken(pf, canend)	FILE *pf;	int canend;#elsePtoken(FILE *pf, int canend)#endif{	register int c;	register char *s, *se; top:	for(;;) {		c = getc(pf);		if (c == EOF) {			if (canend)				return 0;			goto badeof;			}		if (Pct[c] != P_space)			break;		if (c == '\n')			Plineno++;		}	switch(Pct[c]) {		case P_anum:			if (c == '_')				badchar(c);			s = Ptok;			se = s + sizeof(Ptok) - 1;			do {				if (s < se)					*s++ = c;				if ((c = getc(pf)) == EOF) { badeof:					fprintf(stderr,					"unexpected end of file in %s\n",						Pfname);					exit(2);					}				}				while(Pct[c] == P_anum);			ungetc(c,pf);			*s = 0;			return P_anum;		case P_delim:			return c;		case P_slash:			if ((c = getc(pf)) != '*') {				if (c == EOF)					goto badeof;				badchar('/');				}			if (canend && comlen(pf))				goto badeof;			for(;;) {				while((c = getc(pf)) != '*') {					if (c == EOF)						goto badeof;					if (c == '\n')						Plineno++;					} slashseek:				switch(getc(pf)) {					case '/':						goto top;					case EOF:						goto badeof;					case '*':						goto slashseek;					}				}		default:			badchar(c);		}	/* NOT REACHED */	return 0;	} static intPftype(Void){	switch(Ptok[0]) {		case 'C':			if (!strcmp(Ptok+1, "_f"))				return TYCOMPLEX;			break;		case 'E':			if (!strcmp(Ptok+1, "_f")) {				/* TYREAL under forcedouble */				checkreal(1);				return TYREAL;				}			break;		case 'H':			if (!strcmp(Ptok+1, "_f"))				return TYCHAR;			break;		case 'Z':			if (!strcmp(Ptok+1, "_f"))				return TYDCOMPLEX;			break;		case 'd':			if (!strcmp(Ptok+1, "oublereal"))				return TYDREAL;			break;		case 'i':			if (!strcmp(Ptok+1, "nt"))				return TYSUBR;			if (!strcmp(Ptok+1, "nteger"))				return TYLONG;			if (!strcmp(Ptok+1, "nteger1"))				return TYINT1;			break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -