MCPcopy Create free account
hub / github.com/apache/httpd / atoq

Function atoq

modules/mappers/mod_negotiation.c:363–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361 */
362
363static 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;

Callers 1

get_entryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected