Klaus Demo nginx / c1a2b97
allow insertion range if its start or end is the same as existent one Igor Sysoev 13 years ago
1 changed file(s) with 50 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
614614 range[i + 2].end = range[i].end;
615615 range[i + 2].value = range[i].value;
616616
617 range[i].end = (u_short) (s - 1);
618
619617 range[i + 1].start = (u_short) s;
620618 range[i + 1].end = (u_short) e;
621619 range[i + 1].value = ctx->value;
620
621 range[i].end = (u_short) (s - 1);
622
623 goto next;
624 }
625
626 if (s == (ngx_uint_t) range[i].start
627 && e < (ngx_uint_t) range[i].end)
628 {
629 /* shift the range start and insert the new range */
630
631 range = ngx_array_push(a);
632 if (range == NULL) {
633 return NGX_CONF_ERROR;
634 }
635
636 range = a->elts;
637
638 ngx_memcpy(&range[i + 2], &range[i + 1],
639 (a->nelts - 2 - i) * sizeof(ngx_http_geo_range_t));
640
641 range[i + 1].start = (u_short) (e + 1);
642
643 range[i].start = (u_short) s;
644 range[i].end = (u_short) e;
645 range[i].value = ctx->value;
646
647 goto next;
648 }
649
650 if (s > (ngx_uint_t) range[i].start
651 && e == (ngx_uint_t) range[i].end)
652 {
653 /* shift the range end and insert the new range */
654
655 range = ngx_array_push(a);
656 if (range == NULL) {
657 return NGX_CONF_ERROR;
658 }
659
660 range = a->elts;
661
662 ngx_memcpy(&range[i + 2], &range[i + 1],
663 (a->nelts - 2 - i) * sizeof(ngx_http_geo_range_t));
664
665 range[i + 1].start = (u_short) s;
666 range[i + 1].end = (u_short) e;
667 range[i + 1].value = ctx->value;
668
669 range[i].end = (u_short) (s - 1);
622670
623671 goto next;
624672 }