From 0dc8d035d3b5815c13ef257b4a0dcc25ad03821e Mon Sep 17 00:00:00 2001 From: adjoly Date: Wed, 15 May 2024 16:34:04 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix:=20correct?= =?UTF-8?q?=20if=20hostname=20does=20not=20have=20.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/prompt/get_hostname.c | 8 ++++++-- src/prompt/get_prompt.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/prompt/get_hostname.c b/src/prompt/get_hostname.c index 6ed0e70..e501160 100644 --- a/src/prompt/get_hostname.c +++ b/src/prompt/get_hostname.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/02 10:36:31 by adjoly #+# #+# */ -/* Updated: 2024/05/03 10:32:07 by adjoly ### ########.fr */ +/* Updated: 2024/05/15 16:29:19 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,8 +26,12 @@ char *get_hostname(void) delimiter = ft_strchr(buf, '.'); if (!delimiter) { + hostname = ft_strdup(buf); free(buf); - return (buf); + delimiter = ft_strchr(hostname, '\n'); + if (delimiter) + hostname[delimiter - hostname] = '\0'; + return (hostname); } hostname = ft_calloc(delimiter - buf + 1, sizeof(char)); ft_strlcpy(hostname, buf, delimiter - buf + 1); diff --git a/src/prompt/get_prompt.c b/src/prompt/get_prompt.c index 210bc9b..9fdb017 100644 --- a/src/prompt/get_prompt.c +++ b/src/prompt/get_prompt.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/30 13:25:42 by adjoly #+# #+# */ -/* Updated: 2024/05/02 15:50:14 by adjoly ### ########.fr */ +/* Updated: 2024/05/15 16:21:25 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */