diff options
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | src/ft_b_echo.c | 21 | ||||
| -rw-r--r-- | src/ft_u_utils.c | 26 | ||||
| -rw-r--r-- | src/ft_u_utils.h | 20 | ||||
| -rw-r--r-- | src/minishell.c | 1 | 
5 files changed, 66 insertions, 3 deletions
| @@ -27,6 +27,7 @@ SRCS_NAME		+= ft_s_init.c  SRCS_NAME		+= ft_s_lcom.c  SRCS_NAME		+= ft_p_line.c  SRCS_NAME		+= ft_p_lcom.c +SRCS_NAME		+= ft_u_utils.c  #------------------------------------------------------------------------------#  SRCS			= $(addprefix ${SRCS_DIR}, ${SRCS_NAME})  #------------------------------------------------------------------------------# diff --git a/src/ft_b_echo.c b/src/ft_b_echo.c index 326967d..6a3af34 100644 --- a/src/ft_b_echo.c +++ b/src/ft_b_echo.c @@ -13,16 +13,31 @@  #include <libft.h>  #include <stdint.h>  #include "ft_s_struct.h" +#include "ft_u_utils.h"  uint8_t  	ft_b_echo(char *args[],  			t_msh *msh)  { +	char			**ptr; +	int8_t			nopt; +  	(void)msh; -	while (*args) +	ptr = args; +	nopt = 0; +	if (ft_strncmp(ptr[0], "-n", 2) == 0) +	{ +		nopt = 1; +		ptr += 1; +	} +	ft_printf("%s", *ptr); +	ptr++; +	while (*ptr)  	{ -		ft_printf("%s\n", *args); -		args++; +		ft_printf(" %s", *ptr); +		ptr++;  	} +	if (nopt == 0) +		ft_printf("\n");  	return (0);  } diff --git a/src/ft_u_utils.c b/src/ft_u_utils.c new file mode 100644 index 0000000..f5df2f4 --- /dev/null +++ b/src/ft_u_utils.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   ft_u_utils.c                                       :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#include <stdint.h> + +uint64_t +	ft_get_argc(const char *args[]) +{ +	uint64_t	argc; + +	argc = 0; +	while (args[argc]) +	{ +		argc++; +	} +	return (argc); +} diff --git a/src/ft_u_utils.h b/src/ft_u_utils.h new file mode 100644 index 0000000..1a3b324 --- /dev/null +++ b/src/ft_u_utils.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   ft_u_utils.h                                       :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#ifndef FT_U_UTILS_H +#define FT_U_UTILS_H + +#include <stdint.h> + +uint64_t	ft_get_argc(const char *args[]); + +#endif diff --git a/src/minishell.c b/src/minishell.c index fc4c4be..412fae1 100644 --- a/src/minishell.c +++ b/src/minishell.c @@ -52,4 +52,5 @@ int  ** m_  -> core minishell related  ** p_  -> parse related  ** s_  -> structs related +** u_  -> utils related  */ | 
