Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/1104/9

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


64-bit safe.
 [rsc] --rw-rw-r-- M 323293 glenda sys 13457 Nov  4 08:15 sys/src/cmd/bc.y
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:6,13 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:6,13
	  	#define	bsp_max	5000
	  
	  	Biobuf	*in;
	- 	Biobuf	stdin;
	- 	Biobuf	stdout;
	+ 	Biobuf	bstdin;
	+ 	Biobuf	bstdout;
	  	char	cary[1000];
	  	char*	cp = { cary };
	  	char	string[1000];
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:17,23 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:17,23
	  	int	bindx = 0;
	  	int	lev = 0;
	  	int	ln;
	- 	int*	ttp;
	+ 	char*	ttp;
	  	char*	ss = "";
	  	int	bstack[10] = { 0 };
	  	char*	numb[15] =
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:26,33 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:26,33
	  		" 6", " 7", " 8", " 9", " 10", " 11",
	  		" 12", " 13", " 14"
	  	};
	- 	int*	pre;
	- 	int*	post;
	+ 	char*	pre;
	+ 	char*	post;
	  
	  	long	peekc = -1;
	  	int	sargc;
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:59,81 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:59,81
	  		"u","v","w","x","y","z"
	  	};
	  	char*	dot = { "." };
	- 	int	bspace[bsp_max];
	- 	int*	bsp_nxt = { bspace };
	+ 	char*	bspace[bsp_max];
	+ 	char**	bsp_nxt = bspace;
	  	int	bdebug = 0;
	  	int	lflag;
	  	int	cflag;
	  	int	sflag;
	  
	- 	int*	bundle(int, ...);
	- 	void	conout(int*, char*);
	+ 	char*	bundle(int, ...);
	+ 	void	conout(char*, char*);
	  	int	cpeek(int, int, int);
	  	int	getch(void);
	- 	int*	geta(char*);
	- 	int*	getf(char*);
	+ 	char*	geta(char*);
	+ 	char*	getf(char*);
	  	void	getout(void);
	- 	void	output(int*);
	+ 	void	output(char*);
	  	void	pp(char*);
	- 	void	routput(int*);
	+ 	void	routput(char*);
	  	void	tp(char*);
	  	void	yyerror(char*, ...);
	  	int	yyparse(void);
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:86,98 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:86,97
	  %}
	  %union
	  {
	- 	int*	iptr;
	  	char*	cptr;
	  	int	cc;
	  }
	  
	- %type	<iptr>	pstat stat stat1 def slist dlets e ase nase
	- %type	<iptr>	slist re fprefix cargs eora cons constant lora
	+ %type	<cptr>	pstat stat stat1 def slist dlets e ase nase
	+ %type	<cptr>	slist re fprefix cargs eora cons constant lora
	  %type	<cptr>	crs
	  
	  %token	<cptr>	LETTER EQOP _AUTO DOT
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:122,128 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:121,127
	  		ttp = bundle(6, pre, $6, post , "0", numb[lev], "Q");
	  		conout(ttp, (char*)$1);
	  		rcrs = crs;
	- 		output((int*)"");	/* this is horse puk!! */
	+ 		output("");
	  		lev = bindx = 0;
	  	}
	  
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:548,555 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:547,554
	  	_DEFINE LETTER '('
	  	{
	  		$$ = getf($2);
	- 		pre = (int*)"";
	- 		post = (int*)"";
	+ 		pre = (char*)"";
	+ 		post = (char*)"";
	  		lev = 1;
	  		bindx = 0;
	  		bstack[bindx] = 0;
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:791,797 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:790,796
	  	if(ifile > sargc) {
	  		if(ifile >= sargc+2)
	  			getout();
	- 		in = &stdin;
	+ 		in = &bstdin;
	  		Binit(in, 0, OREAD);
	  		ln = 0;
	  		goto loop;
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:807,819 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:806,820
	  	return 0;		/* shut up ken */
	  }
	  
	- int*
	+ char*
	  bundle(int a, ...)
	  {
	- 	int i, *p, *q;
	- 
	- 	p = &a;
	- 	i = *p++;
	+ 	int i;
	+ 	char **q;
	+ 	va_list arg;
	+ 	
	+ 	i = a;
	+ 	va_start(arg, a);
	  	q = bsp_nxt;
	  	if(bdebug)
	  		fprint(2, "bundle %d elements at %lx\n", i, q);
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:820,863 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:821,868
	  	while(i-- > 0) {
	  		if(bsp_nxt >= &bspace[bsp_max])
	  			yyerror("bundling space exceeded");
	- 		*bsp_nxt++ = *p++;
	+ 		*bsp_nxt++ = va_arg(arg, char*);
	  	}
	  	*bsp_nxt++ = 0;
	- 	yyval.iptr = q;
	- 	return q;
	+ 	va_end(arg);
	+ 	yyval.cptr = (char*)q;
	+ 	return (char*)q;
	  }
	  
	  void
	- routput(int *p)
	+ routput(char *p)
	  {
	+ 	char **pp;
	+ 	
	  	if(bdebug)
	  		fprint(2, "routput(%lx)\n", p);
	- 	if(p >= &bspace[0] && p < &bspace[bsp_max]) {
	+ 	if((char**)p >= &bspace[0] && (char**)p < &bspace[bsp_max]) {
	  		/* part of a bundle */
	- 		while(*p != 0)
	- 			routput((int*)(*p++));
	+ 		pp = (char**)p;
	+ 		while(*pp != 0)
	+ 			routput(*pp++);
	  	} else
	- 		Bprint(&stdout, (char*)p);	/* character string */
	+ 		Bprint(&bstdout, p);	/* character string */
	  }
	  
	  void
	- output(int *p)
	+ output(char *p)
	  {
	  	routput(p);
	  	bsp_nxt = &bspace[0];
	- 	Bprint(&stdout, "\n");
	- 	Bflush(&stdout);
	+ 	Bprint(&bstdout, "\n");
	+ 	Bflush(&bstdout);
	  	cp = cary;
	  	crs = rcrs;
	  }
	  
	  void
	- conout(int *p, char *s)
	+ conout(char *p, char *s)
	  {
	- 	Bprint(&stdout, "[");
	+ 	Bprint(&bstdout, "[");
	  	routput(p);
	- 	Bprint(&stdout, "]s%s\n", s);
	- 	Bflush(&stdout);
	+ 	Bprint(&bstdout, "]s%s\n", s);
	+ 	Bflush(&bstdout);
	  	lev--;
	  }
	  
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:866,873 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:871,878
	  {
	  	if(ifile > sargc)
	  		ss = "teletype";
	- 	Bprint(&stdout, "c[%s on line %d, %s]pc\n", s, ln+1, ss);
	- 	Bflush(&stdout);
	+ 	Bprint(&bstdout, "c[%s on line %d, %s]pc\n", s, ln+1, ss);
	+ 	Bflush(&bstdout);
	  	cp = cary;
	  	crs = rcrs;
	  	bindx = 0;
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:880,888 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:885,893
	  {
	  	/* puts the relevant stuff on pre and post for the letter s */
	  	bundle(3, "S", s, pre);
	- 	pre = yyval.iptr;
	+ 	pre = yyval.cptr;
	  	bundle(4, post, "L", s, "s.");
	- 	post = yyval.iptr;
	+ 	post = yyval.cptr;
	  }
	  
	  void
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:890,908 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:895,913
	  {
	  	/* same as pp, but for temps */
	  	bundle(3, "0S", s, pre);
	- 	pre = yyval.iptr;
	+ 	pre = yyval.cptr;
	  	bundle(4, post, "L", s, "s.");
	- 	post = yyval.iptr;
	+ 	post = yyval.cptr;
	  }
	  
	  void
	  yyinit(int argc, char **argv)
	  {
	- 	Binit(&stdout, 1, OWRITE);
	+ 	Binit(&bstdout, 1, OWRITE);
	  	sargv = argv;
	  	sargc = argc - 1;
	  	if(sargc == 0) {
	- 		in = &stdin;
	+ 		in = &bstdin;
	  		Binit(in, 0, OREAD);
	  	} else if((in = Bopen(sargv[1], OREAD)) == 0)
	  		yyerror("cannot open input file");
	/n/sourcesdump/2005/1104/plan9/sys/src/cmd/bc.y:914,934 - 
	/n/sourcesdump/2005/1105/plan9/sys/src/cmd/bc.y:919,939
	  void
	  getout(void)
	  {
	- 	Bprint(&stdout, "q");
	- 	Bflush(&stdout);
	+ 	Bprint(&bstdout, "q");
	+ 	Bflush(&bstdout);
	  	exits(0);
	  }
	  
	- int*
	+ char*
	  getf(char *p)
	  {
	- 	return (int*)funtab[*p - 'a'];
	+ 	return funtab[*p - 'a'];
	  }
	  
	- int*
	+ char*
	  geta(char *p)
	  {
	- 	return (int*)atab[*p - 'a'];
	+ 	return atab[*p - 'a'];
	  }
	  
	  void


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].