Mercurial > hg > nginx
comparison src/core/ngx_string.c @ 3238:415400fa0f10 stable-0.7
merge r2920, r2934, r3116, r3119:
style fixes
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 26 Oct 2009 16:06:11 +0000 |
parents | 4b5cf483c6a8 |
children | 616ff375a68f |
comparison
equal
deleted
inserted
replaced
3237:2efa8d2fcde1 | 3238:415400fa0f10 |
---|---|
28 { | 28 { |
29 if (n == 0) { | 29 if (n == 0) { |
30 return dst; | 30 return dst; |
31 } | 31 } |
32 | 32 |
33 for ( /* void */ ; --n; dst++, src++) { | 33 while (--n) { |
34 *dst = *src; | 34 *dst = *src; |
35 | 35 |
36 if (*dst == '\0') { | 36 if (*dst == '\0') { |
37 return dst; | 37 return dst; |
38 } | 38 } |
39 | |
40 dst++; | |
41 src++; | |
39 } | 42 } |
40 | 43 |
41 *dst = '\0'; | 44 *dst = '\0'; |
42 | 45 |
43 return dst; | 46 return dst; |
563 | 566 |
564 for ( ;; ) { | 567 for ( ;; ) { |
565 c1 = (ngx_uint_t) *s1++; | 568 c1 = (ngx_uint_t) *s1++; |
566 c2 = (ngx_uint_t) *s2++; | 569 c2 = (ngx_uint_t) *s2++; |
567 | 570 |
568 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; | 571 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; |
569 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; | 572 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; |
570 | 573 |
571 if (c1 == c2) { | 574 if (c1 == c2) { |
572 | 575 |
573 if (c1) { | 576 if (c1) { |
574 continue; | 577 continue; |
589 | 592 |
590 while (n) { | 593 while (n) { |
591 c1 = (ngx_uint_t) *s1++; | 594 c1 = (ngx_uint_t) *s1++; |
592 c2 = (ngx_uint_t) *s2++; | 595 c2 = (ngx_uint_t) *s2++; |
593 | 596 |
594 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; | 597 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; |
595 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; | 598 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; |
596 | 599 |
597 if (c1 == c2) { | 600 if (c1 == c2) { |
598 | 601 |
599 if (c1) { | 602 if (c1) { |
600 n--; | 603 n--; |
678 ngx_strcasestrn(u_char *s1, char *s2, size_t n) | 681 ngx_strcasestrn(u_char *s1, char *s2, size_t n) |
679 { | 682 { |
680 ngx_uint_t c1, c2; | 683 ngx_uint_t c1, c2; |
681 | 684 |
682 c2 = (ngx_uint_t) *s2++; | 685 c2 = (ngx_uint_t) *s2++; |
683 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; | 686 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; |
684 | 687 |
685 do { | 688 do { |
686 do { | 689 do { |
687 c1 = (ngx_uint_t) *s1++; | 690 c1 = (ngx_uint_t) *s1++; |
688 | 691 |
689 if (c1 == 0) { | 692 if (c1 == 0) { |
690 return NULL; | 693 return NULL; |
691 } | 694 } |
692 | 695 |
693 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; | 696 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; |
694 | 697 |
695 } while (c1 != c2); | 698 } while (c1 != c2); |
696 | 699 |
697 } while (ngx_strncasecmp(s1, (u_char *) s2, n) != 0); | 700 } while (ngx_strncasecmp(s1, (u_char *) s2, n) != 0); |
698 | 701 |
710 ngx_strlcasestrn(u_char *s1, u_char *last, u_char *s2, size_t n) | 713 ngx_strlcasestrn(u_char *s1, u_char *last, u_char *s2, size_t n) |
711 { | 714 { |
712 ngx_uint_t c1, c2; | 715 ngx_uint_t c1, c2; |
713 | 716 |
714 c2 = (ngx_uint_t) *s2++; | 717 c2 = (ngx_uint_t) *s2++; |
715 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; | 718 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; |
716 last -= n; | 719 last -= n; |
717 | 720 |
718 do { | 721 do { |
719 do { | 722 do { |
720 if (s1 >= last) { | 723 if (s1 >= last) { |
721 return NULL; | 724 return NULL; |
722 } | 725 } |
723 | 726 |
724 c1 = (ngx_uint_t) *s1++; | 727 c1 = (ngx_uint_t) *s1++; |
725 | 728 |
726 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; | 729 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; |
727 | 730 |
728 } while (c1 != c2); | 731 } while (c1 != c2); |
729 | 732 |
730 } while (ngx_strncasecmp(s1, s2, n) != 0); | 733 } while (ngx_strncasecmp(s1, s2, n) != 0); |
731 | 734 |
1335 | 1338 |
1336 if (dst == NULL) { | 1339 if (dst == NULL) { |
1337 | 1340 |
1338 /* find the number of the characters to be escaped */ | 1341 /* find the number of the characters to be escaped */ |
1339 | 1342 |
1340 n = 0; | 1343 n = 0; |
1341 | 1344 |
1342 for (i = 0; i < size; i++) { | 1345 for (i = 0; i < size; i++) { |
1343 if (escape[*src >> 5] & (1 << (*src & 0x1f))) { | 1346 if (escape[*src >> 5] & (1 << (*src & 0x1f))) { |
1344 n++; | 1347 n++; |
1345 } | 1348 } |