diff options
author | filipe oliveira <filipecosta.90@gmail.com> | 2021-08-03 10:21:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-03 12:21:29 +0300 |
commit | 4aa927d16d4458124157bcc1d6a31b54df4f3a3f (patch) | |
tree | 184f3ae645a3e3e54ee8a52eed18bc006160ea0c /src/redis-cli.c | |
parent | 432c92d8df179a6a1aeae2df553c6b3fc810be76 (diff) | |
download | redis-4aa927d16d4458124157bcc1d6a31b54df4f3a3f.tar.gz |
Enabled -x option (Read last argument from STDIN) on redis-benchmark (#9130)
Add the -x option (Read last argument from STDIN) on redis-benchmark.
Other changes:
To be able to use the code from redis-cli some helper methods were moved to cli_common.(h|c)
Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/redis-cli.c')
-rw-r--r-- | src/redis-cli.c | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/src/redis-cli.c b/src/redis-cli.c index edf695ec4..fbd392d4b 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -775,23 +775,6 @@ static void freeHintsCallback(void *ptr) { * Networking / parsing *--------------------------------------------------------------------------- */ -/* Unquote a null-terminated string and return it as a binary-safe sds. */ -static sds unquoteCString(char *str) { - int count; - sds *unquoted = sdssplitargs(str, &count); - sds res = NULL; - - if (unquoted && count == 1) { - res = unquoted[0]; - unquoted[0] = NULL; - } - - if (unquoted) - sdsfreesplitres(unquoted, count); - - return res; -} - /* Send AUTH command to the server */ static int cliAuth(redisContext *ctx, char *user, char *auth) { redisReply *reply; @@ -1879,23 +1862,6 @@ static void parseEnv() { } } -static sds readArgFromStdin(void) { - char buf[1024]; - sds arg = sdsempty(); - - while(1) { - int nread = read(fileno(stdin),buf,1024); - - if (nread == 0) break; - else if (nread == -1) { - perror("Reading from standard input"); - exit(1); - } - arg = sdscatlen(arg,buf,nread); - } - return arg; -} - static void usage(int err) { sds version = cliVersion(); FILE *target = err ? stderr: stdout; @@ -2043,30 +2009,6 @@ static int confirmWithYes(char *msg, int ignore_force) { return (nread != 0 && !strcmp("yes", buf)); } -/* Create an sds array from argv, either as-is or by dequoting every - * element. When quoted is non-zero, may return a NULL to indicate an - * invalid quoted string. - */ -static sds *getSdsArrayFromArgv(int argc, char **argv, int quoted) { - sds *res = sds_malloc(sizeof(sds) * argc); - - for (int j = 0; j < argc; j++) { - if (quoted) { - sds unquoted = unquoteCString(argv[j]); - if (!unquoted) { - while (--j >= 0) sdsfree(res[j]); - sds_free(res); - return NULL; - } - res[j] = unquoted; - } else { - res[j] = sdsnew(argv[j]); - } - } - - return res; -} - static int issueCommandRepeat(int argc, char **argv, long repeat) { while (1) { if (config.cluster_reissue_command || context == NULL || |