summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2010-11-22 10:00:45 +0100
committerPieter Noordhuis <pcnoordhuis@gmail.com>2010-11-22 10:00:45 +0100
commitcb89a472b65691df93b1469a577ec94857f37855 (patch)
tree156581eb05eb891d9607c872b3bb14076d05c608
parent9d9b8e1c79130610b48415a0b0f385e1ac1919e2 (diff)
Fix formatting literal percent characters
-rw-r--r--hiredis.c2
-rw-r--r--test.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/hiredis.c b/hiredis.c
index 36ee6d9..a2d8515 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -564,7 +564,7 @@ int redisvFormatCommand(char **target, const char *format, va_list ap) {
interpolated = 1;
break;
case '%':
- cmd = sdscat(cmd,"%");
+ current = sdscat(current,"%");
break;
}
c++;
diff --git a/test.c b/test.c
index e8289ba..eb7790b 100644
--- a/test.c
+++ b/test.c
@@ -65,6 +65,12 @@ static void test_format_commands() {
len == 4+4+(3+2)+4+(3+2)+4+(0+2));
free(cmd);
+ test("Format command with literal %%: ");
+ len = redisFormatCommand(&cmd,"SET %% %%");
+ test_cond(strncmp(cmd,"*3\r\n$3\r\nSET\r\n$1\r\n%\r\n$1\r\n%\r\n",len) == 0 &&
+ len == 4+4+(3+2)+4+(1+2)+4+(1+2));
+ free(cmd);
+
const char *argv[3];
argv[0] = "SET";
argv[1] = "foo";