LCS: get rid of STOREIDX option. Fix get keys helper.

This commit is contained in:
antirez
2020-04-06 13:23:07 +02:00
parent ef610802c7
commit 7261a5550f
2 changed files with 20 additions and 21 deletions

View File

@@ -1554,30 +1554,30 @@ int *georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numk
return keys;
}
/* LCS ... [STOREIDX <key>] ... */
/* LCS ... [KEYS <key1> <key2>] ... */
int *lcsGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys)
{
int i;
int *keys;
int *keys = getKeysTempBuffer;
UNUSED(cmd);
/* We need to parse the options of the command in order to check for the
* "STOREIDX" argument before the STRINGS argument. */
* "KEYS" argument before the "STRINGS" argument. */
for (i = 1; i < argc; i++) {
char *arg = argv[i]->ptr;
int moreargs = (argc-1) - i;
if (!strcasecmp(arg, "strings")) {
break;
} else if (!strcasecmp(arg, "storeidx") && moreargs) {
keys = getKeysTempBuffer;
} else if (!strcasecmp(arg, "keys") && moreargs >= 2) {
keys[0] = i+1;
*numkeys = 1;
keys[1] = i+2;
*numkeys = 2;
return keys;
}
}
*numkeys = 0;
return NULL;
return keys;
}
/* Helper function to extract keys from memory command.