]> granicus.if.org Git - re2c/commitdiff
Added test for bug #46.
authorUlya Trofimovich <skvadrik@gmail.com>
Fri, 26 Sep 2014 21:35:28 +0000 (22:35 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Fri, 26 Sep 2014 21:35:28 +0000 (22:35 +0100)
re2c/test/bug46_infinite_loop.c [new file with mode: 0644]
re2c/test/bug46_infinite_loop.re [new file with mode: 0644]

diff --git a/re2c/test/bug46_infinite_loop.c b/re2c/test/bug46_infinite_loop.c
new file mode 100644 (file)
index 0000000..9fff8ea
--- /dev/null
@@ -0,0 +1,55 @@
+/* Generated by re2c */
+#line 1 "bug46_infinite_loop.re"
+#include <string.h>
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+    char* YYCURSOR = argv[1];
+    char* YYLIMIT  = YYCURSOR + strlen(YYCURSOR);
+    #define YYFILL(n) do { } while(0)
+
+
+#line 14 "<stdout>"
+{
+       unsigned char yych;
+
+#line 13 "bug46_infinite_loop.re"
+       { }
+#line 20 "<stdout>"
+}
+#line 14 "bug46_infinite_loop.re"
+
+
+/* BUG BEGINS HERE */
+
+#line 27 "<stdout>"
+{
+       unsigned char yych;
+       goto yy3;
+yy4:
+       ++YYCURSOR;
+yy3:
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy7;
+       case 'b':
+       case 'c':       goto yy6;
+       default:        goto yy4;
+       }
+yy6:
+#line 18 "bug46_infinite_loop.re"
+       { printf("exit 0\n"); return 0; }
+#line 45 "<stdout>"
+yy7:
+       ++YYCURSOR;
+       yych = *YYCURSOR;
+       goto yy6;
+}
+#line 19 "bug46_infinite_loop.re"
+
+
+    printf("exit 1\n");
+    return 0;
+}
diff --git a/re2c/test/bug46_infinite_loop.re b/re2c/test/bug46_infinite_loop.re
new file mode 100644 (file)
index 0000000..b32c46b
--- /dev/null
@@ -0,0 +1,23 @@
+#include <string.h>
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+    char* YYCURSOR = argv[1];
+    char* YYLIMIT  = YYCURSOR + strlen(YYCURSOR);
+    #define YYFILL(n) do { } while(0)
+
+/*!re2c
+re2c:define:YYCTYPE = "unsigned char";
+
+""  { } /* dummy rule, must exist for the bug to occur; actual rule is not important */
+*/
+
+/* BUG BEGINS HERE */
+/*!re2c
+[^abc]* "a"? { printf("exit 0\n"); return 0; }
+*/
+
+    printf("exit 1\n");
+    return 0;
+}