From 40ccc551cfdf686cc9020b54274491d017c75bca Mon Sep 17 00:00:00 2001 From: Dima Ryazanov Date: Mon, 19 Dec 2022 16:34:10 -0800 Subject: [PATCH] Re-generate ngx_http_zip_parsers.c using Ragel 7 No actual changes in the logic --- ngx_http_zip_parsers.c | 950 ++++++++++++++++++++++------------------- 1 file changed, 510 insertions(+), 440 deletions(-) diff --git a/ngx_http_zip_parsers.c b/ngx_http_zip_parsers.c index 4f71def..563cb35 100644 --- a/ngx_http_zip_parsers.c +++ b/ngx_http_zip_parsers.c @@ -1,4 +1,3 @@ - #line 1 "ngx_http_zip_parsers.rl" /* Ragel Parser definitions for mod_zip64 */ @@ -8,114 +7,112 @@ static void ngx_http_zip_file_init(ngx_http_zip_file_t *parsing_file) { - ngx_str_null(&parsing_file->uri); - ngx_str_null(&parsing_file->args); - ngx_str_null(&parsing_file->filename); - ngx_str_null(&parsing_file->filename_utf8); - - parsing_file->header_sent = 0; - parsing_file->trailer_sent = 0; - - parsing_file->crc32 = 0; - parsing_file->size = 0; - - parsing_file->missing_crc32 = 0; - parsing_file->need_zip64 = 0; - parsing_file->need_zip64_offset = 0; - parsing_file->is_directory = 0; + ngx_str_null(&parsing_file->uri); + ngx_str_null(&parsing_file->args); + ngx_str_null(&parsing_file->filename); + ngx_str_null(&parsing_file->filename_utf8); + + parsing_file->header_sent = 0; + parsing_file->trailer_sent = 0; + + parsing_file->crc32 = 0; + parsing_file->size = 0; + + parsing_file->missing_crc32 = 0; + parsing_file->need_zip64 = 0; + parsing_file->need_zip64_offset = 0; + parsing_file->is_directory = 0; } - static ngx_int_t ngx_http_zip_clean_range(ngx_http_zip_range_t *range, - int prefix, int suffix, ngx_http_zip_ctx_t *ctx) +int prefix, int suffix, ngx_http_zip_ctx_t *ctx) { - if (suffix) { - range->end = ctx->archive_size; - range->start = ctx->archive_size - range->start; - } else if (prefix) { - range->end = ctx->archive_size; - } else { - range->end++; - /* - * Download Accelerator sends the last byte position - * that equals to the file length - */ - if (range->end >= ctx->archive_size) { - range->end = ctx->archive_size; - } - } - if (range->start < 0) { - return NGX_ERROR; - } - if (range->start >= ctx->archive_size) { - return NGX_ERROR; - } - return NGX_OK; + if (suffix) { + range->end = ctx->archive_size; + range->start = ctx->archive_size - range->start; + } else if (prefix) { + range->end = ctx->archive_size; + } else { + range->end++; + /* + * Download Accelerator sends the last byte position + * that equals to the file length + */ + if (range->end >= ctx->archive_size) { + range->end = ctx->archive_size; + } + } + if (range->start < 0) { + return NGX_ERROR; + } + if (range->start >= ctx->archive_size) { + return NGX_ERROR; + } + return NGX_OK; } -#line 79 "ngx_http_zip_parsers.c" -static const char _request_actions[] = { - 0, 1, 2, 1, 3, 1, 4, 1, - 6, 1, 7, 1, 8, 1, 9, 2, - 0, 7, 2, 3, 1, 2, 5, 1 - +#line 55 "ngx_http_zip_parsers.c" +static const signed char _request_actions[] = { + 0, 1, 2, 1, 3, 1, 4, 1, + 6, 1, 7, 1, 8, 1, 9, 2, + 0, 7, 2, 3, 1, 2, 5, 1, + 0 }; -static const char _request_key_offsets[] = { - 0, 0, 7, 8, 11, 14, 16, 18, - 19, 26, 27, 28, 31 +static const signed char _request_key_offsets[] = { + 0, 0, 7, 8, 11, 14, 16, 18, + 19, 26, 27, 28, 31, 0 }; static const char _request_trans_keys[] = { - 45, 48, 57, 65, 70, 97, 102, 32, - 32, 48, 57, 32, 48, 57, 32, 63, - 32, 63, 32, 32, 48, 57, 65, 70, - 97, 102, 32, 32, 0, 10, 13, 10, - 13, 45, 48, 57, 65, 70, 97, 102, + 45, 48, 57, 65, 70, 97, 102, 32, + 32, 48, 57, 32, 48, 57, 32, 63, + 32, 63, 32, 32, 48, 57, 65, 70, + 97, 102, 32, 32, 0, 10, 13, 10, + 13, 45, 48, 57, 65, 70, 97, 102, 0 }; -static const char _request_single_lengths[] = { - 0, 1, 1, 1, 1, 2, 2, 1, - 1, 1, 1, 3, 3 -}; - -static const char _request_range_lengths[] = { - 0, 3, 0, 1, 1, 0, 0, 0, - 3, 0, 0, 0, 3 +static const signed char _request_single_lengths[] = { + 0, 1, 1, 1, 1, 2, 2, 1, + 1, 1, 1, 3, 3, 0 }; -static const char _request_index_offsets[] = { - 0, 0, 5, 7, 10, 13, 16, 19, - 21, 26, 28, 30, 34 +static const signed char _request_range_lengths[] = { + 0, 3, 0, 1, 1, 0, 0, 0, + 3, 0, 0, 0, 3, 0 }; -static const char _request_indicies[] = { - 0, 2, 2, 2, 1, 3, 1, 3, - 4, 1, 5, 4, 1, 5, 1, 6, - 8, 9, 7, 11, 10, 3, 12, 12, - 12, 1, 1, 13, 15, 14, 1, 17, - 17, 16, 18, 18, 0, 2, 2, 2, - 1, 0 +static const signed char _request_index_offsets[] = { + 0, 0, 5, 7, 10, 13, 16, 19, + 21, 26, 28, 30, 34, 0 }; -static const char _request_trans_targs[] = { - 2, 0, 8, 3, 4, 5, 6, 6, - 7, 9, 11, 7, 8, 10, 10, 7, - 11, 12, 12 +static const signed char _request_cond_targs[] = { + 2, 8, 8, 8, 0, 3, 0, 3, + 4, 0, 5, 4, 0, 5, 0, 6, + 7, 9, 6, 7, 11, 3, 8, 8, + 8, 0, 0, 10, 7, 10, 0, 12, + 12, 11, 12, 12, 2, 8, 8, 8, + 0, 0, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 0 }; -static const char _request_trans_actions[] = { - 15, 0, 15, 0, 7, 0, 1, 0, - 18, 3, 11, 0, 9, 5, 0, 21, - 0, 13, 0 +static const signed char _request_cond_actions[] = { + 15, 15, 15, 15, 0, 0, 0, 0, + 7, 0, 0, 7, 0, 0, 0, 1, + 18, 3, 0, 0, 11, 0, 9, 9, + 9, 0, 0, 5, 21, 0, 0, 13, + 13, 0, 0, 0, 15, 15, 15, 15, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 13, 0, 0 }; -static const char _request_eof_actions[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 13, 0 +static const signed char _request_eof_trans[] = { + 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 0 }; static const int request_start = 1; @@ -123,271 +120,321 @@ static const int request_start = 1; static const int request_en_main = 1; -#line 78 "ngx_http_zip_parsers.rl" +#line 57 "ngx_http_zip_parsers.rl" ngx_int_t ngx_http_zip_parse_request(ngx_http_zip_ctx_t *ctx) { - int cs; - u_char *p = ctx->unparsed_request.elts; - u_char *pe = p + ctx->unparsed_request.nelts; - u_char *eof = pe; - ngx_http_zip_file_t *parsing_file = NULL; - - -#line 160 "ngx_http_zip_parsers.c" + int cs; + u_char *p = ctx->unparsed_request.elts; + u_char *pe = p + ctx->unparsed_request.nelts; + u_char *eof = pe; + ngx_http_zip_file_t *parsing_file = NULL; + + +#line 132 "ngx_http_zip_parsers.c" { - cs = request_start; + cs = (int)request_start; } -#line 165 "ngx_http_zip_parsers.c" +#line 135 "ngx_http_zip_parsers.c" { - int _klen; - unsigned int _trans; - const char *_acts; - unsigned int _nacts; - const char *_keys; - - if ( p == pe ) - goto _test_eof; - if ( cs == 0 ) - goto _out; -_resume: - _keys = _request_trans_keys + _request_key_offsets[cs]; - _trans = _request_index_offsets[cs]; - - _klen = _request_single_lengths[cs]; - if ( _klen > 0 ) { - const char *_lower = _keys; - const char *_mid; - const char *_upper = _keys + _klen - 1; - while (1) { - if ( _upper < _lower ) - break; - - _mid = _lower + ((_upper-_lower) >> 1); - if ( (*p) < *_mid ) - _upper = _mid - 1; - else if ( (*p) > *_mid ) - _lower = _mid + 1; - else { - _trans += (unsigned int)(_mid - _keys); - goto _match; + int _klen; + unsigned int _trans = 0; + const char * _keys; + const signed char * _acts; + unsigned int _nacts; + _resume: {} + if ( p == pe && p != eof ) + goto _out; + if ( p == eof ) { + if ( _request_eof_trans[cs] > 0 ) { + _trans = (unsigned int)_request_eof_trans[cs] - 1; } } - _keys += _klen; - _trans += _klen; - } - - _klen = _request_range_lengths[cs]; - if ( _klen > 0 ) { - const char *_lower = _keys; - const char *_mid; - const char *_upper = _keys + (_klen<<1) - 2; - while (1) { - if ( _upper < _lower ) - break; - - _mid = _lower + (((_upper-_lower) >> 1) & ~1); - if ( (*p) < _mid[0] ) - _upper = _mid - 2; - else if ( (*p) > _mid[1] ) - _lower = _mid + 2; - else { - _trans += (unsigned int)((_mid - _keys)>>1); - goto _match; + else { + _keys = ( _request_trans_keys + (_request_key_offsets[cs])); + _trans = (unsigned int)_request_index_offsets[cs]; + + _klen = (int)_request_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_upper = _keys + _klen - 1; + const char *_mid; + while ( 1 ) { + if ( _upper < _lower ) { + _keys += _klen; + _trans += (unsigned int)_klen; + break; + } + + _mid = _lower + ((_upper-_lower) >> 1); + if ( ( (*( p))) < (*( _mid)) ) + _upper = _mid - 1; + else if ( ( (*( p))) > (*( _mid)) ) + _lower = _mid + 1; + else { + _trans += (unsigned int)(_mid - _keys); + goto _match; + } + } + } + + _klen = (int)_request_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_upper = _keys + (_klen<<1) - 2; + const char *_mid; + while ( 1 ) { + if ( _upper < _lower ) { + _trans += (unsigned int)_klen; + break; + } + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( ( (*( p))) < (*( _mid)) ) + _upper = _mid - 2; + else if ( ( (*( p))) > (*( _mid + 1)) ) + _lower = _mid + 2; + else { + _trans += (unsigned int)((_mid - _keys)>>1); + break; + } + } } + + _match: {} } - _trans += _klen; - } - -_match: - _trans = _request_indicies[_trans]; - cs = _request_trans_targs[_trans]; - - if ( _request_trans_actions[_trans] == 0 ) - goto _again; - - _acts = _request_actions + _request_trans_actions[_trans]; - _nacts = (unsigned int) *_acts++; - while ( _nacts-- > 0 ) - { - switch ( *_acts++ ) - { - case 0: -#line 91 "ngx_http_zip_parsers.rl" - { - parsing_file = ngx_array_push(&ctx->files); - ngx_http_zip_file_init(parsing_file); - - parsing_file->index = ctx->files.nelts - 1; - } - break; - case 1: + cs = (int)_request_cond_targs[_trans]; + + if ( _request_cond_actions[_trans] != 0 ) { + + _acts = ( _request_actions + (_request_cond_actions[_trans])); + _nacts = (unsigned int)(*( _acts)); + _acts += 1; + while ( _nacts > 0 ) { + switch ( (*( _acts)) ) + { + case 0: { + { +#line 70 "ngx_http_zip_parsers.rl" + + parsing_file = ngx_array_push(&ctx->files); + ngx_http_zip_file_init(parsing_file); + + parsing_file->index = ctx->files.nelts - 1; + } + +#line 222 "ngx_http_zip_parsers.c" + + break; + } + case 1: { + { +#line 77 "ngx_http_zip_parsers.rl" + + if (parsing_file->args.len == 0 + && parsing_file->uri.len == sizeof("@directory") - 1 + && ngx_strncmp(parsing_file->uri.data, "@directory", parsing_file->uri.len) == 0) { + parsing_file->is_directory = 1; + // Directory has no content. + parsing_file->size = 0; + parsing_file->crc32 = 0; + parsing_file->missing_crc32 = 0; + parsing_file->uri.data = NULL; + parsing_file->uri.len = 0; + parsing_file->args.data = NULL; + parsing_file->args.len = 0; + } + } + +#line 244 "ngx_http_zip_parsers.c" + + break; + } + case 2: { + { +#line 93 "ngx_http_zip_parsers.rl" + + parsing_file->uri.data = p; + parsing_file->uri.len = 1; + } + +#line 255 "ngx_http_zip_parsers.c" + + break; + } + case 3: { + { #line 98 "ngx_http_zip_parsers.rl" - { - if (parsing_file->args.len == 0 - && parsing_file->uri.len == sizeof("@directory") - 1 - && ngx_strncmp(parsing_file->uri.data, "@directory", parsing_file->uri.len) == 0) { - parsing_file->is_directory = 1; - // Directory has no content. - parsing_file->size = 0; - parsing_file->crc32 = 0; - parsing_file->missing_crc32 = 0; - parsing_file->uri.data = NULL; - parsing_file->uri.len = 0; - parsing_file->args.data = NULL; - parsing_file->args.len = 0; - } - } - break; - case 2: -#line 114 "ngx_http_zip_parsers.rl" - { - parsing_file->uri.data = p; - parsing_file->uri.len = 1; - } - break; - case 3: -#line 119 "ngx_http_zip_parsers.rl" - { - parsing_file->uri.len = p - parsing_file->uri.data; - } - break; - case 4: -#line 122 "ngx_http_zip_parsers.rl" - { - parsing_file->args.data = p; - } - break; - case 5: -#line 125 "ngx_http_zip_parsers.rl" - { - parsing_file->args.len = p - parsing_file->args.data; - } - break; - case 6: -#line 128 "ngx_http_zip_parsers.rl" - { - parsing_file->size = parsing_file->size * 10 + ((*p) - '0'); - } - break; - case 7: -#line 131 "ngx_http_zip_parsers.rl" - { - if ((*p) == '-') { - ctx->missing_crc32 = 1; - parsing_file->missing_crc32 = 1; - ngx_crc32_init(parsing_file->crc32); - } else { - parsing_file->crc32 *= 16; - parsing_file->crc32 += ngx_hextoi(p, 1); - } - } - break; - case 8: -#line 141 "ngx_http_zip_parsers.rl" - { - parsing_file->filename.data = p; - } - break; - case 9: -#line 144 "ngx_http_zip_parsers.rl" - { - parsing_file->filename.len = p - parsing_file->filename.data; - } - break; + + parsing_file->uri.len = p - parsing_file->uri.data; + } + +#line 265 "ngx_http_zip_parsers.c" + + break; + } + case 4: { + { +#line 101 "ngx_http_zip_parsers.rl" + + parsing_file->args.data = p; + } + +#line 275 "ngx_http_zip_parsers.c" + + break; + } + case 5: { + { +#line 104 "ngx_http_zip_parsers.rl" + + parsing_file->args.len = p - parsing_file->args.data; + } + +#line 285 "ngx_http_zip_parsers.c" + + break; + } + case 6: { + { +#line 107 "ngx_http_zip_parsers.rl" + + parsing_file->size = parsing_file->size * 10 + ((( (*( p)))) - '0'); + } + +#line 295 "ngx_http_zip_parsers.c" + + break; + } + case 7: { + { +#line 110 "ngx_http_zip_parsers.rl" + + if ((( (*( p)))) == '-') { + ctx->missing_crc32 = 1; + parsing_file->missing_crc32 = 1; + ngx_crc32_init(parsing_file->crc32); + } else { + parsing_file->crc32 *= 16; + parsing_file->crc32 += ngx_hextoi(p, 1); + } + } + +#line 312 "ngx_http_zip_parsers.c" + + break; + } + case 8: { + { +#line 120 "ngx_http_zip_parsers.rl" + + parsing_file->filename.data = p; + } + #line 322 "ngx_http_zip_parsers.c" - } - } -_again: - if ( cs == 0 ) - goto _out; - if ( ++p != pe ) - goto _resume; - _test_eof: {} - if ( p == eof ) - { - const char *__acts = _request_actions + _request_eof_actions[cs]; - unsigned int __nacts = (unsigned int) *__acts++; - while ( __nacts-- > 0 ) { - switch ( *__acts++ ) { - case 9: -#line 144 "ngx_http_zip_parsers.rl" - { - parsing_file->filename.len = p - parsing_file->filename.data; - } - break; -#line 344 "ngx_http_zip_parsers.c" + break; + } + case 9: { + { +#line 123 "ngx_http_zip_parsers.rl" + + parsing_file->filename.len = p - parsing_file->filename.data; + } + +#line 332 "ngx_http_zip_parsers.c" + + break; + } + } + _nacts -= 1; + _acts += 1; + } + } + + if ( p == eof ) { + if ( cs >= 11 ) + goto _out; + } + else { + if ( cs != 0 ) { + p += 1; + goto _resume; + } + } + _out: {} } - } + +#line 143 "ngx_http_zip_parsers.rl" - _out: {} + + /* suppress warning */ + (void)request_en_main; + + if (cs < +#line 360 "ngx_http_zip_parsers.c" +11 +#line 148 "ngx_http_zip_parsers.rl" +) { + return NGX_ERROR; } - -#line 164 "ngx_http_zip_parsers.rl" - - - /* suppress warning */ - (void)request_en_main; - - if (cs < 11) { - return NGX_ERROR; - } - - ctx->parsed = 1; - - return NGX_OK; + + ctx->parsed = 1; + + return NGX_OK; } -#line 368 "ngx_http_zip_parsers.c" -static const char _range_actions[] = { - 0, 1, 0, 1, 1, 1, 2, 2, - 0, 1, 2, 3, 1 +#line 370 "ngx_http_zip_parsers.c" +static const signed char _range_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 2, + 0, 1, 2, 3, 1, 0 }; -static const char _range_key_offsets[] = { - 0, 0, 1, 2, 3, 4, 5, 6, - 9, 11, 14, 17 +static const signed char _range_key_offsets[] = { + 0, 0, 1, 2, 3, 4, 5, 6, + 9, 11, 14, 17, 0 }; static const char _range_trans_keys[] = { - 98, 121, 116, 101, 115, 61, 45, 48, - 57, 48, 57, 45, 48, 57, 44, 48, + 98, 121, 116, 101, 115, 61, 45, 48, + 57, 48, 57, 45, 48, 57, 44, 48, 57, 44, 48, 57, 0 }; -static const char _range_single_lengths[] = { - 0, 1, 1, 1, 1, 1, 1, 1, - 0, 1, 1, 1 +static const signed char _range_single_lengths[] = { + 0, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 0 }; -static const char _range_range_lengths[] = { - 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1 +static const signed char _range_range_lengths[] = { + 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 0 }; -static const char _range_index_offsets[] = { - 0, 0, 2, 4, 6, 8, 10, 12, - 15, 17, 20, 23 +static const signed char _range_index_offsets[] = { + 0, 0, 2, 4, 6, 8, 10, 12, + 15, 17, 20, 23, 0 }; -static const char _range_trans_targs[] = { - 2, 0, 3, 0, 4, 0, 5, 0, - 6, 0, 7, 0, 8, 9, 0, 10, - 0, 11, 9, 0, 7, 10, 0, 7, - 11, 0, 0 +static const signed char _range_cond_targs[] = { + 2, 0, 3, 0, 4, 0, 5, 0, + 6, 0, 7, 0, 8, 9, 0, 10, + 0, 11, 9, 0, 7, 10, 0, 7, + 11, 0, 0, 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 0 }; -static const char _range_trans_actions[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 7, 0, 10, - 0, 0, 3, 0, 0, 3, 0, 0, - 5, 0, 0 +static const signed char _range_cond_actions[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 7, 0, 10, + 0, 0, 3, 0, 0, 3, 0, 0, + 5, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 }; static const int range_start = 1; @@ -395,153 +442,176 @@ static const int range_start = 1; static const int range_en_main = 1; -#line 181 "ngx_http_zip_parsers.rl" +#line 160 "ngx_http_zip_parsers.rl" ngx_int_t ngx_http_zip_parse_range(ngx_http_request_t *r, ngx_str_t *range_str, ngx_http_zip_ctx_t *ctx) { - int cs, prefix = 0, suffix = 0; - - ngx_http_zip_range_t *range = NULL; - u_char *p = range_str->data; - u_char *pe = range_str->data + range_str->len; + int cs, prefix = 0, suffix = 0; + + ngx_http_zip_range_t *range = NULL; + u_char *p = range_str->data; + u_char *pe = range_str->data + range_str->len; + - -#line 432 "ngx_http_zip_parsers.c" +#line 433 "ngx_http_zip_parsers.c" { - cs = range_start; + cs = (int)range_start; } -#line 437 "ngx_http_zip_parsers.c" +#line 436 "ngx_http_zip_parsers.c" { - int _klen; - unsigned int _trans; - const char *_acts; - unsigned int _nacts; - const char *_keys; - - if ( p == pe ) - goto _test_eof; - if ( cs == 0 ) - goto _out; -_resume: - _keys = _range_trans_keys + _range_key_offsets[cs]; - _trans = _range_index_offsets[cs]; - - _klen = _range_single_lengths[cs]; - if ( _klen > 0 ) { - const char *_lower = _keys; - const char *_mid; - const char *_upper = _keys + _klen - 1; - while (1) { - if ( _upper < _lower ) - break; - - _mid = _lower + ((_upper-_lower) >> 1); - if ( (*p) < *_mid ) - _upper = _mid - 1; - else if ( (*p) > *_mid ) - _lower = _mid + 1; - else { - _trans += (unsigned int)(_mid - _keys); - goto _match; + int _klen; + unsigned int _trans = 0; + const char * _keys; + const signed char * _acts; + unsigned int _nacts; + _resume: {} + if ( p == pe ) + goto _out; + _keys = ( _range_trans_keys + (_range_key_offsets[cs])); + _trans = (unsigned int)_range_index_offsets[cs]; + + _klen = (int)_range_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_upper = _keys + _klen - 1; + const char *_mid; + while ( 1 ) { + if ( _upper < _lower ) { + _keys += _klen; + _trans += (unsigned int)_klen; + break; + } + + _mid = _lower + ((_upper-_lower) >> 1); + if ( ( (*( p))) < (*( _mid)) ) + _upper = _mid - 1; + else if ( ( (*( p))) > (*( _mid)) ) + _lower = _mid + 1; + else { + _trans += (unsigned int)(_mid - _keys); + goto _match; + } } } - _keys += _klen; - _trans += _klen; - } - - _klen = _range_range_lengths[cs]; - if ( _klen > 0 ) { - const char *_lower = _keys; - const char *_mid; - const char *_upper = _keys + (_klen<<1) - 2; - while (1) { - if ( _upper < _lower ) - break; - - _mid = _lower + (((_upper-_lower) >> 1) & ~1); - if ( (*p) < _mid[0] ) - _upper = _mid - 2; - else if ( (*p) > _mid[1] ) - _lower = _mid + 2; - else { - _trans += (unsigned int)((_mid - _keys)>>1); - goto _match; + + _klen = (int)_range_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_upper = _keys + (_klen<<1) - 2; + const char *_mid; + while ( 1 ) { + if ( _upper < _lower ) { + _trans += (unsigned int)_klen; + break; + } + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( ( (*( p))) < (*( _mid)) ) + _upper = _mid - 2; + else if ( ( (*( p))) > (*( _mid + 1)) ) + _lower = _mid + 2; + else { + _trans += (unsigned int)((_mid - _keys)>>1); + break; + } } } - _trans += _klen; - } - -_match: - cs = _range_trans_targs[_trans]; - - if ( _range_trans_actions[_trans] == 0 ) - goto _again; - - _acts = _range_actions + _range_trans_actions[_trans]; - _nacts = (unsigned int) *_acts++; - while ( _nacts-- > 0 ) - { - switch ( *_acts++ ) - { - case 0: -#line 193 "ngx_http_zip_parsers.rl" - { - if (range) { - if (ngx_http_zip_clean_range(range, prefix, suffix, ctx) == NGX_ERROR) { - return NGX_ERROR; - } - } - if ((range = ngx_array_push(&ctx->ranges)) == NULL) { - return NGX_ERROR; - } - range->start = 0; range->end = 0; range->boundary_sent = 0; - suffix = 0; - prefix = 1; - } - break; - case 1: -#line 207 "ngx_http_zip_parsers.rl" - { range->start = range->start * 10 + ((*p) - '0'); } - break; - case 2: -#line 209 "ngx_http_zip_parsers.rl" - { range->end = range->end * 10 + ((*p) - '0'); prefix = 0; } - break; - case 3: -#line 211 "ngx_http_zip_parsers.rl" - { suffix = 1; } - break; -#line 538 "ngx_http_zip_parsers.c" + + _match: {} + cs = (int)_range_cond_targs[_trans]; + + if ( _range_cond_actions[_trans] != 0 ) { + + _acts = ( _range_actions + (_range_cond_actions[_trans])); + _nacts = (unsigned int)(*( _acts)); + _acts += 1; + while ( _nacts > 0 ) { + switch ( (*( _acts)) ) + { + case 0: { + { +#line 172 "ngx_http_zip_parsers.rl" + + if (range) { + if (ngx_http_zip_clean_range(range, prefix, suffix, ctx) == NGX_ERROR) { + return NGX_ERROR; + } + } + if ((range = ngx_array_push(&ctx->ranges)) == NULL) { + return NGX_ERROR; + } + range->start = 0; range->end = 0; range->boundary_sent = 0; + suffix = 0; + prefix = 1; + } + +#line 523 "ngx_http_zip_parsers.c" + + break; + } + case 1: { + { +#line 186 "ngx_http_zip_parsers.rl" + range->start = range->start * 10 + ((( (*( p)))) - '0'); } + +#line 531 "ngx_http_zip_parsers.c" + + break; + } + case 2: { + { +#line 188 "ngx_http_zip_parsers.rl" + range->end = range->end * 10 + ((( (*( p)))) - '0'); prefix = 0; } + +#line 539 "ngx_http_zip_parsers.c" + + break; + } + case 3: { + { +#line 190 "ngx_http_zip_parsers.rl" + suffix = 1; } + +#line 547 "ngx_http_zip_parsers.c" + + break; + } + } + _nacts -= 1; + _acts += 1; + } + + } + + if ( cs != 0 ) { + p += 1; + goto _resume; } + _out: {} } + +#line 203 "ngx_http_zip_parsers.rl" -_again: - if ( cs == 0 ) - goto _out; - if ( ++p != pe ) - goto _resume; - _test_eof: {} - _out: {} + + /* suppress warning */ + (void)range_en_main; + + if (cs < +#line 569 "ngx_http_zip_parsers.c" +10 +#line 208 "ngx_http_zip_parsers.rl" +) { + return NGX_ERROR; } - -#line 224 "ngx_http_zip_parsers.rl" - - - /* suppress warning */ - (void)range_en_main; - - if (cs < 10) { - return NGX_ERROR; - } - - if (range) { - if (ngx_http_zip_clean_range(range, prefix, suffix, ctx) == NGX_ERROR) { - return NGX_ERROR; - } - } - - return NGX_OK; + + if (range) { + if (ngx_http_zip_clean_range(range, prefix, suffix, ctx) == NGX_ERROR) { + return NGX_ERROR; + } + } + + return NGX_OK; }