Mercurial > hg > nginx-vendor-0-7
comparison src/core/ngx_string.c @ 340:10cc350ed8a1 NGINX_0_6_14
nginx 0.6.14
*) Change: now by default the "echo" SSI command uses entity encoding.
*) Feature: the "encoding" parameter in the "echo" SSI command.
*) Feature: the "access_log" directive may be used inside the
"limit_except" block.
*) Bugfix: if all upstream servers were failed, then all servers had
got weight the was equal one until servers became alive; bug
appeared in 0.6.6.
*) Bugfix: a segmentation fault occurred in worker process if
$date_local and $date_gmt were used outside the
ngx_http_ssi_filter_module.
*) Bugfix: a segmentation fault might occur in worker process if debug
log was enabled.
Thanks to Andrei Nigmatulin.
*) Bugfix: ngx_http_memcached_module did not set
$upstream_response_time.
Thanks to Maxim Dounin.
*) Bugfix: a worker process may got caught in an endless loop, if the
memcached was used.
*) Bugfix: nginx supported low case only "close" and "keep-alive"
values in the "Connection" request header line; bug appeared in
0.6.11.
*) Bugfix: sub_filter did not work with empty substitution.
*) Bugfix: in sub_filter parsing.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 15 Oct 2007 00:00:00 +0400 |
parents | 390b8f8309d6 |
children | 4276c2f1f434 |
comparison
equal
deleted
inserted
replaced
339:d19550b67059 | 340:10cc350ed8a1 |
---|---|
440 return buf; | 440 return buf; |
441 } | 441 } |
442 | 442 |
443 | 443 |
444 /* | 444 /* |
445 * We use ngx_strcasecmp()/ngx_strncasecmp() for 7-bit ASCII string only, | 445 * We use ngx_strcasecmp()/ngx_strncasecmp() for 7-bit ASCII strings only, |
446 * and implement our own ngx_strcasecmp()/ngx_strncasecmp() | 446 * and implement our own ngx_strcasecmp()/ngx_strncasecmp() |
447 * to avoid libc locale overhead. Besides, we use the ngx_uint_t's | 447 * to avoid libc locale overhead. Besides, we use the ngx_uint_t's |
448 * instead of the u_char's, because they are slightly faster. | 448 * instead of the u_char's, because they are slightly faster. |
449 */ | 449 */ |
450 | 450 |
498 | 498 |
499 return c1 - c2; | 499 return c1 - c2; |
500 } | 500 } |
501 | 501 |
502 return 0; | 502 return 0; |
503 } | |
504 | |
505 | |
506 u_char * | |
507 ngx_strnstr(u_char *s1, char *s2, size_t len) | |
508 { | |
509 u_char c1, c2; | |
510 size_t n; | |
511 | |
512 c2 = *(u_char *) s2++; | |
513 | |
514 n = ngx_strlen(s2); | |
515 | |
516 do { | |
517 do { | |
518 if (len-- == 0) { | |
519 return NULL; | |
520 } | |
521 | |
522 c1 = *s1++; | |
523 | |
524 if (c1 == 0) { | |
525 return NULL; | |
526 } | |
527 | |
528 } while (c1 != c2); | |
529 | |
530 if (n > len) { | |
531 return NULL; | |
532 } | |
533 | |
534 } while (ngx_strncmp(s1, (u_char *) s2, n) != 0); | |
535 | |
536 return --s1; | |
537 } | |
538 | |
539 | |
540 /* | |
541 * ngx_strstrn() and ngx_strcasestrn() are intended to search for static | |
542 * substring with known length in null-terminated string. The argument n | |
543 * must be length of the second substring - 1. | |
544 */ | |
545 | |
546 u_char * | |
547 ngx_strstrn(u_char *s1, char *s2, size_t n) | |
548 { | |
549 u_char c1, c2; | |
550 | |
551 c2 = *(u_char *) s2++; | |
552 | |
553 do { | |
554 do { | |
555 c1 = *s1++; | |
556 | |
557 if (c1 == 0) { | |
558 return NULL; | |
559 } | |
560 | |
561 } while (c1 != c2); | |
562 | |
563 } while (ngx_strncmp(s1, (u_char *) s2, n) != 0); | |
564 | |
565 return --s1; | |
566 } | |
567 | |
568 | |
569 u_char * | |
570 ngx_strcasestrn(u_char *s1, char *s2, size_t n) | |
571 { | |
572 ngx_uint_t c1, c2; | |
573 | |
574 c2 = (ngx_uint_t) *s2++; | |
575 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2; | |
576 | |
577 do { | |
578 do { | |
579 c1 = (ngx_uint_t) *s1++; | |
580 | |
581 if (c1 == 0) { | |
582 return NULL; | |
583 } | |
584 | |
585 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1; | |
586 | |
587 } while (c1 != c2); | |
588 | |
589 } while (ngx_strncasecmp(s1, (u_char *) s2, n) != 0); | |
590 | |
591 return --s1; | |
503 } | 592 } |
504 | 593 |
505 | 594 |
506 ngx_int_t | 595 ngx_int_t |
507 ngx_rstrncmp(u_char *s1, u_char *s2, size_t n) | 596 ngx_rstrncmp(u_char *s1, u_char *s2, size_t n) |
1248 *dst = d; | 1337 *dst = d; |
1249 *src = s; | 1338 *src = s; |
1250 } | 1339 } |
1251 | 1340 |
1252 | 1341 |
1342 uintptr_t | |
1343 ngx_escape_html(u_char *dst, u_char *src, size_t size) | |
1344 { | |
1345 u_char ch; | |
1346 ngx_uint_t i, len; | |
1347 | |
1348 if (dst == NULL) { | |
1349 | |
1350 len = 0; | |
1351 | |
1352 for (i = 0; i < size; i++) { | |
1353 switch (*src++) { | |
1354 | |
1355 case '<': | |
1356 len += sizeof("<") - 2; | |
1357 break; | |
1358 | |
1359 case '>': | |
1360 len += sizeof(">") - 2; | |
1361 break; | |
1362 | |
1363 case '&': | |
1364 len += sizeof("&") - 2; | |
1365 break; | |
1366 | |
1367 default: | |
1368 break; | |
1369 } | |
1370 } | |
1371 | |
1372 return (uintptr_t) len; | |
1373 } | |
1374 | |
1375 for (i = 0; i < size; i++) { | |
1376 ch = *src++; | |
1377 | |
1378 switch (ch) { | |
1379 | |
1380 case '<': | |
1381 *dst++ = '&'; *dst++ = 'l'; *dst++ = 't'; *dst++ = ';'; | |
1382 break; | |
1383 | |
1384 case '>': | |
1385 *dst++ = '&'; *dst++ = 'g'; *dst++ = 't'; *dst++ = ';'; | |
1386 break; | |
1387 | |
1388 case '&': | |
1389 *dst++ = '&'; *dst++ = 'a'; *dst++ = 'm'; *dst++ = 'p'; | |
1390 *dst++ = ';'; | |
1391 break; | |
1392 | |
1393 default: | |
1394 *dst++ = ch; | |
1395 break; | |
1396 } | |
1397 } | |
1398 | |
1399 return (uintptr_t) dst; | |
1400 } | |
1401 | |
1402 | |
1253 /* ngx_sort() is implemented as insertion sort because we need stable sort */ | 1403 /* ngx_sort() is implemented as insertion sort because we need stable sort */ |
1254 | 1404 |
1255 void | 1405 void |
1256 ngx_sort(void *base, size_t n, size_t size, | 1406 ngx_sort(void *base, size_t n, size_t size, |
1257 int (*cmp)(const void *, const void *)) | 1407 int (*cmp)(const void *, const void *)) |