8000 Move all data to before code to fix http parser for c89. · zwxalgorithm/http-parser@f1d48aa · GitHub
[go: up one dir, main page]

Skip to content

Commit f1d48aa

Browse files
committed
Move all data to before code to fix http parser for c89.
1 parent c0ecab0 commit f1d48aa

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

http_parser.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,13 @@ size_t http_parser_execute (http_parser *parser,
370370
uint64_t index = parser->index;
371371
uint64_t nread = parser->nread;
372372

373+
/* technically we could combine all of these (except for url_mark) into one
374+
variable, saving stack space, but it seems more clear to have them
375+
separated. */
376+
const char *header_field_mark = 0;
377+
const char *header_value_mark = 0;
378+
const char *url_mark = 0;
379+
373380
/* We're in an error state. Don't bother doing anything. */
374381
if (HTTP_PARSER_ERRNO(parser) != HPE_OK) {
375382
return 0;
@@ -396,12 +403,6 @@ size_t http_parser_execute (http_parser *parser,
396403
}
397404
}
398405

399-
/* technically we could combine all of these (except for url_mark) into one
400-
variable, saving stack space, but it seems more clear to have them
401-
separated. */
402-
const char *header_field_mark = 0;
403-
const char *header_value_mark = 0;
404-
const char *url_mark = 0;
405406

406407
if (state == s_header_field)
407408
header_field_mark = data;
@@ -690,12 +691,13 @@ size_t http_parser_execute (http_parser *parser,
690691

691692
case s_req_method:
692693
{
694+
const char *matcher;
693695
if (ch == '\0') {
694696
SET_ERRNO(HPE_INVALID_METHOD);
695697
goto error;
696698
}
697699

698-
const char *matcher = method_strings[parser->method];
700+
matcher = method_strings[parser->method];
699701
if (ch == ' ' && matcher[index] == '\0') {
700702
state = s_req_spaces_before_url;
701703
} else if (ch == matcher[index]) {

0 commit comments

Comments
 (0)
0