Mercurial > hg > nginx-vendor-0-8
comparison src/core/ngx_string.c @ 570:8246d8a2c2be NGINX_0_8_37
nginx 0.8.37
*) Feature: the ngx_http_split_clients_module.
*) Feature: the "map" directive supports keys more than 255 characters.
*) Bugfix: nginx ignored the "private" and "no-store" values in the
"Cache-Control" backend response header line.
*) Bugfix: a "stub" parameter of an "include" SSI directive was not
used, if empty response has 200 status code.
*) Bugfix: if a proxied or FastCGI request was internally redirected to
another proxied or FastCGI location, then a segmentation fault might
occur in a worker process; the bug had appeared in 0.8.33.
Thanks to Yichun Zhang.
*) Bugfix: IMAP connections may hang until they timed out while talking
to Zimbra server.
Thanks to Alan Batie.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 17 May 2010 00:00:00 +0400 |
parents | be4f34123024 |
children | c456a023113c |
comparison
equal
deleted
inserted
replaced
569:19b134bf21c0 | 570:8246d8a2c2be |
---|---|
73 * %[0][width][u][x|X]l long | 73 * %[0][width][u][x|X]l long |
74 * %[0][width|m][u][x|X]i ngx_int_t/ngx_uint_t | 74 * %[0][width|m][u][x|X]i ngx_int_t/ngx_uint_t |
75 * %[0][width][u][x|X]D int32_t/uint32_t | 75 * %[0][width][u][x|X]D int32_t/uint32_t |
76 * %[0][width][u][x|X]L int64_t/uint64_t | 76 * %[0][width][u][x|X]L int64_t/uint64_t |
77 * %[0][width|m][u][x|X]A ngx_atomic_int_t/ngx_atomic_uint_t | 77 * %[0][width|m][u][x|X]A ngx_atomic_int_t/ngx_atomic_uint_t |
78 * %[0][width][.width]f float | 78 * %[0][width][.width]f double, max valid number fits to %18.15f |
79 * %P ngx_pid_t | 79 * %P ngx_pid_t |
80 * %M ngx_msec_t | 80 * %M ngx_msec_t |
81 * %r rlim_t | 81 * %r rlim_t |
82 * %p void * | 82 * %p void * |
83 * %V ngx_str_t * | 83 * %V ngx_str_t * |
141 u_char * | 141 u_char * |
142 ngx_vslprintf(u_char *buf, u_char *last, const char *fmt, va_list args) | 142 ngx_vslprintf(u_char *buf, u_char *last, const char *fmt, va_list args) |
143 { | 143 { |
144 u_char *p, zero; | 144 u_char *p, zero; |
145 int d; | 145 int d; |
146 float f, scale; | 146 double f, scale; |
147 size_t len, slen; | 147 size_t len, slen; |
148 int64_t i64; | 148 int64_t i64; |
149 uint64_t ui64; | 149 uint64_t ui64; |
150 ngx_msec_t ms; | 150 ngx_msec_t ms; |
151 ngx_uint_t width, sign, hex, max_width, frac_width, n; | 151 ngx_uint_t width, sign, hex, max_width, frac_width, n; |
227 switch (*fmt) { | 227 switch (*fmt) { |
228 | 228 |
229 case 'V': | 229 case 'V': |
230 v = va_arg(args, ngx_str_t *); | 230 v = va_arg(args, ngx_str_t *); |
231 | 231 |
232 len = v->len; | 232 len = ngx_min(((size_t) (last - buf)), v->len); |
233 len = (buf + len < last) ? len : (size_t) (last - buf); | |
234 | |
235 buf = ngx_cpymem(buf, v->data, len); | 233 buf = ngx_cpymem(buf, v->data, len); |
236 fmt++; | 234 fmt++; |
237 | 235 |
238 continue; | 236 continue; |
239 | 237 |
240 case 'v': | 238 case 'v': |
241 vv = va_arg(args, ngx_variable_value_t *); | 239 vv = va_arg(args, ngx_variable_value_t *); |
242 | 240 |
243 len = vv->len; | 241 len = ngx_min(((size_t) (last - buf)), vv->len); |
244 len = (buf + len < last) ? len : (size_t) (last - buf); | |
245 | |
246 buf = ngx_cpymem(buf, vv->data, len); | 242 buf = ngx_cpymem(buf, vv->data, len); |
247 fmt++; | 243 fmt++; |
248 | 244 |
249 continue; | 245 continue; |
250 | 246 |
255 while (*p && buf < last) { | 251 while (*p && buf < last) { |
256 *buf++ = *p++; | 252 *buf++ = *p++; |
257 } | 253 } |
258 | 254 |
259 } else { | 255 } else { |
260 len = (buf + slen < last) ? slen : (size_t) (last - buf); | 256 len = ngx_min(((size_t) (last - buf)), slen); |
261 | |
262 buf = ngx_cpymem(buf, p, len); | 257 buf = ngx_cpymem(buf, p, len); |
263 } | 258 } |
264 | 259 |
265 fmt++; | 260 fmt++; |
266 | 261 |
357 } | 352 } |
358 | 353 |
359 break; | 354 break; |
360 | 355 |
361 case 'f': | 356 case 'f': |
362 f = (float) va_arg(args, double); | 357 f = va_arg(args, double); |
363 | 358 |
364 if (f < 0) { | 359 if (f < 0) { |
365 *buf++ = '-'; | 360 *buf++ = '-'; |
366 f = -f; | 361 f = -f; |
367 } | 362 } |
384 | 379 |
385 /* | 380 /* |
386 * (int64_t) cast is required for msvc6: | 381 * (int64_t) cast is required for msvc6: |
387 * it can not convert uint64_t to double | 382 * it can not convert uint64_t to double |
388 */ | 383 */ |
389 ui64 = (uint64_t) ((f - (int64_t) ui64) * scale); | 384 ui64 = (uint64_t) ((f - (int64_t) ui64) * scale + 0.5); |
390 | 385 |
391 buf = ngx_sprintf_num(buf, last, ui64, '0', 0, frac_width); | 386 buf = ngx_sprintf_num(buf, last, ui64, '0', 0, frac_width); |
392 } | 387 } |
393 | 388 |
394 fmt++; | 389 fmt++; |
875 return value; | 870 return value; |
876 } | 871 } |
877 } | 872 } |
878 | 873 |
879 | 874 |
875 /* parse a fixed point number, e.g., ngx_atofp("10.5", 4, 2) returns 1050 */ | |
876 | |
877 ngx_int_t | |
878 ngx_atofp(u_char *line, size_t n, size_t point) | |
879 { | |
880 ngx_int_t value; | |
881 ngx_uint_t dot; | |
882 | |
883 if (n == 0) { | |
884 return NGX_ERROR; | |
885 } | |
886 | |
887 dot = 0; | |
888 | |
889 for (value = 0; n--; line++) { | |
890 | |
891 if (point == 0) { | |
892 return NGX_ERROR; | |
893 } | |
894 | |
895 if (*line == '.') { | |
896 if (dot) { | |
897 return NGX_ERROR; | |
898 } | |
899 | |
900 dot = 1; | |
901 continue; | |
902 } | |
903 | |
904 if (*line < '0' || *line > '9') { | |
905 return NGX_ERROR; | |
906 } | |
907 | |
908 value = value * 10 + (*line - '0'); | |
909 point -= dot; | |
910 } | |
911 | |
912 while (point--) { | |
913 value = value * 10; | |
914 } | |
915 | |
916 if (value < 0) { | |
917 return NGX_ERROR; | |
918 | |
919 } else { | |
920 return value; | |
921 } | |
922 } | |
923 | |
924 | |
880 ssize_t | 925 ssize_t |
881 ngx_atosz(u_char *line, size_t n) | 926 ngx_atosz(u_char *line, size_t n) |
882 { | 927 { |
883 ssize_t value; | 928 ssize_t value; |
884 | 929 |