comparison src/core/ngx_hash.c @ 392:34fb3a573548 NGINX_0_7_8

nginx 0.7.8 *) Feature: the ngx_http_xslt_module. *) Feature: the "$arg_..." variables. *) Feature: Solaris directio support. Thanks to Ivan Debnar. *) Bugfix: now if FastCGI server sends a "Location" header line without status line, then nginx uses 302 status code. Thanks to Maxim Dounin.
author Igor Sysoev <http://sysoev.ru>
date Mon, 04 Aug 2008 00:00:00 +0400
parents 984bb0b1399b
children 05981f639d21
comparison
equal deleted inserted replaced
391:4ec606a899d3 392:34fb3a573548
388 elt = (ngx_hash_elt_t *) ((u_char *) buckets[key] + test[key]); 388 elt = (ngx_hash_elt_t *) ((u_char *) buckets[key] + test[key]);
389 389
390 elt->value = names[n].value; 390 elt->value = names[n].value;
391 elt->len = (u_char) names[n].key.len; 391 elt->len = (u_char) names[n].key.len;
392 392
393 for (i = 0; i < names[n].key.len; i++) { 393 ngx_strlow(elt->name, names[n].key.data, names[n].key.len);
394 elt->name[i] = ngx_tolower(names[n].key.data[i]);
395 }
396 394
397 test[key] = (u_short) (test[key] + NGX_HASH_ELT_SIZE(&names[n])); 395 test[key] = (u_short) (test[key] + NGX_HASH_ELT_SIZE(&names[n]));
398 } 396 }
399 397
400 for (i = 0; i < size; i++) { 398 for (i = 0; i < size; i++) {
620 618
621 return key; 619 return key;
622 } 620 }
623 621
624 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
625 ngx_int_t 641 ngx_int_t
626 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)
627 { 643 {
628 ngx_uint_t asize; 644 ngx_uint_t asize;
629 645
794 810
795 wildcard: 811 wildcard:
796 812
797 /* wildcard hash */ 813 /* wildcard hash */
798 814
799 k = 0; 815 k = ngx_hash_strlow(&key->data[skip], &key->data[skip], last - skip);
800
801 for (i = skip; i < last; i++) {
802 key->data[i] = ngx_tolower(key->data[i]);
803 k = ngx_hash(k, key->data[i]);
804 }
805 816
806 k %= ha->hsize; 817 k %= ha->hsize;
807 818
808 if (skip == 1) { 819 if (skip == 1) {
809 820