Open FAYWORD opened 2 years ago
I found another problem ( - d'nt work with format string) reply = redisCommand(conn,"SET Test:1 %.s", 2, "qwerty"); //this d'nt work (reply == NULL) reply = redisCommand(conn,"SET Test:1 %.2s", "qwerty"); //this d'nt work (reply == NULL) reply = redisCommand(conn,"SET Test:1 %.5d", 1); // this work (Command OK) reply = redisCommand(conn,"SET Test:1 %5d", 1); // this work (Command OK) reply = redisCommand(conn,"SET Test:1 %.*d", 5, 1); //this d'nt work (reply == NULL)
Hi, thanks for the report.
I'm honestly not sure if we want/need to add the *
style format specifiers as Hiredis doesn't aim to replicate full printf
functionally, but just a small subset that is typically useful for communicating with Redis.
Well, I needed to insert only part of the string (up to a certain character). Without this functionality, you will need to compose a new string
If i use %c in format string then command return NULL reply. Example command (SET Test:1 a): reply = redisCommand(conn,"SET Test:1 %s", "a"); // this work (Command OK) reply = redisCommand(conn,"SET Test:1 a"); // this work (Command OK) reply = redisCommand(conn,"SET Test:1 %c", 'a'); // this d'nt work (reply == NULL) reply = redisCommand(conn,"SET T%cst:1 a", 'e'); // this d'nt work (reply == NULL)
This problem also exists in redisAppendCommand, redisvAppendCommand and etc