MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zslParseLexRangeItem

Function zslParseLexRangeItem

app/redis-6.2.6/src/t_zset.c:570–595  ·  view source on GitHub ↗

Parse max or min argument of ZRANGEBYLEX. * (foo means foo (open interval) * [foo means foo (closed interval) * - means the min string possible * + means the max string possible * * If the string is valid the *dest pointer is set to the redis object * that will be used for the comparison, and ex will be set to 0 or 1 * respectively if the item is exclusive or inclusive. C_OK will b

Source from the content-addressed store, hash-verified

568 * If the string is not a valid range C_ERR is returned, and the value
569 * of *dest and *ex is undefined. */
570int zslParseLexRangeItem(robj *item, sds *dest, int *ex) {
571 char *c = item->ptr;
572
573 switch(c[0]) {
574 case '+':
575 if (c[1] != '\0') return C_ERR;
576 *ex = 1;
577 *dest = shared.maxstring;
578 return C_OK;
579 case '-':
580 if (c[1] != '\0') return C_ERR;
581 *ex = 1;
582 *dest = shared.minstring;
583 return C_OK;
584 case '(':
585 *ex = 1;
586 *dest = sdsnewlen(c+1,sdslen(c)-1);
587 return C_OK;
588 case '[':
589 *ex = 0;
590 *dest = sdsnewlen(c+1,sdslen(c)-1);
591 return C_OK;
592 default:
593 return C_ERR;
594 }
595}
596
597/* Free a lex range structure, must be called only after zelParseLexRange()
598 * populated the structure with success (C_OK returned). */

Callers 1

zslParseLexRangeFunction · 0.85

Calls 2

sdsnewlenFunction · 0.85
sdslenFunction · 0.85

Tested by

no test coverage detected