| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Mongrel
Revision: 1029
Author: normalperson
Date: 14 Jul 2008 20:34:03
Changes:http11: fix Ragel parser to work with Ragel 6.2
The main thing is to not update the parser current state (cs) if
we have an error. The other changes were to revert mistakes
in an attempt at Ragel 6.2 compatibility.
| ... | ...@@ -73,10 +73,9 @@ | |
| 73 | 73 | pe = buffer+len; |
| 74 | 74 | |
| 75 | /* assert(*pe == '\0' && "pointer does not end on NUL"); */ | |
| 75 | assert(*pe == '\0' && "pointer does not end on NUL"); | |
| 76 | 76 | assert(pe - p == len - off && "pointers aren't same distance"); |
| 77 | 77 | |
| 78 | ||
| 79 | 78 | |
| 80 | #line 81 "http11_parser.c" | |
| 79 | #line 80 "http11_parser.c" | |
| 81 | 80 | { |
| 82 | 81 | if ( p == pe ) |
| ... | ...@@ -109,5 +108,5 @@ | |
| 109 | 108 | goto _test_eof2; |
| 110 | 109 | case 2: |
| 111 | #line 112 "http11_parser.c" | |
| 110 | #line 111 "http11_parser.c" | |
| 112 | 111 | switch( (*p) ) { |
| 113 | 112 | case 32: goto tr2; |
| ... | ...@@ -135,5 +134,5 @@ | |
| 135 | 134 | goto _test_eof3; |
| 136 | 135 | case 3: |
| 137 | #line 138 "http11_parser.c" | |
| 136 | #line 137 "http11_parser.c" | |
| 138 | 137 | switch( (*p) ) { |
| 139 | 138 | case 42: goto tr4; |
| ... | ...@@ -159,5 +158,5 @@ | |
| 159 | 158 | goto _test_eof4; |
| 160 | 159 | case 4: |
| 161 | #line 162 "http11_parser.c" | |
| 160 | #line 161 "http11_parser.c" | |
| 162 | 161 | switch( (*p) ) { |
| 163 | 162 | case 32: goto tr8; |
| ... | ...@@ -230,5 +229,5 @@ | |
| 230 | 229 | goto _test_eof5; |
| 231 | 230 | case 5: |
| 232 | #line 233 "http11_parser.c" | |
| 231 | #line 232 "http11_parser.c" | |
| 233 | 232 | if ( (*p) == 72 ) |
| 234 | 233 | goto tr10; |
| ... | ...@@ -242,5 +241,5 @@ | |
| 242 | 241 | goto _test_eof6; |
| 243 | 242 | case 6: |
| 244 | #line 245 "http11_parser.c" | |
| 243 | #line 244 "http11_parser.c" | |
| 245 | 244 | if ( (*p) == 84 ) |
| 246 | 245 | goto st7; |
| ... | ...@@ -328,5 +327,5 @@ | |
| 328 | 327 | goto _test_eof14; |
| 329 | 328 | case 14: |
| 330 | #line 331 "http11_parser.c" | |
| 329 | #line 330 "http11_parser.c" | |
| 331 | 330 | if ( (*p) == 10 ) |
| 332 | 331 | goto st15; |
| ... | ...@@ -380,5 +379,5 @@ | |
| 380 | 379 | goto _test_eof57; |
| 381 | 380 | case 57: |
| 382 | #line 383 "http11_parser.c" | |
| 381 | #line 382 "http11_parser.c" | |
| 383 | 382 | goto st0; |
| 384 | 383 | tr21: |
| ... | ...@@ -396,5 +395,5 @@ | |
| 396 | 395 | goto _test_eof17; |
| 397 | 396 | case 17: |
| 398 | #line 399 "http11_parser.c" | |
| 397 | #line 398 "http11_parser.c" | |
| 399 | 398 | switch( (*p) ) { |
| 400 | 399 | case 33: goto tr23; |
| ... | ...@@ -435,5 +434,5 @@ | |
| 435 | 434 | goto _test_eof18; |
| 436 | 435 | case 18: |
| 437 | #line 438 "http11_parser.c" | |
| 436 | #line 437 "http11_parser.c" | |
| 438 | 437 | switch( (*p) ) { |
| 439 | 438 | case 13: goto tr26; |
| ... | ...@@ -449,5 +448,5 @@ | |
| 449 | 448 | goto _test_eof19; |
| 450 | 449 | case 19: |
| 451 | #line 452 "http11_parser.c" | |
| 450 | #line 451 "http11_parser.c" | |
| 452 | 451 | if ( (*p) == 13 ) |
| 453 | 452 | goto tr29; |
| ... | ...@@ -502,5 +501,5 @@ | |
| 502 | 501 | goto _test_eof20; |
| 503 | 502 | case 20: |
| 504 | #line 505 "http11_parser.c" | |
| 503 | #line 504 "http11_parser.c" | |
| 505 | 504 | switch( (*p) ) { |
| 506 | 505 | case 32: goto tr31; |
| ... | ...@@ -524,5 +523,5 @@ | |
| 524 | 523 | goto _test_eof21; |
| 525 | 524 | case 21: |
| 526 | #line 527 "http11_parser.c" | |
| 525 | #line 526 "http11_parser.c" | |
| 527 | 526 | switch( (*p) ) { |
| 528 | 527 | case 32: goto tr34; |
| ... | ...@@ -546,5 +545,5 @@ | |
| 546 | 545 | goto _test_eof22; |
| 547 | 546 | case 22: |
| 548 | #line 549 "http11_parser.c" | |
| 547 | #line 548 "http11_parser.c" | |
| 549 | 548 | if ( (*p) < 65 ) { |
| 550 | 549 | if ( 48 <= (*p) && (*p) <= 57 ) |
| ... | ...@@ -577,5 +576,5 @@ | |
| 577 | 576 | goto _test_eof24; |
| 578 | 577 | case 24: |
| 579 | #line 580 "http11_parser.c" | |
| 578 | #line 579 "http11_parser.c" | |
| 580 | 579 | switch( (*p) ) { |
| 581 | 580 | case 43: goto st24; |
| ... | ...@@ -602,5 +601,5 @@ | |
| 602 | 601 | goto _test_eof25; |
| 603 | 602 | case 25: |
| 604 | #line 605 "http11_parser.c" | |
| 603 | #line 604 "http11_parser.c" | |
| 605 | 604 | switch( (*p) ) { |
| 606 | 605 | case 32: goto tr8; |
| ... | ...@@ -649,5 +648,5 @@ | |
| 649 | 648 | goto _test_eof28; |
| 650 | 649 | case 28: |
| 651 | #line 652 "http11_parser.c" | |
| 650 | #line 651 "http11_parser.c" | |
| 652 | 651 | switch( (*p) ) { |
| 653 | 652 | case 32: goto tr42; |
| ... | ...@@ -701,5 +700,5 @@ | |
| 701 | 700 | goto _test_eof31; |
| 702 | 701 | case 31: |
| 703 | #line 704 "http11_parser.c" | |
| 702 | #line 703 "http11_parser.c" | |
| 704 | 703 | switch( (*p) ) { |
| 705 | 704 | case 32: goto tr8; |
| ... | ...@@ -752,5 +751,5 @@ | |
| 752 | 751 | goto _test_eof34; |
| 753 | 752 | case 34: |
| 754 | #line 755 "http11_parser.c" | |
| 753 | #line 754 "http11_parser.c" | |
| 755 | 754 | switch( (*p) ) { |
| 756 | 755 | case 32: goto tr53; |
| ... | ...@@ -773,5 +772,5 @@ | |
| 773 | 772 | goto _test_eof35; |
| 774 | 773 | case 35: |
| 775 | #line 776 "http11_parser.c" | |
| 774 | #line 775 "http11_parser.c" | |
| 776 | 775 | switch( (*p) ) { |
| 777 | 776 | case 32: goto tr57; |
| ... | ...@@ -794,5 +793,5 @@ | |
| 794 | 793 | goto _test_eof36; |
| 795 | 794 | case 36: |
| 796 | #line 797 "http11_parser.c" | |
| 795 | #line 796 "http11_parser.c" | |
| 797 | 796 | if ( (*p) < 65 ) { |
| 798 | 797 | if ( 48 <= (*p) && (*p) <= 57 ) |
| ... | ...@@ -1209,7 +1208,8 @@ | |
| 1209 | 1208 | _out: {} |
| 1210 | 1209 | } |
| 1211 | #line 122 "http11_parser.rl" | |
| 1210 | #line 121 "http11_parser.rl" | |
| 1212 | 1211 | |
| 1213 | parser->cs = cs; | |
| 1212 | if (!http_parser_has_error(parser)) | |
| 1213 | parser->cs = cs; | |
| 1214 | 1214 | parser->nread += p - (buffer + off); |
| 1215 | 1215 | |
| ... | ...@@ -1240,4 +1240,4 @@ | |
| 1240 | 1240 | |
| 1241 | 1241 | int http_parser_is_finished(http_parser *parser) { |
| 1242 | return parser->cs >= http_parser_first_final; | |
| 1242 | return parser->cs == http_parser_first_final; | |
| 1243 | 1243 | } |
| ... | ...@@ -115,10 +115,11 @@ | |
| 115 | 115 | pe = buffer+len; |
| 116 | 116 | |
| 117 | /* assert(*pe == '\0' && "pointer does not end on NUL"); */ | |
| 117 | assert(*pe == '\0' && "pointer does not end on NUL"); | |
| 118 | 118 | assert(pe - p == len - off && "pointers aren't same distance"); |
| 119 | 119 | |
| 120 | 120 | %% write exec; |
| 121 | 121 | |
| 122 | parser->cs = cs; | |
| 122 | if (!http_parser_has_error(parser)) | |
| 123 | parser->cs = cs; | |
| 123 | 124 | parser->nread += p - (buffer + off); |
| 124 | 125 | |
| ... | ...@@ -149,4 +150,4 @@ | |
| 149 | 150 | |
| 150 | 151 | int http_parser_is_finished(http_parser *parser) { |
| 151 | return parser->cs >= http_parser_first_final; | |
| 152 | return parser->cs == http_parser_first_final; | |
| 152 | 153 | } |