xref: /plan9/sys/src/ape/lib/l/yyless.c (revision 3e12c5d1bb89fc02707907988834ef147769ddaf)
1 #include	<libl.h>
2 #include	<stdio.h>
3 
4 extern	char	yytext[];
5 extern	int	yyleng;
6 extern	int	yyprevious;
7 
8 void	yyunput(int c);
9 
10 void
yyless(int x)11 yyless(int x)
12 {
13 	char *lastch, *ptr;
14 
15 	lastch = yytext+yyleng;
16 	if(x>=0 && x <= yyleng)
17 		ptr = x + yytext;
18 	else
19 		ptr = (char*)x;
20 	while(lastch > ptr)
21 		yyunput(*--lastch);
22 	*lastch = 0;
23 	if (ptr >yytext)
24 		yyprevious = *--lastch;
25 	yyleng = ptr-yytext;
26 }
27