Ejemplo n.º 1
0
casern(){
	register i,j;

	lgf++;
	skip();
	if(((i=getrq())==0) || ((oldmn=findmn(i)) < 0))return;
	skip();
	clrmn(findmn(j=getrq()));
	if(j)contab[oldmn].rq = (contab[oldmn].rq & MMASK) | j;
}
Ejemplo n.º 2
0
casern()
{
	register i, j;

	lgf++;
	skip();
	if ((i = getrq()) == 0 || (oldmn = findmn(i)) < 0)
		return;
	skip();
	clrmn(findmn(j = getrq()));
	if (j) {
		munhash(&contab[oldmn]);
		contab[oldmn].rq = j;
		maddhash(&contab[oldmn]);
	}
}
Ejemplo n.º 3
0
Archivo: n5.c Proyecto: aksr/heirloom
void
caseem(void)
{
	lgf++;
	skip(1);
	em = getrq(1);
}
Ejemplo n.º 4
0
Archivo: n6.c Proyecto: n-t-roff/DWB3.3
void n_casebd(void)
{
	int i, j, k;

	k = 0;
bd0:
	if (skip() || !(i = getrq()) || (j = findft(i)) == -1) {
		if (k)
			goto bd1;
		else 
			return;
	}
	if (j == smnt) {
		k = smnt;
		goto bd0;
	}
	if (k) {
		sbold = j;
		j = k;
	}
bd1:
	skip();
	noscale++;
	bdtab[j] = atoi0();
	noscale = 0;
}
Ejemplo n.º 5
0
casede(){
	register i, req;
	register filep savoff;
	extern filep finds();

	if(dip != d)wbfl();
	req = '.';
	lgf++;
	skip();
	if((i=getrq())==0)goto de1;
	if((offset=finds(i)) == 0)goto de1;
	if(ds)copys();
		else req = copyb();
	wbfl();
	clrmn(oldmn);
	if(newmn)contab[newmn].rq = i | MMASK;
	if(apptr){
		savoff = offset;
		offset = apptr;
		wbt(IMP);
		offset = savoff;
	}
	offset = dip->op;
	if(req != '.')control(req,1);
de1:
	ds = app = 0;
	return;
}
Ejemplo n.º 6
0
Archivo: n5.c Proyecto: aksr/heirloom
static void
_casewh(struct d *dp)
{
	register int i, j, k;

	lgf++;
	skip(1);
	i = vnumb((int *)0);
	if (nonumb)
		return;
	skip(0);
	j = getrq(1);
	if ((k = findn(dp, i)) != NTRAP) {
		dp->mlist[k] = j;
		return;
	}
	for (k = 0; k < NTRAP; k++)
		if (dp->mlist[k] == 0)
			break;
	if (k == NTRAP) {
		flusho();
		errprint("cannot plant trap.");
		return;
	}
	dp->mlist[k] = j;
	dp->nlist[k] = i;
	chkt(dp, i);
}
Ejemplo n.º 7
0
void compute_max_cod(dyn *b, vec& pos, vec& vel)
{
    // First see if the data are already known.

    if (find_qmatch(b->get_dyn_story(), "density_center_type"))
	if (streq(getsq(b->get_dyn_story(), "density_center_type"), "max")) {
	    if (twiddles(getrq(b->get_dyn_story(), "density_center_time"),
			 b->get_system_time(), TTOL)) {
		pos = getvq(b->get_dyn_story(), "density_center_pos");
		vel = getvq(b->get_dyn_story(), "density_center_vel");
		return;
	    }
	}

    real max_density = 0;

    pos = 0;
    vel = 0;

//  for_all_leaves(dyn, b, d)
    for_all_daughters(dyn, b, d) {

	real dens_time = getrq(d->get_dyn_story(), "density_time");

	if (!twiddles(dens_time, b->get_system_time(), TTOL) && print_msg) {
	    warning("compute_max_cod: using out-of-date densities.");
	    PRC(d->format_label()), PRL(dens_time);
	    if (++msg_count > MAX_MSG_COUNT) print_msg = false;
	}

	real this_density = getrq(d->get_dyn_story(), "density");

	if (this_density > 0) {
	    if (max_density < this_density) {
		max_density = this_density;
		pos = d->get_pos();
		vel = d->get_vel();
	    }
	} else if (this_density <= -VERY_LARGE_NUMBER) {
	    if (print_msg) {
		warning("compute_max_cod: density not set.");
		PRL(d->format_label());
	    }
	    if (++msg_count > MAX_MSG_COUNT) print_msg = false;
	}
    }
Ejemplo n.º 8
0
void dyn::scale_radius(real rfac)
{
    if (!oldest_daughter) {
	real rad = getrq(dyn_story, "R_eff");
	if (rad > 0)
	    putrq(dyn_story, "R_eff", rad*rfac);
    }
}
Ejemplo n.º 9
0
Archivo: n5.c Proyecto: aksr/heirloom
void
caseblm(void)
{
	if (!skip(0))
		blmac = getrq(1);
	else
		blmac = 0;
}
Ejemplo n.º 10
0
real dyn::get_radius(bool check_story)		// default = false
{
    if (oldest_daughter) return get_clump_radius();
    if (!check_story) return 0;

    real rad = getrq(dyn_story, "R_eff");
    if (rad < 0) rad = 0;
    return rad;
}
Ejemplo n.º 11
0
void casern(void)
{
	int i, j, k;

	lgf++;
	skip();
	if ((i = getrq()) == 0 || (oldmn = findmn(i)) < 0)
		return;
	skip();
	clrmn(findmn(j = getrq()));
	if (j) {
		munhash(&contabp[oldmn]);
		contabp[oldmn].rq = j;
		maddhash(&contabp[oldmn]);
		if (dip != d )
			for (k = dilev; k; k--)
				if (d[k].curd == i)
					d[k].curd = j;
	}
}
Ejemplo n.º 12
0
Archivo: n6.c Proyecto: n-t-roff/DWB3.3
void n_casefp(void)
{
	int i, j;

	skip();
	if ((i = cbits(getch()) - '0') < 0 || i > nfonts)
		return;
	if (skip() || !(j = getrq()))
		return;
	fontlab[i] = j;
}
Ejemplo n.º 13
0
void casedt(void)
{
	lgf++;
	dip->dimac = dip->ditrap = dip->ditf = 0;
	skip();
	dip->ditrap = vnumb((int *)0);
	if (nonumb)
		return;
	skip();
	dip->dimac = getrq();
}
Ejemplo n.º 14
0
int getsn(void)
{
	int i;

	if ((i = getach()) == 0)
		return(0);
	if (i == '(')
		return(getrq());
	else 
		return(i);
}
Ejemplo n.º 15
0
void casegd(void)
{
	int i, j;

	skip();
	if ((i = getrq()) == 0)
		return;
	if ((j = findmn(i)) >= 0) {
		if (contabp[j].divsiz != NULL) {
			numtabp[DN].val = contabp[j].divsiz->dix;
			numtabp[DL].val = contabp[j].divsiz->diy;
		}
	}
}
Ejemplo n.º 16
0
Archivo: n5.c Proyecto: aksr/heirloom
void
caseuf(void)
{
	register int i, j;
	extern int findft(int, int);

	if (skip(0) || !(i = getrq(2)) || i == 'S' || (j = findft(i, 1))  == -1)
		ulfont = ULFONT; /*default underline position*/
	else 
		ulfont = j;
#ifdef NROFF
	if (ulfont == FT)
		ulfont = ULFONT;
#endif
}
Ejemplo n.º 17
0
void casedi(void)
{
	int i, j, *k;

	lgf++;
	if (skip() || (i = getrq()) == 0) {
		if (dip != d) {
			FINDDIV(savslot);
			wbf((Tchar)0);
		}
		if (dilev > 0) {
			numtabp[DN].val = dip->dnl;
			numtabp[DL].val = dip->maxl;
			FINDDIV(j);
			if ((contabp[j].divsiz = (Divsiz *) malloc(sizeof(Divsiz))) == NULL) {
				ERROR "Cannot alloc diversion size" WARN;
				done2(1);
			} else {
				contabp[j].divsiz->dix = numtabp[DN].val;
				contabp[j].divsiz->diy = numtabp[DL].val;
			}
			dip = &d[--dilev];
			offset = dip->op;
		}
		goto rtn;
	}
	if (++dilev == NDI) {
		--dilev;
		ERROR "Diversions nested too deep" WARN;
		edone(02);
	}
	if (dip != d) {
		FINDDIV(j);
		savslot = j;
		wbf((Tchar)0);
	}
	diflg++;
	dip = &d[dilev];
	dip->op = finds(i);
	dip->curd = i;
	clrmn(oldmn);
	k = (int *) & dip->dnl;
	for (j = 0; j < 10; j++)
		k[j] = 0;	/*not op and curd*/
rtn:
	app = 0;
	diflg = 0;
}
Ejemplo n.º 18
0
Archivo: n4.c Proyecto: aahud/harvey
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--;
	}
}
Ejemplo n.º 19
0
Archivo: n5.c Proyecto: aksr/heirloom
void
caseit(int cflag)
{
	register int i;

	lgf++;
	it = itc = itmac = 0;
	noscale++;
	skip(0);
	i = atoi();
	skip(0);
	if (!nonumb && (itmac = getrq(1))) {
		it = i;
		itc = cflag;
	}
	noscale = 0;
}
Ejemplo n.º 20
0
void caserm(void)
{
	int j;
	int k = 0;

	lgf++;
g0:
	while (!skip() && (j = getrq()) != 0) {
		if (dip != d)
			for (k = dilev; k; k--)
				if (d[k].curd == j) {
					ERROR "cannot remove diversion %s during definition",
								unpair(j) WARN;
					goto g0;
				}
		clrmn(findmn(j));
	}
	lgf--;
}
Ejemplo n.º 21
0
Archivo: n4.c Proyecto: aahud/harvey
void caseaf(void)
{
	int i, k;
	Tchar j;

	lgf++;
	if (skip() || !(i = getrq()) || skip())
		return;
	k = 0;
	j = getch();
	if (!isalpha(cbits(j))) {
		ch = j;
		while ((j = cbits(getch())) >= '0' &&  j <= '9')
			k++;
	}
	if (!k)
		k = j;
	numtabp[findr(i)].fmt = k;	/* was k & BYTEMASK */
}
Ejemplo n.º 22
0
Archivo: n5.c Proyecto: aksr/heirloom
void
casemk(void)
{
	register int i, j;
	struct numtab	*np;

	if (dip != d)
		j = dip->dnl; 
	else 
		j = numtab[NL].val;
	if (skip(0)) {
		dip->mkline = j;
		return;
	}
	if ((i = getrq(1)) == 0)
		return;
	np = findr(i);
	np->val = j;
	prwatchn(np);
}
Ejemplo n.º 23
0
void casede(void)
{
	int i, req;
	Offset savoff;

	req = '.';
	lgf++;
	skip();
	if ((i = getrq()) == 0)
		goto de1;
	if ((offset = finds(i)) == 0)
		goto de1;
	if (newmn)
		savslot = newmn;
	else
		savslot = findmn(i);
	savname = i;
	if (ds)
		copys();
	else
		req = copyb();
	clrmn(oldmn);
	if (newmn) {
		if (contabp[newmn].rq)
			munhash(&contabp[newmn]);
		contabp[newmn].rq = i;
		maddhash(&contabp[newmn]);

	}
	if (apptr) {
		savoff = offset;
		offset = apptr;
		wbf((Tchar) IMP);
		offset = savoff;
	}
	offset = dip->op;
	if (req != '.')
		control(req, 1);
de1:
	ds = app = 0;
}
Ejemplo n.º 24
0
Archivo: n6.c Proyecto: n-t-roff/DWB3.3
void n_setfont(int a)
{
	int i, j;

	if (a)
		i = getrq();
	else 
		i = getsn();
	if (!i || i == 'P') {
		j = font1;
		goto s0;
	}
	if (/* i == 'S' || */ i == '0')
		return;
	if ((j = findft(i)) == -1)
		return;
s0:
	font1 = font;
	font = j;
	mchbits();
}
Ejemplo n.º 25
0
Archivo: n5.c Proyecto: aksr/heirloom
static void
_casech(struct d *dp)
{
	register int i, j, k;

	lgf++;
	skip(1);
	if (!(j = getrq(0)))
		return;
	else  {
		for (k = 0; k < NTRAP; k++)
			if (dp->mlist[k] == j)
				break;
	}
	if (k == NTRAP)
		return;
	skip(0);
	i = vnumb((int *)0);
	if (nonumb)
		dp->mlist[k] = 0;
	dp->nlist[k] = i;
	chkt(dp, i);
}
Ejemplo n.º 26
0
Archivo: n4.c Proyecto: aahud/harvey
/*
 * .nr request; if tracing, don't check optional
 * 2nd argument because tbl generates .in 1.5n
 */
void casenr(void)
{
	int i, j;
	int savtr = trace;

	lgf++;
	skip();
	if ((i = findr(getrq())) == -1)
		goto rtn;
	skip();
	j = inumb(&numtabp[i].val);
	if (nonumb)
		goto rtn;
	numtabp[i].val = j;
	skip();
	trace = 0;
	j = atoi0();		/* BUG??? */
	trace = savtr;
	if (nonumb)
		goto rtn;
	numtabp[i].inc = j;
rtn:
	return;
}
Ejemplo n.º 27
0
Archivo: n1.c Proyecto: 99years/plan9
main(int argc, char *argv[])
{
	char *p;
	int j;
	Tchar i;
	char buf[100];

	buf[0] = '\0';		/* make sure it's empty (silly 3b2) */
	progname = argv[0];
	if ((p = strrchr(progname, '/')) == NULL)
		p = progname;
	else
		p++;
	DWBinit(progname, dwbpaths);
	if (strcmp(p, "nroff") == 0)
		TROFF = 0;
#ifdef UNICODE
	alphabet = 128;	/* unicode for plan 9 */
#endif	/*UNICODE*/
	mnspace();
	nnspace();
	mrehash();
	nrehash();
	numtabp[NL].val = -1;

	while (--argc > 0 && (++argv)[0][0] == '-')
		switch (argv[0][1]) {

		case 'N':	/* ought to be used first... */
			TROFF = 0;
			break;
		case 'd':
			fprintf(stderr, "troff/nroff version %s\n", Version);
			break;
		case 'F':	/* switch font tables from default */
			if (argv[0][2] != '\0') {
				strcpy(termtab, &argv[0][2]);
				strcpy(fontdir, &argv[0][2]);
			} else {
				argv++; argc--;
				strcpy(termtab, argv[0]);
				strcpy(fontdir, argv[0]);
			}
			break;
		case 0:
			goto start;
		case 'i':
			stdi++;
			break;
		case 'n':
			npn = atoi(&argv[0][2]);
			break;
		case 'u':	/* set emboldening amount */
			bdtab[3] = atoi(&argv[0][2]);
			if (bdtab[3] < 0 || bdtab[3] > 50)
				bdtab[3] = 0;
			break;
		case 's':
			if (!(stop = atoi(&argv[0][2])))
				stop++;
			break;
		case 'r':
			sprintf(buf + strlen(buf), ".nr %c %s\n",
				argv[0][2], &argv[0][3]);
			/* not yet cpushback(buf);*/
			/* dotnr(&argv[0][2], &argv[0][3]); */
			break;
		case 'm':
			if (mflg++ >= NMF) {
				ERROR "Too many macro packages: %s", argv[0] WARN;
				break;
			}
			strcpy(mfiles[nmfi], nextf);
			strcat(mfiles[nmfi++], &argv[0][2]);
			break;
		case 'o':
			getpn(&argv[0][2]);
			break;
		case 'T':
			strcpy(devname, &argv[0][2]);
			dotT++;
			break;
		case 'a':
			ascii = 1;
			break;
		case 'h':
			hflg++;
			break;
		case 'e':
			eqflg++;
			break;
		case 'q':
			quiet++;
			save_tty();
			break;
		case 'V':
			fprintf(stdout, "%croff: DWB %s\n", 
					TROFF ? 't' : 'n', DWBVERSION);
			exit(0);
		case 't':
			if (argv[0][2] != '\0')
				trace = trace1 = argv[0][2];
			break;		/* for the sake of compatibility */
		default:
			ERROR "unknown option %s", argv[0] WARN;
			done(02);
		}

start:
	/*
	 * cpushback maintains a LIFO, so push pack the -r arguments
	 * in reverse order to maintain a FIFO in case someone did -rC1 -rC3
	 */
	if (buf[0]) {
		char *p = buf;
		while(*p++)
			;
		while(p > buf) {
			while(strncmp(p, ".nr", 3) != 0)
				p--;
			cpushback(p);
			*p-- = '\0';
		}
	}
	argp = argv;
	rargc = argc;
	nmfi = 0;
	init2();
	setjmp(sjbuf);
loop:
	copyf = lgf = nb = nflush = nlflg = 0;
	if (ip && rbf0(ip) == 0 && ejf && frame->pframe <= ejl && dip == d) {
		nflush++;
		trap = 0;
		eject((Stack *)0);
		goto loop;
	}
	i = getch();
	if (pendt)
		goto Lt;
	if ((j = cbits(i)) == XPAR) {
		copyf++;
		tflg++;
		while (cbits(i) != '\n')
			pchar(i = getch());
		tflg = 0;
		copyf--;			/* pointless */
		goto loop;
	}
	if (j == cc || j == c2) {
		if (j == c2)
			nb++;
		copyf++;
		while ((j = cbits(i = getch())) == ' ' || j == '\t')
			;
		ch = i;
		copyf--;
		control(getrq(), 1);
		flushi();
		goto loop;
	}
Lt:
	ch = i;
	text();
	if (nlflg)
		numtabp[HP].val = 0;
	goto loop;
}
Ejemplo n.º 28
0
main(int argc, char ** argv)
{
    char  *comment;
    bool  c_flag = FALSE;	// if TRUE, a comment given on command line

    real  t_extract;
    bool  t_flag = FALSE;	// if TRUE, a time was specified

    bool  v_flag = FALSE;	// if TRUE, print snap times as read

    int   n = 1;
    bool  n_flag = false;	// if TRUE, a number was specified

    check_help();

    extern char *poptarg;
    int c;
    const char *param_string = "c:n:t:v";

    while ((c = pgetopt(argc, argv, param_string,
		    "$Revision: 1.8 $", _SRC_)) != -1)
	switch(c) {
	    case 'c': c_flag = TRUE;
	    	      comment = poptarg;
		      break;
	    case 't': t_flag = TRUE;
		      t_extract = atof(poptarg);
		      break;
	    case 'n': n_flag = TRUE;
		      n = atoi(poptarg);
		      break;
	    case 'v': v_flag = TRUE;
		      break;
	    case '?': params_to_usage(cerr, argv[0], param_string);
	              get_help();
		      exit(1);
	}            

    if (n < 0) err_exit("n < 0 specified.");
    if (n > 1 && !t_flag) {
	warning("n > 1 but no time specified -- 0 assumed.");
	t_extract = 0;
	t_flag = true;
    }

    node *b = NULL, *bp = NULL;
    int i = 0;

    // Need to ensure that the data are not changed by this function.
    // Currently, get_dyn() ends by calling check_and_correct_node(),
    // which may change pos and vel to force the system to the center
    // of mass frame.  Can fix (1) by suppressing this call in this
    // case, (2) setting a tolerance to avoid forcing if the system is
    // already "close" to the CM frame, or (3) use nodes here, which
    // will never interpret pos or vel and hence will not change them.
    // The only number we really need below is sytsem_time.  Options
    // (1) and (2) are awkward, because this function is a member
    // function and changing its arguments would propagate through the
    // other classes.  However, we could add a static local option to
    // the dyn instance of the function.  Option (3) seems cleanest.
    // To revert, change node to dyn and use b->get_system_time() to
    // determine time.
    //						(Steve, 7/04)

    while (b = get_node()) {

	real time;
	if (find_qmatch(b->get_dyn_story(), "real_system_time"))
	    time = getrq(b->get_dyn_story(), "real_system_time");
	else
	    time = getrq(b->get_dyn_story(), "system_time");

	// real time = b->get_system_time();

	i++;

	if (v_flag) cerr << "Snap time #" << i << " = " << time << endl;

	if (t_flag && time >= t_extract) {

	    if (n > 0) {

		if (c_flag == TRUE)
		    b->log_comment(comment);

		b->log_history(argc, argv);
		put_node(b);
	    }

	    if (--n <= 0) exit(0);
	}

	if (bp) rmtree(bp);
	bp = b;
    }

    if (n > 0 && !t_flag) {
	bp->log_history(argc, argv);
	put_node(bp);
    }

}
Ejemplo n.º 29
0
caserm(){
	lgf++;
	while(!skip()){
		clrmn(findmn(getrq()));
	}
}
Ejemplo n.º 30
0
Archivo: n5.c Proyecto: aksr/heirloom
static void
tmtmcwr(int ab, int tmc, int wr, int ep, int tmm)
{
	const char tmtab[] = {
		'a',000,000,000,000,000,000,000,
		000,000,000,000,000,000,000,000,
		'{','}','&',000,'%','c','e',' ',
		'!',000,000,000,000,000,000,'~',
		000
	};
	struct contab	*cp;
	register int i, j;
	tchar	c;
	char	tmbuf[NTM];
	filep	savip = ip;
	int	discard = 0;

	lgf++;
	if (tmm) {
		if (skip(1) || (i = getrq(0)) == 0)
			return;
		if ((cp = findmn(i)) == NULL || !cp->mx) {
			nosuch(i);
			return;
		}
		savip = ip;
		ip = (filep)cp->mx;
		app++;
		copyf++;
	} else {
		copyf++;
		if (skip(0) && ab)
			errprint("User Abort");
	}
loop:	for (i = 0; i < NTM - 5 - mb_cur_max; ) {
		if (tmm) {
			if ((c = rbf()) == 0) {
				ip = savip;
				tmm = 0;
				app--;
				break;
			}
		} else
			c = getch();
		if (discard) {
			discard--;
			continue;
		}
		if (c == '\n') {
			tmbuf[i++] = '\n';
			break;
		}
	c:	j = cbits(c);
		if (iscopy(c)) {
			int	n;
			if ((n = wctomb(&tmbuf[i], j)) > 0) {
				i += n;
				continue;
			}
		}
		if (xflag == 0) {
			tmbuf[i++] = c;
			continue;
		}
		if (ismot(c))
			continue;
		tmbuf[i++] = '\\';
		if (c == (OHC|BLBIT))
			j = ':';
		else if (istrans(c))
			j = ')';
		else if (j >= 0 && j < sizeof tmtab && tmtab[j])
			j = tmtab[j];
		else if (j == ACUTE)
			j = '\'';
		else if (j == GRAVE)
			j = '`';
		else if (j == UNDERLINE)
			j = '_';
		else if (j == MINUS)
			j = '-';
		else {
			i--;
			if (c == WORDSP)
				j = ' ';
			else if (j == WORDSP)
				continue;
			else if (j == FLSS) {
				discard++;
				continue;
			}
		}
		if (j == XFUNC)
			switch (fbits(c)) {
			case CHAR:
				c = charout[sbits(c)].ch;
				goto c;
			default:
				continue;
			}
		tmbuf[i++] = j;
	}
	if (i == NTM - 2)
		tmbuf[i++] = '\n';
	if (tmc)
		i--;
	tmbuf[i] = 0;
	if (ab)	/* truncate output */
		obufp = obuf;	/* should be a function in n2.c */
	if (ep) {
		flusho();
		errprint("%s", tmbuf);
	} else if (wr < 0) {
		flusho();
		fdprintf(stderr, "%s", tmbuf);
	} else if (i)
		write(wr, tmbuf, i);
	if (tmm)
		goto loop;
	copyf--;
	lgf--;
}