Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How use %c in format string on redisCommand? #1069

Open
FAYWORD opened this issue Jun 16, 2022 · 3 comments · May be fixed by #1113
Open

How use %c in format string on redisCommand? #1069

FAYWORD opened this issue Jun 16, 2022 · 3 comments · May be fixed by #1113

Comments

@FAYWORD
Copy link

FAYWORD commented Jun 16, 2022

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

@FAYWORD
Copy link
Author

FAYWORD commented Jun 16, 2022

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)

@michael-grunder
Copy link
Collaborator

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.

@FAYWORD
Copy link
Author

FAYWORD commented Sep 14, 2022

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

@FAYWORD FAYWORD linked a pull request Sep 14, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants