Exemple #1
0
void setaf(void)	/* return format of number register */
{
	int i, j;

	i = usedr(getsn());
	if (i == -1)
		return;
	if (numtabp[i].fmt > 20)	/* it was probably a, A, i or I */
		*pbp++ = numtabp[i].fmt;
	else
		for (j = (numtabp[i].fmt ? numtabp[i].fmt : 1); j; j--)
			*pbp++ = '0';
}
Exemple #2
0
void caserr(void)
{
	int i, j;
	Numtab *p;

	lgf++;
	while (!skip() && (i = getrq()) ) {
		j = usedr(i);
		if (j < 0)
			continue;
		p = &numtabp[j];
		nunhash(p);
		p->r = p->val = p->inc = p->fmt = 0;
		regcnt--;
	}
}
Exemple #3
0
void
caseif(int x)
{
	extern int falsef;
	register int notflag, true;
	tchar i, j;
	enum warn w = warn;
	int	flt = 0;

	if (x == 3)
		goto i2;
	if (x == 2) {
		notflag = 0;
		true = iflist ? iflist[ifx] : 0;
		goto i1;
	}
	true = 0;
	skip(1);
	if ((cbits(i = getch())) == '!') {
		notflag = 1;
		if (xflag == 0)
			/*EMPTY*/;
		else if ((cbits(i = getch())) == 'f')
			flt = 1;
		else
			ch = i;
	} else if (xflag && cbits(i) == 'f') {
		flt = 1;
		notflag = 0;
	} else {
		notflag = 0;
		ch = i;
	}
	if (flt)
		i = atof0() > 0;
	else
		i = (int)atoi0();
	if (!nonumb) {
		if (i > 0)
			true++;
		goto i1;
	}
	i = getch();
	switch (cbits(i)) {
	case 'e':
		if (!(numtab[PN].val & 01))
			true++;
		break;
	case 'o':
		if (numtab[PN].val & 01)
			true++;
		break;
#ifdef NROFF
	case 'n':
		true++;
	case 't':
#endif
#ifndef NROFF
	case 't':
		true++;
	case 'n':
#endif
		break;
	case 'c':
		if (xflag == 0)
			goto dfl;
		warn &= ~WARN_CHAR;
		tryglf++;
		if (!skip(1)) {
			j = getch();
			true = !ismot(j) && cbits(j) && cbits(j) != ' ';
		}
		tryglf--;
		warn = w;
		break;
	case 'r':
	case 'd':
		if (xflag == 0)
			goto dfl;
		warn &= ~(WARN_MAC|WARN_SPACE|WARN_REG);
		if (!skip(1)) {
			j = getrq(2);
			true = (cbits(i) == 'r' ?
					usedr(j) != NULL : findmn(j) != NULL);
		}
		warn = w;
		break;
	case ' ':
		break;
	default:
	dfl:	true = cmpstr(i);
	}
i1:
	true ^= notflag;
	if (x == 1) {
		if (ifx >= NIF)
			growiflist();
		iflist[ifx] = !true;
	}
	if (true) {
		if (frame->loopf & LOOP_EVAL) {
			if (nonumb)
				goto i3;
			frame->loopf &= ~LOOP_EVAL;
			frame->loopf |= LOOP_NEXT;
		}
i2:
		while ((cbits(i = getch())) == ' ')
			;
		if (cbits(i) == LEFT)
			goto i2;
		ch = i;
		nflush++;
	} else {
i3:
		if (frame->loopf & LOOP_EVAL)
			frame->loopf = LOOP_FREE;
		copyf++;
		falsef++;
		eatblk(0);
		copyf--;
		falsef--;
	}
}