summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/l/reject.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/ape/lib/l/reject.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/ape/lib/l/reject.c')
-rwxr-xr-xsys/src/ape/lib/l/reject.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/sys/src/ape/lib/l/reject.c b/sys/src/ape/lib/l/reject.c
new file mode 100755
index 000000000..0b2aa7c5d
--- /dev/null
+++ b/sys/src/ape/lib/l/reject.c
@@ -0,0 +1,57 @@
+#include <libl.h>
+#include <stdio.h>
+
+extern FILE* yyout;
+extern FILE* yyin;
+extern int yyprevious, *yyfnd;
+extern char yyextra[];
+extern char yytext[];
+extern int yyleng;
+
+extern
+struct
+{
+ int *yyaa, *yybb;
+ int *yystops;
+} *yylstate [], **yylsp, **yyolsp;
+
+int yyback(int *p, int m);
+int yyinput(void);
+void yyoutput(int c);
+void yyunput(int c);
+
+int
+yyracc(int m)
+{
+
+ yyolsp = yylsp;
+ if(yyextra[m]) {
+ while(yyback((*yylsp)->yystops, -m) != 1 && yylsp > yylstate) {
+ yylsp--;
+ yyunput(yytext[--yyleng]);
+ }
+ }
+ yyprevious = yytext[yyleng-1];
+ yytext[yyleng] = 0;
+ return m;
+}
+
+int
+yyreject(void)
+{
+ for(; yylsp < yyolsp; yylsp++)
+ yytext[yyleng++] = yyinput();
+ if(*yyfnd > 0)
+ return yyracc(*yyfnd++);
+ while(yylsp-- > yylstate) {
+ yyunput(yytext[yyleng-1]);
+ yytext[--yyleng] = 0;
+ if(*yylsp != 0 && (yyfnd = (*yylsp)->yystops) && *yyfnd > 0)
+ return yyracc(*yyfnd++);
+ }
+ if(yytext[0] == 0)
+ return 0;
+ yyoutput(yyprevious = yyinput());
+ yyleng = 0;
+ return -1;
+}