Mercurial > hg > nginx
comparison src/http/modules/ngx_http_charset_filter_module.c @ 1310:33d6c994a0b2
Sun Studio on sparc uses different bit order
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 17 Jul 2007 09:23:23 +0000 |
parents | db7c468c447d |
children | acb9b38cb791 9b047c9e96c1 |
comparison
equal
deleted
inserted
replaced
1309:08c6ee7a1b11 | 1310:33d6c994a0b2 |
---|---|
185 static ngx_int_t | 185 static ngx_int_t |
186 ngx_http_charset_header_filter(ngx_http_request_t *r) | 186 ngx_http_charset_header_filter(ngx_http_request_t *r) |
187 { | 187 { |
188 u_char *ct; | 188 u_char *ct; |
189 ngx_int_t charset, source_charset; | 189 ngx_int_t charset, source_charset; |
190 ngx_str_t *mc, *from, *to; | 190 ngx_str_t *mc, *from, *to, s; |
191 ngx_uint_t n; | 191 ngx_uint_t n; |
192 ngx_http_charset_t *charsets; | 192 ngx_http_charset_t *charsets; |
193 ngx_http_charset_ctx_t *ctx; | 193 ngx_http_charset_ctx_t *ctx; |
194 ngx_http_variable_value_t *vv; | 194 ngx_http_variable_value_t *vv; |
195 ngx_http_charset_loc_conf_t *lcf, *mlcf; | 195 ngx_http_charset_loc_conf_t *lcf, *mlcf; |
254 | 254 |
255 if (vv == NULL || vv->not_found) { | 255 if (vv == NULL || vv->not_found) { |
256 return NGX_ERROR; | 256 return NGX_ERROR; |
257 } | 257 } |
258 | 258 |
259 charset = ngx_http_charset_get_charset(charsets, n, | 259 s.len = vv->len; |
260 (ngx_str_t *) vv); | 260 s.data = vv->data; |
261 | |
262 charset = ngx_http_charset_get_charset(charsets, n, &s); | |
261 } | 263 } |
262 } | 264 } |
263 | 265 |
264 } else { | 266 } else { |
265 ctx = ngx_http_get_module_ctx(r->main, ngx_http_charset_filter_module); | 267 ctx = ngx_http_get_module_ctx(r->main, ngx_http_charset_filter_module); |
301 | 303 |
302 if (vv == NULL || vv->not_found) { | 304 if (vv == NULL || vv->not_found) { |
303 return NGX_ERROR; | 305 return NGX_ERROR; |
304 } | 306 } |
305 | 307 |
306 source_charset = ngx_http_charset_get_charset(charsets, n, | 308 s.len = vv->len; |
307 (ngx_str_t *) vv); | 309 s.data = vv->data; |
310 | |
311 source_charset = ngx_http_charset_get_charset(charsets, n, &s); | |
308 } | 312 } |
309 | 313 |
310 if (charset != NGX_HTTP_NO_CHARSET) { | 314 if (charset != NGX_HTTP_NO_CHARSET) { |
311 return ngx_http_charset_set_charset(r, mcf->charsets.elts, charset, | 315 return ngx_http_charset_set_charset(r, mcf->charsets.elts, charset, |
312 source_charset); | 316 source_charset); |
371 | 375 |
372 static ngx_int_t | 376 static ngx_int_t |
373 ngx_http_charset_get_charset(ngx_http_charset_t *charsets, ngx_uint_t n, | 377 ngx_http_charset_get_charset(ngx_http_charset_t *charsets, ngx_uint_t n, |
374 ngx_str_t *charset) | 378 ngx_str_t *charset) |
375 { | 379 { |
376 size_t len; | |
377 ngx_uint_t i; | 380 ngx_uint_t i; |
378 | 381 |
379 len = charset->len & 0xffff; | |
380 | |
381 for (i = 0; i < n; i++) { | 382 for (i = 0; i < n; i++) { |
382 if (charsets[i].name.len != len) { | 383 if (charsets[i].name.len != charset->len) { |
383 continue; | 384 continue; |
384 } | 385 } |
385 | 386 |
386 if (ngx_strncasecmp(charsets[i].name.data, charset->data, len) == 0) { | 387 if (ngx_strncasecmp(charsets[i].name.data, charset->data, charset->len) |
388 == 0) | |
389 { | |
387 return i; | 390 return i; |
388 } | 391 } |
389 } | 392 } |
390 | 393 |
391 return NGX_HTTP_NO_CHARSET; | 394 return NGX_HTTP_NO_CHARSET; |