From d547f3b1a98ed07fdcdaf401a8cbc5fffe9bfa6c Mon Sep 17 00:00:00 2001 From: Jay Satiro Date: Mon, 23 Feb 2015 22:38:22 -0500 Subject: [PATCH] url_parser: remove mixed declarations (dump_url) - Remove erroneous quote in output. (main) - Remove mixed declarations for compatibility with pre-c99 compilers like msvc. Reviewed-By: Fedor Indutny PR-URL: https://github.com/joyent/http-parser/pull/224 --- contrib/url_parser.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/contrib/url_parser.c b/contrib/url_parser.c index b1f9c97..6650b41 100644 --- a/contrib/url_parser.c +++ b/contrib/url_parser.c @@ -14,7 +14,7 @@ dump_url (const char *url, const struct http_parser_url *u) continue; } - printf("\tfield_data[%u]: off: %u len: %u part: \"%.*s\n", + printf("\tfield_data[%u]: off: %u, len: %u, part: %.*s\n", i, u->field_data[i].off, u->field_data[i].len, @@ -24,16 +24,18 @@ dump_url (const char *url, const struct http_parser_url *u) } int main(int argc, char ** argv) { + struct http_parser_url u; + int len, connect, result; + if (argc != 3) { printf("Syntax : %s connect|get url\n", argv[0]); return 1; } - struct http_parser_url u; - int len = strlen(argv[2]); - int connect = strcmp("connect", argv[1]) == 0 ? 1 : 0; + len = strlen(argv[2]); + connect = strcmp("connect", argv[1]) == 0 ? 1 : 0; printf("Parsing %s, connect %d\n", argv[2], connect); - int result = http_parser_parse_url(argv[2], len, connect, &u); + result = http_parser_parse_url(argv[2], len, connect, &u); if (result != 0) { printf("Parse error : %d\n", result); return result;