From b6be8a86ea3c38f210751655fa360e5f8b70853c Mon Sep 17 00:00:00 2001 From: guamss Date: Fri, 30 Jun 2023 14:36:28 +0200 Subject: [PATCH] fix --- src/input/input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/input/input.c b/src/input/input.c index 23a617b..6754c80 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -39,7 +39,7 @@ static char* get_prompt(lst** env) } if (strcmp(user, "root") == 0) { - size = snprintf(NULL, 0, "[%s@%s] > %s # ",user, hostname_buff, cwd) + 10; + size = strlen(user) + strlen(hostname_buff) + strlen(cwd) + 9; out = malloc(size*sizeof(char)); if(out == NULL) return NULL; @@ -48,7 +48,7 @@ static char* get_prompt(lst** env) } else { - size = snprintf(NULL, 0, "[%s@%s] >%s $ ",user, hostname_buff, cwd) + 10; + size = strlen(user) + strlen(hostname_buff) + strlen(cwd) + 9; out = malloc(size*sizeof(char)); if(out == NULL) return NULL;