Je ne veux pas dénoncer mais
This commit is contained in:
parent
7ea602b12c
commit
08261b1921
@ -6,7 +6,7 @@
|
|||||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/17 13:09:08 by erey-bet #+# #+# */
|
/* Created: 2023/02/17 13:09:08 by erey-bet #+# #+# */
|
||||||
/* Updated: 2023/03/13 16:29:47 by erey-bet ### ########.fr */
|
/* Updated: 2023/03/13 16:50:40 by erey-bet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ int is_space(char c)
|
|||||||
|| c == '\r' || c == '\n');
|
|| c == '\r' || c == '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_argument(char *str, int *check)
|
int check_argument(char *str, int *check_backslash_n)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ int check_argument(char *str, int *check)
|
|||||||
if (str[i] != '-' && str[i] != 'n')
|
if (str[i] != '-' && str[i] != 'n')
|
||||||
return (1);
|
return (1);
|
||||||
if (ft_strnstr(str, "n", ft_strlen(str)))
|
if (ft_strnstr(str, "n", ft_strlen(str)))
|
||||||
*check = 1;
|
*check_backslash_n = 1;
|
||||||
else
|
else
|
||||||
return (1);
|
return (1);
|
||||||
return (0);
|
return (0);
|
||||||
@ -35,24 +35,26 @@ int check_argument(char *str, int *check)
|
|||||||
|
|
||||||
int echo(int fd, char **strs)
|
int echo(int fd, char **strs)
|
||||||
{
|
{
|
||||||
int check;
|
int check_backslash_n;
|
||||||
|
int check_start_write;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
check = 0;
|
check_backslash_n = 0;
|
||||||
|
check_start_write = 0;
|
||||||
i = -1;
|
i = -1;
|
||||||
while (strs[++i])
|
while (strs[++i])
|
||||||
{
|
{
|
||||||
while (is_space(*strs[i]))
|
while (is_space(*strs[i]))
|
||||||
strs[i]++;
|
strs[i]++;
|
||||||
if (check == 2 || check_argument(strs[i], &check))
|
if (check_start_write == 1 || check_argument(strs[i], &check_backslash_n))
|
||||||
{
|
{
|
||||||
check = 2;
|
check_start_write = 1;
|
||||||
ft_putstr_fd(strs[i], fd);
|
ft_putstr_fd(strs[i], fd);
|
||||||
if (strs[i + 1] != NULL)
|
if (strs[i + 1] != NULL)
|
||||||
write(fd, " ", 1);
|
write(fd, " ", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!check)
|
if (!check_backslash_n)
|
||||||
write(fd, "\n", 1);
|
write(fd, "\n", 1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user