| 361 | */ |
| 362 | |
| 363 | static float atoq(const char *string) |
| 364 | { |
| 365 | if (!string || !*string) { |
| 366 | return 1.0f; |
| 367 | } |
| 368 | |
| 369 | while (apr_isspace(*string)) { |
| 370 | ++string; |
| 371 | } |
| 372 | |
| 373 | /* be tolerant and accept qvalues without leading zero |
| 374 | * (also for backwards compat, where atof() was in use) |
| 375 | */ |
| 376 | if (*string != '.' && *string++ != '0') { |
| 377 | return 1.0f; |
| 378 | } |
| 379 | |
| 380 | if (*string == '.') { |
| 381 | /* better only one division later, than dealing with fscking |
| 382 | * IEEE format 0.1 factors ... |
| 383 | */ |
| 384 | int i = 0; |
| 385 | |
| 386 | if (*++string >= '0' && *string <= '9') { |
| 387 | i += (*string - '0') * 100; |
| 388 | |
| 389 | if (*++string >= '0' && *string <= '9') { |
| 390 | i += (*string - '0') * 10; |
| 391 | |
| 392 | if (*++string > '0' && *string <= '9') { |
| 393 | i += (*string - '0'); |
| 394 | } |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | return (float)i / 1000.0f; |
| 399 | } |
| 400 | |
| 401 | return 0.0f; |
| 402 | } |
| 403 | |
| 404 | /* |
| 405 | * Get a single mime type entry --- one media type and parameters; |