V8/usr/src/cmd/qed/address.c

Compare this file to the similar file:
Show the results in this format:

/*% cc -c -O %
 */
#include "vars.h"
int *
address()
{
	register int sign, *a;
	int opcnt, nextopand, *b;
	register c;

	nextopand = -1;
	sign = 1;
	opcnt = 0;
	a = dot;
	do {
		do c = getchar(); while (c==' ' || c=='\t');
		if ('0'<=c && c<='9') {
			peekc = c;
			if (!opcnt)
				a = zero;
			a += sign*getnum();
		} else switch (c) {
		case '$':
			a = dol;
			/* fall through */
		case '.':
			if (opcnt)
				error('a');
			break;
		case '\'':
			c = getchar();
			if (opcnt)
				error('a');
			if(posn(c, bname)<0)
				error('k');
			a = zero;
			c = posn(c, bname);	/* outside loop for efficiency */
			do a++; while (a<=dol && names[c]!=(*a|01));
			break;
		case '?':
			sign = -sign;
			/* fall through */
		case '/':
			compile(c);
			b = a;
			for (;;) {
				a += sign;
				if (a<zero)
					a = dol;
				if (a>dol)
					a = zero;
				if (execute(a))
					break;
				if (a==b)
					error('/');
			}
			break;
		default:
			if (nextopand == opcnt) {
				a += sign;
				if (a<zero || dol<a)
					continue;       /* error('$'); */
			}
			if (c!='+' && c!='-' && c!='^') {
				peekc = c;
				if (opcnt==0)
					a = 0;
				return (a);
			}
			sign = 1;
			if (c!='+')
				sign = -sign;
			nextopand = ++opcnt;
			continue;
		}
		sign = 1;
		opcnt++;
	} while (zero<=a && a<=dol);
	error('$');
	/*NOTREACHED*/
}