comparison src/core/ngx_hash.c @ 2136:7a7c9e9024dd

ngx_hash_strlow()
author Igor Sysoev <igor@sysoev.ru>
date Mon, 04 Aug 2008 10:18:36 +0000
parents 8c6521eedf84
children deaa4cabecdc
comparison
equal deleted inserted replaced
2135:8c6521eedf84 2136:7a7c9e9024dd
618 618
619 return key; 619 return key;
620 } 620 }
621 621
622 622
623 ngx_uint_t
624 ngx_hash_strlow(u_char *dst, u_char *src, size_t n)
625 {
626 ngx_uint_t key;
627
628 key = 0;
629
630 while (n--) {
631 *dst = ngx_tolower(*src);
632 key = ngx_hash(key, *dst);
633 dst++;
634 src++;
635 }
636
637 return key;
638 }
639
640
623 ngx_int_t 641 ngx_int_t
624 ngx_hash_keys_array_init(ngx_hash_keys_arrays_t *ha, ngx_uint_t type) 642 ngx_hash_keys_array_init(ngx_hash_keys_arrays_t *ha, ngx_uint_t type)
625 { 643 {
626 ngx_uint_t asize; 644 ngx_uint_t asize;
627 645
792 810
793 wildcard: 811 wildcard:
794 812
795 /* wildcard hash */ 813 /* wildcard hash */
796 814
797 k = 0; 815 k = ngx_hash_strlow(&key->data[skip], &key->data[skip], last - skip);
798
799 for (i = skip; i < last; i++) {
800 key->data[i] = ngx_tolower(key->data[i]);
801 k = ngx_hash(k, key->data[i]);
802 }
803 816
804 k %= ha->hsize; 817 k %= ha->hsize;
805 818
806 if (skip == 1) { 819 if (skip == 1) {
807 820