Cleanup all IP formatting code

Instead of manually checking for strchr(n,':') everywhere,
we can use our new centralized IP formatting functions.
This commit is contained in:
Matt Stancliff
2014-10-23 13:09:58 -04:00
parent 2d90619f88
commit 491881e13b
5 changed files with 12 additions and 33 deletions

View File

@ -130,9 +130,8 @@ static void cliRefreshPrompt(void) {
len = snprintf(config.prompt,sizeof(config.prompt),"redis %s",
config.hostsocket);
else
len = snprintf(config.prompt,sizeof(config.prompt),
strchr(config.hostip,':') ? "[%s]:%d" : "%s:%d",
config.hostip, config.hostport);
len = anetFormatIP(config.prompt, sizeof(config.prompt),
config.hostip, config.hostport);
/* Add [dbnum] if needed */
if (config.dbnum != 0 && config.last_cmd_type != REDIS_REPLY_ERROR)
len += snprintf(config.prompt+len,sizeof(config.prompt)-len,"[%d]",