Fix formatting literal percent characters

This commit is contained in:
Pieter Noordhuis 2010-11-22 10:00:45 +01:00
parent 9d9b8e1c79
commit cb89a472b6
2 changed files with 7 additions and 1 deletions

View File

@ -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++;

6
test.c
View File

@ -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";