Beispiel #1
0
void LoadTriangle(){
	switch (model){
	case 0: readin("cube.in");		break;
	case 1: readin("cow_up.in");	break;
	case 2: readin("phone.in");		break;
	default:readin("cube.in");		break;
	}
}
int main(){
	while(true){
		int m1[100],m2[100];
		int index1,index2;
		if(!readin(m1,&index1))
			break;
		if(!readin(m2,&index2))
			break;		
		qsort(m1,0,index1-1);
		qsort(m2,0,index2-1);
		compare(m1,index1,m2,index2);
	}
	return 0;
}
Beispiel #3
0
/*
 * This is equivalent to filevisit from file.c.
 * Look around to see if we can find the file in another buffer; if we
 * can't find it, create a new buffer, read in the text, and switch to
 * the new buffer. *scratch*, *grep*, *compile* needs to be handled 
 * differently from other buffers which have "filenames".
 */
int
loadbuffer(char *bname)
{
	struct buffer *bufp;
	char *adjf;

	/* check for special buffers which begin with '*' */
	if (bname[0] == '*') {
		if ((bufp = bfind(bname, FALSE)) != NULL) {
			curbp = bufp;
			return (showbuffer(bufp, curwp, WFFULL));
		} else {
			return (FALSE);
		}
	} else {	
		if ((adjf = adjustname(bname, TRUE)) == NULL)
			return (FALSE);
		if ((bufp = findbuffer(adjf)) == NULL)
			return (FALSE);
	}
	curbp = bufp;
	if (showbuffer(bufp, curwp, WFFULL) != TRUE)
		return (FALSE);
	if (bufp->b_fname[0] == '\0') {
		if (readin(adjf) != TRUE) {
			killbuffer(bufp);
			return (FALSE);
		}
	}
	return (TRUE);
}
Beispiel #4
0
int
do_filevisitalt(char *fn)
{
	struct buffer	*bp;
	int		 status;
	char		*adjf;

	status = killbuffer(curbp);
	if (status == ABORT || status == FALSE)
		return (ABORT);

	adjf = adjustname(fn, TRUE);
	if (adjf == NULL)
		return (FALSE);
	if (fisdir(adjf) == TRUE)
		return (do_dired(adjf));
	if ((bp = findbuffer(adjf)) == NULL)
		return (FALSE);
	curbp = bp;
	if (showbuffer(bp, curwp, WFFULL) != TRUE)
		return (FALSE);
	if (bp->b_fname[0] == '\0') {
		if ((status = readin(adjf)) != TRUE)
			killbuffer(bp);
		return (status);
	}
	return (TRUE);
}
Beispiel #5
0
int main()
	{
	freopen("1236.in","r",stdin);
	readin();
	solve();
	return 0;
	}
Beispiel #6
0
int main(int argc, char **argv)
	{
	int i;

#ifdef NEED_ARGV_FIXUP
	argv_fixup( &argc, &argv );
#endif

	flexinit( argc, argv );

	readin();

	ntod();

	for ( i = 1; i <= num_rules; ++i )
		if ( ! rule_useful[i] && i != default_rule )
			line_warning( _( "rule cannot be matched" ),
					rule_linenum[i] );

	if ( spprdflt && ! reject && rule_useful[default_rule] )
		line_warning(
			_( "-s option given but default rule can be matched" ),
			rule_linenum[default_rule] );

	/* Generate the C state transition tables from the DFA. */
	make_tables();

	/* Note, flexend does not return.  It exits with its argument
	 * as status.
	 */
	flexend( 0 );

	return 0;	/* keep compilers/lint happy */
	}
Beispiel #7
0
/* ARGSUSED */
int
poptofile(int f, int n)
{
	struct buffer	*bp;
	struct mgwin	*wp;
	char	 fname[NFILEN], *adjf, *bufp;
	int	 status;

	if (getbufcwd(fname, sizeof(fname)) != TRUE)
		fname[0] = '\0';
	if ((bufp = eread("Find file in other window: ", fname, NFILEN,
	    EFNEW | EFCR | EFFILE | EFDEF)) == NULL)
		return (ABORT);
	else if (bufp[0] == '\0')
		return (FALSE);
	adjf = adjustname(fname, TRUE);
	if (adjf == NULL)
		return (FALSE);
	if ((bp = findbuffer(adjf)) == NULL)
		return (FALSE);
	if (bp == curbp)
		return (splitwind(f, n));
	if ((wp = popbuf(bp)) == NULL)
		return (FALSE);
	curbp = bp;
	curwp = wp;
	if (bp->b_fname[0] == '\0') {
		if ((status = readin(adjf)) != TRUE)
			killbuffer(bp);
		return (status);
	}
	return (TRUE);
}
Beispiel #8
0
void TransRecord::doRun()
{
    if (FALSE == readin()) {
        return;
    }
    output();
}
Beispiel #9
0
/* ARGSUSED */
int
filevisitalt(int f, int n)
{
	struct buffer	*bp;
	char	 fname[NFILEN], *bufp, *adjf;
	int	 status;

	if (getbufcwd(fname, sizeof(fname)) != TRUE)
		fname[0] = '\0';
	bufp = eread("Find alternate file: ", fname, NFILEN,
	    EFNEW | EFCR | EFFILE | EFDEF);
	if (bufp == NULL)
		return (ABORT);
	else if (bufp[0] == '\0')
		return (FALSE);

	status = killbuffer(curbp);
	if (status == ABORT || status == FALSE)
		return (ABORT);

	adjf = adjustname(fname, TRUE);
	if (adjf == NULL)
		return (FALSE);
	if ((bp = findbuffer(adjf)) == NULL)
		return (FALSE);
	curbp = bp;
	if (showbuffer(bp, curwp, WFFULL) != TRUE)
		return (FALSE);
	if (bp->b_fname[0] == '\0') {
		if ((status = readin(adjf)) != TRUE)
			killbuffer(bp);
		return (status);
	}
	return (TRUE);
}
Beispiel #10
0
int
main(int argc, char **argv)
{

	space(0,0,4096,4096);
	init(&xd);
	init(&yd);
	xd.xsize = yd.xsize = 1.;
	xx = (struct val *)malloc((unsigned)sizeof(struct val));
	labsarr = malloc(1);
	labsarr[labsiz++] = 0;
	setopt(argc,argv);
	if(erasf)
		erase();
	readin();
	transpose();
	scale(&xd,(struct val *)&xx->xv);
	scale(&yd,(struct val *)&xx->yv);
	axes();
	title();
	plot();
	move(1,1);
	closevt();
	return(0);
}
Beispiel #11
0
/*
 * dofile:
 *	yank a file into a buffer and execute it
 *	if there are no errors, delete the buffer on exit
 *
 * char *fname;		file name to execute
 */
int dofile(char *fname)
{
	struct buffer *bp;	/* buffer to place file to exeute */
	struct buffer *cb;	/* temp to hold current buf while we read */
	int status;	/* results of various calls */
	char bname[NBUFN];	/* name of buffer */

	makename(bname, fname);	/* derive the name of the buffer */
	unqname(bname);		/* make sure we don't stomp things */
	if ((bp = bfind(bname, TRUE, 0)) == NULL)	/* get the needed buffer */
		return FALSE;

	bp->b_mode = MDVIEW;	/* mark the buffer as read only */
	cb = curbp;		/* save the old buffer */
	curbp = bp;		/* make this one current */
	/* and try to read in the file to execute */
	if ((status = readin(fname)) != TRUE) {
		curbp = cb;	/* restore the current buffer */
		return status;
	}

	/* go execute it! */
	curbp = cb;		/* restore the current buffer */
	if ((status = dobuf(bp)) != TRUE)
		return status;

	/* if not displayed, remove the now unneeded buffer and exit */
	if (bp->b_nwnd == 0)
		zotbuf(bp);
	return TRUE;
}
Beispiel #12
0
int
dorevert(void)
{
	int lineno;
	struct undo_rec *rec;

	if (access(curbp->b_fname, F_OK|R_OK) != 0) {
		dobeep();
		if (errno == ENOENT)
			ewprintf("File %s no longer exists!",
			    curbp->b_fname);
		else
			ewprintf("File %s is no longer readable!",
			    curbp->b_fname);
		return (FALSE);
	}

	/* Save our current line, so we can go back after reloading. */
	lineno = curwp->w_dotline;

	/* Prevent readin from asking if we want to kill the buffer. */
	curbp->b_flag &= ~BFCHG;

	/* Clean up undo memory */
	while ((rec = TAILQ_FIRST(&curbp->b_undo))) {
		TAILQ_REMOVE(&curbp->b_undo, rec, next);
		free_undo_record(rec);
	}

	if (readin(curbp->b_fname))
		return(setlineno(lineno));
	return (FALSE);
}
Beispiel #13
0
int main(void)
{
	char *p = readin("Dataout");
	fprintf(stderr, "p=%s\n", p);
	if (p != NULL)
		free(p);

}
Beispiel #14
0
int getfile(char fname[])
{
  BUFFER *bp;
  LINE *lp;
  char bname[NBUFN];		/* buffer name to put file */
  int i, s;

  for (bp = bheadp; bp != (BUFFER*)0; bp = bp->b_bufp)
    {
      if ((bp->b_flag & BFTEMP) == 0 && strcmp(bp->b_fname, fname) == 0)
	{
	  if (--curbp->b_nwnd == 0)
	    {
	      curbp->b_dotp = curwp->w_dotp;
	      curbp->b_doto = curwp->w_doto;
	      curbp->b_markp = curwp->w_markp;
	      curbp->b_marko = curwp->w_marko;
	    }
	  swbuffer(bp);
	  lp = curwp->w_dotp;
	  i = curwp->w_ntrows / 2;
	  while (i-- && lback(lp) != curbp->b_linep)
	    lp = lback(lp);
	  curwp->w_linep = lp;
	  curwp->w_flag |= WFMODE | WFHARD;
	  mlwrite("[Old buffer]");
	  return (TRUE);
	}
    }
  makename(bname, fname);	/* New buffer name */
  while ((bp = bfind(bname, FALSE, 0)) != (BUFFER*)0)
    {
      s = mlreply("Buffer name: ", bname, NBUFN);
      if (s == ABORT)		/* ^G to just quit */
	return (s);
      if (s == FALSE)
	{			/* CR to clobber it */
	  makename(bname, fname);
	  break;
	}
    }
  if (bp == (BUFFER*)0 && (bp = bfind(bname, TRUE, 0)) == (BUFFER*)0)
    {
      mlwrite("Cannot create buffer");
      return (FALSE);
    }
  if (--curbp->b_nwnd == 0)
    {				/* Undisplay */
      curbp->b_dotp = curwp->w_dotp;
      curbp->b_doto = curwp->w_doto;
      curbp->b_markp = curwp->w_markp;
      curbp->b_marko = curwp->w_marko;
    }
  curbp = bp;			/* Switch to it */
  curwp->w_bufp = bp;
  curbp->b_nwnd++;
  return (readin(fname));	/* Read it in */
}
Beispiel #15
0
int flex_main (int argc, char *argv[])
{
	int     i, exit_status, child_status;

	/* Set a longjmp target. Yes, I know it's a hack, but it gets worse: The
	 * return value of setjmp, if non-zero, is the desired exit code PLUS ONE.
	 * For example, if you want 'main' to return with code '2', then call
	 * longjmp() with an argument of 3. This is because it is invalid to
	 * specify a value of 0 to longjmp. FLEX_EXIT(n) should be used instead of
	 * exit(n);
	 */
	exit_status = setjmp (flex_main_jmp_buf);
	if (exit_status){
        if (stdout && !_stdout_closed && !ferror(stdout)){
            fflush(stdout);
            fclose(stdout);
        }
        while (wait(&child_status) > 0){
            if (!WIFEXITED (child_status)
                || WEXITSTATUS (child_status) != 0){
                /* report an error of a child
                 */
                if( exit_status <= 1 )
                    exit_status = 2;

            }
        }
        return exit_status - 1;
    }

	flexinit (argc, argv);

	readin ();

	skelout ();
	/* %% [1.5] DFA */
	ntod ();

	for (i = 1; i <= num_rules; ++i)
		if (!rule_useful[i] && i != default_rule)
			line_warning (_("rule cannot be matched"),
				      rule_linenum[i]);

	if (spprdflt && !reject && rule_useful[default_rule])
		line_warning (_
			      ("-s option given but default rule can be matched"),
			      rule_linenum[default_rule]);

	/* Generate the C state transition tables from the DFA. */
	make_tables ();

	/* Note, flexend does not return.  It exits with its argument
	 * as status.
	 */
	flexend (0);

	return 0;		/* keep compilers/lint happy */
}
Beispiel #16
0
/*
 * Read a file into the current buffer. This is really easy; all you do it
 * find the name of the file, and call the standard "read a file into the
 * current buffer" code. Bound to "C-X C-R"
 */
int fileread(int f, int n)
{
  int s;
  char fname[NFILEN];

  if ((s = mlreply("Read file: ", fname, NFILEN)) != TRUE)
    return (s);
  return (readin(fname));
}
int main(){
	
	int c=1;
	int i,m1,m2;
	while(scanf("%d%d",&m1,&m2)==2){
		if(m1==-1&&m2==-1)
			break;

		memset(&count,0,sizeof(count));
		memset(&connect,false,sizeof(connect));
		ptr=0;

		if(m1==0&&m2==0)
			printf("Case %d is a tree.\n",c++);
		else{
			readin(m1,m2);
			while(true){
				scanf("%d%d",&m1,&m2);
				if(m1==0&&m2==0)
					break;
				readin(m1,m2);
			}
			
			int zero_count=0,pos;
			for(i=0;i<ptr;i++)
				if(count[i]==0)
					zero_count++,pos=i;
				else if(count[i]>1)
					break;
			if(zero_count==1&&i>=ptr){
				int t=0;
				travel(pos,&t);
				if(t==ptr)
					printf("Case %d is a tree.\n",c++);
				else
					printf("Case %d is not a tree.\n",c++);
			}
			else
				printf("Case %d is not a tree.\n",c++);
		}
	}
	return 0;
}
Beispiel #18
0
void Disp::doRun()
{
    if(FALSE == readin()) {
        cerr << "readin failed.\n";
        return;
    } else {
        uint64_t bits = 0;
        output(bits);
    }
}
Beispiel #19
0
/*
 * Read a file into the current
 * buffer. This is really easy; all you do it
 * find the name of the file, and call the standard
 * "read a file into the current buffer" code.
 * Bound to "C-X C-R".
 */
fileread(f, n)
{
        register int    s;
        char            fname[NFILEN];

	fname[0] = 0;
        if ((s=mlreply("Read file: ", fname, NFILEN)) != TRUE)
                return (s);
        return (readin(fname));
}
Beispiel #20
0
/*
 * Read a file into the current
 * buffer. This is really easy; all you do it
 * find the name of the file, and call the standard
 * "read a file into the current buffer" code.
 * Bound to "C-X C-R".
 */
int fileread(int f, int n)
{
	int s;
	char fname[NFILEN];

	if (restflag)		/* don't allow this command if restricted */
		return resterr();
	if ((s = mlreply("Read file: ", fname, NFILEN)) != TRUE)
		return s;
	return readin(fname, TRUE);
}
Beispiel #21
0
/*
 * getfile()
 *
 * char fname[];	file name to find
 * int lockfl;		check the file for locks?
 */
int getfile(char *fname, int lockfl)
{
	struct buffer *bp;
	struct line *lp;
	int i;
	int s;
	char bname[NBUFN];	/* buffer name to put file */

#if	MSDOS
	mklower(fname);		/* msdos isn't case sensitive */
#endif
	for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
		if ((bp->b_flag & BFINVS) == 0
		    && strcmp(bp->b_fname, fname) == 0) {
			swbuffer(bp);
			lp = curwp->w_dotp;
			i = curwp->w_ntrows / 2;
			while (i-- && lback(lp) != curbp->b_linep)
				lp = lback(lp);
			curwp->w_linep = lp;
			curwp->w_flag |= WFMODE | WFHARD;
			cknewwindow();
			mlwrite("(Old buffer)");
			return TRUE;
		}
	}
	makename(bname, fname);	/* New buffer name.     */
	while ((bp = bfind(bname, FALSE, 0)) != NULL) {
		/* old buffer name conflict code */
		s = mlreply("Buffer name: ", bname, NBUFN);
		if (s == ABORT)	/* ^G to just quit      */
			return s;
		if (s == FALSE) {	/* CR to clobber it     */
			makename(bname, fname);
			break;
		}
	}
	if (bp == NULL && (bp = bfind(bname, TRUE, 0)) == NULL) {
		mlwrite("Cannot create buffer");
		return FALSE;
	}
	if (--curbp->b_nwnd == 0) {	/* Undisplay.           */
		curbp->b_dotp = curwp->w_dotp;
		curbp->b_doto = curwp->w_doto;
		curbp->b_markp = curwp->w_markp;
		curbp->b_marko = curwp->w_marko;
	}
	curbp = bp;		/* Switch to it.        */
	curwp->w_bufp = bp;
	curbp->b_nwnd++;
	s = readin(fname, lockfl);	/* Read it in.          */
	cknewwindow();
	return s;
}
Beispiel #22
0
/*
 * Read a file into the current
 * buffer. This is really easy; all you do it
 * find the name of the file, and call the standard
 * "read a file into the current buffer" code.
 * Bound to "C-X C-R".
 */
fileread(f, n)
{
        register int    s;
        char fname[NFILEN];

	if (restflag)		/* don't allow this command if restricted */
		return(resterr());
        if ((s=mlreply("Read file: ", fname, NFILEN)) != TRUE)
                return(s);
        return(readin(fname, TRUE));
}
Beispiel #23
0
void main(void)
{
record r[100];
int i, j;

	j=readin(r);

	dasort(r, j);
	printf("%-25s%-14s%3s\n", "Name", "ID", "Age");
	for(i=0; i<j; i++)
		printrec(r[i]);
}
Beispiel #24
0
int main(){
//	char treeA[]={'1','2','V','3','V','4','V','5','V','6','V','7','V','8','V','9','V','a','V','b','V','c','V','d','V','e','V','f','V','g','V','i','V','j','V','k','V','l','V'};
//	char treeB[]={'1','2','H','3','H','4','H','5','H','6','H','7','H','8','H','9','H','a','H','b','H','c','H','d','H','e','H','f','H','g','H','i','H','j','H','k','H','l','H'};
//	char treeC[]={'2','1','3','5','4','6','H','7','V','H','V','a','8','V','9','H','c','V','H','g','H','i','b','d','H','k','V','H','f','e','H','V','l','H','V','j','H','V','H'};
//	char value[]={'1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','i','j','k','l'};
	//double areaNode[]={13.60, 3.69, 16.71, 1.87, 5.29, 2.06, 17.80, 4.35, 16.86, 1.96, 15.19, 11.20, 11.48, 10.61, 19.72, 19.37, 2.64, 7.22, 3.18, 10.35}; 
	//double ratio[]={0.52, 0.30, 0.50,  0.35, 1.15, 0.70,  0.25, 0.55,  0.75, 1.07,  0.36,  1.88,  0.51,  0.25,  0.28,  0.42, 0.56, 0.45, 0.25,  0.45};
	vector <double> right, left;
	vector <double> width, height;
	vector <char> value, Polish;
	int size;
	double area;
	readin(value, width, height);// reads in values from files
	Polish.push_back(value[0]);
	for(int z=1; z<value.size(); z++)
		{
			Polish.push_back(value[z]);
			Polish.push_back('V');
		}

//	for(int y=0; y<Polish.size(); y++)
//		{
//			cout<<Polish[y]<<" ";
//		}
	node *root=new node;//creates a node for the base of tree
	root->right=NULL;
	root->left=NULL;
	//size=sizeof(treeA)-1;
	size=Polish.size()-1;
	createTree(root, size , Polish);
	//size=sizeof(treeA);
	size=Polish.size();
	assignValues(value, width, height, root);
//	checkTosee (root); 
	area=areaFunct(right,left, root);
	cout<<"AREA of A:"<<area;
/*	size = sizeof(treeB)-1;
	createTree(root, size, treeB);
	size=sizeof(treeB);
	assignValues(value, width, height, root );
	area=areaFunct(right,left, root);
	cout<<"AREA of B:"<<area;
	size = sizeof(treeC)-1;
	createTree(root, size, treeC);
	size=sizeof(treeC);
	assignValues(value, width, height, root);
	area=areaFunct(right,left, root);
	cout<<"AREA of C:"<<area; */

	annealingFunc(Polish, value, width,height);
	return 0;
}
Beispiel #25
0
int main( int argc , char** argv , char** envp ){

	
	//initHerstory();

	int opt;

	/* Check for file */
	if(argv[1] != NULL && argv[1][0] != '-'){ /* first argument exists and isnt a flag */
		command* c = calloc(1, sizeof(command));
		c->argv[1] = argv[1];
		sh( c );
		exit(0);
	}

	while ((opt = getopt(argc, argv, "d")) != -1) {
		switch (opt) {
			case 'd':
				debug = TRUE;
				fprintf(stderr, "%s\n", "<Entering debugging mode>");
			break;
			default: /* '?' */
				fprintf(stderr, "Usage: %s [-d] (debugging)\n",argv[0]);
				exit(EXIT_FAILURE);
		}
	}


	int running = TRUE;
	char* input = calloc(MAX_INPUT, sizeof(char));
	process* pro;
	while(running){
		printPrompt();
		input = readin(stdin);
		if(input[0] != '\0'){
			pro = parse_cmd(input);
			///addToHistory(pro->original);
			running = runProcess(pro);
		}
	}
	command* cur = pro->head;
	while(cur != NULL){
		command* next = cur->next;
		free(cur);
		cur = next;
	}
	free(pro);

	return 0;
}
Beispiel #26
0
/*ARGSUSED*/
filevisit(f, n)
{
	register BUFFER *bp;
	int	s;
	char	fname[NFILEN];
	char	*adjf;

	if ((s=ereply("Find file: ", fname, NFILEN)) != TRUE)
		return s;
	adjf = adjustname(fname);
	if ((bp = findbuffer(adjf)) == NULL) return FALSE;
	curbp = bp;
	if (showbuffer(bp, curwp, WFHARD) != TRUE) return FALSE;
	if (bp->b_fname[0] == 0)
		return readin(adjf);		/* Read it in.		*/
	return TRUE;
}
Beispiel #27
0
/*
 * make buffer BP current
 */
int swbuffer (BUFFER *bp)
{
  WINDOW *wp;

  if (--curbp->b_nwnd == 0)
    {				/* Last use. */
      curbp->b_dotp = curwp->w_dotp;
      curbp->b_doto = curwp->w_doto;
      curbp->b_markp = curwp->w_markp;
      curbp->b_marko = curwp->w_marko;
    }
  curbp = bp;			/* Switch. */
  if (curbp->b_active != TRUE)
    {				/* buffer not active yet */
      /* read it in and activate it */
      readin (curbp->b_fname);
      curbp->b_dotp = lforw (curbp->b_linep);
      curbp->b_doto = 0;
      curbp->b_active = TRUE;
    }
  curwp->w_bufp = bp;
  curwp->w_linep = bp->b_linep;	/* For macros, ignored */
  curwp->w_flag |= WFMODE | WFFORCE | WFHARD; /* Quite nasty */
  if (bp->b_nwnd++ == 0)
    {				/* First use */
      curwp->w_dotp = bp->b_dotp;
      curwp->w_doto = bp->b_doto;
      curwp->w_markp = bp->b_markp;
      curwp->w_marko = bp->b_marko;
      return (TRUE);
    }
  wp = wheadp;			/* Look for old */
  while (wp != 0)
    {
      if (wp != curwp && wp->w_bufp == bp)
	{
	  curwp->w_dotp = wp->w_dotp;
	  curwp->w_doto = wp->w_doto;
	  curwp->w_markp = wp->w_markp;
	  curwp->w_marko = wp->w_marko;
	  break;
	}
      wp = wp->w_wndp;
    }
  return (TRUE);
}
Beispiel #28
0
int filenext(f,n)
{	int s;
	extern int gargi,gargc;
	extern char **gargv;

	if (filesave(f,n) == FALSE)	/* save current file		*/
		return FALSE;
	if (gargi < gargc)		/* if more files on command line */
	{
		s = readin(gargv[gargi]);
		gargi++;
	}
	else				/* get file name from user	*/
		s = fileread(f,n);
	makename(curbp->b_bname,curbp->b_fname);
	return s;
}
Beispiel #29
0
int loadrep(char *inst_name)
{
    char buf[BUFSIZE];
    FILE *fp;
    extern XFORM *global_transform;
    XFORM *save_transform;

    DB_TAB *ed_rep;
    int retval=1;
    char *save_rep;

    BOUNDS bb;

    if ((ed_rep = db_lookup(inst_name)) == NULL) {	/* not in memory */

	snprintf(buf, MAXFILENAME, "./cells/%s.d", inst_name);
	if((fp = fopen(buf, "r")) == 0) { 		/* cannot find copy on disk */	
	    retval=0;
	} else { 					/* found it on disk, read it in */	

	    if (currep != NULL) {
		save_rep=strsave(currep->name);
	    } else {
		save_rep=NULL;
	    }

	    currep =  db_install(inst_name);  		/* create blank stub */
	    readin(buf, 1, EDI, NULL);
	    currep->modified = 0;

    	    bb.init=0;
	    save_transform = global_transform;
	    db_render(currep, 0, &bb, D_READIN); 	/* set boundbox, etc */
	    global_transform = save_transform;

	    if (save_rep != NULL) {
		currep=db_lookup(save_rep);
		free(save_rep);
	    } else {
		currep=NULL;
	    }
	}
    }
    return(retval);
}
Beispiel #30
0
/*
 * make buffer BP current
 */
int swbuffer(struct buffer *bp)
{
	struct window *wp;

	if (--curbp->b_nwnd == 0) {	/* Last use.            */
		curbp->b_dotp = curwp->w_dotp;
		curbp->b_doto = curwp->w_doto;
		curbp->b_markp = curwp->w_markp;
		curbp->b_marko = curwp->w_marko;
	}
	curbp = bp;		/* Switch.              */
	if (curbp->b_active != TRUE) {	/* buffer not active yet */
		/* read it in and activate it */
		readin(curbp->b_fname);
		curbp->b_dotp = lforw(curbp->b_linep);
		curbp->b_doto = 0;
		curbp->b_active = TRUE;
		curbp->b_mode |= gmode;	/* P.K. */
	}
	curwp->w_bufp = bp;
	curwp->w_linep = bp->b_linep;	/* For macros, ignored. */
	curwp->w_flag |= WFMODE | WFFORCE | WFHARD;	/* Quite nasty.         */
	if (bp->b_nwnd++ == 0) {	/* First use.           */
		curwp->w_dotp = bp->b_dotp;
		curwp->w_doto = bp->b_doto;
		curwp->w_markp = bp->b_markp;
		curwp->w_marko = bp->b_marko;
		cknewwindow();
		return TRUE;
	}
	wp = wheadp;		/* Look for old.        */
	while (wp != NULL) {
		if (wp != curwp && wp->w_bufp == bp) {
			curwp->w_dotp = wp->w_dotp;
			curwp->w_doto = wp->w_doto;
			curwp->w_markp = wp->w_markp;
			curwp->w_marko = wp->w_marko;
			break;
		}
		wp = wp->w_wndp;
	}
	cknewwindow();
	return TRUE;
}