Populate the rangespec according to the objects min and max. */
| 517 | |
| 518 | /* Populate the rangespec according to the objects min and max. */ |
| 519 | static int zslParseRange(robj *min, robj *max, zrangespec *spec) { |
| 520 | char *eptr; |
| 521 | spec->minex = spec->maxex = 0; |
| 522 | |
| 523 | /* Parse the min-max interval. If one of the values is prefixed |
| 524 | * by the "(" character, it's considered "open". For instance |
| 525 | * ZRANGEBYSCORE zset (1.5 (2.5 will match min < x < max |
| 526 | * ZRANGEBYSCORE zset 1.5 2.5 will instead match min <= x <= max */ |
| 527 | if (min->encoding == OBJ_ENCODING_INT) { |
| 528 | spec->min = (long)min->ptr; |
| 529 | } else { |
| 530 | if (((char*)min->ptr)[0] == '(') { |
| 531 | spec->min = strtod((char*)min->ptr+1,&eptr); |
| 532 | if (eptr[0] != '\0' || isnan(spec->min)) return C_ERR; |
| 533 | spec->minex = 1; |
| 534 | } else { |
| 535 | spec->min = strtod((char*)min->ptr,&eptr); |
| 536 | if (eptr[0] != '\0' || isnan(spec->min)) return C_ERR; |
| 537 | } |
| 538 | } |
| 539 | if (max->encoding == OBJ_ENCODING_INT) { |
| 540 | spec->max = (long)max->ptr; |
| 541 | } else { |
| 542 | if (((char*)max->ptr)[0] == '(') { |
| 543 | spec->max = strtod((char*)max->ptr+1,&eptr); |
| 544 | if (eptr[0] != '\0' || isnan(spec->max)) return C_ERR; |
| 545 | spec->maxex = 1; |
| 546 | } else { |
| 547 | spec->max = strtod((char*)max->ptr,&eptr); |
| 548 | if (eptr[0] != '\0' || isnan(spec->max)) return C_ERR; |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | return C_OK; |
| 553 | } |
| 554 | |
| 555 | /* ------------------------ Lexicographic ranges ---------------------------- */ |
| 556 |
no outgoing calls
no test coverage detected