]> git.lizzy.rs Git - plan9front.git/blob - sys/src/liblex/yyless.c
sed: add -u flag that flushes output buffers before reading in further input
[plan9front.git] / sys / src / liblex / yyless.c
1 #include        <u.h>
2 #include        <libc.h>
3 #include        <stdio.h>
4
5 extern  char    yytext[];
6 extern  int     yyleng;
7 extern  int     yyprevious;
8
9 void    yyunput(int c);
10
11 void
12 yyless(int x)
13 {
14         char *lastch, *ptr;
15
16         lastch = yytext+yyleng;
17         if(x>=0 && x <= yyleng)
18                 ptr = x + yytext;
19         else
20                 ptr = (char*)x;
21         while(lastch > ptr)
22                 yyunput(*--lastch);
23         *lastch = 0;
24         if (ptr >yytext)
25                 yyprevious = lastch[-1];
26         yyleng = ptr-yytext;
27 }